Merge branch 'develop'

master
yixian 4 years ago
commit da78f549ef

@ -0,0 +1,76 @@
package au.com.royalpay.payment.manage.management.clearing.beans;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
@Document(collection = "settle_priority_modify")
@JSONType(naming = PropertyNamingStrategy.SnakeCase)
public class PriorityModifyLog {
public static final String OP_ADD = "ADD";
public static final String OP_REMOVE = "REMOVE";
private long id;
private String clientMoniker;
private String operation;
private String operatorId;
private String operatorName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+10")
private Date createTime;
public long getId() {
return id;
}
public PriorityModifyLog setId(long id) {
this.id = id;
return this;
}
public String getClientMoniker() {
return clientMoniker;
}
public PriorityModifyLog setClientMoniker(String clientMoniker) {
this.clientMoniker = clientMoniker;
return this;
}
public String getOperation() {
return operation;
}
public PriorityModifyLog setOperation(String operation) {
this.operation = operation;
return this;
}
public String getOperatorId() {
return operatorId;
}
public PriorityModifyLog setOperatorId(String operatorId) {
this.operatorId = operatorId;
return this;
}
public String getOperatorName() {
return operatorName;
}
public PriorityModifyLog setOperatorName(String operatorName) {
this.operatorName = operatorName;
return this;
}
public Date getCreateTime() {
return createTime;
}
public PriorityModifyLog setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
}

@ -0,0 +1,16 @@
package au.com.royalpay.payment.manage.management.clearing.core;
import au.com.royalpay.payment.manage.management.clearing.beans.PriorityModifyLog;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
public interface PriorityListManager {
List<JSONObject> listPriorityMerchants();
void setMerchantPriority(String clientMoniker, JSONObject manager);
void removePriorityMerchant(String clientMoniker, JSONObject manager);
List<PriorityModifyLog> getMerchantsModifyHistory();
}

@ -0,0 +1,51 @@
package au.com.royalpay.payment.manage.management.clearing.core.impl;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.stream.Stream;
public class MonikerStringUtils {
private MonikerStringUtils() {
}
public static String formatStringArray(String str) {
str = str.replace("", ",");
str = str.replace(" ", ",");
str = str.replace("\r\n", ",");
str = str.replace("\n", ",");
str = str.replace("\r", ",");
String nStr = str.replace(",,", ",");
while (!nStr.equals(str)) {
str = nStr;
nStr = str.replace(",,", ",");
}
str = nStr;
if (str.endsWith(",")) {
str = StringUtils.substring(str, 0, -1);
}
if (str.startsWith(",")) {
str = StringUtils.substring(str, 1);
}
return str;
}
public static Stream<String> splitStringArray(String str) {
return Arrays.stream(formatStringArray(str).split(","));
}
public static JSONObject getSimplifiedClientsInfo(MerchantInfoProvider mchInfoProvider, String moniker) {
JSONObject info = mchInfoProvider.getClientInfoByMoniker(moniker);
if (info == null) {
return null;
}
JSONObject simple = new JSONObject();
simple.put("client_moniker", info.getString("client_moniker"));
simple.put("company_name", info.getString("company_name"));
simple.put("clean_days", info.getIntValue("clean_days"));
simple.put("bd_user_name", info.getString("bd_user_name"));
return simple;
}
}

@ -0,0 +1,109 @@
package au.com.royalpay.payment.manage.management.clearing.core.impl;
import au.com.royalpay.payment.manage.management.clearing.beans.PriorityModifyLog;
import au.com.royalpay.payment.manage.management.clearing.core.PriorityListManager;
import au.com.royalpay.payment.manage.mappers.system.SysSettlePlanMapper;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import au.com.royalpay.payment.tools.utils.id.IdUtil;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
public class PriorityListManagerImpl implements PriorityListManager {
private static final String PRIORITY_ID = "id1_priority";
private static final String COLLECTION_NAME = "settle_priority_modify";
public static final String KEY_WHITELIST_CLIENTS = "whitelist_clients";
private final Logger logger = LoggerFactory.getLogger(getClass());
private final MerchantInfoProvider mchInfoProvider;
private final MongoTemplate mongoTemplate;
private final SysSettlePlanMapper planMapper;
public PriorityListManagerImpl(MerchantInfoProvider mchInfoProvider, MongoTemplate mongoTemplate, SysSettlePlanMapper planMapper) {
this.mchInfoProvider = mchInfoProvider;
this.mongoTemplate = mongoTemplate;
this.planMapper = planMapper;
}
@Override
public List<JSONObject> listPriorityMerchants() {
JSONObject detail = planMapper.findPlanDetail(PRIORITY_ID);
return MonikerStringUtils.splitStringArray(detail.getString(KEY_WHITELIST_CLIENTS))
.map(moniker -> MonikerStringUtils.getSimplifiedClientsInfo(mchInfoProvider, moniker))
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
@Override
public void setMerchantPriority(String clientMoniker, JSONObject manager) {
JSONObject client = mchInfoProvider.getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new NotFoundException("Client " + clientMoniker + " not found");
}
JSONObject detail = planMapper.findPlanDetail(PRIORITY_ID);
String clientMonikers = detail.getString(KEY_WHITELIST_CLIENTS);
List<String> monikerList = MonikerStringUtils.splitStringArray(clientMonikers).collect(Collectors.toList());
if (monikerList.stream().anyMatch(moniker -> moniker.equalsIgnoreCase(clientMoniker))) {
logger.debug("{} exists,ignore", clientMoniker);
return;
}
monikerList.add(clientMoniker.toUpperCase());
planMapper.setWhitelistClients(PRIORITY_ID, String.join(",", monikerList));
try {
PriorityModifyLog log = new PriorityModifyLog()
.setId(IdUtil.getId())
.setClientMoniker(clientMoniker)
.setOperation(PriorityModifyLog.OP_ADD)
.setOperatorId(manager.getString("manager_id"))
.setOperatorName(manager.getString("display_name"))
.setCreateTime(new Date());
mongoTemplate.insert(log);
} catch (Exception ignore) {
}
}
@Override
public void removePriorityMerchant(String clientMoniker, JSONObject manager) {
JSONObject detail = planMapper.findPlanDetail(PRIORITY_ID);
String clientMonikers = detail.getString(KEY_WHITELIST_CLIENTS);
List<String> monikerList = MonikerStringUtils.splitStringArray(clientMonikers).collect(Collectors.toList());
if (!monikerList.removeIf(moniker -> moniker.equalsIgnoreCase(clientMoniker))) {
logger.debug("{} not exists,ignore", clientMoniker);
return;
}
planMapper.setWhitelistClients(PRIORITY_ID, String.join(",", monikerList));
try {
PriorityModifyLog log = new PriorityModifyLog()
.setId(IdUtil.getId())
.setClientMoniker(clientMoniker)
.setOperation(PriorityModifyLog.OP_REMOVE)
.setOperatorId(manager.getString("manager_id"))
.setOperatorName(manager.getString("display_name"))
.setCreateTime(new Date());
mongoTemplate.insert(log);
} catch (Exception ignore) {
}
}
@Override
public List<PriorityModifyLog> getMerchantsModifyHistory() {
Date twoMonthAgo = DateUtils.addMonths(new Date(), -2);
Query query = new Query()
.limit(20)
.with(Sort.by(Sort.Direction.DESC, "createTime"))
.addCriteria(Criteria.where("createTime").gt(twoMonthAgo));
return mongoTemplate.find(query, PriorityModifyLog.class);
}
}

@ -21,8 +21,6 @@ import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -75,20 +73,9 @@ public class SettleTaskServiceImpl implements SettleTasksService {
@Override @Override
public List<JSONObject> listMerchantsInfo(String mchMonikers) { public List<JSONObject> listMerchantsInfo(String mchMonikers) {
List<String> monikers = new ArrayList<>(Arrays.asList(formatStringArray(mchMonikers).split(","))); List<String> monikers = MonikerStringUtils.splitStringArray(mchMonikers).collect(Collectors.toList());
return monikers.parallelStream().map(this::getSimplifiedClientsInfo).filter(Objects::nonNull).collect(Collectors.toList()); return monikers.parallelStream().map(moniker -> MonikerStringUtils.getSimplifiedClientsInfo(mchInfoProvider, moniker))
} .filter(Objects::nonNull).collect(Collectors.toList());
private JSONObject getSimplifiedClientsInfo(String moniker) {
JSONObject info = mchInfoProvider.getClientInfoByMoniker(moniker);
if (info == null) {
return null;
}
JSONObject simple = new JSONObject();
simple.put("client_moniker", info.getString("client_moniker"));
simple.put("clean_days", info.getIntValue("clean_days"));
simple.put("bd_user_name", info.getString("bd_user_name"));
return simple;
} }
@Override @Override
@ -110,24 +97,5 @@ public class SettleTaskServiceImpl implements SettleTasksService {
} }
} }
public static String formatStringArray(String str) {
str = str.replace("", ",");
str = str.replace(" ", ",");
str = str.replace("\r\n", ",");
str = str.replace("\n", ",");
str = str.replace("\r", ",");
String nStr = str.replace(",,", ",");
while (!nStr.equals(str)) {
str = nStr;
nStr = str.replace(",,", ",");
}
str = nStr;
if (str.endsWith(",")) {
str = StringUtils.substring(str, 0, -1);
}
if (str.startsWith(",")) {
str = StringUtils.substring(str, 1);
}
return str;
}
} }

@ -1,13 +1,13 @@
package au.com.royalpay.payment.manage.management.clearing.web; package au.com.royalpay.payment.manage.management.clearing.web;
import au.com.royalpay.payment.manage.management.clearing.beans.PriorityModifyLog;
import au.com.royalpay.payment.manage.management.clearing.core.PriorityListManager;
import au.com.royalpay.payment.manage.management.clearing.core.SettleTasksService; import au.com.royalpay.payment.manage.management.clearing.core.SettleTasksService;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -15,9 +15,11 @@ import java.util.List;
@ManagerMapping(value = "/sys/settle_tasks", role = {ManagerRole.FINANCIAL_STAFF, ManagerRole.DEVELOPER}) @ManagerMapping(value = "/sys/settle_tasks", role = {ManagerRole.FINANCIAL_STAFF, ManagerRole.DEVELOPER})
public class SettleTasksController { public class SettleTasksController {
private SettleTasksService svc; private SettleTasksService svc;
private PriorityListManager priorityListManager;
public SettleTasksController(SettleTasksService svc) { public SettleTasksController(SettleTasksService svc, PriorityListManager priorityListManager) {
this.svc = svc; this.svc = svc;
this.priorityListManager = priorityListManager;
} }
@GetMapping("/plans") @GetMapping("/plans")
@ -40,4 +42,24 @@ public class SettleTasksController {
svc.submitTasks(tasks); svc.submitTasks(tasks);
return getProcessingStatus(); return getProcessingStatus();
} }
@GetMapping("/priority_merchants")
public List<JSONObject> listPriorityMerchants() {
return priorityListManager.listPriorityMerchants();
}
@PutMapping("/priority_merchants/{clientMoniker}")
public void setMerchantPriority(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
priorityListManager.setMerchantPriority(clientMoniker, manager);
}
@DeleteMapping("/priority_merchants/{clientMoniker}")
public void removePriorityMerchant(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
priorityListManager.removePriorityMerchant(clientMoniker, manager);
}
@GetMapping("/priority_merchants_modify_history")
public List<PriorityModifyLog> getMerchantsModifyHistory() {
return priorityListManager.getMerchantsModifyHistory();
}
} }

@ -5,6 +5,7 @@ import com.yixsoft.support.mybatis.autosql.annotations.AdvanceSelect;
import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper; import com.yixsoft.support.mybatis.autosql.annotations.AutoMapper;
import com.yixsoft.support.mybatis.autosql.annotations.AutoSql; import com.yixsoft.support.mybatis.autosql.annotations.AutoSql;
import com.yixsoft.support.mybatis.autosql.annotations.SqlType; import com.yixsoft.support.mybatis.autosql.annotations.SqlType;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -14,7 +15,8 @@ public interface SysSettlePlanMapper {
List<JSONObject> listPlans(); List<JSONObject> listPlans();
@AutoSql(SqlType.SELECT) @AutoSql(SqlType.SELECT)
JSONObject findPlanDetail(String planId); JSONObject findPlanDetail(@Param("plan_id") String planId);
@AutoSql(SqlType.UPDATE)
void setWhitelistClients(@Param("plan_id") String planId, @Param("whitelist_clients") String clientMonikers);
} }

@ -7,11 +7,15 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
url: '/settle_tasks', url: '/settle_tasks',
templateUrl: '/static/analysis/templates/settle_tasks_index.html', templateUrl: '/static/analysis/templates/settle_tasks_index.html',
controller: 'settleTasksRootCtrl' controller: 'settleTasksRootCtrl'
}).state('settle_tasks.priority_list', {
url: '/priority_list',
templateUrl: '/static/analysis/templates/settle_tasks_prioritylist.html',
controller: 'settleTasksPriorityListManageCtrl'
}) })
}]); }]);
app.controller('settleTasksRootCtrl', ['$scope', '$http', '$interval', '$q', '$uibModal', 'commonDialog', app.controller('settleTasksRootCtrl', ['$scope', '$http', '$interval', '$filter', '$q', '$uibModal', '$state', 'commonDialog',
function ($scope, $http, $interval, $q, $uibModal, commonDialog) { function ($scope, $http, $interval, $filter, $q, $uibModal, $state, commonDialog) {
let ctrl = this; let ctrl = this;
$scope.loadPlans = function () { $scope.loadPlans = function () {
$http.get('/sys/settle_tasks/plans').then(function (res) { $http.get('/sys/settle_tasks/plans').then(function (res) {
@ -21,6 +25,9 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
} }
}) })
}; };
$scope.redirectToSettleLogs = function () {
$state.go('clearingLogs.settlementDetail', {date: $filter('date')(new Date(), 'yyyy-MM-dd')})
}
$scope.checkProgressStatus = function () { $scope.checkProgressStatus = function () {
let defer = $q.defer(); let defer = $q.defer();
$http.get('/sys/settle_tasks/curent_progress').then(function (res) { $http.get('/sys/settle_tasks/curent_progress').then(function (res) {
@ -146,6 +153,46 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
$scope.$close($scope.merchantsInfo) $scope.$close($scope.merchantsInfo)
} }
}]); }]);
app.controller('settleTasksPriorityListManageCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) {
$scope.filters = {};
$scope.input = {}
$scope.loadPriorities = function () {
$http.get('/sys/settle_tasks/priority_merchants').then(function (res) {
$scope.clients = res.data;
})
};
$scope.addPriorityClient = function () {
if (!$scope.input.moniker) {
return;
}
$http.put('/sys/settle_tasks/priority_merchants/' + $scope.input.moniker).then(function () {
$scope.loadPriorities();
}, function (res) {
commonDialog.alert({type: 'error', title: 'Error', content: res.data.message})
})
};
$scope.dropPriorityClient = function (client) {
$http['delete']('/sys/settle_tasks/priority_merchants/' + client.client_moniker).then(function () {
$scope.loadPriorities();
}, function (res) {
commonDialog.alert({type: 'error', title: 'Error', content: res.data.message})
})
};
$scope.listHistory = function () {
$uibModal.open({
templateUrl: '/static/analysis/templates/settle_tasks_priority_history.html',
controller: ['$scope', 'history', function (scope, history) {
scope.logs = history.data;
}],
resolve: {
history: ['$http', function (http) {
return http.get('/sys/settle_tasks/priority_merchants_modify_history')
}]
}
})
}
}])
app.controller('newSettleTaskDialogCtrl', ['$scope', '$filter', 'plans', function ($scope, $filter, plans) { app.controller('newSettleTaskDialogCtrl', ['$scope', '$filter', 'plans', function ($scope, $filter, plans) {
$scope.plans = plans; $scope.plans = plans;
$scope.task = { $scope.task = {

@ -1,4 +1,4 @@
<div> <div ui-view>
<section class="content-header"> <section class="content-header">
<h1>Settle Tasks</h1> <h1>Settle Tasks</h1>
<ol class="breadcrumb"> <ol class="breadcrumb">
@ -18,6 +18,14 @@
<uib-progressbar value="progress.progress" animate="true" max-value="100"></uib-progressbar> <uib-progressbar value="progress.progress" animate="true" max-value="100"></uib-progressbar>
</div> </div>
</div> </div>
<div class="box box-info">
<div class="box-header">Toolbox</div>
<div class="box-body">
<button type="button" class="btn btn-primary" ng-click="redirectToSettleLogs()">Today Settlement Logs
</button>
<button type="button" class="btn btn-primary" ng-click="modifyPriorityList()">Priority List</button>
</div>
</div>
<div class="box box-info"> <div class="box box-info">
<div class="box-header"> <div class="box-header">
Tasks Prepare Tasks Prepare

@ -0,0 +1,21 @@
<div class="modal-header">Priority Modify History</div>
<div class="modal-body">
<table class="table table-bordered">
<thead>
<tr>
<th>Client Moniker</th>
<th>Operation</th>
<th>Operator</th>
<th>Time</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="log in logs" ng-class="{'active':log.operation==='ADD'}">
<td ng-bind="log.client_moniker"></td>
<td ng-bind="log.operation"></td>
<td ng-bind="log.operator_name"></td>
<td ng-bind="log.create_time|date:'yyyy-MM-dd HH:mm:ss'"></td>
</tr>
</tbody>
</table>
</div>

@ -0,0 +1,58 @@
<section class="content-header">
<h1>Priority List</h1>
<ol class="breadcrumb">
<li>
<i class="fa fa-list-alt"></i> Analysis
</li>
<li><a ui-sref="^">Settle Tasks</a></li>
<li class="active">Priority List</li>
</ol>
</section>
<section class="content">
<div class="box box-primary">
<div class="box-body">
<div class="input-group">
<input type="text" class="form-control" placeholder="Client Moniker" ng-model="input.moniker">
<div class="input-group-btn">
<button class="btn btn-primary" ng-disabled="!input.moniker" ng-click="addPriorityClient()"><i
class="fa fa-plus"></i>Add Merchant
</button>
</div>
<div class="input-group-btn">
<button class="btn btn-default" ng-click="listHistory()"><i class="fa fa-history"></i> History
</button>
</div>
</div>
</div>
</div>
<div class="box box-info">
<div class="box-header">
<input class="form-control" placeholder="Filter" ng-model="filters.client_moniker">
</div>
<div class="box-body table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Client Moniker</th>
<th>Merchant Name</th>
<th>BD Name</th>
<th>Clean Days</th>
<th>Operation</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="client in clients|propsFilter:filters">
<td ng-bind="client.client_moniker"></td>
<td ng-bind="client.company_name"></td>
<td ng-bind="client.bd_user_name"></td>
<td ng-bind="'T+'+client.clean_days"></td>
<td>
<button class="btn btn-link text-danger" ng-click="dropPriorityClient(client)"><i
class="fa fa-trash"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>

@ -43,6 +43,7 @@
<button class="btn btn-success pull-right" ng-click="reloadPage()"> <button class="btn btn-success pull-right" ng-click="reloadPage()">
<i class="fa fa-refresh"></i>Reload <i class="fa fa-refresh"></i>Reload
</button> </button>
<a ui-sref="settle_tasks">Settle Tasks</a>
</div> </div>
</div> </div>

Loading…
Cancel
Save