diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java index a996be459..a6cdb5645 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientModifySupportImpl.java @@ -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); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientModify.java index 9341e27f2..993640731 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientModify.java @@ -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 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); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/RefundAuditModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/RefundAuditModify.java index 2da1fc16b..adc92de86 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/RefundAuditModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/RefundAuditModify.java @@ -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; } }