From 0d48030501ea9526b46b1f39b1fa6332e1d3d8eb Mon Sep 17 00:00:00 2001 From: yixian Date: Tue, 26 Jun 2018 15:35:47 +0800 Subject: [PATCH] distribute bank ui --- .../clearing/core/CleanService.java | 8 ++- .../clearing/core/impl/CleanServiceImpl.java | 24 +++++++ .../clearing/web/SettlementDevController.java | 14 +++- .../log/ClearingDetailAnalysisMapper.java | 2 + .../mappers/log/ClearingDetailMapper.java | 3 + .../manage/mappers/log/ClearingLogMapper.java | 3 + .../payment/TaskManualSettleMapper.java | 2 + .../mappers/payment/TransactionMapper.java | 3 + .../log/ClearingDetailAnalysisMapper.xml | 5 ++ .../payment/TaskManualSettleMapper.xml | 24 +++++-- .../mappers/payment/TransactionMapper.xml | 11 ++++ src/main/ui/static/analysis/clearing-log.js | 64 ++++++++++++++++++- .../settlement_bank_distribution_dialog.html | 24 +++++++ .../analysis/templates/settlement_detail.html | 23 ++++--- .../CustomerImpressionServiceImplTest.java | 27 -------- 15 files changed, 187 insertions(+), 50 deletions(-) create mode 100644 src/main/ui/static/analysis/templates/settlement_bank_distribution_dialog.html delete mode 100644 src/test/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionServiceImplTest.java 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 3fbe1e9ac..09518584a 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 @@ -83,9 +83,11 @@ public interface CleanService { JSONObject findLogSettleByDate(Date date); - JSONObject validTransactions(Date dt, boolean fix, boolean b, boolean b1); + JSONObject validTransactions(Date date, boolean fix, boolean b, boolean b1); - void distributeBank(Date dt, int clearingId, JSONObject bankDistribution); + void distributeBank(Date date, int clearingId, JSONObject bankDistribution); - void lockClearingLog(Date dt, int clearingId); + void lockClearingLog(Date date, int clearingId); + + void undoSettle(Date date, int clearingId); } 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 4b2e53e46..2eafe4324 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 @@ -5,6 +5,7 @@ import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.tasksupport.SettlementSupport; import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.mappers.log.*; +import au.com.royalpay.payment.manage.mappers.payment.TaskManualSettleMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.CalendarMapper; import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; @@ -97,6 +98,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider @Resource private ClearingDetailAnalysisMapper clearingDetailAnalysisMapper; @Resource + private TaskManualSettleMapper taskManualSettleMapper; + @Resource private ValidationLogMapper validationLogMapper; @Resource private ManagerMapper managerMapper; @@ -1133,6 +1136,27 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider clearingLogMapper.setLogEditable(false, clearingId); } + @Override + @Transactional + public void undoSettle(Date date, int clearingId) { + if (!DateUtils.isSameDay(date, new Date())) { + throw new ForbiddenException("Only today's settlement file can be modified"); + } + JSONObject log = clearingLogMapper.findById(clearingId); + if (log == null || !DateUtils.isSameDay(log.getDate("settle_date"), date)) { + throw new NotFoundException("Settlement log not found"); + } + if (!log.getBooleanValue("editable")) { + throw new ForbiddenException("Settlement log has been sent and unable to edit"); + } + transactionMapper.deleteSettlementTransaction(clearingId); + transactionMapper.removeSettleRemark(clearingId); + clearingDetailAnalysisMapper.clearAnalysis(clearingId); + taskManualSettleMapper.rollbackExecutedTask(clearingId); + clearingDetailMapper.deleteSettleLogs(clearingId); + clearingLogMapper.deleteSettleLogs(clearingId); + } + private byte[] getZipByteArr(List fileByteArrWithName) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(bos); 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 74f00e973..f4dea7830 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 @@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.management.clearing.web; import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.permission.manager.RequireManager; import au.com.royalpay.payment.manage.support.abafile.ABATemplate; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.CommonConsts; @@ -70,7 +71,7 @@ public class SettlementDevController { } @PutMapping("/reports/{date}/clearings/{clearingId}/lock") - public void lockClearingLog(@PathVariable String date,@PathVariable int clearingId){ + public void lockClearingLog(@PathVariable String date, @PathVariable int clearingId) { try { Date dt = dateFormat.parse(date); cleanService.lockClearingLog(dt, clearingId); @@ -79,6 +80,17 @@ public class SettlementDevController { } } + @DeleteMapping("/reports/{date}/clearings/{clearingId}") + @RequireManager(role = ManagerRole.DEVELOPER) + public void undoSettle(@PathVariable String date, @PathVariable int clearingId) { + try { + Date dt = dateFormat.parse(date); + cleanService.undoSettle(dt, clearingId); + } catch (ParseException e) { + throw new BadRequestException("error.payment.valid.invalid_date_format"); + } + } + @RequestMapping("/reports/{date}/settlement_csv") public void getSettlementCsv(@PathVariable String date, HttpServletResponse resp) throws IOException { try { diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingDetailAnalysisMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingDetailAnalysisMapper.java index ffe560d10..f97a11d43 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingDetailAnalysisMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingDetailAnalysisMapper.java @@ -26,4 +26,6 @@ public interface ClearingDetailAnalysisMapper { List listReportChannels(@Param("clearing_detail_id") String clearDetailId); BigDecimal getSysCleaingAmount(@Param("settle_date") String settle_date, @Param("channel") String channel); + + void clearAnalysis(@Param("clearing_id") int clearingId); } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.java index e37ac76e9..62ff594d9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.java @@ -45,4 +45,7 @@ public interface ClearingDetailMapper { @AutoSql(type = SqlType.UPDATE) void updateBanks(@Param("settle_bank") String bank,@Param("clear_detail_id") List clearingDetailIds); + + @AutoSql(type = SqlType.DELETE) + void deleteSettleLogs(@Param("clearing_id") int clearingId); } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingLogMapper.java index ca402dab9..2a7d47b66 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingLogMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClearingLogMapper.java @@ -46,4 +46,7 @@ public interface ClearingLogMapper { @AutoSql(type = SqlType.UPDATE) void setLogEditable(@Param("editable") boolean editable, @Param("clearing_id") int clearingId); + + @AutoSql(type = SqlType.DELETE) + void deleteSettleLogs(@Param("clearing_id") int clearingId); } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java index 910343d73..5116e391d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java @@ -31,4 +31,6 @@ public interface TaskManualSettleMapper { List getEveryLatestRecord(); + void rollbackExecutedTask(@Param("clearing_id") int clearingId); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java index e31fdb1d5..5e153fda9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java @@ -133,4 +133,7 @@ public interface TransactionMapper { List listClientUnsettleDataByDate(@Param("client_id") int clientId, @Param("max_settle_to") Date maxSettleTo); + void deleteSettlementTransaction(@Param("clearing_id") int clearingId); + + void removeSettleRemark(@Param("clearing_id") int clearingId); } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailAnalysisMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailAnalysisMapper.xml index 37c80398e..4db57c4ab 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailAnalysisMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailAnalysisMapper.xml @@ -1,6 +1,11 @@ + + DELETE a FROM log_clearing_detail_analysis a + inner JOIN log_clearing_detail d on d.clear_detail_id = a.clearing_detail_id + where d.clearing_id = #{clearing_id} + - SELECT - s.request_time,c.client_id,c.client_moniker + SELECT + s.request_time, + c.client_id, + c.client_moniker FROM - task_client_manual_settle s - right join sys_clients c on s.client_id = c.client_id - inner join sys_client_config cc on cc.client_id = c.client_id - where (s.request_time=(select max(B.request_time) from task_client_manual_settle B where s.client_id =B.client_id) or s.request_time is null) - and cc.manual_settle = 1 + task_client_manual_settle s + right join sys_clients c on s.client_id = c.client_id + inner join sys_client_config cc on cc.client_id = c.client_id + where (s.request_time = (select max(B.request_time) + from task_client_manual_settle B + where s.client_id = B.client_id) or s.request_time is null) + and cc.manual_settle = 1 \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml index dececd472..ad74bfa4d 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml @@ -1,6 +1,17 @@ + + UPDATE pmt_transactions AS t + INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order + SET clearing_status = 0, clearing_order = NULL, clearing_time = NULL + WHERE d.clearing_id = #{clearing_id} + + + DELETE t FROM pmt_transactions t + INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order + WHERE d.clearing_id = #{clearing_id} AND t.transaction_type = 'Debit' AND t.refund_id IS NULL and t.channel='Settlement' + + + +
+ +
+

+
+
+ +
+ + \ 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 3d71c89be..5cdcce1b5 100644 --- a/src/main/ui/static/analysis/templates/settlement_detail.html +++ b/src/main/ui/static/analysis/templates/settlement_detail.html @@ -47,7 +47,7 @@
Settlement Batches [{{datePattern}}]
-
+
-
- - +
+
+ + + +
diff --git a/src/test/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionServiceImplTest.java b/src/test/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionServiceImplTest.java deleted file mode 100644 index f165f4a3b..000000000 --- a/src/test/au/com/royalpay/payment/manage/apps/core/impls/CustomerImpressionServiceImplTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package au.com.royalpay.payment.manage.apps.core.impls; - -import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -import javax.annotation.Resource; - -/** - * Created by wangning on 08/01/2018. - */ -@SpringBootTest -@ActiveProfiles({"local","alipay","wechat","jd","bestpay"}) -@RunWith(SpringRunner.class) -public class CustomerImpressionServiceImplTest { - @Resource - private CustomerImpressionService customerImpressionService; - @Test - public void generate() throws Exception { - customerImpressionService.generate(9); - } - -} \ No newline at end of file