From 3b53be6de3dfa3fe870db4a858593eaa0f7991cf Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Tue, 3 Apr 2018 14:05:57 +0800 Subject: [PATCH] update contract --- .../appclient/web/RetailAppController.java | 9 ++ .../manage/merchants/core/ClientManager.java | 2 - .../core/impls/ClientManagerImpl.java | 98 ++++++------ .../web/PartnerManageController.java | 5 - .../system/core/ClientContractService.java | 7 +- .../core/impl/ClientContractServiceImpl.java | 144 +++--------------- .../static/payment/partner/partner-manage.js | 6 - .../partner/templates/partner_auth_files.html | 12 -- 8 files changed, 88 insertions(+), 195 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index 9369c9c5f..e7516ea92 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -230,6 +230,15 @@ public class RetailAppController { return retailAppService.getCheckClientInfo(device); } + @RequestMapping(value = "/client/checkContract", method = RequestMethod.GET) + public JSONObject getCheckClientInfoV2(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + String version = device.getString("version"); + if("2.9.3".equals(version)){ + throw new BadRequestException("test"); + } + return retailAppService.getCheckClientInfo(device); + } + @RequestMapping(value = "/client", method = RequestMethod.PUT) public void updateClient(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody AppClientBean appClientBean) { retailAppService.updateClient(device, appClientBean); 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 a3b4f3747..e11c4f1b6 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 @@ -245,8 +245,6 @@ public interface ClientManager { void setSkipClearing(String clientMoniker, Boolean skip_clearing); - void setSkipContract(String clientMoniker, Boolean new_contract); - void enableGatewayUpgrade(String clientMoniker, boolean gatewayUpgrade); void setCustomerSurchargeRate(String clientMoniker, BigDecimal customer_surcharge_rate); 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 0d68bf238..8c87c3b9d 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 @@ -53,7 +53,6 @@ import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage; import au.com.royalpay.payment.tools.connections.mpsupport.exceptions.WechatException; import au.com.royalpay.payment.tools.env.PlatformEnvironment; -import au.com.royalpay.payment.tools.env.RequestEnvironment; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; @@ -2839,20 +2838,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid clientInfoCacheSupport.clearClientCache(clientId); } - @Override - public void setSkipContract(String clientMoniker, Boolean new_contract) { - JSONObject client = getClientInfoByMoniker(clientMoniker); - if (client == null) { - throw new InvalidShortIdException(); - } - JSONObject update = new JSONObject(); - int clientId = client.getIntValue("client_id"); - update.put("client_id", clientId); - update.put("new_contract", new_contract); - clientMapper.update(update); - clientInfoCacheSupport.clearClientCache(clientId); - } - @Override public void enableGatewayUpgrade(String clientMoniker, boolean gatewayUpgrade) { JSONObject client = getClientInfoByMoniker(clientMoniker); @@ -3257,45 +3242,60 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid public JSONObject getCheckClientInfo(int client_id, String account_id) { JSONObject result = clientContractService.getClientContractExpire(client_id); JSONObject account = clientAccountMapper.findById(account_id); - boolean expire = result.getBoolean("rate_expire"); - boolean waring = result.getBoolean("rate_waring"); - boolean old_contract = result.getBoolean("old_contract"); if (PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) { - result.put("is_ordinary", true); - if (!expire && waring) { - String[] key = { result.getString("expire_days") }; - result.put("contract_info", - editContractOrdinaryWaring(key, messageSource.getMessage("sys.contract.ordinary.waring", null, RequestEnvironment.getLocale()))); - } - if (expire) { - result.put("contract_info", messageSource.getMessage("sys.contract.ordinary.info", null, RequestEnvironment.getLocale())); - } - if (old_contract) { - result.put("contract_info", messageSource.getMessage("contract.old.waring", null, RequestEnvironment.getLocale())); - } + result.put("alert", false); } else { - result.put("is_ordinary", false); - if (!expire && waring) { - String[] key = { result.getString("expire_days") }; - result.put("contract_info", - editContractOrdinaryWaring(key, messageSource.getMessage("sys.contract.waring", null, RequestEnvironment.getLocale()))); - } - if (expire) { - result.put("contract_info", messageSource.getMessage("sys.contract.info", null, RequestEnvironment.getLocale())); + if(result.getBoolean("alert")){ + 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("title","【Important!重要!!】GST Modification Notice | 澳洲监管机构关于手续费GST调整问题通知\n"); } - if (old_contract) { - result.put("contract_info", messageSource.getMessage("contract.old.waring", null, RequestEnvironment.getLocale())); - } - - } - JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id"), "pc"); - if (file != null) { - result.put("file_url", file.getString("file_value")); - } else { - result.put("file_url", ""); } return result; - } private String editContractOrdinaryWaring(String[] key, String sourceStr) { 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 6f0318847..5d084d848 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 @@ -534,9 +534,4 @@ public class PartnerManageController { clientContractService.confirmSourceAgreement(account.getIntValue("client_id"),account.getString("account_id"),"PC"); } - @ManagerMapping(value = "/{clientMoniker}/new_contract", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) - public void skipContract(@PathVariable String clientMoniker, @RequestBody JSONObject new_contract) { - clientManager.setSkipContract(clientMoniker, new_contract.getBooleanValue("new_contract")); - } - } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java b/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java index 902ef5e0f..2c9ae2f47 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java @@ -2,17 +2,20 @@ package au.com.royalpay.payment.manage.system.core; import com.alibaba.fastjson.JSONObject; +import java.util.Date; import java.util.List; public interface ClientContractService { - JSONObject getOrGenerateSourceAgreement(int client_id,String channel); + JSONObject getOrGenerateSourceAgreement(int client_id, String channel); - void confirmSourceAgreement(int client_id,String account_id,String channel); + void confirmSourceAgreement(int client_id, String account_id, String channel); JSONObject getSourceAgreement(int client_id); JSONObject getClientContractExpire(int client_id); + void saveContract(int client_id, Date expire_date, String channel); + List list(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java index 4a5c3b07f..1b883f1b1 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java @@ -2,12 +2,10 @@ package au.com.royalpay.payment.manage.system.core.impl; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.system.core.ClientContractService; import au.com.royalpay.payment.tools.env.SysConfigManager; -import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; @@ -21,9 +19,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.annotation.Resource; @@ -38,8 +34,6 @@ public class ClientContractServiceImpl implements ClientContractService { @Resource private ClientsContractMapper clientsContractMapper; @Resource - private ClientRateMapper clientRateMapper; - @Resource private SysConfigManager sysConfigManager; @Resource private ClientAccountMapper clientAccountMapper; @@ -51,40 +45,22 @@ public class ClientContractServiceImpl implements ClientContractService { if (client == null) { throw new NotFoundException("merchant not found"); } - JSONObject expireInfo = getClientContractExpire(client_id); - JSONObject contract = clientsContractMapper.findByClientId(client_id); - Date now = new Date(); - if ((expireInfo.getBoolean("rate_waring") || expireInfo.getBoolean("old_contract")) - && (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0)) { - try { - clientManager.getNewAggregateAgreeFile(client.getString("client_moniker"), null, true); - } catch (Exception e) { - logger.info("App generate PDF failed"); - throw new ServerErrorException("System error"); - } - List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); - saveContract(client_id, now, channel); - return files.get(0); - } else { - List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); - if (!CollectionUtils.isEmpty(files)) { - JSONObject file = files.get(0); - if (expireInfo.getBoolean("rate_expire")) { - contract.put("create_time", now); - contract.put("expiry_date", DateUtils.addYears(now, 1)); - clientsContractMapper.update(contract); - } - return file; - } - return null; + try { + clientManager.getNewAggregateAgreeFile(client.getString("client_moniker"), null, true); + } catch (Exception e) { + logger.info("App generate PDF failed"); + throw new ServerErrorException("System error"); } + List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); + return files.get(0); } - private void saveContract(int client_id, Date now, String channel) { + @Override + public void saveContract(int client_id, Date expire_date, String channel) { JSONObject newContract = new JSONObject(); - newContract.put("create_time", now); - newContract.put("expiry_date", DateUtils.addYears(now, 1)); + newContract.put("create_time", new Date()); + newContract.put("expiry_date", DateUtils.addYears(expire_date, 1)); newContract.put("sign_channel", channel); newContract.put("client_id", client_id); newContract.put("has_sign", false); @@ -98,40 +74,20 @@ public class ClientContractServiceImpl implements ClientContractService { if (client == null) { throw new NotFoundException("merchant not found"); } -// JSONObject rateExpire = getClientContractExpire(client_id); -// boolean expire = rateExpire.getBoolean("rate_expire"); -// boolean waring = rateExpire.getBoolean("rate_waring"); -// boolean old_contract = rateExpire.getBoolean("old_contract"); JSONObject contract = clientsContractMapper.findByClientId(client_id); - if (contract == null) { - throw new BadRequestException("generate contract first"); - } - if (contract.getBoolean("has_sign")) { + if (contract != null && contract.getBoolean("has_sign")) { return; } Date now = new Date(); JSONObject account = clientAccountMapper.findById(account_id); - contract.put("has_sign", 1); contract.put("sign_account_id", account_id); contract.put("sign_channel", channel); contract.put("confirm_time", now); contract.put("signatory", account.getString("display_name")); clientsContractMapper.update(contract); - List rateInfo = clientRateMapper.minExpiryTime(client_id, null); - rateInfo.forEach((p) -> { - p.remove("client_rate_id"); - p.put("create_time", now); - p.put("active_time", now); - p.put("update_time", now); - p.put("manager_id", "0"); - p.put("expiry_time", DateUtils.addYears(now, 1)); - p.put("manager_name", "merchant_" + account_id + "_" + account.getString("display_name")); - clientRateMapper.saveRate(p); - }); + getOrGenerateSourceAgreement(client_id, channel); clientManager.setClientTaxInSurcharge(client.getString("client_moniker"), false); - clientManager.setSkipContract(client.getString("client_moniker"), true); - } @Override @@ -150,74 +106,24 @@ public class ClientContractServiceImpl implements ClientContractService { throw new NotFoundException("merchant not found please check ID"); } JSONObject sysconfig = sysConfigManager.getSysConfig(); - JSONObject defaultResult = new JSONObject(); - defaultResult.put("rate_expire", false); - defaultResult.put("rate_waring", false); - defaultResult.put("old_contract", false); - if (sysconfig != null && !sysconfig.getBoolean("sys_new_contract_on")) { - return defaultResult; - } - if(client.getBooleanValue("new_contract")){ - return defaultResult; - } - - List rateInfo = clientRateMapper.minExpiryTime(client_id, null); JSONObject result = new JSONObject(); - if (CollectionUtils.isEmpty(rateInfo)) { - result.put("rate_expire", true); - result.put("rate_waring", true); - return result; - } - result.put("rate_expire", false); - result.put("rate_waring", false); - result.put("old_contract", false); - Date now = new Date(); - JSONObject contract = clientsContractMapper.findByClientId(client_id); - if (contract != null && contract.getDate("expiry_date").compareTo(now) > 0 && contract.getBoolean("has_sign")) { + result.put("alert", false); + if (sysconfig != null && !sysconfig.getBoolean("sys_new_contract_on")) { return result; } - int waringDays = sysconfig.getIntValue("rate_warning_days"); - Map filterMap = new HashMap<>(); - rateInfo.forEach((p) -> { - String key = p.getString("rate_name"); - JSONObject tmp = filterMap.get(key); - if (tmp == null) { - filterMap.put(key, p); - } else { - if (tmp.getDate("expiry_time").compareTo(p.getDate("expiry_time")) < 0) { - filterMap.put(key, p); - } - } - }); - - for (JSONObject p : filterMap.values()) { - if (now.compareTo(DateUtils.addDays(p.getDate("expiry_time"), 1)) > -1) { - result.put("rate_expire", true); - } - if (DateUtils.addDays(now, waringDays).compareTo(DateUtils.addDays(p.getDate("expiry_time"), 1)) > -1) { - int expireDay = 0; - long expireSS = (DateUtils.addDays(p.getDate("expiry_time"), 1).getTime() - now.getTime()); - expireDay = (int) expireSS / (1000 * 60 * 60 * 24); - if (expireSS % (1000 * 60 * 60 * 24) > 1) { - ++expireDay; + List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); + if (!CollectionUtils.isEmpty(files)) { + JSONObject file = files.get(0); + if (sysconfig.getDate("sys_new_contract_time").compareTo(file.getDate("last_update_date")) > 0) { + JSONObject contract = clientsContractMapper.findByClientId(client_id); + if (contract == null) { + saveContract(client_id, new Date(), null); } - result.put("expire_days", expireDay); - result.put("rate_waring", true); } } - if (!result.getBoolean("rate_waring") && !result.getBoolean("rate_expire")) { - List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); - if (CollectionUtils.isEmpty(files)) { - result.put("old_contract", true); - result.put("rate_waring", true); - } else { - JSONObject file = files.get(0); - if (sysconfig.getDate("sys_new_contract_time").compareTo(file.getDate("last_update_date")) > 0 - || (contract != null && !contract.getBoolean("has_sign"))) { - result.put("old_contract", true); - result.put("rate_waring", true); - } - } + if (client.getBooleanValue("tax_in_surcharge")) { + result.put("alert", true); + return result; } return result; } diff --git a/src/main/ui/static/payment/partner/partner-manage.js b/src/main/ui/static/payment/partner/partner-manage.js index 6a086a6e7..8ea63b82d 100644 --- a/src/main/ui/static/payment/partner/partner-manage.js +++ b/src/main/ui/static/payment/partner/partner-manage.js @@ -2352,12 +2352,6 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter return url; }; - $scope.setSkipContract = function () { - $http.put('/sys/partners/' + $scope.partner.client_moniker + '/new_contract',{new_contract: $scope.partner.new_contract}).then(function(){ - - }) - }; - $scope.updateFile = function () { $http.put('/sys/partners/' + $scope.partner.client_moniker + '/file', $scope.file).then(function () { commonDialog.alert({ diff --git a/src/main/ui/static/payment/partner/templates/partner_auth_files.html b/src/main/ui/static/payment/partner/templates/partner_auth_files.html index 86340d584..b2e069690 100644 --- a/src/main/ui/static/payment/partner/templates/partner_auth_files.html +++ b/src/main/ui/static/payment/partner/templates/partner_auth_files.html @@ -3,18 +3,6 @@ width: 100%; } -
-
Contract
-
- - -
- -
-
- -
Audit Files