From a1bbc19efd270d467a8019cec505380af7646efc Mon Sep 17 00:00:00 2001 From: yixian Date: Tue, 12 May 2020 16:27:04 +1000 Subject: [PATCH] fix: client modify process --- .../manage/merchants/core/ClientManager.java | 17 +++-- .../merchants/core/ClientModifySupport.java | 8 +- .../core/impls/ClientManagerImpl.java | 20 +++-- .../core/impls/ClientModifySupportImpl.java | 33 +++++--- .../entity/ClientGatewaySignModify.java | 71 ++++-------------- .../manage/merchants/entity/ClientModify.java | 75 ++++--------------- ...Modify.java => ClientModifyOperation.java} | 59 ++++++--------- .../impls/CBBankPaypadVersionModify.java | 10 +-- .../entity/impls/ClearDaysModify.java | 15 ++-- .../entity/impls/CredentialCodeModify.java | 13 ++-- .../entity/impls/CustomSwitchModify.java | 43 +++++++++++ .../impls/CustomerSurchargeRateModify.java | 15 ++-- .../entity/impls/EmailSendStandByModify.java | 15 ++-- .../entity/impls/MaxOrderAmountModify.java | 15 ++-- .../entity/impls/OrderExpiryModify.java | 13 ++-- .../entity/impls/PaypadVersionModify.java | 13 ++-- .../entity/impls/RefundAuditModify.java | 9 +-- .../entity/impls/RefundPWDModify.java | 5 +- .../entity/impls/SettleHourModify.java | 15 ++-- .../entity/impls/SurchargeModeModify.java | 1 - .../SwitchAllowSurchargeCreditModify.java | 1 - .../entity/impls/SwitchPermissionModify.java | 12 ++- .../web/PartnerManageController.java | 2 +- 23 files changed, 219 insertions(+), 261 deletions(-) rename src/main/java/au/com/royalpay/payment/manage/merchants/entity/{ClientConfigModify.java => ClientModifyOperation.java} (53%) create mode 100644 src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CustomSwitchModify.java diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 291435655..0d21c9e23 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -99,6 +99,9 @@ public interface ClientManager { @Transactional void switchPermission(JSONObject manager, String clientMoniker, String permissionKey, boolean allow); + @Transactional + void modifyUPayProfile(JSONObject manager, String clientMoniker, String profileKey, boolean allow); + @Transactional void switchChannelPermission(JSONObject manager, String clientMoniker, String channel, boolean allow); @@ -176,7 +179,7 @@ public interface ClientManager { List listSubClients(JSONObject manager, String clientMoniker); - JSONObject listSubClientsByPage(JSONObject manager, String clientMoniker,String searchText, int page); + JSONObject listSubClientsByPage(JSONObject manager, String clientMoniker, String searchText, int page); List listSubClients(int clientId); @@ -210,6 +213,7 @@ public interface ClientManager { /** * 获取所有设备Id分类 + * * @param clientMoniker * @param client_type * @param client_ids @@ -253,9 +257,9 @@ public interface ClientManager { void revertClient(String clientMoniker, JSONObject manager); - void updateClientIdInfo(String clientMoniker,JSONObject params, JSONObject manager); + void updateClientIdInfo(String clientMoniker, JSONObject params, JSONObject manager); - void updateMWRiskInfoByClient(String clientMoniker,JSONObject params, JSONObject manager); + void updateMWRiskInfoByClient(String clientMoniker, JSONObject params, JSONObject manager); JSONObject getAuthFiles(JSONObject manager, String clientMoniker); @@ -287,7 +291,7 @@ public interface ClientManager { List uploadKycFilesForWaitCompliance(JSONObject manager, String clientMoniker, ClientKycFilesInfo filesInfo); - List uploadKycFilesForWaitComplianceForApp(JSONObject account, String clientMoniker, JSONObject filesInfo,String fileType); + List uploadKycFilesForWaitComplianceForApp(JSONObject account, String clientMoniker, JSONObject filesInfo, String fileType); List uploadAuthFilesForWaitCompliance(JSONObject manager, String clientMoniker, ClientAuthFilesInfo filesInfo); @@ -307,6 +311,7 @@ public interface ClientManager { /** * 提交资料,申请卡支付 + * * @param clientMoniker * @param manager */ @@ -392,7 +397,7 @@ public interface ClientManager { void getAggregateCardAgreeFile(String clientMoniker, JSONObject manager, boolean renewal) throws Exception; - void getAggregateCardPromotionaAgreeFile(String clientMoniker, JSONObject manager, boolean renewal,String promotionalEffectiveDate,int promotionalPeriod) throws Exception; + void getAggregateCardPromotionaAgreeFile(String clientMoniker, JSONObject manager, boolean renewal, String promotionalEffectiveDate, int promotionalPeriod) throws Exception; void getNewAggregateAgreeFile(String clientMoniker, JSONObject manager, boolean renewal) throws Exception; @@ -587,7 +592,7 @@ public interface ClientManager { boolean getMergeSettleStatus(JSONObject client); - void changeExtParams(String clientMoniker,JSONObject manager, JSONObject params); + void changeExtParams(String clientMoniker, JSONObject manager, JSONObject params); RPayMerchantEntity applyMWMerchantId(String clientMoniker, JSONObject manager); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientModifySupport.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientModifySupport.java index 8d32edf4e..34b6a6fc1 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientModifySupport.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientModifySupport.java @@ -1,19 +1,21 @@ package au.com.royalpay.payment.manage.merchants.core; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; import au.com.royalpay.payment.manage.merchants.entity.ClientGatewaySignModify; import au.com.royalpay.payment.manage.merchants.entity.ClientModify; +import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation; /** * Create by yixian at 2018-04-12 16:24 */ public interface ClientModifySupport { + void processModify(ClientModifyOperation modify); + void processClientModify(ClientModify clientModify); - void processClientConfigModify(ClientConfigModify clientConfigModify); + void processClientConfigModify(ClientModify clientConfigModify); - void processClientConfigModify(ClientConfigModify clientConfigModify, boolean onlyModifyConfig); + void processClientConfigModify(ClientModify clientConfigModify, boolean onlyModifyConfig); void processClientGatewaySignModify(ClientGatewaySignModify clientGatewaySignModify); } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 9172a14c7..e16a698f5 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1625,11 +1625,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new InvalidShortIdException(); } clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, permissionKey, allow)); - JSONObject upayProfileInfo = sysClientUpayProfileMapper.findInfo(client.getInteger("client_id")); - if (upayProfileInfo != null) { - upayProfileInfo.put(permissionKey, allow); - sysClientUpayProfileMapper.update(upayProfileInfo); + } + + @Override + @Transactional + public void modifyUPayProfile(JSONObject manager, String clientMoniker, String profileKey, boolean allow) { + JSONObject client = getClientInfoByMoniker(clientMoniker); + if (client == null) { + throw new InvalidShortIdException(); } + clientModifySupport.processModify(new CustomSwitchModify(manager, clientMoniker, profileKey, allow, cli -> { + JSONObject profileUpdate = new JSONObject(); + profileUpdate.put(profileKey, allow); + profileUpdate.put("client_id", cli.getIntValue("client_id")); + sysClientUpayProfileMapper.update(profileUpdate); + })); } @Override @@ -3142,7 +3152,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("clean_days", p.getString("clean_days")); } else if ("Alipay".equals(rate_name)) { client.put("alipay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); - }else if ("AlipayOnline".equals(rate_name)) { + } else if ("AlipayOnline".equals(rate_name)) { client.put("alipay_online_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); } }); 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 f1a1b002b..cbfe34003 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 @@ -5,11 +5,10 @@ import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.MerchantSignInfoMapper; 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.ClientConfigModify; import au.com.royalpay.payment.manage.merchants.entity.ClientGatewaySignModify; import au.com.royalpay.payment.manage.merchants.entity.ClientModify; +import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; - import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.stereotype.Service; @@ -34,26 +33,36 @@ public class ClientModifySupportImpl implements ClientModifySupport { private MongoTemplate mongoTemplate; @Override - public void processClientModify(ClientModify modify) { - int clientId = modify.doModify(merchantInfoProvider, clientMapper,mongoTemplate); + public void processModify(ClientModifyOperation modify) { + int clientId = modify.processModify(merchantInfoProvider, mongoTemplate); clientInfoCacheSupport.clearClientCache(clientId); } @Override - public void processClientConfigModify(ClientConfigModify clientConfigModify) { - int clientId =clientConfigModify.doModify(merchantInfoProvider, clientConfigMapper,clientMapper,mongoTemplate); - clientInfoCacheSupport.clearClientCache(clientId); + public void processClientModify(ClientModify modify) { + processModify(modify.setModifyConsumer(modifyObj -> clientMapper.update(modifyObj))); } @Override - public void processClientConfigModify(ClientConfigModify clientConfigModify,boolean onlyModifyConfig) { - int clientId =clientConfigModify.doModify(merchantInfoProvider, clientConfigMapper,clientMapper,mongoTemplate,onlyModifyConfig); - clientInfoCacheSupport.clearClientConfigCache(clientId); + public void processClientConfigModify(ClientModify clientConfigModify) { + processModify(clientConfigModify.setModifyConsumer(modifyObj -> { + clientMapper.update(modifyObj); + clientConfigMapper.update(modifyObj); + })); + } + + @Override + public void processClientConfigModify(ClientModify clientConfigModify, boolean onlyModifyConfig) { + processModify(clientConfigModify.setModifyConsumer(modifyObj -> { + if (!onlyModifyConfig) { + clientMapper.update(modifyObj); + } + clientConfigMapper.update(modifyObj); + })); } @Override public void processClientGatewaySignModify(ClientGatewaySignModify clientGatewaySignModify) { - int clientId =clientGatewaySignModify.doModify(merchantInfoProvider, merchantSignInfoMapper,mongoTemplate); - clientInfoCacheSupport.clearClientCache(clientId); + processModify(clientGatewaySignModify.setMerchantSignInfoMapper(merchantSignInfoMapper)); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientGatewaySignModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientGatewaySignModify.java index 2c72380bf..e3dd601ca 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientGatewaySignModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientGatewaySignModify.java @@ -1,78 +1,39 @@ package au.com.royalpay.payment.manage.merchants.entity; import au.com.royalpay.payment.manage.mappers.system.MerchantSignInfoMapper; -import au.com.royalpay.payment.manage.merchants.beans.mongo.ClientConfigLog; -import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; -import au.com.royalpay.payment.tools.utils.id.IdUtil; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import org.apache.commons.lang3.StringUtils; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.transaction.annotation.Transactional; import java.util.Date; -import java.util.Map; -import java.util.stream.Collectors; +import java.util.function.Consumer; /** * Create by yixian at 2018-04-12 16:19 */ -public abstract class ClientGatewaySignModify { +public abstract class ClientGatewaySignModify extends ClientModifyOperation { - private JSONObject account; - - private String clientMoniker; + private MerchantSignInfoMapper merchantSignInfoMapper; public ClientGatewaySignModify(JSONObject account, String clientMoniker) { - this.account = account; - this.clientMoniker = clientMoniker; + super(account, clientMoniker); } protected abstract String business(); protected abstract JSONObject getModifyResult(); - @Transactional - public int doModify(MerchantInfoProvider merchantInfoProvider, MerchantSignInfoMapper merchantSignInfoMapper, MongoTemplate mongoTemplate) { - JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker); - JSONObject clientGatewaySign = merchantSignInfoMapper.findClientSign(clientMoniker); - JSONObject modifyResult = getModifyResult(); - try { - saveModifyHistory(clientGatewaySign, modifyResult, mongoTemplate); - }catch (Exception e){ - - } - int clientId = client.getIntValue("client_id"); - modifyResult.put("client_moniker", clientMoniker); - modifyResult.put("last_update_by", account.getString("account_id")); - modifyResult.put("last_update_date", new Date()); - merchantSignInfoMapper.update(modifyResult); - return clientId; + @Override + protected Consumer getModifyProcess() { + return client -> { + JSONObject modifyResult = getModifyResult(); + modifyResult.put("client_moniker", getClientMoniker()); + modifyResult.put("last_update_by", getAccount().getString("account_id")); + modifyResult.put("last_update_date", new Date()); + merchantSignInfoMapper.update(modifyResult); + }; } - private void saveModifyHistory(JSONObject clientGatewaySign, JSONObject modifyResult, MongoTemplate mongoTemplate) { - if (account == null) { - return; - } - ClientConfigLog clientConfigLog = new ClientConfigLog(); - clientConfigLog.setId(IdUtil.getId()); - clientConfigLog.setBusiness(business()); - clientConfigLog.setClientId(clientGatewaySign.getIntValue("client_id")); - - boolean isPartner = true; - if (StringUtils.isNotEmpty(account.getString("account_id"))) { - isPartner = true; - } - if (StringUtils.isNotEmpty(account.getString("manager_id"))) { - isPartner = false; - } - clientConfigLog.setUserType(isPartner ? "Merchant" : "Manager"); - clientConfigLog.setCreateTime(new Date()); - clientConfigLog.setNewData(modifyResult.toJSONString()); - clientConfigLog.setUserId(isPartner ? account.getString("account_id") : account.getString("manager_id")); - Map beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, clientGatewaySign::get)); - clientConfigLog.setOriginData(JSON.toJSONString(beforeModify)); - clientConfigLog.setUserName(isPartner ? account.getString("display_name") : account.getString("display_name")); - mongoTemplate.save(clientConfigLog); + public ClientGatewaySignModify setMerchantSignInfoMapper(MerchantSignInfoMapper merchantSignInfoMapper) { + this.merchantSignInfoMapper = merchantSignInfoMapper; + return this; } } 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 cf33238d9..d0e036a35 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,77 +1,32 @@ package au.com.royalpay.payment.manage.merchants.entity; -import au.com.royalpay.payment.manage.mappers.system.ClientMapper; -import au.com.royalpay.payment.manage.merchants.beans.mongo.ClientConfigLog; -import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; -import au.com.royalpay.payment.tools.utils.id.IdUtil; - -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import org.apache.commons.lang3.StringUtils; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Date; -import java.util.Map; -import java.util.stream.Collectors; +import java.util.function.Consumer; /** * Create by yixian at 2018-04-12 16:19 */ -public abstract class ClientModify { +public abstract class ClientModify extends ClientModifyOperation { - private JSONObject account; - - private String clientMoniker; + private Consumer modifyConsumer; public ClientModify(JSONObject account, String clientMoniker) { - this.account = account; - this.clientMoniker = clientMoniker; + super(account, clientMoniker); } - protected abstract String business(); - - protected abstract JSONObject getModifyResult(); - - @Transactional - public int doModify(MerchantInfoProvider merchantInfoProvider, ClientMapper clientMapper, MongoTemplate mongoTemplate) { - JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker); - JSONObject modifyResult = getModifyResult(); - try { - saveModifyHistory(client, modifyResult, mongoTemplate); - }catch (Exception e){ - - } - int clientId = client.getIntValue("client_id"); - modifyResult.put("client_id", clientId); - clientMapper.update(modifyResult); - return clientId; + @Override + protected Consumer getModifyProcess() { + return client -> { + JSONObject modifyResult = getModifyResult(); + int clientId = client.getIntValue("client_id"); + modifyResult.put("client_id", clientId); + modifyConsumer.accept(modifyResult); + }; } - private void saveModifyHistory(JSONObject client, JSONObject modifyResult, MongoTemplate mongoTemplate) { - if (account == null) { - return; - } - ClientConfigLog clientConfigLog = new ClientConfigLog(); - clientConfigLog.setId(IdUtil.getId()); - clientConfigLog.setBusiness(business()); - clientConfigLog.setClientId(client.getIntValue("client_id")); - - boolean isPartner = true; - if (StringUtils.isNotEmpty(account.getString("account_id"))) { - isPartner = true; - } - if (StringUtils.isNotEmpty(account.getString("manager_id"))) { - isPartner = false; - } - clientConfigLog.setUserType(isPartner ? "Merchant" : "Manager"); - clientConfigLog.setCreateTime(new Date()); - clientConfigLog.setNewData(modifyResult.toJSONString()); - clientConfigLog.setUserId(isPartner ? account.getString("account_id") : account.getString("manager_id")); - Map beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get)); - clientConfigLog.setOriginData(JSON.toJSONString(beforeModify)); - clientConfigLog.setUserName(isPartner ? account.getString("display_name") : account.getString("display_name")); - mongoTemplate.save(clientConfigLog); + public ClientModify setModifyConsumer(Consumer modifyConsumer) { + this.modifyConsumer = modifyConsumer; + return this; } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientConfigModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientModifyOperation.java similarity index 53% rename from src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientConfigModify.java rename to src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientModifyOperation.java index 18c50176c..d84d8c4ca 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientConfigModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientModifyOperation.java @@ -1,32 +1,26 @@ 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.merchants.beans.mongo.ClientConfigLog; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import au.com.royalpay.payment.tools.utils.id.IdUtil; - import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; - import org.apache.commons.lang3.StringUtils; import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.Map; +import java.util.function.Consumer; import java.util.stream.Collectors; /** - * Create by yixian at 2018-04-12 16:19 + * Create by davep at 2020-05-12 14:32 */ -public abstract class ClientConfigModify { - - private JSONObject account; - - private String clientMoniker; +public abstract class ClientModifyOperation { + private final JSONObject account; + private final String clientMoniker; - public ClientConfigModify(JSONObject account, String clientMoniker) { + protected ClientModifyOperation(JSONObject account, String clientMoniker) { this.account = account; this.clientMoniker = clientMoniker; } @@ -35,36 +29,21 @@ public abstract class ClientConfigModify { protected abstract JSONObject getModifyResult(); - public int doModify(MerchantInfoProvider merchantInfoProvider, ClientConfigMapper clientConfigMapper, ClientMapper clientMapper, MongoTemplate mongoTemplate) { - JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker); - JSONObject modifyResult = getModifyResult(); - try { - saveModifyHistory(client, modifyResult, mongoTemplate); - }catch (Exception e){ + protected abstract Consumer getModifyProcess(); - } - int clientId = client.getIntValue("client_id"); - modifyResult.put("client_id", clientId); - clientConfigMapper.update(modifyResult); - clientMapper.update(modifyResult); - return clientId; - } - - public int doModify(MerchantInfoProvider merchantInfoProvider, ClientConfigMapper clientConfigMapper, ClientMapper clientMapper, MongoTemplate mongoTemplate,boolean onlyModifyConfig) { - JSONObject clientConfig = merchantInfoProvider.getClientConfigInfoByMoniker(clientMoniker); + public int processModify(MerchantInfoProvider merchantInfoProvider, MongoTemplate mongoTemplate) { + JSONObject client = merchantInfoProvider.getClientInfoByMoniker(getClientMoniker()); JSONObject modifyResult = getModifyResult(); try { - saveModifyHistory(clientConfig, modifyResult, mongoTemplate); - }catch (Exception e){ + saveModifyHistory(client, modifyResult, mongoTemplate); + } catch (Exception e) { } - int clientId = clientConfig.getIntValue("client_id"); - modifyResult.put("client_id", clientId); - clientConfigMapper.update(modifyResult); - return clientId; + getModifyProcess().accept(client); + return client.getIntValue("client_id"); } - private void saveModifyHistory(JSONObject client, JSONObject modifyResult,MongoTemplate mongoTemplate) { + protected void saveModifyHistory(JSONObject client, JSONObject modifyResult, MongoTemplate mongoTemplate) { if (account == null) { return; } @@ -86,7 +65,15 @@ public abstract class ClientConfigModify { clientConfigLog.setUserId(isPartner ? account.getString("account_id") : account.getString("manager_id")); Map beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get)); clientConfigLog.setOriginData(JSON.toJSONString(beforeModify)); - clientConfigLog.setUserName(isPartner ? account.getString("display_name") : account.getString("display_name")); + clientConfigLog.setUserName(account.getString("display_name")); mongoTemplate.insert(clientConfigLog); } + + public JSONObject getAccount() { + return account; + } + + public String getClientMoniker() { + return clientMoniker; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CBBankPaypadVersionModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CBBankPaypadVersionModify.java index 4c4db3701..6d87f14ec 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CBBankPaypadVersionModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CBBankPaypadVersionModify.java @@ -1,17 +1,17 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; +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 CBBankPaypadVersionModify extends ClientConfigModify { - private String cbbank_paypad_version; +public class CBBankPaypadVersionModify extends ClientModify { + private String cbbankPaypadVersion; public CBBankPaypadVersionModify(JSONObject account, String clientMoniker, String paypad_version) { super(account, clientMoniker); - this.cbbank_paypad_version = paypad_version; + this.cbbankPaypadVersion = paypad_version; } @Override @@ -23,7 +23,7 @@ public class CBBankPaypadVersionModify extends ClientConfigModify { @Override protected JSONObject getModifyResult() { JSONObject modify = new JSONObject(); - modify.put("cbbank_paypad_version", cbbank_paypad_version); + modify.put("cbbank_paypad_version", cbbankPaypadVersion); return modify; } } \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/ClearDaysModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/ClearDaysModify.java index b53b5289c..18d53654c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/ClearDaysModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/ClearDaysModify.java @@ -1,30 +1,29 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +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 ClearDaysModify extends ClientConfigModify { - private int settle_hour; +public class ClearDaysModify extends ClientModify { + private int settleHour; - public ClearDaysModify(JSONObject account, String clientMoniker, int settle_hour) { + public ClearDaysModify(JSONObject account, String clientMoniker, int settleHour) { super(account, clientMoniker); - this.settle_hour = settle_hour; + this.settleHour = settleHour; } @Override protected String business() { - return "修改商户清算截止时间为:"+settle_hour; + return "修改商户清算截止时间为:" + settleHour; } @Override protected JSONObject getModifyResult() { JSONObject modify = new JSONObject(); - modify.put("settle_hour", settle_hour); + modify.put("settle_hour", settleHour); return modify; } } \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CredentialCodeModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CredentialCodeModify.java index b586c1761..83bf41b6e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CredentialCodeModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CredentialCodeModify.java @@ -1,19 +1,18 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +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 CredentialCodeModify extends ClientConfigModify { - private String credential_code; +public class CredentialCodeModify extends ClientModify { + private String credentialCode; - public CredentialCodeModify(JSONObject account, String clientMoniker, String credential_code) { + public CredentialCodeModify(JSONObject account, String clientMoniker, String credentialCode) { super(account, clientMoniker); - this.credential_code = credential_code; + this.credentialCode = credentialCode; } @Override @@ -24,7 +23,7 @@ public class CredentialCodeModify extends ClientConfigModify { @Override protected JSONObject getModifyResult() { JSONObject modify = new JSONObject(); - modify.put("credential_code", credential_code); + modify.put("credential_code", credentialCode); return modify; } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CustomSwitchModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CustomSwitchModify.java new file mode 100644 index 000000000..82b180a0d --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CustomSwitchModify.java @@ -0,0 +1,43 @@ +package au.com.royalpay.payment.manage.merchants.entity.impls; + +import au.com.royalpay.payment.manage.merchants.entity.ClientModifyOperation; +import com.alibaba.fastjson.JSONObject; + +import java.util.function.Consumer; + +/** + * Create by yixian at 2018-04-12 16:43 + */ +public class CustomSwitchModify extends ClientModifyOperation { + private final String key; + private final boolean value; + private final Consumer modifyProcess; + + + public CustomSwitchModify(JSONObject account, String clientMoniker, String key, boolean value, Consumer modifyProcess) { + super(account, clientMoniker); + this.key = key; + this.value = value; + this.modifyProcess = modifyProcess; + } + + @Override + protected String business() { + + return (value ? "开启 " : "关闭 ") + key; + } + + @Override + protected JSONObject getModifyResult() { + JSONObject modify = new JSONObject(); + modify.put(key, value); + return modify; + } + + @Override + protected Consumer getModifyProcess() { + return modifyProcess; + } + + +} \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CustomerSurchargeRateModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CustomerSurchargeRateModify.java index 23544c98e..1afc7b5f4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CustomerSurchargeRateModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/CustomerSurchargeRateModify.java @@ -1,7 +1,6 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +import au.com.royalpay.payment.manage.merchants.entity.ClientModify; import com.alibaba.fastjson.JSONObject; import java.math.BigDecimal; @@ -9,24 +8,24 @@ import java.math.BigDecimal; /** * Create by yixian at 2018-04-12 16:43 */ -public class CustomerSurchargeRateModify extends ClientConfigModify { - private BigDecimal customer_surcharge_rate; +public class CustomerSurchargeRateModify extends ClientModify { + private BigDecimal customerSurchargeRate; - public CustomerSurchargeRateModify(JSONObject account, String clientMoniker, BigDecimal customer_surcharge_rate) { + public CustomerSurchargeRateModify(JSONObject account, String clientMoniker, BigDecimal customerSurchargeRate) { super(account, clientMoniker); - this.customer_surcharge_rate = customer_surcharge_rate; + this.customerSurchargeRate = customerSurchargeRate; } @Override protected String business() { - return "修改商户客户手续费率为:"+customer_surcharge_rate; + return "修改商户客户手续费率为:" + customerSurchargeRate; } @Override protected JSONObject getModifyResult() { JSONObject modify = new JSONObject(); - modify.put("customer_surcharge_rate", customer_surcharge_rate); + modify.put("customer_surcharge_rate", customerSurchargeRate); return modify; } } \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/EmailSendStandByModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/EmailSendStandByModify.java index f8e4f9323..ad9db9163 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/EmailSendStandByModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/EmailSendStandByModify.java @@ -1,7 +1,6 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +import au.com.royalpay.payment.manage.merchants.entity.ClientModify; import com.alibaba.fastjson.JSONObject; import java.math.BigDecimal; @@ -9,24 +8,24 @@ import java.math.BigDecimal; /** * Create by yixian at 2018-04-12 16:43 */ -public class EmailSendStandByModify extends ClientConfigModify { - private BigDecimal max_order_amount; +public class EmailSendStandByModify extends ClientModify { + private BigDecimal maxOrderAmount; - public EmailSendStandByModify(JSONObject account, String clientMoniker, BigDecimal max_order_amount) { + public EmailSendStandByModify(JSONObject account, String clientMoniker, BigDecimal maxOrderAmount) { super(account, clientMoniker); - this.max_order_amount = max_order_amount; + this.maxOrderAmount = maxOrderAmount; } @Override protected String business() { - return "修改商户最大订单额为:"+max_order_amount; + return "修改商户最大订单额为:" + maxOrderAmount; } @Override protected JSONObject getModifyResult() { JSONObject modify = new JSONObject(); - modify.put("max_order_amount", max_order_amount); + modify.put("max_order_amount", maxOrderAmount); return modify; } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/MaxOrderAmountModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/MaxOrderAmountModify.java index 87e75bee6..d1c186876 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/MaxOrderAmountModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/MaxOrderAmountModify.java @@ -1,7 +1,6 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +import au.com.royalpay.payment.manage.merchants.entity.ClientModify; import com.alibaba.fastjson.JSONObject; import java.math.BigDecimal; @@ -9,24 +8,24 @@ import java.math.BigDecimal; /** * Create by yixian at 2018-04-12 16:43 */ -public class MaxOrderAmountModify extends ClientConfigModify { - private BigDecimal max_order_amount; +public class MaxOrderAmountModify extends ClientModify { + private BigDecimal maxOrderAmount; - public MaxOrderAmountModify(JSONObject account, String clientMoniker, BigDecimal max_order_amount) { + public MaxOrderAmountModify(JSONObject account, String clientMoniker, BigDecimal maxOrderAmount) { super(account, clientMoniker); - this.max_order_amount = max_order_amount; + this.maxOrderAmount = maxOrderAmount; } @Override protected String business() { - return "修改商户最大订单额为:"+max_order_amount; + return "修改商户最大订单额为:" + maxOrderAmount; } @Override protected JSONObject getModifyResult() { JSONObject modify = new JSONObject(); - modify.put("max_order_amount", max_order_amount); + modify.put("max_order_amount", maxOrderAmount); return modify; } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/OrderExpiryModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/OrderExpiryModify.java index 6ca63adf8..163d874e7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/OrderExpiryModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/OrderExpiryModify.java @@ -1,19 +1,18 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +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 OrderExpiryModify extends ClientConfigModify { - private String order_expiry_config; +public class OrderExpiryModify extends ClientModify { + private String orderExpiryConfig; - public OrderExpiryModify(JSONObject account, String clientMoniker, String order_expiry_config) { + public OrderExpiryModify(JSONObject account, String clientMoniker, String orderExpiryConfig) { super(account, clientMoniker); - this.order_expiry_config = order_expiry_config; + this.orderExpiryConfig = orderExpiryConfig; } @Override @@ -24,7 +23,7 @@ public class OrderExpiryModify extends ClientConfigModify { @Override protected JSONObject getModifyResult() { JSONObject modify = new JSONObject(); - modify.put("order_expiry_config", order_expiry_config); + modify.put("order_expiry_config", orderExpiryConfig); return modify; } } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/PaypadVersionModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/PaypadVersionModify.java index 6972662ec..ea81abe5d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/PaypadVersionModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/PaypadVersionModify.java @@ -1,18 +1,17 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +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 PaypadVersionModify extends ClientConfigModify { - private String paypad_version; +public class PaypadVersionModify extends ClientModify { + private String paypadVersion; - public PaypadVersionModify(JSONObject account, String clientMoniker, String paypad_version) { + public PaypadVersionModify(JSONObject account, String clientMoniker, String paypadVersion) { super(account, clientMoniker); - this.paypad_version = paypad_version; + this.paypadVersion = paypadVersion; } @Override @@ -24,7 +23,7 @@ public class PaypadVersionModify extends ClientConfigModify { @Override protected JSONObject getModifyResult() { JSONObject modify = new JSONObject(); - modify.put("paypad_version", paypad_version); + modify.put("paypad_version", paypadVersion); return modify; } } \ No newline at end of file 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 52de0d4be..c68e90989 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 @@ -1,23 +1,22 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +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 ClientConfigModify { +public class RefundAuditModify extends ClientModify { private boolean enable; public RefundAuditModify(JSONObject account, String clientMoniker, boolean enable) { - super( account, clientMoniker); + super(account, clientMoniker); this.enable = enable; } @Override protected String business() { - return (enable?"打开":"关闭")+"refund_audit"; + return (enable ? "打开" : "关闭") + "refund_audit"; } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/RefundPWDModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/RefundPWDModify.java index 15e252685..2c3bea1aa 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/RefundPWDModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/RefundPWDModify.java @@ -1,13 +1,12 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +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 RefundPWDModify extends ClientConfigModify { +public class RefundPWDModify extends ClientModify { private String refund_pwd; private String refund_pwd_salt; diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SettleHourModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SettleHourModify.java index 8951f5294..cf963abc8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SettleHourModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SettleHourModify.java @@ -1,30 +1,29 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +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 SettleHourModify extends ClientConfigModify { - private Integer settle_hour; +public class SettleHourModify extends ClientModify { + private Integer settleHour; - public SettleHourModify(JSONObject account, String clientMoniker, Integer settle_hour) { + public SettleHourModify(JSONObject account, String clientMoniker, Integer settleHour) { super(account, clientMoniker); - this.settle_hour = settle_hour; + this.settleHour = settleHour; } @Override protected String business() { - return "修改商户清算截止时间为:"+settle_hour; + return "修改商户清算截止时间为:" + settleHour; } @Override protected JSONObject getModifyResult() { JSONObject modify = new JSONObject(); - modify.put("settle_hour", settle_hour); + modify.put("settle_hour", settleHour); return modify; } } \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SurchargeModeModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SurchargeModeModify.java index 28cd86c5c..4bd56b6c0 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SurchargeModeModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SurchargeModeModify.java @@ -1,6 +1,5 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; import au.com.royalpay.payment.manage.merchants.entity.ClientModify; import com.alibaba.fastjson.JSONObject; diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchAllowSurchargeCreditModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchAllowSurchargeCreditModify.java index 50176f562..a6b676057 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchAllowSurchargeCreditModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchAllowSurchargeCreditModify.java @@ -1,6 +1,5 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; import au.com.royalpay.payment.manage.merchants.entity.ClientModify; import com.alibaba.fastjson.JSONObject; diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchPermissionModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchPermissionModify.java index 0118080b0..c351fe7df 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchPermissionModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchPermissionModify.java @@ -1,15 +1,14 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; - +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 SwitchPermissionModify extends ClientConfigModify { - private String key; - private boolean value; +public class SwitchPermissionModify extends ClientModify { + private final String key; + private final boolean value; public SwitchPermissionModify(JSONObject account, String clientMoniker, String key, boolean value) { super(account, clientMoniker); @@ -19,8 +18,7 @@ public class SwitchPermissionModify extends ClientConfigModify { @Override protected String business() { - - return (value?"开启 ":"关闭 ")+key; + return (value ? "开启 " : "关闭 ") + key; } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java index 59fae1acf..5ae92e4b2 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java @@ -990,7 +990,7 @@ public class PartnerManageController { */ @ManagerMapping(value = "/{clientMoniker}/payment_card_permission", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) public void switchInternationalCard(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager){ - clientManager.switchPermission(manager, clientMoniker, "enable_international_card", pass.getBooleanValue("allow")); + clientManager.modifyUPayProfile(manager, clientMoniker, "enable_international_card", pass.getBooleanValue("allow")); } }