commit
b7ef26926e
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 73 KiB |
@ -0,0 +1,11 @@
|
|||||||
|
package au.com.royalpay.payment.manage.merchants.core;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create by yixian at 2018-04-12 16:24
|
||||||
|
*/
|
||||||
|
public interface ClientModifySupport {
|
||||||
|
|
||||||
|
void processClientModify(ClientModify clientModify);
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package au.com.royalpay.payment.manage.merchants.core.impls;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
||||||
|
import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport;
|
||||||
|
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
|
||||||
|
import au.com.royalpay.payment.manage.merchants.entity.ClientModify;
|
||||||
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create by yixian at 2018-04-12 16:25
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ClientModifySupportImpl implements ClientModifySupport {
|
||||||
|
@Resource
|
||||||
|
private MerchantInfoProvider merchantInfoProvider;
|
||||||
|
@Resource
|
||||||
|
private ClientInfoCacheSupport clientInfoCacheSupport;
|
||||||
|
@Resource
|
||||||
|
private ClientMapper clientMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processClientModify(ClientModify modify) {
|
||||||
|
int clientId = modify.doModify(merchantInfoProvider, mapper, clientMapper);
|
||||||
|
clientInfoCacheSupport.clearClientCache(clientId);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package au.com.royalpay.payment.manage.merchants.entity;
|
||||||
|
|
||||||
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
||||||
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create by yixian at 2018-04-12 16:19
|
||||||
|
*/
|
||||||
|
public abstract class ClientModify {
|
||||||
|
|
||||||
|
private JSONObject manager;
|
||||||
|
private JSONObject account;
|
||||||
|
|
||||||
|
private String clientMoniker;
|
||||||
|
|
||||||
|
public ClientModify(JSONObject manager, JSONObject account, String clientMoniker) {
|
||||||
|
this.manager = manager;
|
||||||
|
this.account = account;
|
||||||
|
this.clientMoniker = clientMoniker;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract String business();
|
||||||
|
|
||||||
|
protected abstract JSONObject getModifyResult();
|
||||||
|
|
||||||
|
public int doModify(MerchantInfoProvider merchantInfoProvider, ModifyHistoryMapper modifyHistoryMapper, ClientMapper clientMapper) {
|
||||||
|
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
|
||||||
|
JSONObject modifyResult = getModifyResult();
|
||||||
|
saveModifyHistory(modifyHistoryMapper, client, modifyResult);
|
||||||
|
int clientId = client.getIntValue("client_id");
|
||||||
|
modifyResult.put("client_id", clientId);
|
||||||
|
clientMapper.update(modifyResult);
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveModifyHistory(ModifyHistoryMapper modifyHistoryMapper, JSONObject client, JSONObject modifyResult) {
|
||||||
|
Map<String, Object> beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get));
|
||||||
|
JSONObject modifyHistory = new JSONObject();
|
||||||
|
modifyHistory.put("client_id", client.getIntValue("client_id"));
|
||||||
|
modifyHistory.put("business", business());
|
||||||
|
modifyHistory.put("user_type", manager == null ? "Merchant" : "Manager");
|
||||||
|
modifyHistory.put("user_id", manager == null ? account.getString("account_id") : manager.getString("manager_id"));
|
||||||
|
modifyHistory.put("username", manager == null ? account.getString("display_name") : manager.getString("display_name"));
|
||||||
|
modifyHistory.put("origin_data", JSON.toJSONString(beforeModify));
|
||||||
|
modifyHistory.put("new_data", modifyResult.toJSONString());
|
||||||
|
modifyHistoryMapper.saveModifyHistory(modifyHistory);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package au.com.royalpay.payment.manage.merchants.entity.impls;
|
||||||
|
|
||||||
|
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 RefundAuditModify extends ClientModify {
|
||||||
|
private boolean enable;
|
||||||
|
|
||||||
|
public RefundAuditModify(JSONObject account, String clientMoniker, boolean enable) {
|
||||||
|
super(null, account, clientMoniker);
|
||||||
|
this.enable = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String business() {
|
||||||
|
return "refund_audit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JSONObject getModifyResult() {
|
||||||
|
JSONObject modify = new JSONObject();
|
||||||
|
modify.put("enable_refund_auth", enable)
|
||||||
|
return modify;
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue