diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 05b3c61cb..89630c392 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -268,14 +268,16 @@ public class RetailAppServiceImp implements RetailAppService { @Override public JSONObject setRequireRemarkConfig(JSONObject device, boolean enabled) { JSONObject user = userInfo(device); - clientManager.switchPermission(null, user.getString("client_moniker"), "require_remark", enabled); + JSONObject account = clientAccountMapper.findById(device.getString("account_id")); + clientManager.switchPermission(account, user.getString("client_moniker"), "require_remark", enabled); return userInfo(device); } @Override public JSONObject setRequireCustInfoConfig(JSONObject device, boolean enabled) { JSONObject user = userInfo(device); - clientManager.switchPermission(null, user.getString("client_moniker"), "require_custinfo", enabled); + JSONObject account = clientAccountMapper.findById(device.getString("account_id")); + clientManager.switchPermission(account, user.getString("client_moniker"), "require_custinfo", enabled); return userInfo(device); } 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 1fc7260a1..065afda01 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,5 +1,6 @@ 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.ClientModify; /** @@ -8,4 +9,6 @@ import au.com.royalpay.payment.manage.merchants.entity.ClientModify; public interface ClientModifySupport { void processClientModify(ClientModify clientModify); + + void processClientConfigModify(ClientConfigModify clientConfigModify); } 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 d36f6675a..957b5a658 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 @@ -43,7 +43,11 @@ import au.com.royalpay.payment.manage.merchants.core.ClientConfigService; import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport; +import au.com.royalpay.payment.manage.merchants.entity.impls.ApproveEmailAuditModify; +import au.com.royalpay.payment.manage.merchants.entity.impls.GreenChannelAuditModify; +import au.com.royalpay.payment.manage.merchants.entity.impls.MerchantIdAuditModify; import au.com.royalpay.payment.manage.merchants.entity.impls.RefundAuditModify; +import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionAuditModify; import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.signin.beans.TodoNotice; import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider; @@ -582,20 +586,18 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid JSONObject update = new JSONObject(); int clientId = client.getIntValue("client_id"); String originSubMerchantId = client.getString("sub_merchant_id"); - update.put("client_id", clientId); String subMerchantId = subMerchantInfo.getString("sub_merchant_id"); WeChatPayConfig.Merchant availableMerchant = mpPaymentApi.determineMerchant(subMerchantId); - update.put("merchant_id", availableMerchant == null ? null : availableMerchant.getMerchantId()); - update.put("sub_merchant_id", subMerchantId); - clientMapper.update(update); + clientModifySupport.processClientModify( + new MerchantIdAuditModify(manager, clientMoniker, subMerchantId, availableMerchant == null ? null : availableMerchant.getMerchantId())); List children = clientMapper.listChildClients(clientId); for (JSONObject child : children) { if (Objects.equals(child.getString("sub_merchant_id"), originSubMerchantId)) { update.put("client_id", child.getIntValue("client_id")); - clientMapper.update(update); + clientModifySupport.processClientModify( + new MerchantIdAuditModify(manager, clientMoniker, subMerchantId, availableMerchant == null ? null : availableMerchant.getMerchantId())); } } - clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -617,6 +619,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client.getIntValue("source") == 5) { client.put("source", 1); } + clientMapper.update(client); sendCommissionWechatMessage(client);// wxMessage if (pass == 1) { @@ -650,11 +653,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client.getString("sub_merchant_id") == null || client.getString("sub_merchant_id").equals("")) { throw new BadRequestException("该商户未设置微信 Sub Merchant ID!"); } - clientMapper.update(client); + clientModifySupport.processClientModify(new GreenChannelAuditModify(manager, clientMoniker, manager.getString("manager_id"))); saveClientAuditProcess(client.getIntValue("client_id"), 10, 1, "绿色通道申请通过", manager); sendCommissionWechatMessage(client); initAdminUserAndSendEmail(manager, clientMoniker, client); - clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } private void initAdminUserAndSendEmail(JSONObject manager, String clientMoniker, JSONObject client) { @@ -831,15 +833,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new BadRequestException("Client Not Complied yet!"); } int clientId = client.getIntValue("client_id"); - updateClientApproveEmailStatus(clientId, 1); - clientInfoCacheSupport.clearClientCache(clientId); + updateClientApproveEmailStatus(1, manager, clientMoniker); } - private void updateClientApproveEmailStatus(int clientId, int status) { - JSONObject clientUpdate = new JSONObject(); - clientUpdate.put("client_id", clientId); - clientUpdate.put("approve_email_send", status); - clientMapper.update(clientUpdate); + private void updateClientApproveEmailStatus(int status, JSONObject account, String client_moniker) { + clientModifySupport.processClientModify(new ApproveEmailAuditModify(account, client_moniker, status)); } @Override @@ -862,7 +860,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid mailStatus = 2; break; } - updateClientApproveEmailStatus(client.getIntValue("client_id"), mailStatus); + updateClientApproveEmailStatus(mailStatus, null, null); } else { logger.debug("get mail status:" + emailId + "-- none"); // updateClientApproveEmailStatus(client.getIntValue("client_id"), 0); @@ -883,6 +881,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkOrgPermission(manager, client); client.put(permissionKey, allow); clientMapper.update(client); + + clientModifySupport.processClientConfigModify(new SwitchPermissionAuditModify(manager,)); clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } @@ -2151,7 +2151,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid file.put("last_update_by", manager.getString("display_name")); } JSONObject contract = clientsContractMapper.findByClientId(client.getIntValue("client_id")); - if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0 || !contract.getBoolean("has_sign") || existFile == null || existFile.isEmpty()) { + if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0 || !contract.getBoolean("has_sign") || existFile == null + || existFile.isEmpty()) { clientFilesMapper.save(file); } else { file.put("file_id", existFile.getString("file_id")); @@ -2252,13 +2253,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public void updateRefundPwd(JSONObject account, String pwd) { JSONObject client = getClientInfo(account.getIntValue("client_id")); - if(client==null){ + if (client == null) { throw new BadRequestException("Client Not Found"); } String salt = PasswordUtils.newSalt(); String pwdHash = PasswordUtils.hashPwd(pwd, salt); JSONObject record = new JSONObject(); - record.put("client_id",client.getIntValue("client_id")); + record.put("client_id", client.getIntValue("client_id")); record.put("refund_pwd", pwdHash); record.put("refund_pwd_salt", salt); clientConfigService.update(record); @@ -3010,7 +3011,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } private TemplateMessage initSendToComplianceGreenChannelTemplate(String loginUrl, String wxopenid, String templateId2, String bd_user_name, - JSONObject client) { + JSONObject client) { TemplateMessage msg = new TemplateMessage(wxopenid, templateId2, loginUrl); msg.put("first", bd_user_name + " 提交了新商户绿色通道申请,请审核", "#ff0000"); msg.put("keyword1", client.getString("client_moniker") + "申请绿色通道", "#0000ff"); @@ -3258,53 +3259,67 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } else { if (expireInfo.getBoolean("alert")) { result = new JSONObject(); -// result.put("content","Dear Valued Merchants,\n" + -// "\n" + -// "\n" + -// "\n" + -// "We would like to extend our warm gratitude to your business for your continued support of RoyalPay. Without our merchants we wouldn't be where we are today. \n" + -// "\n" + -// "\n" + -// "\n" + -// "RoyalPay has and always will be committed to complying with all Australian laws, rules and regulations. With our deep roots in China, we also work with all Chinese regulations simultaneously with Australia. Since our humble beginnings in 2016 we have worked with the ATO (Australian Tax Office) to make sure that we are in alignment with all tax requirements. \n" + -// "\n" + -// "\n" + -// "\n" + -// "\n" + -// "During FY18 we entered negotiations with the ATO to file for GST exemptions for the part of surcharge fees. The ATO has recently advised that we have been unsuccessful in this bid. To ensure we comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST. \n" + -// "\n" + -// "\n" + -// "\n" + -// "This will result in contractual changes to your agreement. However, your business may be eligible to claim this amount back depending on the tax relationship of your business. Please consult with your accounting team in relation to these changes. \n" + -// "\n" + -// "\n" + -// "\n" + -// "If you have any questions related to this change please direct them to our Sales Management Team or your relevant BD officer.\n" + -// "\n" + -// "\n" + -// "\n" + -// "(note: GST is for the surcharge fee only, not related to the price of the goods.)\n" + -// "\n" + -// "\n" + -// "\n" + -// "尊敬的商户,\n" + -// "\n" + -// "\n" + -// "\n" + -// "\n" + -// "感谢您选择RoyalPay。作为澳洲移动支付的先行者和领导者,RoyalPay自2016年起就开始针对交易手续费这一澳洲目前空白的税务问题对接澳大利亚相关监管机构。作为市场上全新的支付模式,这两年来我们不断地与相关机构探讨最为合适的监管法令应用,同时澳洲的相应法律法规也在不断地完善来提供更全面的监管,来营造更加稳定、健康、健全的金融市场。\n" + -// "\n" + -// "\n" + -// "\n" + -// "RoyalPay于近期正式收到澳洲监管机构的通知,针对手续费Tax Free的申请和特殊税务条款考量做出了相应的回复:目前澳洲市场上的移动支付(扫码)解决方案所产生的手续费部分的GST并不能享受Tax Free及部分减免的政策条款。我们已经替2018年前交易的商户补足了手续费部分的税金,并应澳大利亚税务局ATO的要求进行了合同上手续费GST部分的相应调整。您也可咨询专业的会计师来申请您额外的手续费GST Return。感谢您的支持和理解,愿我们一起共同努力,塑造一个良好而有序的澳洲移动支付市场。\n" + -// "\n" + -// "\n" + -// "\n" + -// "有任何疑问,请随时联络我们的客服与公众号。\n" + -// "\n" + -// "(注:GST只针对手续费部分,与商品价格无关)\n" + -// "\n"); - result.put("content", "

Dear Valued Merchants,


We would like to extend our warm gratitude to your business for your continued support of RoyalPay. Without our merchants we wouldn't be where we are today. 


RoyalPay has and always will be committed to complying with all Australian laws, rules and regulations. With our deep roots in China, we also work with all Chinese regulations simultaneously with Australia. Since our humble beginnings in 2016 we have worked with the ATO (Australian Tax Office) to make sure that we are in alignment with all tax requirements. 


During FY18 we entered negotiations with the ATO to file for GST exemptions for the part of surcharge fees. The ATO has recently advised that we have been unsuccessful in this bid. To ensure we comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST. 


This will result in contractual changes to your agreement. However, your business may be eligible to claim this amount back depending on the tax relationship of your business. Please consult with your accounting team in relation to these changes. 


If you have any questions related to this change please direct them to our Sales Management Team or your relevant BD officer.


(note: GST is for the surcharge fee only, not related to the price of the goods.)


尊敬的商户,


感谢您选择RoyalPay。作为澳洲移动支付的先行者和领导者,RoyalPay自2016年起就开始针对交易手续费这一澳洲目前空白的税务问题对接澳大利亚相关监管机构。作为市场上全新的支付模式,这两年来我们不断地与相关机构探讨最为合适的监管法令应用,同时澳洲的相应法律法规也在不断地完善来提供更全面的监管,来营造更加稳定、健康、健全的金融市场。


RoyalPay于近期正式收到澳洲监管机构的通知,针对手续费Tax Free的申请和特殊税务条款考量做出了相应的回复:目前澳洲市场上的移动支付(扫码)解决方案所产生的手续费部分的GST并不能享受Tax Free及部分减免的政策条款。我们已经替2018年前交易的商户补足了手续费部分的税金,并应澳大利亚税务局ATO的要求进行了合同上手续费GST部分的相应调整。您也可咨询专业的会计师来申请您额外的手续费GST Return。感谢您的支持和理解,愿我们一起共同努力,塑造一个良好而有序的澳洲移动支付市场。


有任何疑问,请随时联络我们的客服与公众号。

(注:GST只针对手续费部分,与商品价格无关)


"); + // result.put("content","Dear Valued Merchants,\n" + + // "\n" + + // "\n" + + // "\n" + + // "We would like to extend our warm gratitude to your business for your continued support of RoyalPay. + // Without our merchants we wouldn't be where we are today. \n" + + // "\n" + + // "\n" + + // "\n" + + // "RoyalPay has and always will be committed to complying with all Australian laws, rules and + // regulations. With our deep roots in China, we also work with all Chinese regulations simultaneously + // with Australia. Since our humble beginnings in 2016 we have worked with the ATO (Australian Tax + // Office) to make sure that we are in alignment with all tax requirements. \n" + + // "\n" + + // "\n" + + // "\n" + + // "\n" + + // "During FY18 we entered negotiations with the ATO to file for GST exemptions for the part of + // surcharge fees. The ATO has recently advised that we have been unsuccessful in this bid. To ensure we + // comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST. + // \n" + + // "\n" + + // "\n" + + // "\n" + + // "This will result in contractual changes to your agreement. However, your business may be eligible to + // claim this amount back depending on the tax relationship of your business. Please consult with your + // accounting team in relation to these changes. \n" + + // "\n" + + // "\n" + + // "\n" + + // "If you have any questions related to this change please direct them to our Sales Management Team or + // your relevant BD officer.\n" + + // "\n" + + // "\n" + + // "\n" + + // "(note: GST is for the surcharge fee only, not related to the price of the goods.)\n" + + // "\n" + + // "\n" + + // "\n" + + // "尊敬的商户,\n" + + // "\n" + + // "\n" + + // "\n" + + // "\n" + + // "感谢您选择RoyalPay。作为澳洲移动支付的先行者和领导者,RoyalPay自2016年起就开始针对交易手续费这一澳洲目前空白的税务问题对接澳大利亚相关监管机构。作为市场上全新的支付模式,这两年来我们不断地与相关机构探讨最为合适的监管法令应用,同时澳洲的相应法律法规也在不断地完善来提供更全面的监管,来营造更加稳定、健康、健全的金融市场。\n" + // + + // "\n" + + // "\n" + + // "\n" + + // "RoyalPay于近期正式收到澳洲监管机构的通知,针对手续费Tax Free的申请和特殊税务条款考量做出了相应的回复:目前澳洲市场上的移动支付(扫码)解决方案所产生的手续费部分的GST并不能享受Tax + // Free及部分减免的政策条款。我们已经替2018年前交易的商户补足了手续费部分的税金,并应澳大利亚税务局ATO的要求进行了合同上手续费GST部分的相应调整。您也可咨询专业的会计师来申请您额外的手续费GST + // Return。感谢您的支持和理解,愿我们一起共同努力,塑造一个良好而有序的澳洲移动支付市场。\n" + + // "\n" + + // "\n" + + // "\n" + + // "有任何疑问,请随时联络我们的客服与公众号。\n" + + // "\n" + + // "(注:GST只针对手续费部分,与商品价格无关)\n" + + // "\n"); + result.put("content", + "

Dear Valued Merchants,


We would like to extend our warm gratitude to your business for your continued support of RoyalPay. Without our merchants we wouldn't be where we are today. 


RoyalPay has and always will be committed to complying with all Australian laws, rules and regulations. With our deep roots in China, we also work with all Chinese regulations simultaneously with Australia. Since our humble beginnings in 2016 we have worked with the ATO (Australian Tax Office) to make sure that we are in alignment with all tax requirements. 


During FY18 we entered negotiations with the ATO to file for GST exemptions for the part of surcharge fees. The ATO has recently advised that we have been unsuccessful in this bid. To ensure we comply with the ATO, we will need to adjust our current service agreements to be exclusionary of GST. 


This will result in contractual changes to your agreement. However, your business may be eligible to claim this amount back depending on the tax relationship of your business. Please consult with your accounting team in relation to these changes. 


If you have any questions related to this change please direct them to our Sales Management Team or your relevant BD officer.


(note: GST is for the surcharge fee only, not related to the price of the goods.)


尊敬的商户,


感谢您选择RoyalPay。作为澳洲移动支付的先行者和领导者,RoyalPay自2016年起就开始针对交易手续费这一澳洲目前空白的税务问题对接澳大利亚相关监管机构。作为市场上全新的支付模式,这两年来我们不断地与相关机构探讨最为合适的监管法令应用,同时澳洲的相应法律法规也在不断地完善来提供更全面的监管,来营造更加稳定、健康、健全的金融市场。


RoyalPay于近期正式收到澳洲监管机构的通知,针对手续费Tax Free的申请和特殊税务条款考量做出了相应的回复:目前澳洲市场上的移动支付(扫码)解决方案所产生的手续费部分的GST并不能享受Tax Free及部分减免的政策条款。我们已经替2018年前交易的商户补足了手续费部分的税金,并应澳大利亚税务局ATO的要求进行了合同上手续费GST部分的相应调整。您也可咨询专业的会计师来申请您额外的手续费GST Return。感谢您的支持和理解,愿我们一起共同努力,塑造一个良好而有序的澳洲移动支付市场。


有任何疑问,请随时联络我们的客服与公众号。

(注:GST只针对手续费部分,与商品价格无关)


"); result.put("title", "【Important!重要!!】GST Modification Notice | 澳洲监管机构关于手续费GST调整问题通知\n"); } } 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 a6cdb5645..1b525406e 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 @@ -4,6 +4,7 @@ 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; +import au.com.royalpay.payment.manage.merchants.entity.ClientConfigModify; import au.com.royalpay.payment.manage.merchants.entity.ClientModify; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; import org.springframework.stereotype.Service; @@ -24,10 +25,14 @@ public class ClientModifySupportImpl implements ClientModifySupport { @Resource private ClientConfigMapper clientConfigMapper; - @Override public void processClientModify(ClientModify modify) { - int clientId = modify.doModify(merchantInfoProvider, clientConfigMapper, clientMapper); + int clientId = modify.doModify(merchantInfoProvider, clientMapper); clientInfoCacheSupport.clearClientCache(clientId); } + + @Override + public void processClientConfigModify(ClientConfigModify clientConfigModify) { + clientConfigModify.doModify(merchantInfoProvider, clientConfigMapper); + } } 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 new file mode 100644 index 000000000..0c4e6c506 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/ClientConfigModify.java @@ -0,0 +1,89 @@ +package au.com.royalpay.payment.manage.merchants.entity; + +import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper; +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; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Create by yixian at 2018-04-12 16:19 + */ +public abstract class ClientConfigModify { + + private JSONObject account; + + private String clientMoniker; + + public ClientConfigModify(JSONObject account, String clientMoniker) { + this.account = account; + this.clientMoniker = clientMoniker; + } + + protected abstract String business(); + + protected abstract JSONObject getModifyResult(); + + @Transactional + public int doModify(MerchantInfoProvider merchantInfoProvider, ClientConfigMapper clientConfigMapper) { + JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker); + JSONObject modifyResult = getModifyResult(); + saveModifyHistory(client, modifyResult); + int clientId = client.getIntValue("client_id"); + modifyResult.put("client_id", clientId); + clientConfigMapper.update(modifyResult); + return clientId; + } + + private void saveModifyHistory(JSONObject client, JSONObject modifyResult) { + if (account == null) { + return; + } + boolean isManager = 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; + } + if (StringUtils.isNotEmpty(account.getString("manager_id"))) { + isManager = true; + } + 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("origin_data", JSON.toJSONString(beforeModify)); + modifyHistory.put("new_data", modifyResult.toJSONString()); + + BufferedWriter out = null; + try { + // TODO: 2018/4/12 kira 文件地址 + File file = new File("/Users/wangning/Desktop/asd.txt"); + if (file == null) { + file.createNewFile(); + } + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true))); + out.write("asdasdasdasd" + "\r\n"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} 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 993640731..ed8f46ac6 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,6 +1,5 @@ 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; @@ -9,6 +8,11 @@ import com.alibaba.fastjson.JSONObject; import org.springframework.transaction.annotation.Transactional; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; import java.util.Map; import java.util.stream.Collectors; @@ -33,17 +37,17 @@ public abstract class ClientModify { protected abstract JSONObject getModifyResult(); @Transactional - public int doModify(MerchantInfoProvider merchantInfoProvider, ClientConfigMapper clientConfigMapper, ClientMapper clientMapper) { + public int doModify(MerchantInfoProvider merchantInfoProvider, ClientMapper clientMapper) { JSONObject client = merchantInfoProvider.getClientInfoByMoniker(clientMoniker); JSONObject modifyResult = getModifyResult(); - saveModifyHistory(clientConfigMapper, client, modifyResult); + saveModifyHistory(client, modifyResult); int clientId = client.getIntValue("client_id"); modifyResult.put("client_id", clientId); clientMapper.update(modifyResult); return clientId; } - private void saveModifyHistory(ClientConfigMapper clientConfigMapper, JSONObject client, JSONObject modifyResult) { + private void saveModifyHistory(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")); @@ -53,6 +57,24 @@ 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()); - clientConfigMapper.save(modifyHistory); + + BufferedWriter out = null; + try { + // TODO: 2018/4/12 kira 文件地址 + File file = new File("/Users/wangning/Desktop/asd.txt"); + if (file == null) { + file.createNewFile(); + } + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true))); + out.write("asdasdasdasd" + "\r\n"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } } 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 new file mode 100644 index 000000000..83443b94e --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/ApproveEmailAuditModify.java @@ -0,0 +1,30 @@ +package au.com.royalpay.payment.manage.merchants.entity.impls; + +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 ApproveEmailAuditModify extends ClientModify { + private int approve_email_send; + + public ApproveEmailAuditModify(JSONObject account, String clientMoniker, int approve_email_send) { + super(account, null, clientMoniker); + this.approve_email_send = approve_email_send; + + } + + @Override + protected String business() { + return "开启绿色通道"; + } + + @Override + protected JSONObject getModifyResult() { + JSONObject modify = new JSONObject(); + modify.put("approve_email_send", approve_email_send); + return modify; + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..eea4b7c40 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/GreenChannelAuditModify.java @@ -0,0 +1,36 @@ +package au.com.royalpay.payment.manage.merchants.entity.impls; + +import au.com.royalpay.payment.manage.merchants.entity.ClientModify; + +import com.alibaba.fastjson.JSONObject; + +import java.util.Date; + +/** + * Create by yixian at 2018-04-12 16:43 + */ +public class GreenChannelAuditModify extends ClientModify { + private String manager_id; + + public GreenChannelAuditModify(JSONObject account, String clientMoniker, String manager_id) { + super(account, null, clientMoniker); + this.manager_id = manager_id; + + } + + @Override + protected String business() { + return "开启绿色通道"; + } + + @Override + protected JSONObject getModifyResult() { + JSONObject modify = new JSONObject(); + modify.put("approver", manager_id); + modify.put("approve_result", 2); + modify.put("approve_time", new Date()); + modify.put("skip_clearing", 0); + modify.put("open_status", 1); + return modify; + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..0aa68ca0b --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/MerchantIdAuditModify.java @@ -0,0 +1,33 @@ +package au.com.royalpay.payment.manage.merchants.entity.impls; + +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 MerchantIdAuditModify extends ClientModify { + private String sub_merchant_id; + private String merchant_id; + + public MerchantIdAuditModify(JSONObject account, String clientMoniker, String sub_merchant_id, String merchant_id) { + super(account, null, clientMoniker); + this.sub_merchant_id = sub_merchant_id; + this.merchant_id = merchant_id; + + } + + @Override + protected String business() { + return "修改商户号:sub_merchant_id:"+ sub_merchant_id +" merchant_id:"+merchant_id; + } + + @Override + protected JSONObject getModifyResult() { + JSONObject modify = new JSONObject(); + modify.put("sub_merchant_id", sub_merchant_id); + modify.put("merchant_id", merchant_id); + return modify; + } +} 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 adc92de86..afb9074ae 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 @@ -16,7 +16,7 @@ public class RefundAuditModify extends ClientModify { @Override protected String business() { - return "refund_audit"; + return (enable?"打开":"关闭")+"refund_audit"; } @Override 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 new file mode 100644 index 000000000..57ba6e7c6 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/entity/impls/SwitchPermissionAuditModify.java @@ -0,0 +1,32 @@ +package au.com.royalpay.payment.manage.merchants.entity.impls; + +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 SwitchPermissionAuditModify extends ClientModify { + private String key; + private boolean value; + + public SwitchPermissionAuditModify(JSONObject manager, JSONObject account, String clientMoniker, String key, boolean value) { + super(manager, account, clientMoniker); + this.key = key; + this.value = value; + } + + @Override + protected String business() { + + return (value?"开启 ":"关闭 ")+key; + } + + @Override + protected JSONObject getModifyResult() { + JSONObject modify = new JSONObject(); + modify.put(key, value); + return modify; + } +} \ No newline at end of file