parent
1453f0505a
commit
a1bbc19efd
@ -1,19 +1,21 @@
|
|||||||
package au.com.royalpay.payment.manage.merchants.core;
|
package au.com.royalpay.payment.manage.merchants.core;
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify;
|
|
||||||
import au.com.royalpay.payment.manage.merchants.entity.ClientGatewaySignModify;
|
import au.com.royalpay.payment.manage.merchants.entity.ClientGatewaySignModify;
|
||||||
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
||||||
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create by yixian at 2018-04-12 16:24
|
* Create by yixian at 2018-04-12 16:24
|
||||||
*/
|
*/
|
||||||
public interface ClientModifySupport {
|
public interface ClientModifySupport {
|
||||||
|
|
||||||
|
void processModify(ClientModifyOperation modify);
|
||||||
|
|
||||||
void processClientModify(ClientModify clientModify);
|
void processClientModify(ClientModify clientModify);
|
||||||
|
|
||||||
void processClientConfigModify(ClientConfigModify clientConfigModify);
|
void processClientConfigModify(ClientModify clientConfigModify);
|
||||||
|
|
||||||
void processClientConfigModify(ClientConfigModify clientConfigModify, boolean onlyModifyConfig);
|
void processClientConfigModify(ClientModify clientConfigModify, boolean onlyModifyConfig);
|
||||||
|
|
||||||
void processClientGatewaySignModify(ClientGatewaySignModify clientGatewaySignModify);
|
void processClientGatewaySignModify(ClientGatewaySignModify clientGatewaySignModify);
|
||||||
}
|
}
|
||||||
|
@ -1,78 +1,39 @@
|
|||||||
package au.com.royalpay.payment.manage.merchants.entity;
|
package au.com.royalpay.payment.manage.merchants.entity;
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.mappers.system.MerchantSignInfoMapper;
|
import au.com.royalpay.payment.manage.mappers.system.MerchantSignInfoMapper;
|
||||||
import au.com.royalpay.payment.manage.merchants.beans.mongo.ClientConfigLog;
|
|
||||||
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
||||||
import au.com.royalpay.payment.tools.utils.id.IdUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create by yixian at 2018-04-12 16:19
|
* Create by yixian at 2018-04-12 16:19
|
||||||
*/
|
*/
|
||||||
public abstract class ClientGatewaySignModify {
|
public abstract class ClientGatewaySignModify extends ClientModifyOperation {
|
||||||
|
|
||||||
private JSONObject account;
|
private MerchantSignInfoMapper merchantSignInfoMapper;
|
||||||
|
|
||||||
private String clientMoniker;
|
|
||||||
|
|
||||||
public ClientGatewaySignModify(JSONObject account, String clientMoniker) {
|
public ClientGatewaySignModify(JSONObject account, String clientMoniker) {
|
||||||
this.account = account;
|
super(account, clientMoniker);
|
||||||
this.clientMoniker = clientMoniker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String business();
|
protected abstract String business();
|
||||||
|
|
||||||
protected abstract JSONObject getModifyResult();
|
protected abstract JSONObject getModifyResult();
|
||||||
|
|
||||||
@Transactional
|
@Override
|
||||||
public int doModify(MerchantInfoProvider merchantInfoProvider, MerchantSignInfoMapper merchantSignInfoMapper, MongoTemplate mongoTemplate) {
|
protected Consumer<JSONObject> getModifyProcess() {
|
||||||
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
|
return client -> {
|
||||||
JSONObject clientGatewaySign = merchantSignInfoMapper.findClientSign(clientMoniker);
|
|
||||||
JSONObject modifyResult = getModifyResult();
|
JSONObject modifyResult = getModifyResult();
|
||||||
try {
|
modifyResult.put("client_moniker", getClientMoniker());
|
||||||
saveModifyHistory(clientGatewaySign, modifyResult, mongoTemplate);
|
modifyResult.put("last_update_by", getAccount().getString("account_id"));
|
||||||
}catch (Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
int clientId = client.getIntValue("client_id");
|
|
||||||
modifyResult.put("client_moniker", clientMoniker);
|
|
||||||
modifyResult.put("last_update_by", account.getString("account_id"));
|
|
||||||
modifyResult.put("last_update_date", new Date());
|
modifyResult.put("last_update_date", new Date());
|
||||||
merchantSignInfoMapper.update(modifyResult);
|
merchantSignInfoMapper.update(modifyResult);
|
||||||
return clientId;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveModifyHistory(JSONObject clientGatewaySign, JSONObject modifyResult, MongoTemplate mongoTemplate) {
|
public ClientGatewaySignModify setMerchantSignInfoMapper(MerchantSignInfoMapper merchantSignInfoMapper) {
|
||||||
if (account == null) {
|
this.merchantSignInfoMapper = merchantSignInfoMapper;
|
||||||
return;
|
return this;
|
||||||
}
|
|
||||||
ClientConfigLog clientConfigLog = new ClientConfigLog();
|
|
||||||
clientConfigLog.setId(IdUtil.getId());
|
|
||||||
clientConfigLog.setBusiness(business());
|
|
||||||
clientConfigLog.setClientId(clientGatewaySign.getIntValue("client_id"));
|
|
||||||
|
|
||||||
boolean isPartner = true;
|
|
||||||
if (StringUtils.isNotEmpty(account.getString("account_id"))) {
|
|
||||||
isPartner = true;
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(account.getString("manager_id"))) {
|
|
||||||
isPartner = false;
|
|
||||||
}
|
|
||||||
clientConfigLog.setUserType(isPartner ? "Merchant" : "Manager");
|
|
||||||
clientConfigLog.setCreateTime(new Date());
|
|
||||||
clientConfigLog.setNewData(modifyResult.toJSONString());
|
|
||||||
clientConfigLog.setUserId(isPartner ? account.getString("account_id") : account.getString("manager_id"));
|
|
||||||
Map<String, Object> beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, clientGatewaySign::get));
|
|
||||||
clientConfigLog.setOriginData(JSON.toJSONString(beforeModify));
|
|
||||||
clientConfigLog.setUserName(isPartner ? account.getString("display_name") : account.getString("display_name"));
|
|
||||||
mongoTemplate.save(clientConfigLog);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,77 +1,32 @@
|
|||||||
package au.com.royalpay.payment.manage.merchants.entity;
|
package au.com.royalpay.payment.manage.merchants.entity;
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
||||||
import au.com.royalpay.payment.manage.merchants.beans.mongo.ClientConfigLog;
|
|
||||||
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
||||||
import au.com.royalpay.payment.tools.utils.id.IdUtil;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import java.util.function.Consumer;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create by yixian at 2018-04-12 16:19
|
* Create by yixian at 2018-04-12 16:19
|
||||||
*/
|
*/
|
||||||
public abstract class ClientModify {
|
public abstract class ClientModify extends ClientModifyOperation {
|
||||||
|
|
||||||
private JSONObject account;
|
|
||||||
|
|
||||||
private String clientMoniker;
|
private Consumer<JSONObject> modifyConsumer;
|
||||||
|
|
||||||
public ClientModify(JSONObject account, String clientMoniker) {
|
public ClientModify(JSONObject account, String clientMoniker) {
|
||||||
this.account = account;
|
super(account, clientMoniker);
|
||||||
this.clientMoniker = clientMoniker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String business();
|
@Override
|
||||||
|
protected Consumer<JSONObject> getModifyProcess() {
|
||||||
protected abstract JSONObject getModifyResult();
|
return client -> {
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public int doModify(MerchantInfoProvider merchantInfoProvider, ClientMapper clientMapper, MongoTemplate mongoTemplate) {
|
|
||||||
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
|
|
||||||
JSONObject modifyResult = getModifyResult();
|
JSONObject modifyResult = getModifyResult();
|
||||||
try {
|
|
||||||
saveModifyHistory(client, modifyResult, mongoTemplate);
|
|
||||||
}catch (Exception e){
|
|
||||||
|
|
||||||
}
|
|
||||||
int clientId = client.getIntValue("client_id");
|
int clientId = client.getIntValue("client_id");
|
||||||
modifyResult.put("client_id", clientId);
|
modifyResult.put("client_id", clientId);
|
||||||
clientMapper.update(modifyResult);
|
modifyConsumer.accept(modifyResult);
|
||||||
return clientId;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
private void saveModifyHistory(JSONObject client, JSONObject modifyResult, MongoTemplate mongoTemplate) {
|
|
||||||
if (account == null) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
ClientConfigLog clientConfigLog = new ClientConfigLog();
|
|
||||||
clientConfigLog.setId(IdUtil.getId());
|
|
||||||
clientConfigLog.setBusiness(business());
|
|
||||||
clientConfigLog.setClientId(client.getIntValue("client_id"));
|
|
||||||
|
|
||||||
boolean isPartner = true;
|
public ClientModify setModifyConsumer(Consumer<JSONObject> modifyConsumer) {
|
||||||
if (StringUtils.isNotEmpty(account.getString("account_id"))) {
|
this.modifyConsumer = modifyConsumer;
|
||||||
isPartner = true;
|
return this;
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(account.getString("manager_id"))) {
|
|
||||||
isPartner = false;
|
|
||||||
}
|
|
||||||
clientConfigLog.setUserType(isPartner ? "Merchant" : "Manager");
|
|
||||||
clientConfigLog.setCreateTime(new Date());
|
|
||||||
clientConfigLog.setNewData(modifyResult.toJSONString());
|
|
||||||
clientConfigLog.setUserId(isPartner ? account.getString("account_id") : account.getString("manager_id"));
|
|
||||||
Map<String, Object> beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get));
|
|
||||||
clientConfigLog.setOriginData(JSON.toJSONString(beforeModify));
|
|
||||||
clientConfigLog.setUserName(isPartner ? account.getString("display_name") : account.getString("display_name"));
|
|
||||||
mongoTemplate.save(clientConfigLog);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,29 @@
|
|||||||
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify;
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create by yixian at 2018-04-12 16:43
|
* Create by yixian at 2018-04-12 16:43
|
||||||
*/
|
*/
|
||||||
public class ClearDaysModify extends ClientConfigModify {
|
public class ClearDaysModify extends ClientModify {
|
||||||
private int settle_hour;
|
private int settleHour;
|
||||||
|
|
||||||
public ClearDaysModify(JSONObject account, String clientMoniker, int settle_hour) {
|
public ClearDaysModify(JSONObject account, String clientMoniker, int settleHour) {
|
||||||
super(account, clientMoniker);
|
super(account, clientMoniker);
|
||||||
this.settle_hour = settle_hour;
|
this.settleHour = settleHour;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String business() {
|
protected String business() {
|
||||||
|
|
||||||
return "修改商户清算截止时间为:"+settle_hour;
|
return "修改商户清算截止时间为:" + settleHour;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JSONObject getModifyResult() {
|
protected JSONObject getModifyResult() {
|
||||||
JSONObject modify = new JSONObject();
|
JSONObject modify = new JSONObject();
|
||||||
modify.put("settle_hour", settle_hour);
|
modify.put("settle_hour", settleHour);
|
||||||
return modify;
|
return modify;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create by yixian at 2018-04-12 16:43
|
||||||
|
*/
|
||||||
|
public class CustomSwitchModify extends ClientModifyOperation {
|
||||||
|
private final String key;
|
||||||
|
private final boolean value;
|
||||||
|
private final Consumer<JSONObject> modifyProcess;
|
||||||
|
|
||||||
|
|
||||||
|
public CustomSwitchModify(JSONObject account, String clientMoniker, String key, boolean value, Consumer<JSONObject> modifyProcess) {
|
||||||
|
super(account, clientMoniker);
|
||||||
|
this.key = key;
|
||||||
|
this.value = value;
|
||||||
|
this.modifyProcess = modifyProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String business() {
|
||||||
|
|
||||||
|
return (value ? "开启 " : "关闭 ") + key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JSONObject getModifyResult() {
|
||||||
|
JSONObject modify = new JSONObject();
|
||||||
|
modify.put(key, value);
|
||||||
|
return modify;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Consumer<JSONObject> getModifyProcess() {
|
||||||
|
return modifyProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,30 +1,29 @@
|
|||||||
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
||||||
|
|
||||||
import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify;
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create by yixian at 2018-04-12 16:43
|
* Create by yixian at 2018-04-12 16:43
|
||||||
*/
|
*/
|
||||||
public class SettleHourModify extends ClientConfigModify {
|
public class SettleHourModify extends ClientModify {
|
||||||
private Integer settle_hour;
|
private Integer settleHour;
|
||||||
|
|
||||||
public SettleHourModify(JSONObject account, String clientMoniker, Integer settle_hour) {
|
public SettleHourModify(JSONObject account, String clientMoniker, Integer settleHour) {
|
||||||
super(account, clientMoniker);
|
super(account, clientMoniker);
|
||||||
this.settle_hour = settle_hour;
|
this.settleHour = settleHour;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String business() {
|
protected String business() {
|
||||||
|
|
||||||
return "修改商户清算截止时间为:"+settle_hour;
|
return "修改商户清算截止时间为:" + settleHour;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JSONObject getModifyResult() {
|
protected JSONObject getModifyResult() {
|
||||||
JSONObject modify = new JSONObject();
|
JSONObject modify = new JSONObject();
|
||||||
modify.put("settle_hour", settle_hour);
|
modify.put("settle_hour", settleHour);
|
||||||
return modify;
|
return modify;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue