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 @@ SELECT - s.request_time, - c.client_id, - c.client_moniker + s.request_time, + cc.client_id, + cc.client_moniker, + ifnull(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)), 0) as unsettle 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_client_config cc ON cc.client_id = s.client_id + LEFT JOIN pmt_transactions t on cc.client_id = t.client_id + and t.clearing_status = 0 + 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 + group by cc.client_id - \ No newline at end of file + + + SELECT + count(distinct cc.client_id) as manual_settle_clients, + ifnull(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)), 0) as unsettle + FROM + task_client_manual_settle s + RIGHT JOIN sys_client_config cc ON cc.client_id = s.client_id + LEFT JOIN pmt_transactions t on cc.client_id = t.client_id + and t.clearing_status = 0 + 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 + + 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 @@ --> + + + + + + 未清算交易额 + + + + + + + + + 开通手动清算商户数 + + + + + + + + + 总商户数 + + + + + + 商户 @@ -37,5 +67,23 @@ + + + + Total Records:{{pagination.totalCount}};Total + Pages:{{pagination.totalPages}} + + + - \ No newline at end of file +