|
|
@ -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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|