From a4bfebe22a287636290e00b149e35d4e2fe6a784 Mon Sep 17 00:00:00 2001 From: yixian Date: Tue, 26 Jun 2018 12:37:02 +0800 Subject: [PATCH] settle log view edit --- .../core/impls/DashboardServiceImpl.java | 1 + .../beans/CityPartnerCommissionAnalysis.java | 1 + .../beans/ReferrerCommissionAnalysis.java | 1 + .../impls/XPlanFundConfigServiceImpl.java | 3 +- .../clearing/core/CleanService.java | 2 +- .../clearing/core/impl/CleanServiceImpl.java | 21 ++- .../core/impl/SettleDelayConfigurerImpl.java | 1 + .../core/impls/ActRedPackServiceImpl.java | 1 + src/main/ui/static/analysis/clearing-log.js | 176 ++++++++++++------ .../analysis/templates/settlement_detail.html | 93 +++++++-- 10 files changed, 210 insertions(+), 90 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java index ce393d720..c9937503d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java @@ -27,6 +27,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; diff --git a/src/main/java/au/com/royalpay/payment/manage/citypartner/beans/CityPartnerCommissionAnalysis.java b/src/main/java/au/com/royalpay/payment/manage/citypartner/beans/CityPartnerCommissionAnalysis.java index 0f0a9133b..ff589afc3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/citypartner/beans/CityPartnerCommissionAnalysis.java +++ b/src/main/java/au/com/royalpay/payment/manage/citypartner/beans/CityPartnerCommissionAnalysis.java @@ -6,6 +6,7 @@ import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import com.alibaba.fastjson.JSONObject; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; /** diff --git a/src/main/java/au/com/royalpay/payment/manage/citypartner/beans/ReferrerCommissionAnalysis.java b/src/main/java/au/com/royalpay/payment/manage/citypartner/beans/ReferrerCommissionAnalysis.java index af2bc0ea4..611b090a8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/citypartner/beans/ReferrerCommissionAnalysis.java +++ b/src/main/java/au/com/royalpay/payment/manage/citypartner/beans/ReferrerCommissionAnalysis.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.tools.CommonConsts; import com.alibaba.fastjson.JSONObject; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; /** diff --git a/src/main/java/au/com/royalpay/payment/manage/fund/core/impls/XPlanFundConfigServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/fund/core/impls/XPlanFundConfigServiceImpl.java index 826c05081..56ee61c21 100644 --- a/src/main/java/au/com/royalpay/payment/manage/fund/core/impls/XPlanFundConfigServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/fund/core/impls/XPlanFundConfigServiceImpl.java @@ -24,6 +24,7 @@ import com.github.miemiedev.mybatis.paginator.domain.PageList; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -118,10 +119,10 @@ public class XPlanFundConfigServiceImpl implements XPlanFundConfigService { private JSONObject getClient(String clientMoniker) { JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); - client.putAll(clientConfigService.find(client.getIntValue("client_id"))); if (client == null) { throw new InvalidShortIdException(); } + client.putAll(clientConfigService.find(client.getIntValue("client_id"))); return client; } 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 36a053966..3fbe1e9ac 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 @@ -43,7 +43,7 @@ public interface CleanService { void settlementXlsx(Date date, HttpServletResponse response) throws IOException; - List getXlsx(Date date) throws IOException; + List getXlsx(Date dt, String bank) throws IOException; List getAba(Date dt, String bank) 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 0779043c8..4b2e53e46 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 @@ -211,7 +211,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider addBigDecimal(total, log, "wechat_charge"); addBigDecimal(total, log, "royalpay_charge"); addBigDecimal(total, log, "net_amount"); - List logDetails = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")); + int clearingId = log.getIntValue("clearing_id"); + List logDetails = clearingDetailMapper.listReportsOfSettlement(clearingId); details.addAll(logDetails); List banks = logDetails.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList()); List bankStatistics = banks.stream().map(bank -> { @@ -219,13 +220,14 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider data.put("bank", bank); data.put("total_settle", logDetails.stream() .filter(detail -> bank.equals(detail.getString("settle_bank"))) - .map(detail -> detail.getBigDecimal("net_amount")) + .map(detail -> detail.getBigDecimal("clearing_amount")) .reduce(BigDecimal::add) ); return data; }).collect(Collectors.toList()); log.put("bank_statistics", bankStatistics); log.put("editable", DateUtils.isSameDay(log.getDate("settle_date"), new Date()) && log.getBooleanValue("editable")); + log.put("channel_analysis", clearingDetailAnalysisMapper.analysisChannelReport(clearingId)); } total.put("logs", logs); total.put("details", details); @@ -340,7 +342,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider String filename = "Merchant_Settlement_Info_" + dateString + RandomStringUtils.random(8, false, true) + ".xlsx"; zos.putNextEntry(new ZipEntry(filename)); List details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")); - byte[] xlsx = generateSettleXlsxFile(dt, details); + byte[] xlsx = generateSettleXlsxFile(dt, details, null); IOUtils.write(xlsx, zos); } zos.flush(); @@ -348,7 +350,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider } @Override - public List getXlsx(Date dt) throws IOException { + public List getXlsx(Date dt, String bank) throws IOException { List logs = clearingLogMapper.findByDate(dt); if (logs.isEmpty()) { throw new NotFoundException(); @@ -360,7 +362,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider String filename = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + "_" + fileIndex + ".xlsx"; JSONObject file = new JSONObject(); file.put("name", filename); - file.put("byteArr", generateSettleXlsxFile(dt, clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")))); + file.put("byteArr", generateSettleXlsxFile(dt, clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")), bank)); result.add(file); fileIndex++; } @@ -369,7 +371,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider String filename = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + ".xlsx"; JSONObject file = new JSONObject(); file.put("name", filename); - file.put("byteArr", generateSettleXlsxFile(dt, clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")))); + file.put("byteArr", generateSettleXlsxFile(dt, clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")), bank)); result.add(file); } } @@ -391,7 +393,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider return files.stream().filter(file -> bank.equals(file.bank())).collect(Collectors.toList()); } - private byte[] generateSettleXlsxFile(Date dt, List settlements) throws IOException { + private byte[] generateSettleXlsxFile(Date dt, List settlements, String bank) throws IOException { Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMM")); int rowNum = 0; @@ -399,6 +401,9 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) { continue; } + if (bank != null && Objects.equals(settle.getString("settle_bank"), bank)) { + continue; + } Row row = sheet.createRow(rowNum++); row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("bsb_no")); row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("account_no")); @@ -931,7 +936,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider String fileName1 = "Merchant_Settlement_Info_xlsx_" + DateFormatUtils.format(date, "yyyyMMdd"); List attachList = new ArrayList<>(); JSONObject attach1 = new JSONObject(); - List xlsxFileList = getXlsx(date); + List xlsxFileList = getXlsx(date, "CBA"); if (xlsxFileList.size() > 1) { fileName1 += ".zip"; attach1.put("content", Base64.encodeBase64String(getZipByteArr(xlsxFileList))); diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/SettleDelayConfigurerImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/SettleDelayConfigurerImpl.java index f791d1d1f..d5eb104f7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/SettleDelayConfigurerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/SettleDelayConfigurerImpl.java @@ -34,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; diff --git a/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java index 8b93b74b1..231fb5f48 100644 --- a/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/redpack/core/impls/ActRedPackServiceImpl.java @@ -34,6 +34,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.Assert; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.Collections; import java.util.Date; import java.util.List; diff --git a/src/main/ui/static/analysis/clearing-log.js b/src/main/ui/static/analysis/clearing-log.js index 4067e4606..5ff29eb1a 100644 --- a/src/main/ui/static/analysis/clearing-log.js +++ b/src/main/ui/static/analysis/clearing-log.js @@ -241,65 +241,119 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func }) } }]); - app.controller('settlementDetailCtrl', ['$scope', '$stateParams', '$http','$uibModal','$filter','detail','commonDialog', function ($scope, $stateParams,$http,$uibModal,$filter, detail,commonDialog) { - $scope.detail = detail.data; - $scope.hasSentMail = false; - $scope.sendNotice = false; - $scope.noticeResend = false; + app.controller('settlementDetailCtrl', ['$scope', '$stateParams', '$http', '$uibModal', '$filter', '$state', 'detail', 'commonDialog', + function ($scope, $stateParams, $http, $uibModal, $filter, $state, detail, commonDialog) { + $scope.detail = detail.data; + $scope.hasSentMail = false; + $scope.sendNotice = false; + $scope.noticeResend = false; + $scope.analysisFilter = {}; + $scope.currentAnalysis = $scope.detail; - $scope.settleAnalysis = [ - {settleDays: 1, clients: 0, settleAmount: 0, settles: []}, - {settleDays: 2, clients: 0, settleAmount: 0, settles: []}, - {settleDays: 3, clients: 0, settleAmount: 0, settles: []} - ]; - angular.forEach($scope.detail.details, function (settleItem) { - var settleDays = settleItem.clear_days; - var analysisItem = $scope.settleAnalysis[Math.min(settleDays - 1, 2)]; - analysisItem.settles.push(settleItem); - analysisItem.clients++; - analysisItem.settleAmount = Decimal.add(analysisItem.settleAmount, settleItem.clearing_amount).toFixed(2, Decimal.ROUND_FLOOR) - }); - var nowStr = $filter('date')(new Date(), "yyyy-MM-dd"); - $scope.datePattern = $stateParams.date; - if($scope.datePattern == nowStr){ - $scope.sendNotice = true; - } - $scope.displaySendCheckCode = function () { - $uibModal.open({ - templateUrl: '/static/analysis/templates/settlement_send_check_code.html', - controller: 'settlementSendCheckCodeCtrl', - size: 'sm' - }); - }; + function getAnalysisTemplate() { + return [ + {settleDays: 1, clients: 0, settleAmount: 0, settles: []}, + {settleDays: 2, clients: 0, settleAmount: 0, settles: []}, + {settleDays: 3, clients: 0, settleAmount: 0, settles: []} + ]; + } - $http.get('/sys/settlement/reports/'+$stateParams.date+'/send_status/').then(function (resp) { - if(resp.data!=null && resp.data.mail_status ==1){ - $scope.hasSentMail = true; + $scope.settleAnalysis = getAnalysisTemplate(); + + $scope.batchAnalysis = { + 'All': $scope.settleAnalysis + }; + angular.forEach($scope.detail.logs, function (batch) { + $scope.batchAnalysis[batch.clearing_id+''] = getAnalysisTemplate(); + }); + + angular.forEach($scope.detail.details, function (settleItem) { + var settleDays = settleItem.clear_days; + attachAnalysis($scope.settleAnalysis[Math.min(settleDays - 1, 2)]); + attachAnalysis($scope.batchAnalysis[settleItem.clearing_id+''][Math.min(settleDays - 1, 2)]); + function attachAnalysis(analysisItem) { + analysisItem.settles.push(settleItem); + analysisItem.clients++; + analysisItem.settleAmount = Decimal.add(analysisItem.settleAmount, settleItem.clearing_amount).toFixed(2, Decimal.ROUND_FLOOR); + } + }); + var nowStr = $filter('date')(new Date(), "yyyy-MM-dd"); + $scope.datePattern = $stateParams.date; + if ($scope.datePattern == nowStr) { + $scope.sendNotice = true; } - }) - $scope.$on("sendMailSuccess", - function (event, msg) { - $scope.hasSentMail = true; - }); + $scope.displaySendCheckCode = function () { + $uibModal.open({ + templateUrl: '/static/analysis/templates/settlement_send_check_code.html', + controller: 'settlementSendCheckCodeCtrl', + size: 'sm' + }); + }; + + $scope.switchSettleBatch = function (batch) { + if (batch == null) { + $scope.currentAnalysis = $scope.detail; + $scope.analysisFilter.clearing_id = null; + } else { + $scope.analysisFilter.clearing_id = batch.clearing_id; + $scope.currentAnalysis = batch; + } + + }; - $scope.confirmSendSettlementMail = function () { - commonDialog.confirm({ - title: 'Confirm to send notice', - content: '请确认账户已扣款后再发送清算通知', - choises : [{label: 'Send', className: 'btn-success', key: '1'}, - {label: 'Cancel', className: 'btn-danger', key: '2', dismiss: true}] - }).then(function () { - $scope.noticeResend=true; - $http.post('/sys/settlement/settlement_notice').then(function () { - commonDialog.alert({title: 'Success', content: '发送成功', type: 'success'}); - $scope.noticeResend=false; - },function (resp) { - commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); - $scope.noticeResend=false; + $scope.getCurrentLog = function () { + return $scope.detail.logs.filter(function (log) { + return log.clearing_id === $scope.analysisFilter.clearing_id + })[0]; + }; + + $http.get('/sys/settlement/reports/' + $stateParams.date + '/send_status/').then(function (resp) { + if (resp.data != null && resp.data.mail_status == 1) { + $scope.hasSentMail = true; + } + }); + $scope.$on("sendMailSuccess", + function (event, msg) { + $scope.hasSentMail = true; }); - }) - }; - }]); + + $scope.confirmSendSettlementMail = function () { + commonDialog.confirm({ + title: 'Confirm to send notice', + content: '请确认账户已扣款后再发送清算通知', + choises: [{label: 'Send', className: 'btn-success', key: '1'}, + {label: 'Cancel', className: 'btn-danger', key: '2', dismiss: true}] + }).then(function () { + $scope.noticeResend = true; + $http.post('/sys/settlement/settlement_notice').then(function () { + commonDialog.alert({title: 'Success', content: '发送成功', type: 'success'}); + $scope.noticeResend = false; + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + $scope.noticeResend = false; + }); + }) + }; + + $scope.lockSettleLog = function (clearingId) { + commonDialog.confirm({title: '确认操作', content: '当前操作将标记本批次清算已发送,无法撤回,确认操作?'}).then(function () { + $http.put('/sys/settlement/reports/' + $stateParams.date + '/clearings/' + clearingId + '/lock').then(function () { + $scope.detail.logs.filter(function (log) { + return log.clearing_id === clearingId + }).forEach(function (log) { + log.editable = 0 + }); + commonDialog.alert({title: 'Success', content: 'Operation success', type: 'success'}); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); + }) + }) + }; + + $scope.distributeBankDialog = function () { + var log = $scope.getCurrentLog(); + } + }]); app.controller('settlementTransactionsCtrl', ['$scope', '$stateParams', 'detail', function ($scope, $stateParams, detail) { $scope.ctrl = {channel: null}; $scope.report = detail.data; @@ -341,7 +395,7 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func }; }]); - app.controller('settlementSendCheckCodeCtrl',['$scope', '$http','$rootScope','$stateParams', function ($scope, $http,$rootScope,$stateParams) { + app.controller('settlementSendCheckCodeCtrl', ['$scope', '$http', '$rootScope', '$stateParams', function ($scope, $http, $rootScope, $stateParams) { $scope.sendCheckCodeButton = false; $scope.sendMailButton = false; $scope.check_code = ''; @@ -354,15 +408,15 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func $scope.sendSettlementMail = function () { $scope.error_msg = '正在发送,请稍后。'; - if($scope.check_code =='' || $scope.check_code == null){ + if ($scope.check_code == '' || $scope.check_code == null) { $scope.error_msg = '请输入验证码'; return; } - $scope.sendMailButton= true; - $http.get('/sys/settlement/reports/'+$stateParams.date+'/send_settlement_xlsx/'+$scope.check_code).then(function (resp) { - $scope.error_msg =resp.data.msg; - $scope.sendMailButton= false; - if(resp.data.result==0){ + $scope.sendMailButton = true; + $http.get('/sys/settlement/reports/' + $stateParams.date + '/send_settlement_xlsx/' + $scope.check_code).then(function (resp) { + $scope.error_msg = resp.data.msg; + $scope.sendMailButton = false; + if (resp.data.result == 0) { $scope.sendMailButton = true; $rootScope.$broadcast("sendMailSuccess", '123'); } diff --git a/src/main/ui/static/analysis/templates/settlement_detail.html b/src/main/ui/static/analysis/templates/settlement_detail.html index 216373876..3d71c89be 100644 --- a/src/main/ui/static/analysis/templates/settlement_detail.html +++ b/src/main/ui/static/analysis/templates/settlement_detail.html @@ -28,69 +28,118 @@ class="btn btn-primary"> Settlement.aba - - - - +
+
Settlement Batches [{{datePattern}}]
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
    +
  • + Bank Statistics +
  • +
  • +
    + + +
    +
  • +
+
+
-
Settlement analysis at {{datePattern}}
+
Settlement analysis
Total Credit - +
Total Debit - +
Gross Amount - +
Net Amount - +
Total Charge + ng-bind="(currentAnalysis.wechat_charge+currentAnalysis.royalpay_charge)|currency:''">
Channel Charge - +
RoyalPay Charge - +
Operate Time - +
+ +
    -
  • +
  • T+{{group.settleDays}} @@ -104,9 +153,11 @@
      -
    • +
    • - + Gross Amount:{{ channel.gross_amount|currency:''}} RoyalPay Charge:{{channel.royalpay_charge|currency:''}} @@ -115,8 +166,12 @@
    -
    -
    T+{{group.settleDays}}: Clients:{{group.clients}} Amount:{{group.settleAmount|currency:''}}
    + +
    +
    T+{{group.settleDays}}: Clients:{{group.clients}} + Amount:{{group.settleAmount|currency:''}} +