master
wangning 7 years ago
parent b7ef26926e
commit 6380c5d5b5

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

@ -1,10 +1,14 @@
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.tools.merchants.core.MerchantInfoProvider;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.stream.Collectors;
@ -28,17 +32,18 @@ public abstract class ClientModify {
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 modifyResult = getModifyResult();
saveModifyHistory(modifyHistoryMapper, client, modifyResult);
saveModifyHistory(clientConfigMapper, 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) {
private void saveModifyHistory(ClientConfigMapper clientConfigMapper, 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"));
@ -48,6 +53,6 @@ public abstract class ClientModify {
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);
clientConfigMapper.save(modifyHistory);
}
}

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

Loading…
Cancel
Save