From e7817f5449bfabcbf6a75741694605e7dc90493c Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 12 Apr 2018 23:03:28 +0800 Subject: [PATCH] tmp --- .../manage/merchants/core/ClientManager.java | 2 +- .../core/impls/ClientManagerImpl.java | 15 ++++--------- .../merchants/entity/ClientConfigModify.java | 12 +++++----- .../manage/merchants/entity/ClientModify.java | 22 +++++++++++++------ .../entity/impls/ApproveEmailAuditModify.java | 2 +- .../entity/impls/GreenChannelAuditModify.java | 2 +- .../entity/impls/MerchantIdAuditModify.java | 2 +- .../entity/impls/RefundAuditModify.java | 2 +- .../impls/SwitchPermissionAuditModify.java | 8 +++---- .../merchants/web/PartnerViewController.java | 3 +-- 10 files changed, 35 insertions(+), 35 deletions(-) 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 039a68912..600482fb0 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 @@ -115,7 +115,7 @@ public interface ClientManager { void toggleAccountReceiveNoticeByOpenId(String openid, boolean enable); @Transactional - void togglePayNotice(String clientMoniker, boolean enable); + void togglePayNotice(JSONObject account,String clientMoniker, boolean enable); @Transactional void changeRole(JSONObject manager, String clientMoniker, String accountId, int role); 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 957b5a658..769484ff6 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 @@ -878,12 +878,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - checkOrgPermission(manager, client); - client.put(permissionKey, allow); - clientMapper.update(client); - - clientModifySupport.processClientConfigModify(new SwitchPermissionAuditModify(manager,)); - clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); + clientModifySupport.processClientConfigModify(new SwitchPermissionAuditModify(manager,clientMoniker,permissionKey,allow)); } @Override @@ -894,10 +889,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new NotFoundException("Client Not Exists"); } - JSONObject update = new JSONObject(); - update.put("client_id", client.getIntValue("client_id")); - update.put("enable_" + channel.toLowerCase(), allow); - clientMapper.update(update); + clientModifySupport.processClientConfigModify(new SwitchPermissionAuditModify(manager,clientMoniker,"enable_" + channel.toLowerCase(),allow)); logger.info(manager.getString("display_name") + "(" + manager.getString("manager_id") + ") switched client " + clientMoniker + " channel " + channel + " to " + allow); return; @@ -1065,11 +1057,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } @Override - public void togglePayNotice(String clientMoniker, boolean enable) { + public void togglePayNotice(JSONObject account,String clientMoniker, boolean enable) { JSONObject partner = getClientInfoByMoniker(clientMoniker); Assert.notNull(partner); partner.put("enable_pay_notice", enable); clientMapper.update(partner); + clientModifySupport.processClientConfigModify(new SwitchPermissionAuditModify(account,clientMoniker,"enable_pay_notice", enable)); clientInfoCacheSupport.clearClientCache(partner.getIntValue("client_id")); } 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/ClientConfigModify.java index 0c4e6c506..e94bdbd79 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/ClientConfigModify.java @@ -50,20 +50,20 @@ public abstract class ClientConfigModify { if (account == null) { return; } - boolean isManager = true; + boolean isPartner = true; Map beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get)); JSONObject modifyHistory = new JSONObject(); modifyHistory.put("client_id", client.getIntValue("client_id")); modifyHistory.put("business", business()); if (StringUtils.isNotEmpty(account.getString("account_id"))) { - isManager = false; + isPartner = true; } if (StringUtils.isNotEmpty(account.getString("manager_id"))) { - isManager = true; + isPartner = false; } - modifyHistory.put("user_type", manager == null ? "Merchant" : "Manager"); - modifyHistory.put("user_id", manager == null ? account.getString("account_id") : manager.getString("manager_id")); - modifyHistory.put("username", manager == null ? account.getString("display_name") : manager.getString("display_name")); + modifyHistory.put("user_type", isPartner ? "Merchant" : "Manager"); + modifyHistory.put("user_id", isPartner ? account.getString("account_id") : account.getString("manager_id")); + modifyHistory.put("username", isPartner ? account.getString("display_name") : account.getString("display_name")); modifyHistory.put("origin_data", JSON.toJSONString(beforeModify)); modifyHistory.put("new_data", modifyResult.toJSONString()); 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 ed8f46ac6..7d9d1afa8 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 @@ -6,6 +6,7 @@ import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; import org.springframework.transaction.annotation.Transactional; import java.io.BufferedWriter; @@ -21,13 +22,11 @@ import java.util.stream.Collectors; */ public abstract class ClientModify { - private JSONObject manager; private JSONObject account; private String clientMoniker; - public ClientModify(JSONObject manager, JSONObject account, String clientMoniker) { - this.manager = manager; + public ClientModify(JSONObject account, String clientMoniker) { this.account = account; this.clientMoniker = clientMoniker; } @@ -48,16 +47,25 @@ public abstract class ClientModify { } private void saveModifyHistory(JSONObject client, JSONObject modifyResult) { + if (account == null) { + return; + } + boolean isPartner = true; Map beforeModify = modifyResult.keySet().stream().collect(Collectors.toMap(key -> key, client::get)); JSONObject modifyHistory = new JSONObject(); modifyHistory.put("client_id", client.getIntValue("client_id")); modifyHistory.put("business", business()); - modifyHistory.put("user_type", manager == null ? "Merchant" : "Manager"); - modifyHistory.put("user_id", manager == null ? account.getString("account_id") : manager.getString("manager_id")); - modifyHistory.put("username", manager == null ? account.getString("display_name") : manager.getString("display_name")); + if (StringUtils.isNotEmpty(account.getString("account_id"))) { + isPartner = true; + } + if (StringUtils.isNotEmpty(account.getString("manager_id"))) { + isPartner = false; + } + modifyHistory.put("user_type", isPartner ? "Merchant" : "Manager"); + modifyHistory.put("user_id", isPartner ? account.getString("account_id") : account.getString("manager_id")); + modifyHistory.put("username", isPartner ? account.getString("display_name") : account.getString("display_name")); modifyHistory.put("origin_data", JSON.toJSONString(beforeModify)); modifyHistory.put("new_data", modifyResult.toJSONString()); - BufferedWriter out = null; try { // TODO: 2018/4/12 kira 文件地址 diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/ApproveEmailAuditModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/ApproveEmailAuditModify.java index 83443b94e..f05bf9688 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/ApproveEmailAuditModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/ApproveEmailAuditModify.java @@ -11,7 +11,7 @@ public class ApproveEmailAuditModify extends ClientModify { private int approve_email_send; public ApproveEmailAuditModify(JSONObject account, String clientMoniker, int approve_email_send) { - super(account, null, clientMoniker); + super(account, clientMoniker); this.approve_email_send = approve_email_send; } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/GreenChannelAuditModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/GreenChannelAuditModify.java index eea4b7c40..5bb0070b7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/GreenChannelAuditModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/GreenChannelAuditModify.java @@ -13,7 +13,7 @@ public class GreenChannelAuditModify extends ClientModify { private String manager_id; public GreenChannelAuditModify(JSONObject account, String clientMoniker, String manager_id) { - super(account, null, clientMoniker); + super(account, clientMoniker); this.manager_id = manager_id; } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/MerchantIdAuditModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/MerchantIdAuditModify.java index 0aa68ca0b..3c743255b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/MerchantIdAuditModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/MerchantIdAuditModify.java @@ -12,7 +12,7 @@ public class MerchantIdAuditModify extends ClientModify { private String merchant_id; public MerchantIdAuditModify(JSONObject account, String clientMoniker, String sub_merchant_id, String merchant_id) { - super(account, null, clientMoniker); + super(account, clientMoniker); this.sub_merchant_id = sub_merchant_id; this.merchant_id = merchant_id; 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 afb9074ae..db4d50724 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 @@ -10,7 +10,7 @@ public class RefundAuditModify extends ClientModify { private boolean enable; public RefundAuditModify(JSONObject account, String clientMoniker, boolean enable) { - super(null, account, clientMoniker); + super( account, clientMoniker); this.enable = enable; } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchPermissionAuditModify.java b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchPermissionAuditModify.java index 57ba6e7c6..6f7b85edb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchPermissionAuditModify.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchPermissionAuditModify.java @@ -1,18 +1,18 @@ package au.com.royalpay.payment.manage.merchants.entity.impls; -import au.com.royalpay.payment.manage.merchants.entity.ClientModify; +import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; import com.alibaba.fastjson.JSONObject; /** * Create by yixian at 2018-04-12 16:43 */ -public class SwitchPermissionAuditModify extends ClientModify { +public class SwitchPermissionAuditModify extends ClientConfigModify { private String key; private boolean value; - public SwitchPermissionAuditModify(JSONObject manager, JSONObject account, String clientMoniker, String key, boolean value) { - super(manager, account, clientMoniker); + public SwitchPermissionAuditModify(JSONObject account, String clientMoniker, String key, boolean value) { + super(account, clientMoniker); this.key = key; this.value = value; } diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java index 0f7a2a89f..7cd2836f8 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java @@ -13,7 +13,6 @@ import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.connections.mpsupport.beans.WxOauthType; -import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.http.HttpUtils; @@ -219,7 +218,7 @@ public class PartnerViewController { @PartnerMapping(value = "/pay_notice", method = RequestMethod.PUT, roles = PartnerRole.ADMIN) @ResponseBody public void togglePayNotice(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject enable) { - clientManager.togglePayNotice(account.getString("client_moniker"), enable.getBooleanValue("enable")); + clientManager.togglePayNotice(account,account.getString("client_moniker"), enable.getBooleanValue("enable")); } @PartnerMapping(value = "/audit_refund", method = RequestMethod.PUT, roles = PartnerRole.ADMIN)