distribute bank ui

master
yixian 6 years ago
parent a4bfebe22a
commit 0d48030501

@ -83,9 +83,11 @@ public interface CleanService {
JSONObject findLogSettleByDate(Date date);
JSONObject validTransactions(Date dt, boolean fix, boolean b, boolean b1);
JSONObject validTransactions(Date date, boolean fix, boolean b, boolean b1);
void distributeBank(Date dt, int clearingId, JSONObject bankDistribution);
void distributeBank(Date date, int clearingId, JSONObject bankDistribution);
void lockClearingLog(Date dt, int clearingId);
void lockClearingLog(Date date, int clearingId);
void undoSettle(Date date, int clearingId);
}

@ -5,6 +5,7 @@ import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.tasksupport.SettlementSupport;
import au.com.royalpay.payment.manage.management.clearing.core.CleanService;
import au.com.royalpay.payment.manage.mappers.log.*;
import au.com.royalpay.payment.manage.mappers.payment.TaskManualSettleMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.system.CalendarMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
@ -97,6 +98,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
@Resource
private ClearingDetailAnalysisMapper clearingDetailAnalysisMapper;
@Resource
private TaskManualSettleMapper taskManualSettleMapper;
@Resource
private ValidationLogMapper validationLogMapper;
@Resource
private ManagerMapper managerMapper;
@ -1133,6 +1136,27 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
clearingLogMapper.setLogEditable(false, clearingId);
}
@Override
@Transactional
public void undoSettle(Date date, int clearingId) {
if (!DateUtils.isSameDay(date, new Date())) {
throw new ForbiddenException("Only today's settlement file can be modified");
}
JSONObject log = clearingLogMapper.findById(clearingId);
if (log == null || !DateUtils.isSameDay(log.getDate("settle_date"), date)) {
throw new NotFoundException("Settlement log not found");
}
if (!log.getBooleanValue("editable")) {
throw new ForbiddenException("Settlement log has been sent and unable to edit");
}
transactionMapper.deleteSettlementTransaction(clearingId);
transactionMapper.removeSettleRemark(clearingId);
clearingDetailAnalysisMapper.clearAnalysis(clearingId);
taskManualSettleMapper.rollbackExecutedTask(clearingId);
clearingDetailMapper.deleteSettleLogs(clearingId);
clearingLogMapper.deleteSettleLogs(clearingId);
}
private byte[] getZipByteArr(List<JSONObject> fileByteArrWithName) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(bos);

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.management.clearing.web;
import au.com.royalpay.payment.manage.management.clearing.core.CleanService;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.permission.manager.RequireManager;
import au.com.royalpay.payment.manage.support.abafile.ABATemplate;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.CommonConsts;
@ -70,7 +71,7 @@ public class SettlementDevController {
}
@PutMapping("/reports/{date}/clearings/{clearingId}/lock")
public void lockClearingLog(@PathVariable String date,@PathVariable int clearingId){
public void lockClearingLog(@PathVariable String date, @PathVariable int clearingId) {
try {
Date dt = dateFormat.parse(date);
cleanService.lockClearingLog(dt, clearingId);
@ -79,6 +80,17 @@ public class SettlementDevController {
}
}
@DeleteMapping("/reports/{date}/clearings/{clearingId}")
@RequireManager(role = ManagerRole.DEVELOPER)
public void undoSettle(@PathVariable String date, @PathVariable int clearingId) {
try {
Date dt = dateFormat.parse(date);
cleanService.undoSettle(dt, clearingId);
} catch (ParseException e) {
throw new BadRequestException("error.payment.valid.invalid_date_format");
}
}
@RequestMapping("/reports/{date}/settlement_csv")
public void getSettlementCsv(@PathVariable String date, HttpServletResponse resp) throws IOException {
try {

@ -26,4 +26,6 @@ public interface ClearingDetailAnalysisMapper {
List<JSONObject> listReportChannels(@Param("clearing_detail_id") String clearDetailId);
BigDecimal getSysCleaingAmount(@Param("settle_date") String settle_date, @Param("channel") String channel);
void clearAnalysis(@Param("clearing_id") int clearingId);
}

@ -45,4 +45,7 @@ public interface ClearingDetailMapper {
@AutoSql(type = SqlType.UPDATE)
void updateBanks(@Param("settle_bank") String bank,@Param("clear_detail_id") List<String> clearingDetailIds);
@AutoSql(type = SqlType.DELETE)
void deleteSettleLogs(@Param("clearing_id") int clearingId);
}

@ -46,4 +46,7 @@ public interface ClearingLogMapper {
@AutoSql(type = SqlType.UPDATE)
void setLogEditable(@Param("editable") boolean editable, @Param("clearing_id") int clearingId);
@AutoSql(type = SqlType.DELETE)
void deleteSettleLogs(@Param("clearing_id") int clearingId);
}

@ -31,4 +31,6 @@ public interface TaskManualSettleMapper {
List<JSONObject> getEveryLatestRecord();
void rollbackExecutedTask(@Param("clearing_id") int clearingId);
}

@ -133,4 +133,7 @@ public interface TransactionMapper {
List<JSONObject> listClientUnsettleDataByDate(@Param("client_id") int clientId, @Param("max_settle_to") Date maxSettleTo);
void deleteSettlementTransaction(@Param("clearing_id") int clearingId);
void removeSettleRemark(@Param("clearing_id") int clearingId);
}

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper">
<delete id="clearAnalysis">
DELETE a FROM log_clearing_detail_analysis a
inner JOIN log_clearing_detail d on d.clear_detail_id = a.clearing_detail_id
where d.clearing_id = #{clearing_id}
</delete>
<select id="analysisChannelReport" resultType="com.alibaba.fastjson.JSONObject">
SELECT
a.channel,

@ -1,14 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.payment.TaskManualSettleMapper">
<update id="rollbackExecutedTask">
UPDATE task_client_manual_settle s
INNER JOIN log_clearing_detail d ON d.clear_detail_id = s.clearing_order
SET s.finish_time = NULL, s.clearing_order = NULL
WHERE d.clearing_id = #{clearing_id}
</update>
<select id="getEveryLatestRecord" resultType="com.alibaba.fastjson.JSONObject">
SELECT
s.request_time,c.client_id,c.client_moniker
s.request_time,
c.client_id,
c.client_moniker
FROM
task_client_manual_settle s
right join sys_clients c on s.client_id = c.client_id
inner join sys_client_config cc on cc.client_id = c.client_id
where (s.request_time=(select max(B.request_time) from task_client_manual_settle B where s.client_id =B.client_id) or s.request_time is null)
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
</select>
</mapper>

@ -1,6 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.payment.TransactionMapper">
<update id="removeSettleRemark">
UPDATE pmt_transactions AS t
INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order
SET clearing_status = 0, clearing_order = NULL, clearing_time = NULL
WHERE d.clearing_id = #{clearing_id}
</update>
<delete id="deleteSettlementTransaction">
DELETE t FROM pmt_transactions t
INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order
WHERE d.clearing_id = #{clearing_id} AND t.transaction_type = 'Debit' AND t.refund_id IS NULL and t.channel='Settlement'
</delete>
<select id="listTransFlowPage" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.*,if(t.refund_id is not null,'refund',if(t.transaction_type='Debit' AND
t.system_generate=0,'clearing','payment')) trans_type,

@ -264,13 +264,14 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
'All': $scope.settleAnalysis
};
angular.forEach($scope.detail.logs, function (batch) {
$scope.batchAnalysis[batch.clearing_id+''] = getAnalysisTemplate();
$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)]);
attachAnalysis($scope.batchAnalysis[settleItem.clearing_id + ''][Math.min(settleDays - 1, 2)]);
function attachAnalysis(analysisItem) {
analysisItem.settles.push(settleItem);
analysisItem.clients++;
@ -352,6 +353,35 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope.distributeBankDialog = function () {
var log = $scope.getCurrentLog();
$uibModal.open({
templateUrl: '/static/analysis/templates/settlement_bank_distribution_dialog.html',
controller: 'bankDistributionDialogCtrl',
resolve: {
clearingBatch: function () {
return log;
},
banksConfig: ['$http', function ($http) {
return $http.get('/sys/settlement/available_banks')
}],
settleDate: function () {
return $stateParams.date;
}
}
})
};
$scope.rollbackSettlement = function () {
var log = $scope.getCurrentLog();
commonDialog.confirm({
title: '确认操作',
content: '回滚当前清算id=' + log.clearing_id + ',确认?'
}).then(function () {
$http.delete('/sys/settlement/reports/' + $stateParams.date + '/clearings/' + log.clearing_id).then(function () {
$state.reload();
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
})
}
}]);
app.controller('settlementTransactionsCtrl', ['$scope', '$stateParams', 'detail', function ($scope, $stateParams, detail) {
@ -359,6 +389,36 @@ define(['angular', 'decimal', 'uiBootstrap', 'uiRouter', 'angularEcharts'], func
$scope.report = detail.data;
}]);
app.controller('bankDistributionDialogCtrl', ['$scope', '$http', 'decimal', 'clearingBatch', 'banksConfig', 'settleDate',
function ($scope, $http, Decimal, clearingBatch, banksConfig, settleDate) {
$scope.banksConfig = banksConfig.data;
$scope.bankData = [];
angular.forEach($scope.banksConfig.banks, function (bank) {
if (bank !== $scope.banksConfig.remains_to) {
$scope.bankData.push({bank: bank, amount: 0});
}
});
$scope.remainingAmount = function () {
var total = clearingBatch.clearing_amount;
angular.forEach($scope.bankData, function (config) {
total = Decimal.sub(total, config.amount);
});
return Decimal.max(0, total).toFixed(2, Decimal.ROUND_DOWN);
};
$scope.submitDistribution = function () {
$scope.errmsg = null;
var data = {};
angular.forEach($scope.bankData, function (config) {
data[config.bank] = config.amount;
});
$http.put('/sys/settlement/reports/' + settleDate + '/clearings/' + clearingBatch.clearing_id + '/bank_distribution', data).then(function () {
$scope.$close();
}, function (resp) {
$scope.errmsg = resp.data.message;
})
}
}]);
app.controller('settleDateConfigCtrl', ['$scope', '$http', '$filter', 'commonDialog', function ($scope, $http, $filter, commonDialog) {
$scope.loadMonthPlan = function (mon) {
$http.get('/sysconfig/clear_days/months/' + $filter('date')(mon, 'yyyyMM')).then(function (resp) {

@ -0,0 +1,24 @@
<div class="modal-header">
<h4>Distribute Bank</h4>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="form-group" ng-repeat="cfg in bankData">
<label class="control-label col-xs-2" ng-bind="cfg.bank"></label>
<div class="col-xs-9">
<input class="form-control" type="number" ng-model="cfg.amount">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-2" ng-bind="banksConfig.remains_to"></label>
<div class="col-xs-9">
<p class="form-control-static" ng-bind="remainingAmount()"></p>
</div>
</div>
</div>
<div class="alert alert-danger" ng-if="errmsg" ng-bind="errmsg"></div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="submitDistribution()">Submit</button>
<button class="btn btn-danger" ng-click="$dismiss()">Cancel</button>
</div>

@ -47,7 +47,7 @@
<div class="box box-default">
<div class="box-header">Settlement Batches [{{datePattern}}]</div>
<div class="box-body">
<div class="row">
<div class="row margin-bottom">
<div class="col-xs-12">
<div class="btn-group">
<button class="btn btn-default" ng-click="switchSettleBatch(null)"
@ -62,15 +62,18 @@
</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)">
<div class="row" ng-if="analysisFilter.clearing_id!=null && getCurrentLog().editable">
<div class="col-xs-12">
<button class="btn btn-danger" ng-click="lockSettleLog(analysisFilter.clearing_id)">
Mark as send
</button>
<button class="btn btn-primary" ng-if="getCurrentLog().editable"
ng-click="distributeBankDialog()">
<button class="btn btn-primary" ng-click="distributeBankDialog()">
Distribute Bank
</button>
<button class="btn btn-primary" ng-if="'undo_settle'|withFunc" ng-click="rollbackSettlement()">
Undo Settlement
</button>
</div>
</div>
</div>
</div>

@ -1,27 +0,0 @@
package au.com.royalpay.payment.manage.apps.core.impls;
import au.com.royalpay.payment.manage.apps.core.CustomerImpressionService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* Created by wangning on 08/01/2018.
*/
@SpringBootTest
@ActiveProfiles({"local","alipay","wechat","jd","bestpay"})
@RunWith(SpringRunner.class)
public class CustomerImpressionServiceImplTest {
@Resource
private CustomerImpressionService customerImpressionService;
@Test
public void generate() throws Exception {
customerImpressionService.generate(9);
}
}
Loading…
Cancel
Save