prevent duplicate chargeback on same order

master
yixian 4 years ago
parent efabb145b0
commit 5b0813612f

@ -5,6 +5,7 @@ import au.com.royalpay.payment.core.beans.ChargebackStatus;
import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.exceptions.OrderNotMatchException; import au.com.royalpay.payment.core.exceptions.OrderNotMatchException;
import au.com.royalpay.payment.core.utils.ExtParamsUtils;
import au.com.royalpay.payment.manage.mappers.log.AppMessageLogMapper; import au.com.royalpay.payment.manage.mappers.log.AppMessageLogMapper;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
@ -392,7 +393,19 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
if (evt == null) { if (evt == null) {
return; return;
} }
JSONObject order = orderMapper.find(evt.getOrders().get(0).getRealOrderId());
if (order == null) {
throw new BadRequestException("Order Not found");
}
if (ExtParamsUtils.getExtParamsBooleanValue(order, "chargeback_mark")) {
throw new BadRequestException("Duplicated chargeback on same order");
}
cardSecureService.submitChargeBackReport(evt); cardSecureService.submitChargeBackReport(evt);
JSONObject update = new JSONObject();
update.put("order_id", order.getString("order_id"));
update.put(ExtParamsUtils.EXT_PARAMS, order.getString(ExtParamsUtils.EXT_PARAMS));
ExtParamsUtils.putExtParam(update, "chargeback_mark", true);
orderMapper.update(update);
} }
} }
@ -1378,6 +1391,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
} }
@Override @Override
@Transactional
public void markChargebackStatus(String riskId, JSONObject manager, ChargebackStatus status) { public void markChargebackStatus(String riskId, JSONObject manager, ChargebackStatus status) {
RiskEvent risk = getRiskEvent(riskId); RiskEvent risk = getRiskEvent(riskId);
if (risk == null) { if (risk == null) {
@ -1389,6 +1403,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
if (status == null || status == ChargebackStatus.PROCESSING) { if (status == null || status == ChargebackStatus.PROCESSING) {
throw new BadRequestException("Invalid status"); throw new BadRequestException("Invalid status");
} }
if (risk.getResultType() < 5) {
riskProcessLogService.addRiskProcessLog(riskId, riskProcessLogService.addRiskProcessLog(riskId,
manager.getString("manager_id"), manager.getString("manager_id"),
manager.getString("display_name"), manager.getString("display_name"),
@ -1396,6 +1411,11 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
RiskResultTypeEnum.ALREADY_HANDLED.getResultType(), RiskResultTypeEnum.ALREADY_HANDLED.getResultType(),
RiskResultTypeEnum.ALREADY_HANDLED.getResultType()); RiskResultTypeEnum.ALREADY_HANDLED.getResultType());
cardSecureService.changeChargebackReportStatus(riskId, status); cardSecureService.changeChargebackReportStatus(riskId, status);
JSONObject evt = new JSONObject();
evt.put("risk_id", risk.getRiskId());
evt.put("result_type", RiskResultTypeEnum.ALREADY_HANDLED.getResultType());
riskEventMapper.update(evt);
}
} }
private List<String> getShopTemplate() { private List<String> getShopTemplate() {

@ -415,7 +415,7 @@ define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'],
$scope.commitChargebackStatus = function (std) { $scope.commitChargebackStatus = function (std) {
commonDialog.confirm({title: '确认操作', content: '当前操作不可逆,并会将风控项标记为办结状态,确认操作?'}).then(function () { commonDialog.confirm({title: '确认操作', content: '当前操作不可逆,并会将风控项标记为办结状态,确认操作?'}).then(function () {
$http.put('/risk/business/chargebacks/' + $scope.riskEvent.risk_id + '/status', {status: std}).then(function () { $http.put('/risk/business/chargebacks/' + $scope.riskEvent.risk_id + '/mark_status', {status: std}).then(function () {
$state.reload(); $state.reload();
commonDialog.alert({title: 'Success', content: '修改成功', type: success}) commonDialog.alert({title: 'Success', content: '修改成功', type: success})
}, function (res) { }, function (res) {

@ -264,12 +264,12 @@
ng-if="clientInfo.is_valid == 0">重新启用商户 ng-if="clientInfo.is_valid == 0">重新启用商户
</button> </button>
<button class="btn btn-danger" type="button" <button class="btn btn-danger" type="button"
ng-if="orderTypes[riskEvent.order_type].require_result" ng-if="orderTypes[riskEvent.order_type].require_result && riskEvent.result_type<5"
ng-click="commitChargebackStatus('ACCEPTED')"> ng-click="commitChargebackStatus('ACCEPTED')">
放弃申诉 放弃申诉
</button> </button>
<button class="btn btn-success" type="button" <button class="btn btn-success" type="button"
ng-if="orderTypes[riskEvent.order_type].require_result" ng-if="orderTypes[riskEvent.order_type].require_result && riskEvent.result_type<5"
ng-click="commitChargebackStatus('DECLINED')"> ng-click="commitChargebackStatus('DECLINED')">
申诉成功 申诉成功
</button> </button>

Loading…
Cancel
Save