From 1a3fa95ddd6893c611fea15449117613ccc6973d Mon Sep 17 00:00:00 2001 From: luoyang Date: Mon, 30 Mar 2020 17:12:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?add=20=E6=89=8B=E5=8A=A8=E6=B8=85=E7=AE=97?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../payment/TaskManualSettleMapper.java | 6 ++- .../settlement/core/ManualSettleSupport.java | 5 +- .../core/impls/ManualSettleSupportImpl.java | 37 +++++++------- .../manage/system/web/contractController.java | 14 +++--- .../payment/TaskManualSettleMapper.xml | 44 ++++++++++++---- src/main/ui/static/sys/contract.js | 18 +++++-- .../static/sys/templates/manual_settle.html | 50 ++++++++++++++++++- 8 files changed, 132 insertions(+), 44 deletions(-) diff --git a/pom.xml b/pom.xml index 57a345101..dbaabb13c 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.4.21 + 1.4.22 UTF-8 1.8.0 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 5116e391d..1fb8be112 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 @@ -5,6 +5,8 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -29,7 +31,9 @@ public interface TaskManualSettleMapper { @AutoSql(type = SqlType.UPDATE) void update(JSONObject task); - List getEveryLatestRecord(); + PageList getEveryLatestRecord(PageBounds pagination); + + JSONObject getManualSettleAnalysis(); void rollbackExecutedTask(@Param("clearing_id") int clearingId); diff --git a/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java b/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java index a9a94ef07..db76cd0ae 100644 --- a/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java +++ b/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java @@ -3,7 +3,6 @@ package au.com.royalpay.payment.manage.settlement.core; import com.alibaba.fastjson.JSONObject; import java.util.Date; -import java.util.List; /** * Create by yixian at 2018-03-20 17:42 @@ -14,5 +13,7 @@ public interface ManualSettleSupport { JSONObject findCurrentSettle(int clientId, boolean includingUnsettleData); - List listWithClearInfo(); + JSONObject listWithClearInfo(int page); + + JSONObject getWithManualSettleAnalysis(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java index 7baef44dd..fea829bcf 100644 --- a/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java @@ -1,5 +1,6 @@ package au.com.royalpay.payment.manage.settlement.core.impls; +import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper; import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper; import au.com.royalpay.payment.manage.mappers.payment.TaskManualSettleMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; @@ -13,14 +14,17 @@ import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; +import au.com.royalpay.payment.tools.utils.PageListUtils; import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.Order; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -45,6 +49,8 @@ public class ManualSettleSupportImpl implements ManualSettleSupport { private CalendarMapper calendarMapper; @Resource private ClientManager clientManager; + @Resource + private ClientAnalysisMapper clientAnalysisMapper; @Override public JSONObject requestManualSettle(Date settleTo, String accountId) { @@ -138,22 +144,19 @@ public class ManualSettleSupportImpl implements ManualSettleSupport { } @Override - public List listWithClearInfo() { - List manuals = taskManualSettleMapper.getEveryLatestRecord(); - List client_ids = new ArrayList<>(manuals.size()); - manuals.parallelStream().forEach(p -> { - client_ids.add(p.getInteger("client_id")); - }); - List clientUnsettle = transactionMapper.getClientsUnClearedAmount(client_ids); - for (JSONObject manual : manuals) { - for (JSONObject settle : clientUnsettle) { - if (manual.getIntValue("client_id") == settle.getIntValue("client_id")) { - manual.put("unsettle", settle.getBigDecimal("clearing_amount")); - break; - } - } - } + public JSONObject listWithClearInfo(int page) { + PageList manuals = taskManualSettleMapper.getEveryLatestRecord( + new PageBounds(page, 20, Order.formString("unsettle.desc"))); + return PageListUtils.buildPageListResult(manuals); + } - return manuals; + @Override + public JSONObject getWithManualSettleAnalysis() { + JSONObject params = new JSONObject(); + params.put("end", new Date()); + JSONObject analysis = taskManualSettleMapper.getManualSettleAnalysis(); + analysis.put("total_partners", clientAnalysisMapper.countClientsAll(params)); + return analysis; } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java b/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java index d6eeaf32b..375111ff9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java @@ -4,17 +4,13 @@ import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.pos.datasource.ReadOnlyConnection; import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport; import au.com.royalpay.payment.manage.system.core.ClientContractService; - import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; - import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; - import javax.annotation.Resource; @RestController @@ -41,7 +37,13 @@ public class contractController { @ManagerMapping(value = "/manualSettle/list", method = RequestMethod.GET) @ReadOnlyConnection - public List manualList() { - return manualSettleSupport.listWithClearInfo(); + public JSONObject manualList(@RequestParam(defaultValue = "1") int page) { + return manualSettleSupport.listWithClearInfo(page); + } + + @ManagerMapping(value = "/manualSettle/analysis", method = RequestMethod.GET) + @ReadOnlyConnection + public JSONObject manualSettleAnalysis() { + return manualSettleSupport.getWithManualSettleAnalysis(); } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.xml index b2387a587..df1ad9c86 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.xml @@ -9,16 +9,38 @@ - \ No newline at end of file + + + diff --git a/src/main/ui/static/sys/contract.js b/src/main/ui/static/sys/contract.js index d86d2f869..4349aedf2 100644 --- a/src/main/ui/static/sys/contract.js +++ b/src/main/ui/static/sys/contract.js @@ -65,13 +65,21 @@ define(['angular'], function (angular) { }]); app.controller('manualSettleCtrl', ['$scope', '$http', '$state', '$filter', 'commonDialog', function ($scope, $http, $state, $filter, commonDialog) { - $scope.getManualSettleAnalysis = function () { - $http.get('/manage/common/analysis/manualSettle/list').then(function (resp) { - $scope.manual_settle_analysis = resp.data; + $scope.pagination = {}; + $scope.getManualSettleAnalysis = function (page) { + var params = {}; + params.page = page || $scope.pagination.page || 1; + $http.get('/manage/common/analysis/manualSettle/list', {params: params}).then(function (resp) { + $scope.manual_settle_analysis = resp.data.data; + $scope.pagination = resp.data.pagination; }); }; - $scope.getManualSettleAnalysis(); + $scope.getManualSettleAnalysis(1); + + $http.get('/manage/common/analysis/manualSettle/analysis').then(function (resp) { + $scope.manual_dashboard_analysis = resp.data; + }); }]); return app; -}); \ No newline at end of file +}); diff --git a/src/main/ui/static/sys/templates/manual_settle.html b/src/main/ui/static/sys/templates/manual_settle.html index 16c1e9382..2804dacc6 100644 --- a/src/main/ui/static/sys/templates/manual_settle.html +++ b/src/main/ui/static/sys/templates/manual_settle.html @@ -17,6 +17,36 @@ --> \ No newline at end of file + From ce9582ea520e3f695cb375a7c76f8d50b4eb70f5 Mon Sep 17 00:00:00 2001 From: luoyang Date: Mon, 30 Mar 2020 18:35:57 +0800 Subject: [PATCH 2/3] fix h5 redirect url encode --- src/main/ui/static/templates/skip_wxbrowser.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/ui/static/templates/skip_wxbrowser.js b/src/main/ui/static/templates/skip_wxbrowser.js index fbf786dcd..bdd95f702 100644 --- a/src/main/ui/static/templates/skip_wxbrowser.js +++ b/src/main/ui/static/templates/skip_wxbrowser.js @@ -8,6 +8,8 @@ $(function () { } else { location.href = window.target_href; } + decode(); + $('.close-weixin-tip').bind('touchstart', function () { $(".weixin-tip").hide(); checkOrderStd(window.client_moniker, window.partner_order_id, true); @@ -19,6 +21,17 @@ $(function () { location.href = window.target_href; }); + function decode() { + var redirect = window.redirect; + while (redirect.indexOf('://') < 0) { + redirect = decodeURIComponent(redirect); + if (redirect == window.redirect) { + break; + } + window.redirect = redirect; + } + } + function checkOrderStd(clientMoniker, merchantOrderId, needLoop) { if (!clientMoniker || !merchantOrderId) { return; From d8712533688d3a97c01ac42369419e34d5abf771 Mon Sep 17 00:00:00 2001 From: luoyang Date: Wed, 1 Apr 2020 18:14:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?add=20=E6=94=AF=E6=8C=81=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E6=B8=85=E7=AE=97=E6=8A=A5=E8=A1=A8=E4=B8=8B=E8=BD=BD=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E3=80=81=E9=80=80=E6=AC=BE=E5=A2=9E=E5=8A=A0=E5=BC=B9?= =?UTF-8?q?=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../web/PartnerCardDashboardController.java | 21 +- .../clearing/core/CleanService.java | 8 + .../clearing/core/impl/CleanServiceImpl.java | 234 ++++++++++++++++++ .../web/CleanLogClientController.java | 47 +++- .../log/ClearingDetailAnalysisMapper.java | 2 + .../mappers/log/ClearingDetailMapper.java | 2 + .../mappers/payment/TransactionMapper.java | 2 + .../manage/merchants/core/ClientManager.java | 2 + .../core/impls/ClientManagerImpl.java | 41 ++- .../core/impls/TradeLogServiceImpl.java | 31 ++- src/main/resources/application-dev.properties | 12 +- .../resources/application-local.properties | 22 +- .../log/ClearingDetailAnalysisMapper.xml | 25 +- .../mappers/log/ClearingDetailMapper.xml | 23 +- .../mappers/payment/TransactionMapper.xml | 37 ++- .../commons/services/clearingDetailService.js | 37 ++- .../commons/services/partnerRefunder.js | 48 ++-- .../static/payment/partner/partner-manage.js | 23 ++ .../templates/incremental_service.html | 2 +- .../partner/templates/partner_settlement.html | 10 +- .../tradelog/partner-settlement-log.js | 3 + .../templates/partner_settlement_logs.html | 15 +- 23 files changed, 587 insertions(+), 62 deletions(-) diff --git a/pom.xml b/pom.xml index dbaabb13c..9ee3066b1 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.4.22 + 1.4.23 UTF-8 1.8.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerCardDashboardController.java b/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerCardDashboardController.java index 8bd73549f..682949f6e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerCardDashboardController.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/web/PartnerCardDashboardController.java @@ -5,17 +5,20 @@ import au.com.royalpay.payment.manage.logview.beans.ClientLoginLogQueryBean; 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.pos.datasource.ReadOnlyConnection; -import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.signin.core.ClientLoginLogRepository; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.CommonConsts; -import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.text.ParseException; +import java.util.Date; import java.util.List; import java.util.Map; @@ -27,6 +30,7 @@ import java.util.Map; value = "/analysis/partner_card", method = RequestMethod.GET) public class PartnerCardDashboardController { + private Logger logger = LoggerFactory.getLogger(getClass()); @Resource private PartnerCardDashboardService partnerCardDashboardService; @Resource @@ -89,6 +93,19 @@ public class PartnerCardDashboardController { return cleanService.getCleanLogTransactions(detailId, manager); } + @RequestMapping("/{client_id}/settlement_logs/report_date/{reportDate}") + @ReadOnlyConnection + public JSONObject listClearingTransactionsOfMergeSettle(@PathVariable int client_id, @PathVariable String reportDate,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + Date date = new Date(); + try { + date = DateUtils.parseDate(reportDate, "yyyy-MM-dd"); + } catch (ParseException e) { + logger.error("parse report date error:{}", e.getMessage()); + } + String realRDate = DateFormatUtils.format(DateUtils.addDays(date, 1), "yyyy-MM-dd"); + return cleanService.getCleanLogTransactionsOfMergeSettle(client_id,realRDate, manager); + } + @RequestMapping("/settlement_logs/{detailId}/analysis/{channel}") @ReadOnlyConnection public Map getDayAndChannelOfAnalysisMap(@PathVariable int detailId, 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 026a3d6be..073af0d8f 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 @@ -34,6 +34,8 @@ public interface CleanService { JSONObject getCleanLogTransactions(int detailId, JSONObject manager); + JSONObject getCleanLogTransactionsOfMergeSettle(int clientId, String repotDate, JSONObject manager); + Map getDayAndChannelOfAnalysisMap(int detailId, String channel,JSONObject manager); JSONObject getCleanLogTransactions(int client_id, String detailId); @@ -69,10 +71,16 @@ public interface CleanService { JSONObject listClearingTransactions(int client_id, String clearingDetailId, JSONObject partner); + JSONObject listClearingTransactionsByMergeSettle(int client_id, String clearingDetailId, JSONObject partner); + Map channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel,JSONObject partner); + Map channelAndDayOfMergeSettleAnalysis(int client_id, String reportDate, String channel,JSONObject partner); + void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp); + void exportTransactionsByReportDate(String reportDate, JSONObject partner, HttpServletResponse resp); + List getSettlementMonthReport(int year, int monthOfYear); void writeSettlementMonthReportToExcel(int year, int monthOfYear, OutputStream ous) 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 416292f35..27925411a 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 @@ -304,6 +304,28 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider return cleanLog; } + @Override + public JSONObject getCleanLogTransactionsOfMergeSettle(int clientId, String reportDate, JSONObject manager) { + JSONObject clearClient = clearingDetailMapper.listReportOfMergeSettle(reportDate, clientId); + if (clearClient == null) { + throw new NotFoundException(); + } + JSONObject client = clientManager.getClientInfo(clientId); + Assert.notNull(client, "Client ID invalid"); + checkOrgPermission(manager, client); + List transactions = transactionMapper.listTransactionsOfMergeSettleClearingOrder(reportDate,clientId, + new PageBounds(Order.formString("order_id.asc"))); + clearClient.put("report", transactions); + List channels = clearingDetailAnalysisMapper.listReportChannelsOfMergeSettle(reportDate, clientId); + JSONObject channelsObj = new JSONObject(); + for (JSONObject channel : channels) { + channelsObj.put(channel.getString("channel"), channel); + } + clearClient.put("channels", channelsObj); + clearClient.put("client_moniker", client.getString("client_moniker")); + return clearClient; + } + @Override public Map getDayAndChannelOfAnalysisMap(int detailId, String channel, JSONObject manager) { JSONObject cleanLog = clearingDetailMapper.findByDetailId(detailId); @@ -850,6 +872,40 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider return clearClient; } + @Override + public JSONObject listClearingTransactionsByMergeSettle(int client_id, String reportDate, JSONObject partner) { + JSONObject client = clientManager.getClientInfo(client_id); + Assert.notNull(client, "Client not exists"); + int parent_client_id = client.getIntValue("parent_client_id"); + if (partner.get("client_id") != null) { + if (client_id != partner.getIntValue("client_id") && parent_client_id != partner.getIntValue("client_id")) { + throw new ForbiddenException("No Permission"); + } + } + JSONObject clearClient = clearingDetailMapper.listReportOfMergeSettle(reportDate, client_id); + if (clearClient == null) { + throw new NotFoundException(); + } + List transactions = transactionMapper.listTransactionsOfMergeSettleClearingOrder(reportDate,client_id, + new PageBounds(Order.formString("order_id.asc"))); + + String timezone_client = client.getString("timezone"); + if (timezone_client != null) { + transactions.parallelStream().forEach(p -> { + TimeZoneUtils.switchTimeZone(p, timezone_client, "transaction_time"); + }); + } + clearClient.put("report", transactions); + List channels = clearingDetailAnalysisMapper.listReportChannelsOfMergeSettle(reportDate, client_id); + JSONObject channelsObj = new JSONObject(); + for (JSONObject channel : channels) { + channelsObj.put(channel.getString("channel"), channel); + } + clearClient.put("channels", channelsObj); + clearClient.put("client_moniker", client.getString("client_moniker")); + return clearClient; + } + @Override public Map channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel, JSONObject partner) { JSONObject client = clientManager.getClientInfo(client_id); @@ -862,6 +918,19 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider return getDayAnalysisMap(clearingDetailId, channel, client); } + @Override + public Map channelAndDayOfMergeSettleAnalysis(int client_id, String reportDate, String channel, JSONObject partner) { + JSONObject client = clientManager.getClientInfo(client_id); + Assert.notNull(client, "Client not exists"); + int parent_client_id = client.getIntValue("parent_client_id"); + + if (client_id != partner.getIntValue("client_id") && parent_client_id != partner.getIntValue("client_id")) { + throw new ForbiddenException("No Permission"); + } + JSONObject parentClient = clientManager.getClientInfo(parent_client_id); + return getDayAnalysisMapOfMergeSettle(reportDate, channel, parentClient); + } + private Map getDayAnalysisMap(String clearingDetailId, String channel, JSONObject client) { List transactions = transactionMapper.listTransactionsOfClearingOrder(Integer.parseInt(clearingDetailId), new PageBounds(Order.formString("order_id.asc"))); @@ -907,6 +976,51 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider return dayAnalysisMap; } + private Map getDayAnalysisMapOfMergeSettle(String reportDate, String channel, JSONObject client) { + List transactions = transactionMapper.listTransactionsOfMergeSettleClearingOrder(reportDate, client.getIntValue("client_id"), + new PageBounds(Order.formString("order_id.asc"))); + String timezone_client = client.getString("timezone"); + if (!channel.equals("null")) { + transactions = transactions.stream().filter(t -> t.getString("channel").equals(channel)).collect(Collectors.toList()); + } + List dateKeysList = new ArrayList<>(); + dateKeysList.add("transaction_time"); + if (timezone_client != null) { + transactions.parallelStream().forEach(p -> { + TimeZoneUtils.switchTimeZone(p, timezone_client, "transaction_time"); + }); + TimeZoneUtils.switchTimeZoneToString(transactions, timezone_client, TimeZoneUtils.PATTERN_DATE, dateKeysList); + } + + Map> dayTransactionsMap = transactions.stream().collect(Collectors.groupingBy(x -> x.getString("transaction_time").substring(0, 10))); + Map dayAnalysisMap = new TreeMap<>(); + for (Map.Entry> entry : dayTransactionsMap.entrySet()) { + JSONObject analysis = new JSONObject(); + List transactionsOfDay = entry.getValue(); + + BigDecimal total_credit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Credit")).filter(t -> t.containsKey("clearing_amount")).map(t -> t.getBigDecimal("clearing_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal total_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("clearing_amount")).map(t -> t.getBigDecimal("clearing_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal total_charge_credit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Credit")).filter(t -> t.containsKey("total_surcharge")).map(t -> t.getBigDecimal("total_surcharge")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal total_charge_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("total_surcharge")).map(t -> t.getBigDecimal("total_surcharge")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal net_amount_credit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Credit")).filter(t -> t.containsKey("settle_amount")).map(t -> t.getBigDecimal("settle_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal net_amount_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("settle_amount")).map(t -> t.getBigDecimal("settle_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal tax_amount_credit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Credit")).filter(t -> t.containsKey("tax_amount")).map(t -> t.getBigDecimal("tax_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal tax_amount_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("tax_amount")).map(t -> t.getBigDecimal("tax_amount")).reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal tax_amount = tax_amount_credit.subtract(tax_amount_debit); + analysis.put("total_credit", total_credit.setScale(2, RoundingMode.HALF_UP)); + analysis.put("total_debit", total_debit.setScale(2, RoundingMode.HALF_UP)); + analysis.put("net_amount", net_amount_credit.subtract(net_amount_debit).setScale(2, RoundingMode.HALF_UP)); + analysis.put("clearing_amount", net_amount_credit.subtract(net_amount_debit).setScale(2, RoundingMode.HALF_UP)); + analysis.put("tax_amount", tax_amount.setScale(2, RoundingMode.HALF_UP)); + analysis.put("total_surcharge", total_charge_credit.subtract(total_charge_debit).setScale(2, RoundingMode.HALF_UP)); + analysis.put("total_charge", total_charge_credit.subtract(total_charge_debit).add(tax_amount).setScale(2, RoundingMode.HALF_UP)); + analysis.put("gross_amount", total_credit.subtract(total_debit).setScale(2, RoundingMode.HALF_UP)); + dayAnalysisMap.put(entry.getKey(), analysis); + } + return dayAnalysisMap; + } + @Override public void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp) { OutputStream ous = null; @@ -1028,6 +1142,126 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider } } + @Override + public void exportTransactionsByReportDate(String reportDate, JSONObject partner, HttpServletResponse resp) { + OutputStream ous = null; + try { + JSONObject clearTransation = listClearingTransactionsByMergeSettle(partner.getIntValue("client_id"), reportDate, partner); + resp.setContentType("application/octet-stream;"); + resp.addHeader("Content-Disposition", + "attachment; filename=" + "Merchant_Settlement_Info_" + reportDate + ".xlsx"); + ous = resp.getOutputStream(); + Workbook wb = new XSSFWorkbook(); + Cell cell = null; + Font font = wb.createFont(); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + font.setFontHeightInPoints((short) 10); + CellStyle analysisStyle = wb.createCellStyle(); + analysisStyle.setFont(font); + + //红色字体提示 + Font font2 = wb.createFont(); + font.setBoldweight(Font.BOLDWEIGHT_BOLD); + font2.setFontHeightInPoints((short) 10); + font2.setColor(HSSFColor.RED.index); + CellStyle analysisStyle2 = wb.createCellStyle(); + analysisStyle2.setFont(font2); + + Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + reportDate); + int rowNum = 0; + Row row = sheet.createRow(rowNum); + String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency", + "Input Amount", "Total Amount", "Clearing Amount(AUD)", "Sruchange Rate", "Surcharge(AUD)", "GST(AUD)", "Settle Amount(AUD)", "Remark", "Dev No", "Dev Remark"}; + String[] analysis = {"Total Credit(AUD)", "Total Debit(AUD)", "Gross Amount(AUD)", "Total GST(AUD)", "Total Charge(AUD)", "Net Amount(AUD)"}; + for (int i = 0; i < title.length; i++) { + row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]); + } + JSONObject channels = clearTransation.getJSONObject("channels"); + + for (Object o : clearTransation.getJSONArray("report")) { + JSONObject settle = (JSONObject) o; + if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) { + continue; + } + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("order_id")); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("client_order_id")); + Calendar calendar = (Calendar) settle.get("transaction_time"); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(DateFormatUtils.format(calendar, "yyyy-MM-dd HH:mm:ss", calendar.getTimeZone())); + row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("channel")); + if (settle.getInteger("gateway") != null) { + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(TradeType.fromGatewayNumber(settle.getIntValue("gateway")).getTradeType()); + } else { + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue("-"); + } + row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("exchange_rate").setScale(5, BigDecimal.ROUND_DOWN).toPlainString()); + cell = row.createCell(6, Cell.CELL_TYPE_STRING); + cell.setCellValue(settle.getString("transaction_type")); + cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null); + row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_currency")); + cell = row.createCell(8, Cell.CELL_TYPE_STRING); + cell.setCellValue(settle.getBigDecimal("display_amount") == null ? "" + : "Credit".equals(settle.getString("transaction_type")) ? + settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() : + "-" + settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); + cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null); + cell = row.createCell(9, Cell.CELL_TYPE_STRING); + cell.setCellValue(settle.getBigDecimal("transaction_amount") == null ? "" + : "Credit".equals(settle.getString("transaction_type")) ? + settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() : + "-" + settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); + cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null); + cell = row.createCell(10, Cell.CELL_TYPE_STRING); + cell.setCellValue(settle.getBigDecimal("clearing_amount") == null ? "" + : "Credit".equals(settle.getString("transaction_type")) ? + settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() : + "-" + settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); + cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null); + row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(channels.getString(settle.getString("channel")) == null ? "" + : channels.getJSONObject(settle.getString("channel")).getBigDecimal("rate").toPlainString() + "%"); + //手续费 + gst + row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("total_surcharge") == null ? "" + : settle.getBigDecimal("total_surcharge").setScale(2, RoundingMode.DOWN).toPlainString()); + row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("tax_amount") == null ? "" + : settle.getBigDecimal("tax_amount").setScale(2, RoundingMode.DOWN).toPlainString()); + cell = row.createCell(14, Cell.CELL_TYPE_STRING); + cell.setCellValue(settle.getBigDecimal("settle_amount") == null ? "" + : "Credit".equals(settle.getString("transaction_type")) ? + settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() : + "-" + settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); + cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null); + row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("order_detail")); + String clientDevId = StringUtils.defaultString(settle.getString("dev_id"), "-"); + JSONObject device = clientDeviceMapper.find(settle.getString("dev_id")); + String clientDevRemark = "-"; + if (device != null) { + clientDevId = device.getString("client_dev_id"); + clientDevRemark = device.getString("remark"); + } + row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(clientDevId); + row.createCell(17, Cell.CELL_TYPE_STRING).setCellValue(clientDevRemark); + } + row = sheet.createRow(++rowNum); + for (int i = 0; i < analysis.length; i++) { + cell = row.createCell(i, Cell.CELL_TYPE_STRING); + cell.setCellStyle(analysisStyle); + cell.setCellValue(analysis[i]); + } + row = sheet.createRow(++rowNum); + row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("total_payment")); + row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("total_refund")); + row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("gross_amount")); + row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("tax_amount")); + row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("total_charge")); + row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("clearing_amount")); + wb.write(ous); + ous.flush(); + } catch (IOException e) { + } finally { + IOUtils.closeQuietly(ous); + } + } + @Override public List getSettlementMonthReport(int year, int monthOfYear) { return clearingLogMapper.getSettlementMonthReport(year, monthOfYear); diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/CleanLogClientController.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/CleanLogClientController.java index 2c59a8b13..73eb6d09b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/CleanLogClientController.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/CleanLogClientController.java @@ -2,16 +2,19 @@ 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.PartnerMapping; -import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.text.ParseException; +import java.util.Date; import java.util.List; import java.util.Map; @@ -23,6 +26,7 @@ import java.util.Map; public class CleanLogClientController { @Resource private CleanService cleanService; + private Logger logger = LoggerFactory.getLogger(getClass()); @RequestMapping public List listMonthCleanLogs(@RequestParam String month, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject client) { @@ -39,18 +43,59 @@ public class CleanLogClientController { return cleanService.listClearingTransactions(client_id, clearingDetailId, partner); } + @RequestMapping("/{client_id}/settlement_logs/report_date/{reportDate}") + public JSONObject listClearingTransactionsOfMergeSettle(@PathVariable int client_id, @PathVariable String reportDate, + @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) { + Date date = new Date(); + try { + date = DateUtils.parseDate(reportDate, "yyyy-MM-dd"); + } catch (ParseException e) { + logger.error("parse report date error:{}", e.getMessage()); + } + String realRDate = DateFormatUtils.format(DateUtils.addDays(date, 1), "yyyy-MM-dd"); + JSONObject data = cleanService.listClearingTransactionsByMergeSettle(partner.getIntValue("client_id"), realRDate, partner); + data.put("report_date", reportDate); + return data; + } + @RequestMapping("/{client_id}/settlement_logs/{clearingDetailId}/analysis/{channel}") public Map channelAndDayOfAnalysis(@PathVariable int client_id, @PathVariable String clearingDetailId, @PathVariable String channel, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) { return cleanService.channelAndDayOfAnalysis(client_id, clearingDetailId,channel,partner); } + @RequestMapping("/{client_id}/settlement_logs/report_date/{reportDate}/analysis/{channel}") + public Map channelAndDayOfMergeSettleAnalysis(@PathVariable int client_id, @PathVariable String reportDate, + @PathVariable String channel, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) { + Date date = new Date(); + try { + date = DateUtils.parseDate(reportDate, "yyyy-MM-dd"); + } catch (ParseException e) { + logger.error("parse report date error:{}", e.getMessage()); + } + String realRDate = DateFormatUtils.format(DateUtils.addDays(date, 1), "yyyy-MM-dd"); + return cleanService.channelAndDayOfMergeSettleAnalysis(client_id, realRDate,channel,partner); + } + @PartnerMapping("/{client_id}/settlement_logs/{clearingDetailId}/export") public void exportListClearingTransactions(@PathVariable int client_id, @PathVariable String clearingDetailId, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse resp) { cleanService.exportListClearingTransactions(client_id, clearingDetailId, partner, resp); } + @PartnerMapping("/{client_id}/settlement_logs/report_date/{reportDate}/export") + public void exportTransactionsByReportDate(@PathVariable int client_id, @PathVariable String reportDate, + @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse resp) { + Date date = new Date(); + try { + date = DateUtils.parseDate(reportDate, "yyyy-MM-dd"); + } catch (ParseException e) { + logger.error("parse report date error:{}", e.getMessage()); + } + String realRDate = DateFormatUtils.format(DateUtils.addDays(date, 1), "yyyy-MM-dd"); + cleanService.exportTransactionsByReportDate(realRDate, partner, resp); + } + // @RequestMapping(value = "/{clearId}.json") // public JSONObject getCleanLog(@PathVariable int clearId, @ModelAttribute(Consts.PARTNER_STATUS) JSONObject // client) { 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 e3909408a..ab8135def 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,6 +26,8 @@ public interface ClearingDetailAnalysisMapper { @AutoSql(type = SqlType.SELECT) List listReportChannels(@Param("clearing_detail_id") String clearDetailId); + List listReportChannelsOfMergeSettle(@Param("report_date") String reportDate, @Param("client_id") int clientId); + 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 89a8d9953..7ce6ff78a 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 @@ -37,6 +37,8 @@ public interface ClearingDetailMapper { @AutoSql(type = SqlType.SELECT) JSONObject listReport(@Param("clear_detail_id") String clearDetailId, @Param("client_id") int client_id); + JSONObject listReportOfMergeSettle(@Param("report_date") String reportDate, @Param("client_id") int client_id); + @AutoSql(type = SqlType.SELECT) JSONObject listReportByDate(@Param("report_date") Date date, @Param("client_id") int clientId); 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 1aa16dbe8..25bd07d38 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 @@ -59,6 +59,8 @@ public interface TransactionMapper { List listTransactionsOfClearingOrder(@Param("clearing_order") int detailId, PageBounds pagination); + List listTransactionsOfMergeSettleClearingOrder(@Param("report_date") String reportDate, @Param("client_id") int clientId, PageBounds pagination); + List listSettlementTransactions(@Param("clearing_order") int detailId); PageList listSettlementLog(JSONObject params, PageBounds pagination); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 975e0cb13..b51b34a96 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -558,4 +558,6 @@ public interface ClientManager { RSvcMchBean findSvcMchByAccountId(String accountId); void queryModifyClientIds(int clientId, JSONObject params); + + boolean getMergeSettleStatus(JSONObject client); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index df87e3b4a..e37d42b31 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -82,6 +82,7 @@ import cn.yixblog.platform.http.HttpRequestGenerator; import cn.yixblog.platform.http.HttpRequestResult; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; @@ -4004,6 +4005,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid JSONObject params = query.toParams(timezone); params.put("client_id", client_id); queryModifyClientIds(client_id, params); + boolean mergeSettle = getMergeSettleStatus(client); + + if (mergeSettle && query.getClient_ids() == null) { + params.remove("client_ids"); + params.put("merge_settle", true); + } PageList logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); JSONObject result = PageListUtils.buildPageListResult(logs); @@ -4047,17 +4054,25 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid JSONObject params = query.toParams(timezone); params.put("client_id", client_id); queryModifyClientIds(client_id, params); + boolean mergeSettle = getMergeSettleStatus(client); + + if (mergeSettle && query.getClient_ids() == null) { + params.remove("client_ids"); + params.put("merge_settle", true); + } PageList logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), 10000, Order.formString("clearing_time.desc"))); //Excel 多sheet导出 try (HSSFWorkbook workbook = new HSSFWorkbook()) { if (query.getClient_ids() == null) { addSheet(0, workbook, client, logs); - List childs = clientMapper.listChildClients(client.getIntValue("client_id")); - for (int i = 0; i < childs.size(); i++) { - params.put("client_id", childs.get(i).getInteger("client_id")); - PageList childLogs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), 10000, Order.formString("clearing_time.desc"))); - if (childLogs.size() > 0) { - addSheet(i + 1, workbook, childs.get(i), childLogs); + if (!mergeSettle) { + List childs = clientMapper.listChildClients(client.getIntValue("client_id")); + for (int i = 0; i < childs.size(); i++) { + params.put("client_id", childs.get(i).getInteger("client_id")); + PageList childLogs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), 10000, Order.formString("clearing_time.desc"))); + if (childLogs.size() > 0) { + addSheet(i + 1, workbook, childs.get(i), childLogs); + } } } } else { @@ -6671,6 +6686,20 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } } + @Override + public boolean getMergeSettleStatus(JSONObject client) { + String extParams = client.getString("ext_params"); + if (extParams != null) { + try { + JSONObject ext = JSON.parseObject(extParams); + return ext.getBooleanValue("merge_settle"); + } catch (JSONException e) { + return false; + } + } + return false; + } + private void afterGeekShopSave(JSONObject serviceInfo, JSONObject client) { JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id")); clientConfig.put("geek_shop_status", 1); diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java index 9ace49c48..64a28bfde 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java @@ -1000,15 +1000,22 @@ public class TradeLogServiceImpl implements TradeLogService { @Override public JSONObject listSettlementLog(TradeLogQuery query, JSONObject partner) { + JSONObject client = clientManager.getClientInfoByMoniker(partner.getString("client_moniker")); int clientId = partner.getIntValue("client_id"); String timezone = partner.getJSONObject("client").getString("timezone"); JSONObject params = query.toParams(timezone); params.put("client_id", clientId); clientManager.queryModifyClientIds(clientId, params); + JSONObject result = new JSONObject(); + result.put("analysis", transactionMapper.getClientAmountAnalysis(params)); + boolean mergeSettle = clientManager.getMergeSettleStatus(client); + if (mergeSettle && query.getClient_ids() == null) { + params.remove("client_ids"); + params.put("merge_settle", true); + } PageList logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); - JSONObject result = PageListUtils.buildPageListResult(logs); - result.put("analysis", transactionMapper.getClientAmountAnalysis(params)); + result.putAll(PageListUtils.buildPageListResult(logs)); if (query.getPage() == 1) { if (!logs.isEmpty()) { JSONObject clearingDetail = clearingDetailMapper.findByDetailId(logs.get(0).getIntValue("clear_detail_id")); @@ -1039,17 +1046,25 @@ public class TradeLogServiceImpl implements TradeLogService { JSONObject params = query.toParams(timezone); params.put("client_id", clientId); clientManager.queryModifyClientIds(clientId, params); + boolean mergeSettle = clientManager.getMergeSettleStatus(client); + + if (mergeSettle && query.getClient_ids() == null) { + params.remove("client_ids"); + params.put("merge_settle", true); + } PageList logs = transactionMapper.listSettlementLog(params, new PageBounds(1, 100000000, Order.formString("clearing_time.desc"))); try (HSSFWorkbook workbook = new HSSFWorkbook()) { if (query.getClient_ids() == null) { addSheet(0, workbook, client, logs); - List childs = clientMapper.listChildClients(client.getIntValue("client_id")); - for (int i = 0; i < childs.size(); i++) { - params.put("client_id", childs.get(i).getInteger("client_id")); - PageList childLogs = transactionMapper.listSettlementLog(params, new PageBounds(1, 100000000, Order.formString("clearing_time.desc"))); - if (childLogs.size() > 0) { - addSheet(i + 1, workbook, childs.get(i), childLogs); + if (!mergeSettle) { + List childs = clientMapper.listChildClients(client.getIntValue("client_id")); + for (int i = 0; i < childs.size(); i++) { + params.put("client_id", childs.get(i).getInteger("client_id")); + PageList childLogs = transactionMapper.listSettlementLog(params, new PageBounds(1, 100000000, Order.formString("clearing_time.desc"))); + if (childLogs.size() > 0) { + addSheet(i + 1, workbook, childs.get(i), childLogs); + } } } } else { diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 6f4d63ef2..1cf8273d3 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -3,14 +3,14 @@ spring.datasource.type = com.zaxxer.hikari.HikariDataSource #数据源master spring.datasource.master.schema-name=royalpay_production -spring.datasource.master.host=192.168.0.4:3306 +spring.datasource.master.host=119.28.3.196:3310 spring.datasource.master.jdbc-url=jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false -spring.datasource.master.username=taylor -spring.datasource.master.password=taylor +spring.datasource.master.username=readonly +spring.datasource.master.password=read0nly #数据源salve spring.datasource.slave.schema-name=royalpay_production -spring.datasource.slave.host=192.168.0.4:3306 +spring.datasource.slave.host=119.28.3.196:3310 spring.datasource.slave.jdbc-url=jdbc:mysql://${spring.datasource.slave.host}/${spring.datasource.slave.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false -spring.datasource.slave.username=taylor -spring.datasource.slave.password=taylor +spring.datasource.slave.username=readonly +spring.datasource.slave.password=read0nly diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 3455edb96..1cf8273d3 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -1,6 +1,16 @@ -spring.datasource.driver-class-name=com.mysql.jdbc.Driver -spring.datasource.schema-name=royalpay_production -spring.datasource.host=127.0.0.1:3306 -spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false -spring.datasource.username=root -spring.datasource.password=root \ No newline at end of file +#多数据源配置 +spring.datasource.type = com.zaxxer.hikari.HikariDataSource +#数据源master + +spring.datasource.master.schema-name=royalpay_production +spring.datasource.master.host=119.28.3.196:3310 +spring.datasource.master.jdbc-url=jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false +spring.datasource.master.username=readonly +spring.datasource.master.password=read0nly + +#数据源salve +spring.datasource.slave.schema-name=royalpay_production +spring.datasource.slave.host=119.28.3.196:3310 +spring.datasource.slave.jdbc-url=jdbc:mysql://${spring.datasource.slave.host}/${spring.datasource.slave.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false +spring.datasource.slave.username=readonly +spring.datasource.slave.password=read0nly 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 4db57c4ab..2163c5568 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 @@ -31,6 +31,29 @@ WHERE c.settle_date = #{settle_date} GROUP BY a.channel + + - \ No newline at end of file + diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.xml index 8170880c7..8444788cb 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/log/ClearingDetailMapper.xml @@ -68,6 +68,27 @@ + + - \ 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 d04b5e7b5..e64ed299a 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 @@ -559,23 +559,23 @@ @@ -1155,6 +1156,30 @@ AND t.clearing_order = #{clearing_order} ]]> + + +