From 6d9986d0440073ec3b571e8a32ce41cf0441f504 Mon Sep 17 00:00:00 2001 From: Yixian Date: Wed, 23 Mar 2022 15:31:14 +0800 Subject: [PATCH] customized settle download view; shopify hmac log --- .../clearing/core/CleanService.java | 2 ++ .../clearing/core/impl/CleanServiceImpl.java | 12 ++++++++- .../clearing/web/SettlementDevController.java | 7 +++++ .../log/CustomizedSettleLogMapper.java | 7 +++++ .../shopify/support/HmacVerificationUtil.java | 7 +++++ src/main/ui/static/analysis/clearing-log.js | 16 +++++++++++ .../templates/dialog_customized_settle.html | 27 +++++++++++++++++++ .../analysis/templates/settlement_detail.html | 3 +++ .../payment/manage/valid/ImageTest.java | 3 --- 9 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 src/main/ui/static/analysis/templates/dialog_customized_settle.html 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 315f36874..08751c31a 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 @@ -56,6 +56,8 @@ public interface CleanService { void settlementAba(Date date, HttpServletResponse response) throws IOException; + List getCustomizedSettleDaily(Date date); + void getCustomizedSettleABA(int logId, HttpServletResponse response); void getSettlementFilesForBatch(String batchId, HttpServletResponse resp) throws IOException; 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 e61bfb6ca..a2feb922b 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 @@ -668,6 +668,15 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider } } + @Override + public List getCustomizedSettleDaily(Date date) { + DateTime dtFrom = new DateTime(date); + DateTime dtTo = dtFrom.plusDays(1); + List logs = customizedSettleLogMapper.listByDate(dtFrom.toDate(), dtTo.toDate()); + logs.forEach(log -> log.put("aba_file", String.format("/sys/settlement/customized_settle/%s/aba_file", log.getIntValue("log_id")))); + return logs; + } + @Override public void getCustomizedSettleABA(int logId, HttpServletResponse response) { JSONObject log = customizedSettleLogMapper.find(logId); @@ -686,7 +695,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider settle.put("client_moniker", log.getString("client_moniker")); ABAFile file = generateSettleAbaFile(bank, group, new Date(), Collections.singletonList(settle)); response.setContentType("application/octet-stream;"); - response.addHeader("Content-Disposition", "attachment; filename=" + file.filename()); + String filename = String.format("[%s]Manual_Settle_%s_%s.aba", logId, log.getString("client_moniker"), DateTime.now().toString("yyyyMMdd")); + response.addHeader("Content-Disposition", "attachment; filename=" + filename); try (OutputStream ous = response.getOutputStream()) { ous.write(file.output(1)); ous.flush(); diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettlementDevController.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettlementDevController.java index f2ca28d44..7e0d4a5f4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettlementDevController.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/SettlementDevController.java @@ -9,6 +9,7 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.merchants.beans.BalanceGroup; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import com.alibaba.fastjson.JSONObject; +import org.joda.time.DateTime; import org.springframework.core.io.ByteArrayResource; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -170,6 +171,12 @@ public class SettlementDevController { } } + @GetMapping("/customized_settle/dates/{date}") + public List customizedSettleInDay(@PathVariable String date){ + Date dt = DateTime.parse(date).withTimeAtStartOfDay().toDate(); + return cleanService.getCustomizedSettleDaily(dt); + } + @GetMapping("/customized_settle/{logId}/aba_file") public void getCustomizedSettleABAFile(@PathVariable int logId,HttpServletResponse response){ cleanService.getCustomizedSettleABA(logId, response); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/CustomizedSettleLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/CustomizedSettleLogMapper.java index 0d34da48e..46c7587c6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/log/CustomizedSettleLogMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/CustomizedSettleLogMapper.java @@ -5,10 +5,17 @@ import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper; import com.yixsoft.support.mybatis.autosql.annotations.AutoSql; import com.yixsoft.support.mybatis.autosql.annotations.SqlType; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator; +import java.util.Date; +import java.util.List; + @AutoMapper(tablename = "log_settle_customized", pkName = "log_id", keyGenerator = Jdbc3KeyGenerator.class) public interface CustomizedSettleLogMapper { @AutoSql(SqlType.SELECT) JSONObject find(@Param("log_id") int logId); + + @Select("select * from log_settle_customized where create_time between #{date_from} and #{date_to}") + List listByDate(@Param("date_from") Date dateFrom,@Param("date_to") Date dateTo); } diff --git a/src/main/java/au/com/royalpay/payment/manage/shopify/support/HmacVerificationUtil.java b/src/main/java/au/com/royalpay/payment/manage/shopify/support/HmacVerificationUtil.java index 5ba85aac0..5c5b159aa 100644 --- a/src/main/java/au/com/royalpay/payment/manage/shopify/support/HmacVerificationUtil.java +++ b/src/main/java/au/com/royalpay/payment/manage/shopify/support/HmacVerificationUtil.java @@ -5,6 +5,8 @@ import org.apache.commons.codec.digest.HmacUtils; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.crypto.RuntimeCryptoException; import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.crypto.Mac; import javax.crypto.SecretKey; @@ -15,6 +17,10 @@ import java.security.Security; import java.util.Locale; public class HmacVerificationUtil { + private static final Logger logger = LoggerFactory.getLogger(HmacVerificationUtil.class); + + private HmacVerificationUtil() { + } public static boolean checkParameters(String message, String secret, String hmac) { try { @@ -32,6 +38,7 @@ public class HmacVerificationUtil { public static boolean hmacSHA256(String input, String key, String hmac) { String encode = encode(input, key, HmacAlgorithms.HMAC_SHA_256); + logger.debug("input={}; key={}; encoded={}; request-hmac: {}", input, key, encode, hmac); return StringUtils.equals(encode, hmac); } diff --git a/src/main/ui/static/analysis/clearing-log.js b/src/main/ui/static/analysis/clearing-log.js index de03c8a8f..bc1efedb3 100644 --- a/src/main/ui/static/analysis/clearing-log.js +++ b/src/main/ui/static/analysis/clearing-log.js @@ -269,6 +269,18 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func $state.reload(); }; + $scope.showCustomizedSettle = function () { + $uibModal.open({ + templateUrl: '/static/analysis/templates/dialog_customized_settle.html', + controller: 'customizedDialogCtrl', + resolve: { + customizedLogs: function () { + return $http.get('/sys/settlement/customized_settlements/dates/' + $scope.datePattern) + } + } + }) + } + let nowStr = $filter('date')(new Date(), "yyyy-MM-dd"); $scope.datePattern = $stateParams.date; if ($scope.datePattern == nowStr) { @@ -375,6 +387,10 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func }) } }]); + + app.controller('customizedDialogCtrl', ['$scope', 'customizedLogs', function ($scope, customizedLogs) { + $scope.customizedLogs = customizedLogs.data + }]) app.controller('settlementTransactionsCtrl', ['$scope', '$stateParams', 'detail', function ($scope, $stateParams, detail) { $scope.ctrl = {channel: null}; $scope.report = detail.data; diff --git a/src/main/ui/static/analysis/templates/dialog_customized_settle.html b/src/main/ui/static/analysis/templates/dialog_customized_settle.html new file mode 100644 index 000000000..cc9223f51 --- /dev/null +++ b/src/main/ui/static/analysis/templates/dialog_customized_settle.html @@ -0,0 +1,27 @@ + + + \ No newline at end of file diff --git a/src/main/ui/static/analysis/templates/settlement_detail.html b/src/main/ui/static/analysis/templates/settlement_detail.html index 91aeb1787..2c34afd32 100644 --- a/src/main/ui/static/analysis/templates/settlement_detail.html +++ b/src/main/ui/static/analysis/templates/settlement_detail.html @@ -43,6 +43,9 @@ + Settle Tasks diff --git a/src/test/java/au/com/royalpay/payment/manage/valid/ImageTest.java b/src/test/java/au/com/royalpay/payment/manage/valid/ImageTest.java index d1b72d958..97c587a80 100644 --- a/src/test/java/au/com/royalpay/payment/manage/valid/ImageTest.java +++ b/src/test/java/au/com/royalpay/payment/manage/valid/ImageTest.java @@ -1,10 +1,8 @@ package au.com.royalpay.payment.manage.valid; -import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import cn.yixblog.platform.http.HttpRequestGenerator; import cn.yixblog.platform.http.HttpRequestResult; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.io.IOUtils; import org.junit.Test; import org.springframework.web.bind.annotation.RequestMethod; @@ -12,7 +10,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.IOException; import java.io.InputStream;