master
wangning 7 years ago
parent b7ef26926e
commit 6380c5d5b5

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.merchants.core.impls; package au.com.royalpay.payment.manage.merchants.core.impls;
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper; 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.ClientInfoCacheSupport;
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport; import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
@ -20,11 +21,13 @@ public class ClientModifySupportImpl implements ClientModifySupport {
private ClientInfoCacheSupport clientInfoCacheSupport; private ClientInfoCacheSupport clientInfoCacheSupport;
@Resource @Resource
private ClientMapper clientMapper; private ClientMapper clientMapper;
@Resource
private ClientConfigMapper clientConfigMapper;
@Override @Override
public void processClientModify(ClientModify modify) { public void processClientModify(ClientModify modify) {
int clientId = modify.doModify(merchantInfoProvider, mapper, clientMapper); int clientId = modify.doModify(merchantInfoProvider, clientConfigMapper, clientMapper);
clientInfoCacheSupport.clearClientCache(clientId); clientInfoCacheSupport.clearClientCache(clientId);
} }
} }

@ -1,10 +1,14 @@
package au.com.royalpay.payment.manage.merchants.entity; package au.com.royalpay.payment.manage.merchants.entity;
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -28,17 +32,18 @@ public abstract class ClientModify {
protected abstract JSONObject getModifyResult(); protected abstract JSONObject getModifyResult();
public int doModify(MerchantInfoProvider merchantInfoProvider, ModifyHistoryMapper modifyHistoryMapper, ClientMapper clientMapper) { @Transactional
public int doModify(MerchantInfoProvider merchantInfoProvider, ClientConfigMapper clientConfigMapper, ClientMapper clientMapper) {
JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker); JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker);
JSONObject modifyResult = getModifyResult(); JSONObject modifyResult = getModifyResult();
saveModifyHistory(modifyHistoryMapper, client, modifyResult); saveModifyHistory(clientConfigMapper, client, modifyResult);
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); clientMapper.update(modifyResult);
return clientId; return clientId;
} }
private void saveModifyHistory(ModifyHistoryMapper modifyHistoryMapper, JSONObject client, JSONObject modifyResult) { private void saveModifyHistory(ClientConfigMapper clientConfigMapper, JSONObject client, JSONObject modifyResult) {
Map<String, Object> beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get)); Map<String, Object> beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get));
JSONObject modifyHistory = new JSONObject(); JSONObject modifyHistory = new JSONObject();
modifyHistory.put("client_id", client.getIntValue("client_id")); modifyHistory.put("client_id", client.getIntValue("client_id"));
@ -48,6 +53,6 @@ public abstract class ClientModify {
modifyHistory.put("username", manager == null ? account.getString("display_name") : manager.getString("display_name")); modifyHistory.put("username", manager == null ? account.getString("display_name") : manager.getString("display_name"));
modifyHistory.put("origin_data", JSON.toJSONString(beforeModify)); modifyHistory.put("origin_data", JSON.toJSONString(beforeModify));
modifyHistory.put("new_data", modifyResult.toJSONString()); modifyHistory.put("new_data", modifyResult.toJSONString());
modifyHistoryMapper.saveModifyHistory(modifyHistory); clientConfigMapper.save(modifyHistory);
} }
} }

@ -22,7 +22,7 @@ public class RefundAuditModify extends ClientModify {
@Override @Override
protected JSONObject getModifyResult() { protected JSONObject getModifyResult() {
JSONObject modify = new JSONObject(); JSONObject modify = new JSONObject();
modify.put("enable_refund_auth", enable) modify.put("enable_refund_auth", enable);
return modify; return modify;
} }
} }

Loading…
Cancel
Save