settle log view edit

master
yixian 6 years ago
parent 0de03e2364
commit a4bfebe22a

@ -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;

@ -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.*;
/**

@ -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.*;
/**

@ -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;
}

@ -43,7 +43,7 @@ public interface CleanService {
void settlementXlsx(Date date, HttpServletResponse response) throws IOException;
List<JSONObject> getXlsx(Date date) throws IOException;
List<JSONObject> getXlsx(Date dt, String bank) throws IOException;
List<ABAFile> getAba(Date dt, String bank) throws IOException;

@ -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<JSONObject> logDetails = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
int clearingId = log.getIntValue("clearing_id");
List<JSONObject> logDetails = clearingDetailMapper.listReportsOfSettlement(clearingId);
details.addAll(logDetails);
List<String> banks = logDetails.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList());
List<JSONObject> 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<JSONObject> 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<JSONObject> getXlsx(Date dt) throws IOException {
public List<JSONObject> getXlsx(Date dt, String bank) throws IOException {
List<JSONObject> 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<JSONObject> settlements) throws IOException {
private byte[] generateSettleXlsxFile(Date dt, List<JSONObject> 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<JSONObject> attachList = new ArrayList<>();
JSONObject attach1 = new JSONObject();
List<JSONObject> xlsxFileList = getXlsx(date);
List<JSONObject> xlsxFileList = getXlsx(date, "CBA");
if (xlsxFileList.size() > 1) {
fileName1 += ".zip";
attach1.put("content", Base64.encodeBase64String(getZipByteArr(xlsxFileList)));

@ -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;

@ -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;

@ -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');
}

@ -28,69 +28,118 @@
class="btn btn-primary">
<i class="fa fa-download"></i> Settlement.aba
</a>
<button type="button" class="btn btn-warning " ng-if="(('1000'|withRole) && !hasSentMail)&&sendNotice" data-toggle="modal" ng-click="displaySendCheckCode()">
Send Settlement Mail
<button type="button" class="btn btn-warning " ng-if="(('1000'|withRole) && !hasSentMail)&&sendNotice"
data-toggle="modal" ng-click="displaySendCheckCode()">
Send Settlement Mail
</button>
<button class="btn btn-success" ng-if="hasSentMail" disabled="true">
<i class="fa fa-check" aria-hidden="true"></i>
Mail Has Sent
</button>
<button class="btn btn-warning" ng-if="hasSentMail && sendNotice" ng-click="confirmSendSettlementMail()" ng-disabled="noticeResend">
<button class="btn btn-warning" ng-if="hasSentMail && sendNotice" ng-click="confirmSendSettlementMail()"
ng-disabled="noticeResend">
Send Settlement Notice
</button>
</div>
</div>
<div class="box box-default">
<div class="box-header">Settlement Batches [{{datePattern}}]</div>
<div class="box-body">
<div class="row">
<div class="col-xs-12">
<div class="btn-group">
<button class="btn btn-default" ng-click="switchSettleBatch(null)"
ng-class="{active:analysisFilter.clearing_id==null}">All
</button>
<button class="btn btn-default" ng-repeat="log in detail.logs"
ng-click="switchSettleBatch(log)"
ng-class="{active:analysisFilter.clearing_id==log.clearing_id}">
<i class="fa fa-lock" ng-if="!log.editable"></i>
<span ng-bind="log.operate_time"></span>
</button>
</div>
</div>
</div>
<div class="row" ng-if="analysisFilter.clearing_id!=null">
<button class="btn btn-danger" ng-if="getCurrentLog().editable"
ng-click="lockSettleLog(analysisFilter.clearing_id)">
Mark as send
</button>
<button class="btn btn-primary" ng-if="getCurrentLog().editable"
ng-click="distributeBankDialog()">
Distribute Bank
</button>
</div>
</div>
</div>
<div class="row" ng-if="analysisFilter.clearing_id!=null">
<div class="col-xs-12">
<ul class="list-group">
<li class="list-group-item">
<span class="list-group-item-heading">Bank Statistics</span>
</li>
<li class="list-group-item" ng-repeat="bank in getCurrentLog().bank_statistics">
<div class="row">
<span class="col-xs-1 text-bold" ng-bind="bank.bank"></span>
<span class="col-xs-11" ng-bind="bank.total_settle|currency:''"></span>
</div>
</li>
</ul>
</div>
</div>
<div class="box box-default">
<div class="box-header">Settlement analysis at {{datePattern}}</div>
<div class="box-header">Settlement analysis</div>
<div class="box-body">
<div class="row">
<div class="col-xs-6 col-sm-3">
<span class="col-xs-6 text-bold">Total Credit</span>
<span class="col-xs-6" ng-bind="detail.total_credit|currency:''"></span>
<span class="col-xs-6" ng-bind="currentAnalysis.total_credit|currency:''"></span>
</div>
<div class="col-xs-6 col-sm-3">
<span class="col-xs-6 text-bold">Total Debit</span>
<span class="col-xs-6" ng-bind="detail.total_debit|currency:''"></span>
<span class="col-xs-6" ng-bind="currentAnalysis.total_debit|currency:''"></span>
</div>
<div class="col-xs-6 col-sm-3">
<span class="col-xs-6 text-bold">Gross Amount</span>
<span class="col-xs-6" ng-bind="detail.gross_amount|currency:''"></span>
<span class="col-xs-6" ng-bind="currentAnalysis.gross_amount|currency:''"></span>
</div>
<div class="col-xs-6 col-sm-3">
<span class="col-xs-6 text-bold">Net Amount</span>
<span class="col-xs-6" ng-bind="detail.net_amount|currency:''"></span>
<span class="col-xs-6" ng-bind="currentAnalysis.net_amount|currency:''"></span>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-3">
<span class="col-xs-6 text-bold">Total Charge</span>
<span class="col-xs-6"
ng-bind="(detail.wechat_charge+detail.royalpay_charge)|currency:''"></span>
ng-bind="(currentAnalysis.wechat_charge+currentAnalysis.royalpay_charge)|currency:''"></span>
</div>
<div class="col-xs-6 col-sm-3">
<span class="col-xs-6 text-bold">Channel Charge</span>
<span class="col-xs-6" ng-bind="detail.wechat_charge|currency:''"></span>
<span class="col-xs-6" ng-bind="currentAnalysis.wechat_charge|currency:''"></span>
</div>
<div class="col-xs-6 col-sm-3">
<span class="col-xs-6 text-bold">RoyalPay Charge</span>
<span class="col-xs-6" ng-bind="detail.royalpay_charge|currency:''"></span>
<span class="col-xs-6" ng-bind="currentAnalysis.royalpay_charge|currency:''"></span>
</div>
<div class="col-xs-6 col-sm-3">
<span class="col-xs-6 text-bold">Operate Time</span>
<span class="col-xs-6" ng-bind="detail.operate_time|date:'dd/MMM/yyyy HH:mm:ss'"></span>
<span class="col-xs-6"
ng-bind="currentAnalysis.operate_time|date:'dd/MMM/yyyy HH:mm:ss'"></span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<ul class="list-group">
<li class="list-group-item" ng-repeat="group in settleAnalysis">
<li class="list-group-item"
ng-repeat="group in batchAnalysis[analysisFilter.clearing_id==null?'All':analysisFilter.clearing_id+'']">
<div class="row">
<span class="col-sm-2 col-xs-4 text-center">T+{{group.settleDays}}</span>
<span class="col-sm-10 col-xs-8 text-right">
@ -104,9 +153,11 @@
<div class="row">
<div class="col-xs-12">
<ul class="list-group">
<li class="list-group-item" ng-repeat="channel in detail.channel_analysis" ng-if="channel.channel!='System'">
<li class="list-group-item" ng-repeat="channel in currentAnalysis.channel_analysis"
ng-if="channel.channel!='System'">
<div class="row">
<span class="col-xs-2"><img ng-src="{{channel.channel|channel_image}}" class="channel-icon-lg"></span>
<span class="col-xs-2"><img ng-src="{{channel.channel|channel_image}}"
class="channel-icon-lg"></span>
<span class="col-xs-10">Gross Amount:{{ channel.gross_amount|currency:''}}</span>
<span class="col-xs-10">RoyalPay Charge:{{channel.royalpay_charge|currency:''}}</span>
@ -115,8 +166,12 @@
</ul>
</div>
</div>
<div class="box box-default" ng-repeat="group in settleAnalysis">
<div class="box-header">T+{{group.settleDays}}: Clients:{{group.clients}} Amount:{{group.settleAmount|currency:''}}</div>
<div class="box box-default"
ng-repeat="group in batchAnalysis[analysisFilter.clearing_id==null?'All':analysisFilter.clearing_id+'']">
<div class="box-header">T+{{group.settleDays}}: Clients:{{group.clients}}
Amount:{{group.settleAmount|currency:''}}
</div>
<div class="box-body table-responsive">
<table class="table table-bordered table-striped table-hover">
<thead>

Loading…
Cancel
Save