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,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);
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
Loading…
Reference in new issue