From 4079349402b6b9286a05c442767b0ef8cc328779 Mon Sep 17 00:00:00 2001 From: Todking Date: Mon, 27 Sep 2021 14:18:20 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=80=BB=E4=BD=93=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clearing/core/CleanService.java | 2 +- .../clearing/core/impl/CleanServiceImpl.java | 19 ++++++++++++++++++- .../clearing/web/FinancialController.java | 12 ++++++------ .../payment/validation/order-validation.js | 19 +++++++++++++++++++ .../validation/templates/valid_new.html | 1 + 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java index 0581a03e7..315f36874 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java @@ -100,7 +100,7 @@ public interface CleanService { List findLogSettleByDate(Date date); - JSONObject validTransactions(Date date, boolean fix, boolean b, boolean b1); + JSONObject validTransactions(Date date, boolean fix, boolean b, boolean b1,boolean isSendMessage); void distributeBank(Date date, int clearingId, JSONObject bankDistribution); diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java index 478b3ef5d..2d989d1c6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java @@ -1,6 +1,7 @@ package au.com.royalpay.payment.manage.management.clearing.core.impl; import au.com.royalpay.payment.core.PaymentApi; +import au.com.royalpay.payment.core.beans.OrderValidationChannelResult; import au.com.royalpay.payment.core.beans.OrderValidationResult; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.exceptions.ParamInvalidException; @@ -1577,7 +1578,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider } @Override - public JSONObject validTransactions(Date dt, boolean fix, boolean b, boolean b1) { + public JSONObject validTransactions(Date dt, boolean fix, boolean b, boolean b1, boolean isSendMessage) { if (!b) { JSONObject reportItem = validationLogMapper.findByDate(dt); if (reportItem != null) { @@ -1591,6 +1592,22 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider log.put("result", report.getReport().toJSONString()); validationLogMapper.removeByDate(dt); validationLogMapper.save(log); + // 是否发送消息通知 + if (isSendMessage) { + List developers = managerMapper.listDetailsByRole(null, ManagerRole.DEVELOPER.getMask()); + List channelResults = report.getChannelResults(); + boolean valid = channelResults.stream().map(OrderValidationChannelResult::isSuccess).reduce(Boolean::logicalAnd).orElse(true); + StringBuilder statusString = new StringBuilder("订单校对已完成,状态:" + (valid ? "🌤️【成功】" : "🌨️【失败】")); + statusString.append("\r\n"); + for (OrderValidationChannelResult info : channelResults) { + if (info.isSuccess()) { + continue; + } + statusString.append(info.getChannel().getChannelCode()).append(": [ ").append(info.isSuccess() ? "成功" : "失败") + .append(StringUtils.defaultIfBlank(info.getErrorMsg(), "")).append(" ]").append("\r\n"); + } + publisher.publishEvent(new TaskFinishNotifyEvent(this, PlatformEnvironment.getEnv().getCompany() + " 订单校对", statusString.toString(), developers, valid)); + } return JSON.parseObject(log.getString("result")); } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/FinancialController.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/FinancialController.java index dd7de3bc3..961caefda 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/FinancialController.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/FinancialController.java @@ -59,10 +59,11 @@ public class FinancialController { @GetMapping("/order_validations/{date}") public JSONObject getCheckReport(@PathVariable String date, @RequestParam(defaultValue = "false") boolean fix, - @RequestParam(name = "use_cache", defaultValue = "true") boolean useCache) { + @RequestParam(name = "use_cache", defaultValue = "true") boolean useCache, + @RequestParam(name = "is_send_message", defaultValue = "false") boolean isSendMessage) { try { Date dt = DateUtils.parseDate(date, new String[]{"yyyyMMdd"}); - return cleanService.validTransactions(dt, fix, !useCache, false); + return cleanService.validTransactions(dt, fix, !useCache, false,isSendMessage); } catch (ParseException e) { throw new ParamInvalidException("date", "error.payment.valid.invalid_date_format"); } @@ -97,8 +98,8 @@ public class FinancialController { @GetMapping("/get/transaction/status/{transactionId}") public TransactionStatus getTransactionStatus(@PathVariable String transactionId) { - if(transactionId.isEmpty()){ - throw new ParamInvalidException("date","Transaction flow is empty"); + if (transactionId.isEmpty()) { + throw new ParamInvalidException("date", "Transaction flow is empty"); } return cleanService.getTransactionStatus(transactionId); } @@ -109,12 +110,11 @@ public class FinancialController { @RequestParam(value = "noCache") boolean noCache, @RequestParam(value = "billType", required = false) String billType, @RequestParam(value = "channel") String channel, - HttpServletResponse response) { + HttpServletResponse response) { ChannelReconciliationFileContent file = cleanService.downloadChannelReconciliationFile(pid, au.com.royalpay.payment.tools.utils.DateUtils.parseDate(billDate) , noCache, channel, billType); - try (InputStream in = new ByteArrayInputStream(file.content())) { response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(file.name(), Charsets.UTF_8.name())); response.setContentLength(file.length()); diff --git a/src/main/ui/static/payment/validation/order-validation.js b/src/main/ui/static/payment/validation/order-validation.js index fc901dba7..683d30057 100644 --- a/src/main/ui/static/payment/validation/order-validation.js +++ b/src/main/ui/static/payment/validation/order-validation.js @@ -164,6 +164,25 @@ define(['angular', 'uiRouter'], function () { $scope.date = angular.copy($stateParams.date) $scope.date = $scope.date.substr(0, 4) + '-' + $scope.date.substr(4, 2) + '-' + $scope.date.substr(6) $scope.warningLevel = JSON.parse(sessionStorage.getItem('warningLevel')) + $scope.validItAgain = function () { + commonDialog + .confirm({ + title: 'Confirm reconciliations', + contentHtml: $sce.trustAsHtml('Agree to send push message'), + }) + .then(function () { + var isSendMessage = document.getElementById('isSendMessage').checked + $http + .get('/sys/financial/order_validations/' + $stateParams.date, { + params: { + use_cache: false, + is_send_message: isSendMessage, + }, + timeout: 300000, + }) + .then($scope.startValid()) + }) + } // 加载渠道信息 $scope.startValid = function () { $http diff --git a/src/main/ui/static/payment/validation/templates/valid_new.html b/src/main/ui/static/payment/validation/templates/valid_new.html index 38246adf3..b41c07c8d 100644 --- a/src/main/ui/static/payment/validation/templates/valid_new.html +++ b/src/main/ui/static/payment/validation/templates/valid_new.html @@ -10,6 +10,7 @@ +