parent
1453f0505a
commit
a1bbc19efd
@ -1,19 +1,21 @@
|
||||
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.ClientModify;
|
||||
import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2018-04-12 16:24
|
||||
*/
|
||||
public interface ClientModifySupport {
|
||||
|
||||
void processModify(ClientModifyOperation modify);
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -1,78 +1,39 @@
|
||||
package au.com.royalpay.payment.manage.merchants.entity;
|
||||
|
||||
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 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.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2018-04-12 16:19
|
||||
*/
|
||||
public abstract class ClientGatewaySignModify {
|
||||
public abstract class ClientGatewaySignModify extends ClientModifyOperation {
|
||||
|
||||
private JSONObject account;
|
||||
|
||||
private String clientMoniker;
|
||||
private MerchantSignInfoMapper merchantSignInfoMapper;
|
||||
|
||||
public ClientGatewaySignModify(JSONObject account, String clientMoniker) {
|
||||
this.account = account;
|
||||
this.clientMoniker = clientMoniker;
|
||||
super(account, clientMoniker);
|
||||
}
|
||||
|
||||
protected abstract String business();
|
||||
|
||||
protected abstract JSONObject getModifyResult();
|
||||
|
||||
@Transactional
|
||||
public int doModify(MerchantInfoProvider merchantInfoProvider, MerchantSignInfoMapper merchantSignInfoMapper, MongoTemplate mongoTemplate) {
|
||||
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
|
||||
JSONObject clientGatewaySign = merchantSignInfoMapper.findClientSign(clientMoniker);
|
||||
@Override
|
||||
protected Consumer<JSONObject> getModifyProcess() {
|
||||
return client -> {
|
||||
JSONObject modifyResult = getModifyResult();
|
||||
try {
|
||||
saveModifyHistory(clientGatewaySign, modifyResult, mongoTemplate);
|
||||
}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("client_moniker", getClientMoniker());
|
||||
modifyResult.put("last_update_by", getAccount().getString("account_id"));
|
||||
modifyResult.put("last_update_date", new Date());
|
||||
merchantSignInfoMapper.update(modifyResult);
|
||||
return clientId;
|
||||
};
|
||||
}
|
||||
|
||||
private void saveModifyHistory(JSONObject clientGatewaySign, JSONObject modifyResult, MongoTemplate mongoTemplate) {
|
||||
if (account == null) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
public ClientGatewaySignModify setMerchantSignInfoMapper(MerchantSignInfoMapper merchantSignInfoMapper) {
|
||||
this.merchantSignInfoMapper = merchantSignInfoMapper;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -1,77 +1,32 @@
|
||||
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 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.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2018-04-12 16:19
|
||||
*/
|
||||
public abstract class ClientModify {
|
||||
|
||||
private JSONObject account;
|
||||
public abstract class ClientModify extends ClientModifyOperation {
|
||||
|
||||
private String clientMoniker;
|
||||
private Consumer<JSONObject> modifyConsumer;
|
||||
|
||||
public ClientModify(JSONObject account, String clientMoniker) {
|
||||
this.account = account;
|
||||
this.clientMoniker = clientMoniker;
|
||||
super(account, clientMoniker);
|
||||
}
|
||||
|
||||
protected abstract String business();
|
||||
|
||||
protected abstract JSONObject getModifyResult();
|
||||
|
||||
@Transactional
|
||||
public int doModify(MerchantInfoProvider merchantInfoProvider, ClientMapper clientMapper, MongoTemplate mongoTemplate) {
|
||||
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
|
||||
@Override
|
||||
protected Consumer<JSONObject> getModifyProcess() {
|
||||
return client -> {
|
||||
JSONObject modifyResult = getModifyResult();
|
||||
try {
|
||||
saveModifyHistory(client, modifyResult, mongoTemplate);
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
int clientId = client.getIntValue("client_id");
|
||||
modifyResult.put("client_id", clientId);
|
||||
clientMapper.update(modifyResult);
|
||||
return clientId;
|
||||
}
|
||||
|
||||
private void saveModifyHistory(JSONObject client, JSONObject modifyResult, MongoTemplate mongoTemplate) {
|
||||
if (account == null) {
|
||||
return;
|
||||
modifyConsumer.accept(modifyResult);
|
||||
};
|
||||
}
|
||||
ClientConfigLog clientConfigLog = new ClientConfigLog();
|
||||
clientConfigLog.setId(IdUtil.getId());
|
||||
clientConfigLog.setBusiness(business());
|
||||
clientConfigLog.setClientId(client.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, client::get));
|
||||
clientConfigLog.setOriginData(JSON.toJSONString(beforeModify));
|
||||
clientConfigLog.setUserName(isPartner ? account.getString("display_name") : account.getString("display_name"));
|
||||
mongoTemplate.save(clientConfigLog);
|
||||
public ClientModify setModifyConsumer(Consumer<JSONObject> modifyConsumer) {
|
||||
this.modifyConsumer = modifyConsumer;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,29 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2018-04-12 16:43
|
||||
*/
|
||||
public class ClearDaysModify extends ClientConfigModify {
|
||||
private int settle_hour;
|
||||
public class ClearDaysModify extends ClientModify {
|
||||
private int settleHour;
|
||||
|
||||
public ClearDaysModify(JSONObject account, String clientMoniker, int settle_hour) {
|
||||
public ClearDaysModify(JSONObject account, String clientMoniker, int settleHour) {
|
||||
super(account, clientMoniker);
|
||||
this.settle_hour = settle_hour;
|
||||
this.settleHour = settleHour;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String business() {
|
||||
|
||||
return "修改商户清算截止时间为:"+settle_hour;
|
||||
return "修改商户清算截止时间为:" + settleHour;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getModifyResult() {
|
||||
JSONObject modify = new JSONObject();
|
||||
modify.put("settle_hour", settle_hour);
|
||||
modify.put("settle_hour", settleHour);
|
||||
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;
|
||||
|
||||
import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify;
|
||||
|
||||
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* Create by yixian at 2018-04-12 16:43
|
||||
*/
|
||||
public class SettleHourModify extends ClientConfigModify {
|
||||
private Integer settle_hour;
|
||||
public class SettleHourModify extends ClientModify {
|
||||
private Integer settleHour;
|
||||
|
||||
public SettleHourModify(JSONObject account, String clientMoniker, Integer settle_hour) {
|
||||
public SettleHourModify(JSONObject account, String clientMoniker, Integer settleHour) {
|
||||
super(account, clientMoniker);
|
||||
this.settle_hour = settle_hour;
|
||||
this.settleHour = settleHour;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String business() {
|
||||
|
||||
return "修改商户清算截止时间为:"+settle_hour;
|
||||
return "修改商户清算截止时间为:" + settleHour;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getModifyResult() {
|
||||
JSONObject modify = new JSONObject();
|
||||
modify.put("settle_hour", settle_hour);
|
||||
modify.put("settle_hour", settleHour);
|
||||
return modify;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue