From 392e1814e5e08e442331209d7420434e28a467ad Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Wed, 7 Mar 2018 14:35:22 +0800 Subject: [PATCH 01/30] fix --- src/main/ui/static/boot/indexMainApp.js | 27 ++++++++++++++++++- .../static/commons/templates/ag_detail.html | 19 +++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/main/ui/static/commons/templates/ag_detail.html diff --git a/src/main/ui/static/boot/indexMainApp.js b/src/main/ui/static/boot/indexMainApp.js index c2eeff92d..336d4c84a 100644 --- a/src/main/ui/static/boot/indexMainApp.js +++ b/src/main/ui/static/boot/indexMainApp.js @@ -107,13 +107,28 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo $scope.loadPartnerNotice(); }) }; + $scope.showAG = function (ag) { + $uibModal.open({ + templateUrl: '/static/commons/templates/ag_detail.html', + controller: 'agreementDetailCtrl', + resolve: { + ag: ag + }, + size: 'lg', + backdrop:'static', + keyboard:false + }).result.then(function () { + $scope.loadPartnerNotice(); + }) + }; + //$scope.showAG(); $scope.refundNotice = {counts: 0}; $scope.openRefundNotice = false; $scope.showRefundNotice = function () { $http.get('/api/payment/v1.0/refund/json/auditions').then(function (resp) { $scope.refundNotice.counts = resp.data.counts; }); - } + }; $scope.showRefundNotice(); $scope.toggleOpenRefundNotice = function () { var openRefundNotice = angular.copy($scope.openRefundNotice); @@ -276,6 +291,16 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo } }]); + app.controller('agreementDetailCtrl', ['$scope', '$http', '$sce', 'ag', function ($scope, $http, $sce, ag) { + $scope.agreeCheck = false; + $scope.agree = function () { + $scope.$close(); + }; + $scope.notAgree = function () { + window.location.href = "https://mpay.royalpay.com.au"; + } + }]); + app.controller('changePwdCtrl', ['$scope', '$http', function ($scope, $http) { $scope.formData = {}; $scope.submit = function (form) { diff --git a/src/main/ui/static/commons/templates/ag_detail.html b/src/main/ui/static/commons/templates/ag_detail.html new file mode 100644 index 000000000..9ad31f4ee --- /dev/null +++ b/src/main/ui/static/commons/templates/ag_detail.html @@ -0,0 +1,19 @@ + + + \ No newline at end of file From 115e2ffbee7a03e0b26d78173e108f54695bbf37 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Wed, 7 Mar 2018 17:07:54 +0800 Subject: [PATCH 02/30] contract --- .../appclient/core/RetailAppService.java | 2 + .../core/impls/RetailAppServiceImp.java | 50 ++++-- .../appclient/web/RetailAppController.java | 136 ++++++++------- .../manage/apps/core/AppFileService.java | 10 ++ .../apps/core/impls/AppFileServiceImpl.java | 75 +++++++++ .../mappers/system/ClientFilesMapper.java | 6 +- .../mappers/system/ClientRateMapper.java | 2 + .../mappers/system/ClientsContractMapper.java | 26 +++ .../manage/merchants/core/ClientManager.java | 14 +- .../core/impls/ClientManagerImpl.java | 155 +++++++++++------- .../web/PartnerManageController.java | 29 +++- .../mappers/system/ClientFilesMapper.xml | 16 ++ .../mappers/system/ClientRateMapper.xml | 10 ++ .../mappers/system/ClientsContractMapper.xml | 10 ++ 14 files changed, 405 insertions(+), 136 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientFilesMapper.xml create mode 100644 src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index ac99a87ba..e60b3dd93 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -109,4 +109,6 @@ public interface RetailAppService { JSONObject getAd(JSONObject device); JSONObject getAdDetail(JSONObject device, String article_id); + + JSONObject getClientRateExpire(int client_id); } 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 dd24c77db..8cf9af7f6 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 @@ -16,6 +16,7 @@ import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; import au.com.royalpay.payment.manage.mappers.system.ClientSettleDelayConfMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper; @@ -38,6 +39,7 @@ import au.com.royalpay.payment.tools.device.support.DeviceRegister; import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; +import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; @@ -62,6 +64,7 @@ import org.slf4j.LoggerFactory; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.text.DateFormat; @@ -136,6 +139,8 @@ public class RetailAppServiceImp implements RetailAppService { private ClientDeviceTokenMapper clientDeviceTokenMapper; @Resource private JpushMessageHelper jpushMessageHelper; + @Resource + private ClientRateMapper clientRateMapper; private Map senderMap = new HashMap<>(); @@ -175,8 +180,8 @@ public class RetailAppServiceImp implements RetailAppService { setAllClientIds(params, client_id); params.put("client_id", client_id); JSONObject res = transactionAnalysisMapper.getClientTransaction(params); -// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); -// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); + // res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); + // res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); // res.put("refund_amount", transactionAnalysisMapper.analysisRefundAmount(params)); res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); res.put("old_customers", transactionAnalysisMapper.countOldCustomers(params)); @@ -202,8 +207,8 @@ public class RetailAppServiceImp implements RetailAppService { params.put("client_id", client_id); JSONObject res = transactionAnalysisMapper.getClientTransaction(params); -// res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); -// res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); + // res.put("trade_amount", transactionAnalysisMapper.analysisTotalAmount(params)); + // res.put("trade_count", transactionAnalysisMapper.analysisTotalCount(params)); res.put("not_settled", transactionAnalysisMapper.analysisNotSettled(params)); return res; } @@ -629,7 +634,7 @@ public class RetailAppServiceImp implements RetailAppService { public void sendNoticeMessage(final NoticeInfo notice, final String[] client_monikers) { for (String clientMoniker : client_monikers) { JSONObject client = clientManager.getClientInfoByMoniker(clientMoniker); - if(client==null){ + if (client == null) { continue; } sendingAppleMsgPool.execute(() -> { @@ -1035,12 +1040,12 @@ public class RetailAppServiceImp implements RetailAppService { Boolean isUpdate = PlatformEnvironment.getEnv().isAppUpdate(clientType); String updateContent = PlatformEnvironment.getEnv().getAppUpdateContent(clientType); int update_type = 0;// 0:不更新 1:更新 2:强制更新 - String versionInt = version.replace(".",""); - String newAppVersionInt = newAppVersion.replace(".",""); - if (Integer.valueOf(versionInt) rateInfo = clientRateMapper.minExpiryTime(client_id, null); + JSONObject result = new JSONObject(); + result.put("rate_expire", false); + result.put("rate_waring", false); + if (CollectionUtils.isEmpty(rateInfo)) { + return result; + } + Date now = new Date(); + rateInfo.forEach((p)->{ + if (now.compareTo(p.getDate("expiry_time")) > -1) { + result.put("rate_expire", true); + } + if (DateUtils.addDays(now, 10).compareTo(p.getDate("expiry_time")) > -1) { + result.put("rate_waring", true); + } + }); + return result; + } + private static boolean mathchLetterorNum(String str) { String regex = "[A-Za-z0-9]{8}"; return str.matches(regex); 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 368ed4069..c67a61bfe 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 @@ -1,9 +1,28 @@ package au.com.royalpay.payment.manage.appclient.web; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +import javax.annotation.Resource; +import javax.validation.Valid; + +import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; +import au.com.royalpay.payment.manage.apps.core.AppFileService; import au.com.royalpay.payment.manage.bill.bean.NewBillBean; import au.com.royalpay.payment.manage.bill.bean.QueryBillBean; import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean; @@ -16,28 +35,10 @@ import au.com.royalpay.payment.tools.device.advise.AppClientController; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.http.HttpUtils; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - -import org.springframework.validation.Errors; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import javax.annotation.Resource; -import javax.validation.Valid; - /** * Created by yishuqian on 28/03/2017. */ -@AppClientController + @AppClientController @RequestMapping("/api/v1.0/retail/app") public class RetailAppController { @Resource @@ -48,6 +49,8 @@ public class RetailAppController { private BillOrderService billOrderService; @Resource private BillService billService; + @Resource + private AppFileService appFileService; @RequestMapping(value = "/token", method = RequestMethod.PUT) public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) { @@ -59,7 +62,6 @@ public class RetailAppController { return retailAppService.listSubClients(device); } - @RequestMapping(value = "/common", method = RequestMethod.GET) public JSONObject getTransactionCommonData(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, AppQueryBean appQueryBean) { return retailAppService.getTransactionCommonData(device, appQueryBean); @@ -102,20 +104,21 @@ public class RetailAppController { return retailAppService.getClientSettlementLog(device, appQueryBean); } - @RequestMapping("/transaction_log/{clearing_detail_id}") - public JSONObject getTransactionLogByClearingDetailId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable int clearing_detail_id, @RequestParam(required = false) String timezone) { + public JSONObject getTransactionLogByClearingDetailId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable int clearing_detail_id, + @RequestParam(required = false) String timezone) { return retailAppService.getTransactionLogsByClearingDetailId(device, clearing_detail_id, timezone); } - /*消息模块begin*/ + /* 消息模块begin */ @RequestMapping(value = "/notice", method = RequestMethod.GET) public JSONObject listNotices(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam Map params) { return retailAppService.listNotices(device, (JSONObject) JSON.toJSON(params)); } @RequestMapping(value = "/notice/{noticeId}", method = RequestMethod.PUT) - public void updateNoticePartnerHasRead(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId, @RequestBody JSONObject account_param) { + public void updateNoticePartnerHasRead(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId, + @RequestBody JSONObject account_param) { if (!device.getString("account_id").equals(account_param.getString("account_id"))) { throw new ForbiddenException("You have no permission"); } @@ -126,12 +129,12 @@ public class RetailAppController { public JSONObject getNoticeId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId) { return retailAppService.getNoticeDetailById(device, noticeId); } - /*消息模块end*/ - + /* 消息模块end */ - /*我的页面begin*/ + /* 我的页面begin */ @RequestMapping(value = "/partner_password/{account_id}", method = RequestMethod.PUT) - public void changePassword(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String account_id, @RequestBody @Valid ChangePwdBean change, Errors errors) { + public void changePassword(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String account_id, + @RequestBody @Valid ChangePwdBean change, Errors errors) { HttpUtils.handleValidErrors(errors); retailAppService.changeAccountPassword(device, change, account_id); } @@ -155,12 +158,12 @@ public class RetailAppController { public void signOut(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { retailAppService.sign_out(device); } - /*我的页面end*/ + /* 我的页面end */ - /*活动页面 begin*/ + /* 活动页面 begin */ @RequestMapping(value = "/activities", method = RequestMethod.GET) public JSONObject getActivities(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(defaultValue = "activity_page") String type, - @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) { + @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) { return retailAppService.getActivities(device, type, page, limit); } @@ -174,7 +177,7 @@ public class RetailAppController { return retailAppService.checkT1Client(device); } - /*活动页面 end*/ + /* 活动页面 end */ /** * 获取最新版本 @@ -191,17 +194,19 @@ public class RetailAppController { public JSONObject getClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { return retailAppService.getClientInfo(device); } + @RequestMapping(value = "/client/check", method = RequestMethod.GET) + public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + return retailAppService.getClientRateExpire(device.getIntValue("client_id")); + } @RequestMapping(value = "/client", method = RequestMethod.PUT) public void updateClient(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody AppClientBean appClientBean) { retailAppService.updateClient(device, appClientBean); } - @RequestMapping(value = "/daily_transactions/date/{dateStr}", method = RequestMethod.GET) public JSONObject listDailyTransactions(@PathVariable String dateStr, @RequestParam(defaultValue = "Australia/Melbourne") String timezone, - @RequestParam(defaultValue = "false") boolean thisdevice, - @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + @RequestParam(defaultValue = "false") boolean thisdevice, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { return retailAppService.listDailyTransactions(dateStr, timezone, thisdevice, device); } @@ -251,7 +256,8 @@ public class RetailAppController { } @RequestMapping(value = "/cash_back/clean_info", method = RequestMethod.GET) - public JSONObject getCashbackCleanInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "client_id", required = false) String client_id) { + public JSONObject getCashbackCleanInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, + @RequestParam(value = "client_id", required = false) String client_id) { if (client_id == null) { client_id = device.getString("client_id"); } @@ -263,11 +269,11 @@ public class RetailAppController { signInStatusManager.clientQRCodeAppSignIn(device, codeId); } - - /*优惠券Begin*/ + /* 优惠券Begin */ @RequestMapping(value = "/coupon/used", method = RequestMethod.GET) - public JSONObject getCoupons(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int limit) { + public JSONObject getCoupons(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "page", defaultValue = "1") int page, + @RequestParam(value = "limit", defaultValue = "10") int limit) { return retailAppService.getCoupons(device, page, limit); } @@ -280,8 +286,7 @@ public class RetailAppController { public void useCoupon(@PathVariable String coupon_log_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { retailAppService.useCoupon(device, coupon_log_id); } - /*优惠券End*/ - + /* 优惠券End */ /** * 广告位 @@ -296,30 +301,43 @@ public class RetailAppController { return retailAppService.getAdDetail(device, article_id); } - - - @RequestMapping(value = "/bills/{bill_id}",method = RequestMethod.GET) - public JSONObject getBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ - return billService.getBillDetail(bill_id,device.getIntValue("client_id")); + @RequestMapping(value = "/bills/{bill_id}", method = RequestMethod.GET) + public JSONObject getBill(@PathVariable("bill_id") String bill_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + return billService.getBillDetail(bill_id, device.getIntValue("client_id")); } - @RequestMapping(value = "/bills/list",method = RequestMethod.GET) - public JSONObject getBills(QueryBillBean queryBillBean,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ - return billService.queryBills(device.getIntValue("client_id"),queryBillBean); + + @RequestMapping(value = "/bills/list", method = RequestMethod.GET) + public JSONObject getBills(QueryBillBean queryBillBean, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + return billService.queryBills(device.getIntValue("client_id"), queryBillBean); } - @RequestMapping(value = "/bills",method = RequestMethod.PUT) - public JSONObject addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@RequestBody NewBillBean newBillBean){ - JSONObject result = billService.save(device.getIntValue("client_id"),newBillBean); + + @RequestMapping(value = "/bills", method = RequestMethod.PUT) + public JSONObject addBill(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody NewBillBean newBillBean) { + JSONObject result = billService.save(device.getIntValue("client_id"), newBillBean); result.remove("bill"); return result; } - @RequestMapping(value = "/bills/{bill_id}/close",method = RequestMethod.POST) - public void closeBill(@PathVariable("bill_id")String bill_id,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ - billService.updateBillStatus(bill_id,"2",device.getIntValue("client_id")); + + @RequestMapping(value = "/bills/{bill_id}/close", method = RequestMethod.POST) + public void closeBill(@PathVariable("bill_id") String bill_id, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + billService.updateBillStatus(bill_id, "2", device.getIntValue("client_id")); } - @RequestMapping(value = "/bills/orders/{bill_id}",method = RequestMethod.GET) - public JSONObject getBillOrders(@PathVariable("bill_id")String bill_id, QueryBillOrderBean queryBillOrderBean,@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ - JSONObject result =billOrderService.query(bill_id,device.getIntValue("client_id"),queryBillOrderBean); - result.put("analysis",billOrderService.analysis(bill_id,device.getIntValue("client_id"),queryBillOrderBean)); + + @RequestMapping(value = "/bills/orders/{bill_id}", method = RequestMethod.GET) + public JSONObject getBillOrders(@PathVariable("bill_id") String bill_id, QueryBillOrderBean queryBillOrderBean, + @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + JSONObject result = billOrderService.query(bill_id, device.getIntValue("client_id"), queryBillOrderBean); + result.put("analysis", billOrderService.analysis(bill_id, device.getIntValue("client_id"), queryBillOrderBean)); return result; } + + @RequestMapping(value = "/file/agree", method = RequestMethod.PUT) + public JSONObject generateSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + return appFileService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); + } + + @RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST) + public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + appFileService.confirmSourceAgreement(device.getIntValue("client_id")); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java new file mode 100644 index 000000000..8b3da4594 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java @@ -0,0 +1,10 @@ +package au.com.royalpay.payment.manage.apps.core; + +import com.alibaba.fastjson.JSONObject; + +public interface AppFileService { + + JSONObject getOrGenerateSourceAgreement(int client_id); + + void confirmSourceAgreement(int client_id); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java new file mode 100644 index 000000000..b893f6b72 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java @@ -0,0 +1,75 @@ +package au.com.royalpay.payment.manage.apps.core.impls; + +import au.com.royalpay.payment.manage.apps.core.AppFileService; +import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; +import au.com.royalpay.payment.manage.merchants.core.ClientManager; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; + +import com.alibaba.fastjson.JSONObject; + +import org.apache.commons.lang3.time.DateUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +@Service +public class AppFileServiceImpl implements AppFileService { + + Logger logger = LoggerFactory.getLogger(AppFileServiceImpl.class); + @Resource + private ClientFilesMapper clientFilesMapper; + @Resource + private ClientManager clientManager; + @Resource + private ClientsContractMapper clientsContractMapper; + + @Override + @Transactional + public JSONObject getOrGenerateSourceAgreement(int client_id) { + JSONObject client = clientManager.getClientInfo(client_id); + JSONObject contract = clientsContractMapper.findByClientId(client_id); + List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); + Date now = new Date(); + if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) { + try { + clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null); + } catch (Exception e) { + logger.info("App generate PDF failed"); + } + files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); + saveContract(client_id, now); + return files.get(0); + } else { + return files.get(0); + } + + } + + private void saveContract(int client_id, Date now) { + JSONObject newContract = new JSONObject(); + newContract.put("create_time", now); + newContract.put("expiry_date", DateUtils.addYears(now, 1)); + newContract.put("sign_channel", "App"); + newContract.put("client_id", client_id); + newContract.put("has_sign", false); + clientsContractMapper.save(newContract); + } + + @Override + public void confirmSourceAgreement(int client_id) { + JSONObject file = clientsContractMapper.findByClientId(client_id); + if (file == null) { + throw new BadRequestException("generate contract first"); + } + file.put("has_sign", 1); + clientsContractMapper.update(file); + } + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientFilesMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientFilesMapper.java index f79d2dfed..bf626bc3b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientFilesMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientFilesMapper.java @@ -25,6 +25,8 @@ public interface ClientFilesMapper { @AutoSql(type = SqlType.SELECT) JSONObject findFileById(@Param("file_id") String file_id); - @AutoSql(type = SqlType.SELECT) - JSONObject findFileByClientAndType(@Param("client_id") int client_id, @Param("file_name") String file_name); + List findFileByClientAndType(@Param("client_id") int client_id, @Param("file_name") String file_name); + + void confirmAgreeFile(@Param("client_id") int client_id); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.java index 0f3021bf5..321fd8a37 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.java @@ -36,4 +36,6 @@ public interface ClientRateMapper { List listClientRatesForSaving(@Param("client_id") int clientId, @Param("active_time") Date activeTime, @Param("expiry_time") Date expiryTime, @Param("rate_value") Double rateValue, @Param("clean_days") Integer cleanDays, @Param("rate_name") String rateName); + + List minExpiryTime(@Param("client_id")int client_id,@Param("rate_name") String rate_name); } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java new file mode 100644 index 000000000..043079965 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java @@ -0,0 +1,26 @@ +package au.com.royalpay.payment.manage.mappers.system; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.alibaba.fastjson.JSONObject; + +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; + +/** + * Created by yishuqian on 06/03/2017. + */ +@AutoMapper(tablename = "sys_clients_contract", pkName = "id") +public interface ClientsContractMapper { + @AutoSql(type = SqlType.INSERT) + void save(JSONObject partner); + + @AutoSql(type = SqlType.UPDATE) + void update(JSONObject partner); + + JSONObject findByClientId(@Param("client_id") int clientId); + +} 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 cc679bfbb..5c05476b4 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 @@ -1,24 +1,32 @@ package au.com.royalpay.payment.manage.merchants.core; -import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo; import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; -import au.com.royalpay.payment.manage.merchants.beans.*; +import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; +import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; +import au.com.royalpay.payment.manage.merchants.beans.ClientRateConfig; +import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo; +import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; +import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; +import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; + import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; + import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; import java.math.BigDecimal; import java.util.List; +import javax.servlet.http.HttpServletResponse; + /** * Created by yixian on 2016-06-25. */ 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 0a314423a..2b796fcb6 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 @@ -14,8 +14,28 @@ import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper; -import au.com.royalpay.payment.manage.mappers.system.*; -import au.com.royalpay.payment.manage.merchants.beans.*; +import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; +import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper; +import au.com.royalpay.payment.manage.mappers.system.ManagerMapper; +import au.com.royalpay.payment.manage.mappers.system.OrgMapper; +import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper; +import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder; +import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; +import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; +import au.com.royalpay.payment.manage.merchants.beans.ClientRateConfig; +import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo; +import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; +import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; +import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply; import au.com.royalpay.payment.manage.merchants.core.ClientComplyValidator; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.notice.core.MailService; @@ -43,16 +63,21 @@ import au.com.royalpay.payment.tools.merchants.qrboard.QRBoard; import au.com.royalpay.payment.tools.merchants.qrboard.QRBoardProvider; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.PartnerRole; -import au.com.royalpay.payment.tools.utils.*; +import au.com.royalpay.payment.tools.utils.ImageUtils; +import au.com.royalpay.payment.tools.utils.PageListUtils; +import au.com.royalpay.payment.tools.utils.PasswordUtils; +import au.com.royalpay.payment.tools.utils.PdfUtils; +import au.com.royalpay.payment.tools.utils.QRCodeUtils; +import au.com.royalpay.payment.tools.utils.TimeZoneUtils; import au.com.royalpay.payment.tools.websocket.notify.PartnerPageEvent; -import cn.yixblog.platform.http.HttpRequestGenerator; -import cn.yixblog.platform.http.HttpRequestResult; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; + import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; @@ -71,27 +96,40 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.RequestMethod; import org.thymeleaf.context.Context; import org.thymeleaf.spring4.SpringTemplateEngine; -import javax.annotation.Resource; -import javax.imageio.ImageIO; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; import java.awt.*; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.math.BigDecimal; import java.net.URISyntaxException; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; import java.util.List; +import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import javax.annotation.Resource; +import javax.imageio.ImageIO; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; + +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; + import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission; /** @@ -168,6 +206,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private FinancialBDConfigMapper financialBDConfigMapper; + @Resource + private ClientsContractMapper clientsContractMapper; + private static final String SOURCE_AGREE_FILE = "source_agree_file"; private static final String CLIENT_BANK_FILE = "client_bank_file"; private static final String CLIENT_ID_FILE = "client_id_file"; @@ -1848,37 +1889,23 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("company_name_acn", client.getString("company_name") + " (ABN " + client.getString("abn") + ")"); } - JSONObject weChatRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Wechat"); - if (weChatRate == null) { - throw new BadRequestException("The Partner's Rate is not config!"); - } - client.put("wechat_rate", weChatRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); - client.put("clean", "T+" + weChatRate.getString("clean_days")); - client.put("clean_days", weChatRate.getString("clean_days")); - - try { - JSONObject alipayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Alipay"); - if (alipayRate != null) { - client.put("alipay_rate", alipayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); - } - - JSONObject bestPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "Bestpay"); - if (bestPayRate != null) { - client.put("bestpay_rate", bestPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); - } - - JSONObject jdRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "jd"); - if (jdRate != null) { - client.put("jd_rate", jdRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); - } - - JSONObject alipayOnlineRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "AlipayOnline"); - if (alipayOnlineRate != null) { - client.put("alipay_online_rate", alipayOnlineRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); - } - } catch (Exception ignored) { - // do nothing - } + List clientRate = clientRateMapper.minExpiryTime(client.getIntValue("client_id"),null); + clientRate.forEach((p)->{ + String rate_name = p.getString("rate_name"); + if("Wechat".equals(rate_name)){ + client.put("wechat_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + client.put("clean", "T+" + p.getString("clean_days")); + 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("Bestpay".equals(rate_name)){ + client.put("bestpay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + }else if("jd".equals(rate_name)){ + client.put("jd_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + }else if("AlipayOnline".equals(rate_name)){ + client.put("alipay_online_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + } + }); JSONObject account = getBankAccountByClientId(client.getIntValue("client_id")); if (account == null || account.size() <= 0) { @@ -1897,7 +1924,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid File file = new File(clientMoniker + "_agreement.pdf"); ByteArrayOutputStream bos = pdu.templetPdfBos(file); InputStream stream = new ByteArrayInputStream(bos.toByteArray()); - JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker + "_agreement.pdf", false); + JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker +"_"+System.currentTimeMillis()+ "_agreement.pdf", false); if (fileRes != null) { importAgreeFile(clientMoniker, manager, fileRes.getString("url")); } @@ -1991,15 +2018,24 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new InvalidShortIdException(); } if (sourceFile != null) { - JSONObject existFile = clientFilesMapper.findFileByClientAndType(client.getIntValue("client_id"), SOURCE_AGREE_FILE); - + List existFiles = clientFilesMapper.findFileByClientAndType(client.getIntValue("client_id"), SOURCE_AGREE_FILE); + JSONObject existFile = null; + if (!CollectionUtils.isEmpty(existFiles)) { + existFile = existFiles.get(0); + } + Date now = new Date(); JSONObject file = new JSONObject(); file.put("file_name", SOURCE_AGREE_FILE); file.put("file_value", sourceFile); file.put("client_id", client.getIntValue("client_id")); - file.put("last_update_date", new Date()); - file.put("last_update_by", manager.getString("display_name")); - if (existFile == null || existFile.isEmpty()) { + file.put("last_update_date", now); + if(manager == null){ + file.put("last_update_by", "System Import"); + }else { + 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||existFile == null || existFile.isEmpty()) { clientFilesMapper.save(file); } else { file.put("file_id", existFile.getString("file_id")); @@ -2007,7 +2043,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } client.put("open_status", 2); clientMapper.update(client); - saveClientAuditProcess(client.getIntValue("client_id"), 1, 2, "Compliance合同制作中", manager); + + if (manager != null) { + saveClientAuditProcess(client.getIntValue("client_id"), 1, 2, "Compliance合同制作中", manager); + } } } @@ -2017,8 +2056,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - JSONObject existFiles = clientFilesMapper.findFileByClientAndType(client.getIntValue("client_id"), SOURCE_AGREE_FILE); - if (existFiles == null || existFiles.isEmpty()) { + List existFiles = clientFilesMapper.findFileByClientAndType(client.getIntValue("client_id"), SOURCE_AGREE_FILE); + if (CollectionUtils.isEmpty(existFiles)) { throw new BadRequestException("The Agree File is not Complete!"); } client.put("open_status", 3); @@ -2077,7 +2116,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } checkOrgPermission(manager, client); if (StringUtils.isNotBlank(master_merchant)) { - //throw new NotFoundException("Invalid Input"); + // throw new NotFoundException("Invalid Input"); JSONObject master_client = getClientInfoByMoniker(master_merchant); if (master_client == null) { throw new InvalidShortIdException(); @@ -2296,7 +2335,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid public void updateSysClientFiles(JSONObject manager, int clientId, String fileType, String fileValue) { if (fileValue != null) { - JSONObject existFile = clientFilesMapper.findFileByClientAndType(clientId, fileType); + + List existFiles = clientFilesMapper.findFileByClientAndType(clientId, fileType); + JSONObject existFile = null; + if (!CollectionUtils.isEmpty(existFiles)) { + existFile = existFiles.get(0); + } JSONObject fileJson = new JSONObject(); fileJson.put("client_id", clientId); fileJson.put("last_update_date", new Date()); @@ -2825,7 +2869,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"); @@ -2984,7 +3028,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new InvalidShortIdException(); } checkOrgPermission(manager, client); - List applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"), new PageBounds(Order.formString("create_time.desc"))); + List applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"), + new PageBounds(Order.formString("create_time.desc"))); if (!applices.isEmpty()) { return applices; } else { 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 3bb6f6056..16f88fd5d 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 @@ -1,27 +1,42 @@ package au.com.royalpay.payment.manage.merchants.web; import au.com.royalpay.payment.manage.dev.core.MerchantLocationService; -import au.com.royalpay.payment.manage.merchants.beans.*; +import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo; +import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; +import au.com.royalpay.payment.manage.merchants.beans.ClientRateConfig; +import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo; +import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; +import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; +import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; -import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; -import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.manage.permission.manager.RequireManager; 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.http.HttpUtils; +import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; +import au.com.royalpay.payment.tools.permission.enums.ManagerRole; + import com.alibaba.fastjson.JSONObject; + import org.springframework.validation.Errors; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; import java.io.IOException; import java.io.OutputStream; import java.util.List; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + /** * Created by yixian on 2016-06-27. */ diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientFilesMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientFilesMapper.xml new file mode 100644 index 000000000..e58c81269 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientFilesMapper.xml @@ -0,0 +1,16 @@ + + + + + + update sys_files + set state = 2 + where file_name = 'source_agree_file' + and client_id = #{client_id} + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml index e49faa46d..9c8788324 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml @@ -87,4 +87,14 @@ order by update_time desc ]]> + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml new file mode 100644 index 000000000..f0b8b14c7 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file From 25d6d34a3f55196c0f0ecbac53f0e62fca656458 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Wed, 7 Mar 2018 18:10:07 +0800 Subject: [PATCH 03/30] update --- .../core/impls/RetailAppServiceImp.java | 3 -- .../appclient/web/RetailAppController.java | 43 ++++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) 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 8cf9af7f6..33c24b1c2 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 @@ -25,7 +25,6 @@ import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; import au.com.royalpay.payment.manage.notice.core.NoticeManage; import au.com.royalpay.payment.manage.notice.core.NoticePartner; import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper; -import au.com.royalpay.payment.manage.pushMessage.JpushMessageHelper; import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInAccountService; @@ -138,8 +137,6 @@ public class RetailAppServiceImp implements RetailAppService { @Resource private ClientDeviceTokenMapper clientDeviceTokenMapper; @Resource - private JpushMessageHelper jpushMessageHelper; - @Resource private ClientRateMapper clientRateMapper; private Map senderMap = new HashMap<>(); 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 c67a61bfe..34c73b63c 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 @@ -1,23 +1,5 @@ package au.com.royalpay.payment.manage.appclient.web; -import java.math.BigDecimal; -import java.util.List; -import java.util.Map; - -import javax.annotation.Resource; -import javax.validation.Valid; - -import org.springframework.validation.Errors; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; @@ -35,10 +17,28 @@ import au.com.royalpay.payment.tools.device.advise.AppClientController; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.http.HttpUtils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +import javax.annotation.Resource; +import javax.validation.Valid; + /** * Created by yishuqian on 28/03/2017. */ - @AppClientController +@AppClientController @RequestMapping("/api/v1.0/retail/app") public class RetailAppController { @Resource @@ -333,7 +333,10 @@ public class RetailAppController { @RequestMapping(value = "/file/agree", method = RequestMethod.PUT) public JSONObject generateSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - return appFileService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); + JSONObject file = appFileService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); + JSONObject result = new JSONObject(); + result.put("file_value",file.getString("file_value")); + return result; } @RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST) From 206106caac981163ad7d79f06cf0a76dc85d27bd Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Wed, 7 Mar 2018 19:14:36 +0800 Subject: [PATCH 04/30] update --- .../appclient/web/RetailAppController.java | 18 +++++++++--------- .../apps/core/impls/AppFileServiceImpl.java | 11 ++++++++++- 2 files changed, 19 insertions(+), 10 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 34c73b63c..bbb7700ee 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 @@ -14,6 +14,7 @@ import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.device.advise.AppClientController; +import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.http.HttpUtils; @@ -51,6 +52,8 @@ public class RetailAppController { private BillService billService; @Resource private AppFileService appFileService; + @Resource + private SysConfigManager sysConfigManager; @RequestMapping(value = "/token", method = RequestMethod.PUT) public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) { @@ -194,9 +197,14 @@ public class RetailAppController { public JSONObject getClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { return retailAppService.getClientInfo(device); } + @RequestMapping(value = "/client/check", method = RequestMethod.GET) public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - return retailAppService.getClientRateExpire(device.getIntValue("client_id")); + JSONObject result = retailAppService.getClientRateExpire(device.getIntValue("client_id")); + JSONObject file = appFileService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); + result.put("file_url", file.getString("file_value")); + result.put("contract_info",sysConfigManager.getSysConfig().getString("contract_info")); + return result; } @RequestMapping(value = "/client", method = RequestMethod.PUT) @@ -331,14 +339,6 @@ public class RetailAppController { return result; } - @RequestMapping(value = "/file/agree", method = RequestMethod.PUT) - public JSONObject generateSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - JSONObject file = appFileService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); - JSONObject result = new JSONObject(); - result.put("file_value",file.getString("file_value")); - return result; - } - @RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST) public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { appFileService.confirmSourceAgreement(device.getIntValue("client_id")); diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java index b893f6b72..81cceb7f4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java @@ -1,5 +1,6 @@ package au.com.royalpay.payment.manage.apps.core.impls; +import au.com.royalpay.payment.manage.appclient.core.RetailAppService; import au.com.royalpay.payment.manage.apps.core.AppFileService; import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; @@ -29,6 +30,8 @@ public class AppFileServiceImpl implements AppFileService { private ClientManager clientManager; @Resource private ClientsContractMapper clientsContractMapper; + @Resource + private RetailAppService retailAppService; @Override @Transactional @@ -47,7 +50,13 @@ public class AppFileServiceImpl implements AppFileService { saveContract(client_id, now); return files.get(0); } else { - return files.get(0); + JSONObject expireInfo = retailAppService.getClientRateExpire(client_id); + JSONObject file = files.get(0); + if(expireInfo.getBoolean("rate_expire")){ + file.put("last_update_date",now); + } + clientFilesMapper.update(file); + return file; } } From 29d783540075fa94a04b2e9e3a9ffa4024540937 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 09:02:50 +0800 Subject: [PATCH 05/30] update --- .../payment/manage/appclient/web/RetailAppController.java | 2 +- .../payment/manage/apps/core/impls/AppFileServiceImpl.java | 4 ++-- 2 files changed, 3 insertions(+), 3 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 bbb7700ee..7e9bfb945 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 @@ -203,7 +203,7 @@ public class RetailAppController { JSONObject result = retailAppService.getClientRateExpire(device.getIntValue("client_id")); JSONObject file = appFileService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); result.put("file_url", file.getString("file_value")); - result.put("contract_info",sysConfigManager.getSysConfig().getString("contract_info")); + result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); return result; } diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java index 81cceb7f4..9b815285b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java @@ -38,7 +38,6 @@ public class AppFileServiceImpl implements AppFileService { public JSONObject getOrGenerateSourceAgreement(int client_id) { JSONObject client = clientManager.getClientInfo(client_id); JSONObject contract = clientsContractMapper.findByClientId(client_id); - List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); Date now = new Date(); if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) { try { @@ -46,11 +45,12 @@ public class AppFileServiceImpl implements AppFileService { } catch (Exception e) { logger.info("App generate PDF failed"); } - files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); + List files =clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); saveContract(client_id, now); return files.get(0); } else { JSONObject expireInfo = retailAppService.getClientRateExpire(client_id); + List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); JSONObject file = files.get(0); if(expireInfo.getBoolean("rate_expire")){ file.put("last_update_date",now); From 5db729488011cea4cf92f3a26358d462d209c2c8 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 11:11:48 +0800 Subject: [PATCH 06/30] update --- .../appclient/core/RetailAppService.java | 2 +- .../core/impls/RetailAppServiceImp.java | 11 ++++++-- .../appclient/web/RetailAppController.java | 10 ++++++- .../manage/apps/core/AppFileService.java | 2 ++ .../apps/core/impls/AppFileServiceImpl.java | 27 +++++++++++++++---- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index e60b3dd93..d4c9a2ec1 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -110,5 +110,5 @@ public interface RetailAppService { JSONObject getAdDetail(JSONObject device, String article_id); - JSONObject getClientRateExpire(int client_id); + JSONObject getClientContractExpire(int client_id); } 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 33c24b1c2..c4b75b1d9 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 @@ -18,6 +18,7 @@ import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper; import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; import au.com.royalpay.payment.manage.mappers.system.ClientSettleDelayConfMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; @@ -138,6 +139,8 @@ public class RetailAppServiceImp implements RetailAppService { private ClientDeviceTokenMapper clientDeviceTokenMapper; @Resource private ClientRateMapper clientRateMapper; + @Resource + private ClientsContractMapper clientsContractMapper; private Map senderMap = new HashMap<>(); @@ -1329,7 +1332,7 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public JSONObject getClientRateExpire(int client_id) { + public JSONObject getClientContractExpire(int client_id) { JSONObject client = clientManager.getClientInfo(client_id); if (client == null) { throw new NotFoundException("merchant not found please check ID"); @@ -1338,10 +1341,14 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject result = new JSONObject(); result.put("rate_expire", false); result.put("rate_waring", 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")){ + return result; + } if (CollectionUtils.isEmpty(rateInfo)) { return result; } - Date now = new Date(); rateInfo.forEach((p)->{ if (now.compareTo(p.getDate("expiry_time")) > -1) { result.put("rate_expire", true); 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 7e9bfb945..44ed09636 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 @@ -200,7 +200,7 @@ public class RetailAppController { @RequestMapping(value = "/client/check", method = RequestMethod.GET) public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - JSONObject result = retailAppService.getClientRateExpire(device.getIntValue("client_id")); + JSONObject result = retailAppService.getClientContractExpire(device.getIntValue("client_id")); JSONObject file = appFileService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); result.put("file_url", file.getString("file_value")); result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); @@ -339,6 +339,14 @@ public class RetailAppController { return result; } + @RequestMapping(value = "/file/agree", method = RequestMethod.GET) + public JSONObject generateSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + JSONObject file = appFileService.getSourceAgreement(device.getIntValue("client_id")); + JSONObject result = new JSONObject(); + result.put("file_url",file.getString("file_value")); + return result; + } + @RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST) public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { appFileService.confirmSourceAgreement(device.getIntValue("client_id")); diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java index 8b3da4594..2b21248dc 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java +++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java @@ -7,4 +7,6 @@ public interface AppFileService { JSONObject getOrGenerateSourceAgreement(int client_id); void confirmSourceAgreement(int client_id); + + JSONObject getSourceAgreement(int client_id); } diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java index 9b815285b..0d4cd6394 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java @@ -6,6 +6,8 @@ import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper; import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.exceptions.NotFoundException; +import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import com.alibaba.fastjson.JSONObject; @@ -14,6 +16,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.Date; import java.util.List; @@ -37,6 +40,9 @@ public class AppFileServiceImpl implements AppFileService { @Transactional public JSONObject getOrGenerateSourceAgreement(int client_id) { JSONObject client = clientManager.getClientInfo(client_id); + if (client == null) { + throw new NotFoundException("merchant not found"); + } JSONObject contract = clientsContractMapper.findByClientId(client_id); Date now = new Date(); if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) { @@ -44,18 +50,20 @@ public class AppFileServiceImpl implements AppFileService { clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null); } catch (Exception e) { logger.info("App generate PDF failed"); + throw new ServerErrorException("System error"); } - List files =clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); + List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); saveContract(client_id, now); return files.get(0); } else { - JSONObject expireInfo = retailAppService.getClientRateExpire(client_id); + JSONObject expireInfo = retailAppService.getClientContractExpire(client_id); List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); JSONObject file = files.get(0); - if(expireInfo.getBoolean("rate_expire")){ - file.put("last_update_date",now); + if (expireInfo.getBoolean("rate_expire")) { + contract.put("create_time", now); + contract.put("expiry_date", DateUtils.addYears(now, 1)); + clientsContractMapper.update(contract); } - clientFilesMapper.update(file); return file; } @@ -81,4 +89,13 @@ public class AppFileServiceImpl implements AppFileService { clientsContractMapper.update(file); } + @Override + public JSONObject getSourceAgreement(int client_id) { + List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); + if (CollectionUtils.isEmpty(files)) { + throw new NotFoundException("Contract not generated"); + } + return files.get(0); + } + } From 863b7794e3c0802321e88a11fed282e5c6d4c888 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 14:09:07 +0800 Subject: [PATCH 07/30] update --- .../appclient/core/RetailAppService.java | 1 - .../core/impls/RetailAppServiceImp.java | 29 ------------- .../appclient/web/RetailAppController.java | 12 +++--- .../web/PartnerManageController.java | 22 +++++++++- .../core/ClientContractService.java} | 7 +++- .../core/impl/ClientContractServiceImpl.java} | 41 ++++++++++++++++--- .../payment/manage/system/package-info.java | 1 + 7 files changed, 69 insertions(+), 44 deletions(-) rename src/main/java/au/com/royalpay/payment/manage/{apps/core/AppFileService.java => system/core/ClientContractService.java} (57%) rename src/main/java/au/com/royalpay/payment/manage/{apps/core/impls/AppFileServiceImpl.java => system/core/impl/ClientContractServiceImpl.java} (68%) create mode 100644 src/main/java/au/com/royalpay/payment/manage/system/package-info.java diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index d4c9a2ec1..ed8eecdb4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -110,5 +110,4 @@ public interface RetailAppService { JSONObject getAdDetail(JSONObject device, String article_id); - JSONObject getClientContractExpire(int client_id); } 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 c4b75b1d9..25c1f66e6 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 @@ -1331,35 +1331,6 @@ public class RetailAppServiceImp implements RetailAppService { return res; } - @Override - public JSONObject getClientContractExpire(int client_id) { - JSONObject client = clientManager.getClientInfo(client_id); - if (client == null) { - throw new NotFoundException("merchant not found please check ID"); - } - List rateInfo = clientRateMapper.minExpiryTime(client_id, null); - JSONObject result = new JSONObject(); - result.put("rate_expire", false); - result.put("rate_waring", 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")){ - return result; - } - if (CollectionUtils.isEmpty(rateInfo)) { - return result; - } - rateInfo.forEach((p)->{ - if (now.compareTo(p.getDate("expiry_time")) > -1) { - result.put("rate_expire", true); - } - if (DateUtils.addDays(now, 10).compareTo(p.getDate("expiry_time")) > -1) { - result.put("rate_waring", true); - } - }); - return result; - } - private static boolean mathchLetterorNum(String str) { String regex = "[A-Za-z0-9]{8}"; return str.matches(regex); 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 44ed09636..1bc15bf10 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 @@ -4,7 +4,7 @@ import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; -import au.com.royalpay.payment.manage.apps.core.AppFileService; +import au.com.royalpay.payment.manage.system.core.ClientContractService; import au.com.royalpay.payment.manage.bill.bean.NewBillBean; import au.com.royalpay.payment.manage.bill.bean.QueryBillBean; import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean; @@ -51,7 +51,7 @@ public class RetailAppController { @Resource private BillService billService; @Resource - private AppFileService appFileService; + private ClientContractService clientContractService; @Resource private SysConfigManager sysConfigManager; @@ -200,8 +200,8 @@ public class RetailAppController { @RequestMapping(value = "/client/check", method = RequestMethod.GET) public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - JSONObject result = retailAppService.getClientContractExpire(device.getIntValue("client_id")); - JSONObject file = appFileService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); + JSONObject result = clientContractService.getClientContractExpire(device.getIntValue("client_id")); + JSONObject file = clientContractService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); result.put("file_url", file.getString("file_value")); result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); return result; @@ -341,7 +341,7 @@ public class RetailAppController { @RequestMapping(value = "/file/agree", method = RequestMethod.GET) public JSONObject generateSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - JSONObject file = appFileService.getSourceAgreement(device.getIntValue("client_id")); + JSONObject file = clientContractService.getSourceAgreement(device.getIntValue("client_id")); JSONObject result = new JSONObject(); result.put("file_url",file.getString("file_value")); return result; @@ -349,6 +349,6 @@ public class RetailAppController { @RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST) public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - appFileService.confirmSourceAgreement(device.getIntValue("client_id")); + clientContractService.confirmSourceAgreement(device.getIntValue("client_id")); } } 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 16f88fd5d..7ff183dc4 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 @@ -10,10 +10,13 @@ import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.permission.manager.PartnerMapping; import au.com.royalpay.payment.manage.permission.manager.RequireManager; +import au.com.royalpay.payment.manage.system.core.ClientContractService; 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.env.SysConfigManager; import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; @@ -50,7 +53,10 @@ public class PartnerManageController { private TradeLogService tradeLogService; @Resource private MerchantLocationService merchantLocationService; - + @Resource + private ClientContractService clientContractService; + @Resource + private SysConfigManager sysConfigManager; @RequestMapping(method = RequestMethod.GET) @RequireManager(role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT, ManagerRole.FINANCIAL_STAFF, ManagerRole.DIRECTOR}) public JSONObject listClients(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, PartnerQuery query) { @@ -517,4 +523,18 @@ public class PartnerManageController { public List getMerchantIds(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { return clientManager.listMerchantIds(clientMoniker,manager); } + + @PartnerMapping(value = "/check", method = RequestMethod.GET) + public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { + JSONObject result = clientContractService.getClientContractExpire(account.getIntValue("client_id")); + JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id")); + result.put("file_url", file.getString("file_value")); + result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); + return result; + } + + @PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST) + public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { + clientContractService.confirmSourceAgreement(account.getIntValue("client_id")); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java b/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java similarity index 57% rename from src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java rename to src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java index 2b21248dc..ca4eacb0f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/core/AppFileService.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java @@ -1,12 +1,15 @@ -package au.com.royalpay.payment.manage.apps.core; +package au.com.royalpay.payment.manage.system.core; import com.alibaba.fastjson.JSONObject; -public interface AppFileService { +public interface ClientContractService { JSONObject getOrGenerateSourceAgreement(int client_id); void confirmSourceAgreement(int client_id); JSONObject getSourceAgreement(int client_id); + + JSONObject getClientContractExpire(int client_id); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java similarity index 68% rename from src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java rename to src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java index 0d4cd6394..1f5a058a0 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/core/impls/AppFileServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java @@ -1,10 +1,11 @@ -package au.com.royalpay.payment.manage.apps.core.impls; +package au.com.royalpay.payment.manage.system.core.impl; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; -import au.com.royalpay.payment.manage.apps.core.AppFileService; 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.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; @@ -24,9 +25,9 @@ import java.util.List; import javax.annotation.Resource; @Service -public class AppFileServiceImpl implements AppFileService { +public class ClientContractServiceImpl implements ClientContractService { - Logger logger = LoggerFactory.getLogger(AppFileServiceImpl.class); + Logger logger = LoggerFactory.getLogger(ClientContractServiceImpl.class); @Resource private ClientFilesMapper clientFilesMapper; @Resource @@ -35,6 +36,8 @@ public class AppFileServiceImpl implements AppFileService { private ClientsContractMapper clientsContractMapper; @Resource private RetailAppService retailAppService; + @Resource + private ClientRateMapper clientRateMapper; @Override @Transactional @@ -56,7 +59,7 @@ public class AppFileServiceImpl implements AppFileService { saveContract(client_id, now); return files.get(0); } else { - JSONObject expireInfo = retailAppService.getClientContractExpire(client_id); + JSONObject expireInfo = getClientContractExpire(client_id); List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); JSONObject file = files.get(0); if (expireInfo.getBoolean("rate_expire")) { @@ -98,4 +101,32 @@ public class AppFileServiceImpl implements AppFileService { return files.get(0); } + @Override + public JSONObject getClientContractExpire(int client_id) { + JSONObject client = clientManager.getClientInfo(client_id); + if (client == null) { + throw new NotFoundException("merchant not found please check ID"); + } + List rateInfo = clientRateMapper.minExpiryTime(client_id, null); + JSONObject result = new JSONObject(); + result.put("rate_expire", false); + result.put("rate_waring", 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")){ + return result; + } + if (CollectionUtils.isEmpty(rateInfo)) { + return result; + } + rateInfo.forEach((p)->{ + if (now.compareTo(p.getDate("expiry_time")) > -1) { + result.put("rate_expire", true); + } + if (DateUtils.addDays(now, 10).compareTo(p.getDate("expiry_time")) > -1) { + result.put("rate_waring", true); + } + }); + return result; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/package-info.java b/src/main/java/au/com/royalpay/payment/manage/system/package-info.java new file mode 100644 index 000000000..158177406 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/system/package-info.java @@ -0,0 +1 @@ +package au.com.royalpay.payment.manage.system; \ No newline at end of file From 585401834bf0c0260607df9852af092a8b0092cf Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Thu, 8 Mar 2018 15:35:33 +0800 Subject: [PATCH 08/30] new act --- src/main/ui/static/boot/indexMainApp.js | 19 +++++++++++++++++-- .../static/commons/templates/ag_detail.html | 5 +++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/ui/static/boot/indexMainApp.js b/src/main/ui/static/boot/indexMainApp.js index 336d4c84a..412e25bce 100644 --- a/src/main/ui/static/boot/indexMainApp.js +++ b/src/main/ui/static/boot/indexMainApp.js @@ -121,7 +121,18 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo $scope.loadPartnerNotice(); }) }; - //$scope.showAG(); + + $scope.getAgStatus = function () { + $http.get('/sys/partners/check').then(function (resp) { + // $scope.rate_expire = resp.data.rate_expire; + $scope.rate_waring = resp.data.rate_waring; + // $scope.file_url = resp.data.file_url; + if($scope.rate_waring){ + $scope.showAG(resp.data); + } + }); + }; + $scope.getAgStatus(); $scope.refundNotice = {counts: 0}; $scope.openRefundNotice = false; $scope.showRefundNotice = function () { @@ -292,9 +303,13 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo }]); app.controller('agreementDetailCtrl', ['$scope', '$http', '$sce', 'ag', function ($scope, $http, $sce, ag) { + $scope.ag = angular.copy(ag); $scope.agreeCheck = false; $scope.agree = function () { - $scope.$close(); + $http.post('/sys/partners/agree/confirm').then(function () { + }, function (resp) { + $scope.$close(); + }) }; $scope.notAgree = function () { window.location.href = "https://mpay.royalpay.com.au"; diff --git a/src/main/ui/static/commons/templates/ag_detail.html b/src/main/ui/static/commons/templates/ag_detail.html index 9ad31f4ee..883e43529 100644 --- a/src/main/ui/static/commons/templates/ag_detail.html +++ b/src/main/ui/static/commons/templates/ag_detail.html @@ -4,7 +4,7 @@ @@ -14,6 +14,7 @@ 我已阅读完合同内容,并同意相关条款 - + + \ No newline at end of file From fef08a3f58923504b39b95c302aa4e6ea1851ef6 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 15:35:45 +0800 Subject: [PATCH 09/30] update --- .../core/impl/ClientContractServiceImpl.java | 59 ++++++++++++++----- 1 file changed, 45 insertions(+), 14 deletions(-) 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 1f5a058a0..2292ef9c5 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 @@ -1,6 +1,5 @@ package au.com.royalpay.payment.manage.system.core.impl; -import au.com.royalpay.payment.manage.appclient.core.RetailAppService; 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; @@ -35,8 +34,6 @@ public class ClientContractServiceImpl implements ClientContractService { @Resource private ClientsContractMapper clientsContractMapper; @Resource - private RetailAppService retailAppService; - @Resource private ClientRateMapper clientRateMapper; @Override @@ -46,9 +43,15 @@ public class ClientContractServiceImpl implements ClientContractService { if (client == null) { throw new NotFoundException("merchant not found"); } + JSONObject expireInfo = getClientContractExpire(client_id); + if(expireInfo.getBoolean("rate_waring")){ + List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); + return files.get(0); + } + JSONObject contract = clientsContractMapper.findByClientId(client_id); Date now = new Date(); - if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) { + if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0 ) { try { clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null); } catch (Exception e) { @@ -59,7 +62,6 @@ public class ClientContractServiceImpl implements ClientContractService { saveContract(client_id, now); return files.get(0); } else { - JSONObject expireInfo = getClientContractExpire(client_id); List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); JSONObject file = files.get(0); if (expireInfo.getBoolean("rate_expire")) { @@ -83,13 +85,39 @@ public class ClientContractServiceImpl implements ClientContractService { } @Override + @Transactional public void confirmSourceAgreement(int client_id) { - JSONObject file = clientsContractMapper.findByClientId(client_id); - if (file == null) { + JSONObject rateExpire = getClientContractExpire(client_id); + boolean expire = rateExpire.getBoolean("rate_expire"); + boolean waring = rateExpire.getBoolean("rate_waring"); + if(!(expire && waring)){ + return; + } + JSONObject contract = clientsContractMapper.findByClientId(client_id); + if (contract == null) { throw new BadRequestException("generate contract first"); } - file.put("has_sign", 1); - clientsContractMapper.update(file); + contract.put("has_sign", 1); + clientsContractMapper.update(contract); + Date now = new Date(); + List rateInfo = clientRateMapper.minExpiryTime(client_id, null); + if(expire){ + rateInfo.forEach((p)->{ + p.remove("client_rate_id"); + p.put("create_time",now); + p.put("active_time",now); + p.put("expiry_time",DateUtils.addYears(now,1)); + }); + } + if(!expire && waring){ + rateInfo.forEach((p)->{ + p.remove("client_rate_id"); + p.put("create_time",now); + p.put("active_time",DateUtils.addYears(p.getDate("active_time"),1)); + p.put("expiry_time",DateUtils.addYears(p.getDate("expiry_time"),1)); + }); + } + } @Override @@ -109,17 +137,20 @@ public class ClientContractServiceImpl implements ClientContractService { } 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); Date now = new Date(); JSONObject contract = clientsContractMapper.findByClientId(client_id); - if(contract!=null && contract.getDate("expiry_date").compareTo(now)>0 && contract.getBoolean("has_sign")){ + if (contract != null && contract.getDate("expiry_date").compareTo(now) > 0 && contract.getBoolean("has_sign")) { return result; } - if (CollectionUtils.isEmpty(rateInfo)) { - return result; - } - rateInfo.forEach((p)->{ + + rateInfo.forEach((p) -> { if (now.compareTo(p.getDate("expiry_time")) > -1) { result.put("rate_expire", true); } From 1731d9e973af61e2531e5c70d1737f4d6409b83e Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 17:32:23 +0800 Subject: [PATCH 10/30] update --- .../appclient/core/RetailAppService.java | 3 +++ .../core/impls/RetailAppServiceImp.java | 24 ++++++++++++++----- .../appclient/web/RetailAppController.java | 8 ++----- .../manage/merchants/core/ClientManager.java | 2 ++ .../core/impls/ClientManagerImpl.java | 24 +++++++++++++++++++ .../web/PartnerManageController.java | 7 ++---- .../core/impl/ClientContractServiceImpl.java | 7 ++++-- 7 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index ed8eecdb4..bd5a7ba1d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -4,6 +4,7 @@ import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; + import com.alibaba.fastjson.JSONObject; import java.math.BigDecimal; @@ -110,4 +111,6 @@ public interface RetailAppService { JSONObject getAdDetail(JSONObject device, String article_id); + JSONObject getCheckClientInfo(JSONObject device); + } 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 24d0194fa..39aaaa78c 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 @@ -16,9 +16,7 @@ import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper; import au.com.royalpay.payment.manage.mappers.system.ClientSettleDelayConfMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerRelationAlipayMapper; import au.com.royalpay.payment.manage.merchants.core.ClientManager; @@ -30,6 +28,7 @@ import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl; +import au.com.royalpay.payment.manage.system.core.ClientContractService; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport; import au.com.royalpay.payment.tools.device.DeviceSupport; @@ -37,9 +36,9 @@ import au.com.royalpay.payment.tools.device.message.AppMessage; import au.com.royalpay.payment.tools.device.message.AppMsgSender; import au.com.royalpay.payment.tools.device.support.DeviceRegister; import au.com.royalpay.payment.tools.env.PlatformEnvironment; +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.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; @@ -64,7 +63,6 @@ import org.slf4j.LoggerFactory; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.text.DateFormat; @@ -138,9 +136,9 @@ public class RetailAppServiceImp implements RetailAppService { @Resource private ClientDeviceTokenMapper clientDeviceTokenMapper; @Resource - private ClientRateMapper clientRateMapper; + private ClientContractService clientContractService; @Resource - private ClientsContractMapper clientsContractMapper; + private SysConfigManager sysConfigManager; private Map senderMap = new HashMap<>(); @@ -1338,6 +1336,20 @@ public class RetailAppServiceImp implements RetailAppService { return res; } + @Override + public JSONObject getCheckClientInfo(JSONObject device) { + JSONObject result = clientContractService.getClientContractExpire(device.getIntValue("client_id")); + JSONObject account = clientAccountMapper.findById(device.getString("account_id")); + if(PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER){ + result.put("is_ordinary",true); + return result; + } + JSONObject file = clientContractService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); + result.put("file_url", file.getString("file_value")); + result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); + return result; + } + private static boolean mathchLetterorNum(String str) { String regex = "[A-Za-z0-9]{8}"; return str.matches(regex); 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 1bc15bf10..dcab8dfbf 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 @@ -4,7 +4,6 @@ import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; import au.com.royalpay.payment.manage.appclient.core.RetailAppService; -import au.com.royalpay.payment.manage.system.core.ClientContractService; import au.com.royalpay.payment.manage.bill.bean.NewBillBean; import au.com.royalpay.payment.manage.bill.bean.QueryBillBean; import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean; @@ -12,6 +11,7 @@ import au.com.royalpay.payment.manage.bill.core.BillOrderService; import au.com.royalpay.payment.manage.bill.core.BillService; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; +import au.com.royalpay.payment.manage.system.core.ClientContractService; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.device.advise.AppClientController; import au.com.royalpay.payment.tools.env.SysConfigManager; @@ -200,11 +200,7 @@ public class RetailAppController { @RequestMapping(value = "/client/check", method = RequestMethod.GET) public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - JSONObject result = clientContractService.getClientContractExpire(device.getIntValue("client_id")); - JSONObject file = clientContractService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); - result.put("file_url", file.getString("file_value")); - result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); - return result; + return retailAppService.getCheckClientInfo(device); } @RequestMapping(value = "/client", method = RequestMethod.PUT) 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 5c05476b4..41947c5ec 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 @@ -283,4 +283,6 @@ public interface ClientManager { List listMerchantIds(String clientMoniker,JSONObject manager); void clearCacheSubMerchantIdApplices(String clientMoniker); + + JSONObject getCheckClientInfo(JSONObject account); } 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 2b796fcb6..9c9707bbb 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 @@ -42,6 +42,7 @@ 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; import au.com.royalpay.payment.manage.signin.core.SignInAccountService; +import au.com.royalpay.payment.manage.system.core.ClientContractService; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; @@ -208,6 +209,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private ClientsContractMapper clientsContractMapper; + @Resource + private ClientContractService clientContractService; private static final String SOURCE_AGREE_FILE = "source_agree_file"; private static final String CLIENT_BANK_FILE = "client_bank_file"; @@ -1890,6 +1893,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } List clientRate = clientRateMapper.minExpiryTime(client.getIntValue("client_id"),null); + if(CollectionUtils.isEmpty(clientRate)){ + throw new BadRequestException("The Partner's Rate is not config!"); + } clientRate.forEach((p)->{ String rate_name = p.getString("rate_name"); if("Wechat".equals(rate_name)){ @@ -3106,4 +3112,22 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker") public void clearCacheSubMerchantIdApplices(String clientMoniker) { } + + @Override + public JSONObject getCheckClientInfo(JSONObject account) { + JSONObject result = clientContractService.getClientContractExpire(account.getIntValue("client_id")); + if(PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER){ + result.put("is_ordinary",true); + boolean expire = result.getBoolean("rate_expire"); + boolean waring = result.getBoolean("rate_waring"); + if(!expire && waring){ + + } + return result; + } + JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id")); + result.put("file_url", file.getString("file_value")); + result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); + return result; + } } 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 7ff183dc4..a6d19ba52 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 @@ -20,6 +20,7 @@ import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; +import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import com.alibaba.fastjson.JSONObject; @@ -526,11 +527,7 @@ public class PartnerManageController { @PartnerMapping(value = "/check", method = RequestMethod.GET) public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { - JSONObject result = clientContractService.getClientContractExpire(account.getIntValue("client_id")); - JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id")); - result.put("file_url", file.getString("file_value")); - result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); - return result; + return clientManager.getCheckClientInfo(account); } @PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST) 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 2292ef9c5..60daf37a0 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 @@ -5,6 +5,7 @@ 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; @@ -35,6 +36,8 @@ public class ClientContractServiceImpl implements ClientContractService { private ClientsContractMapper clientsContractMapper; @Resource private ClientRateMapper clientRateMapper; + @Resource + private SysConfigManager sysConfigManager; @Override @Transactional @@ -149,12 +152,12 @@ public class ClientContractServiceImpl implements ClientContractService { if (contract != null && contract.getDate("expiry_date").compareTo(now) > 0 && contract.getBoolean("has_sign")) { return result; } - + int waringDays = sysConfigManager.getSysConfig().getIntValue("rate_warning_days"); rateInfo.forEach((p) -> { if (now.compareTo(p.getDate("expiry_time")) > -1) { result.put("rate_expire", true); } - if (DateUtils.addDays(now, 10).compareTo(p.getDate("expiry_time")) > -1) { + if (DateUtils.addDays(now, waringDays).compareTo(p.getDate("expiry_time")) > -1) { result.put("rate_waring", true); } }); From 7ee91fb8854c21c4deb69bc744b208ffe816fb89 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 18:31:43 +0800 Subject: [PATCH 11/30] update --- .../core/impls/ClientManagerImpl.java | 62 +++++++++++++------ .../core/impl/ClientContractServiceImpl.java | 3 + 2 files changed, 46 insertions(+), 19 deletions(-) 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 9c9707bbb..4c8bd226c 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 @@ -80,6 +80,7 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; @@ -1892,23 +1893,23 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("company_name_acn", client.getString("company_name") + " (ABN " + client.getString("abn") + ")"); } - List clientRate = clientRateMapper.minExpiryTime(client.getIntValue("client_id"),null); - if(CollectionUtils.isEmpty(clientRate)){ + List clientRate = clientRateMapper.minExpiryTime(client.getIntValue("client_id"), null); + if (CollectionUtils.isEmpty(clientRate)) { throw new BadRequestException("The Partner's Rate is not config!"); } - clientRate.forEach((p)->{ + clientRate.forEach((p) -> { String rate_name = p.getString("rate_name"); - if("Wechat".equals(rate_name)){ + if ("Wechat".equals(rate_name)) { client.put("wechat_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); client.put("clean", "T+" + p.getString("clean_days")); client.put("clean_days", p.getString("clean_days")); - }else if("Alipay".equals(rate_name)){ + } else if ("Alipay".equals(rate_name)) { client.put("alipay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); - }else if("Bestpay".equals(rate_name)){ + } else if ("Bestpay".equals(rate_name)) { client.put("bestpay_rate", p.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); - }else if("jd".equals(rate_name)){ + } else if ("jd".equals(rate_name)) { client.put("jd_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)); } }); @@ -1930,7 +1931,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid File file = new File(clientMoniker + "_agreement.pdf"); ByteArrayOutputStream bos = pdu.templetPdfBos(file); InputStream stream = new ByteArrayInputStream(bos.toByteArray()); - JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker +"_"+System.currentTimeMillis()+ "_agreement.pdf", false); + JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker + "_" + System.currentTimeMillis() + "_agreement.pdf", false); if (fileRes != null) { importAgreeFile(clientMoniker, manager, fileRes.getString("url")); } @@ -2035,13 +2036,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid file.put("file_value", sourceFile); file.put("client_id", client.getIntValue("client_id")); file.put("last_update_date", now); - if(manager == null){ + if (manager == null) { file.put("last_update_by", "System Import"); - }else { + } else { 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||existFile == null || existFile.isEmpty()) { + if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0 || existFile == null || existFile.isEmpty()) { clientFilesMapper.save(file); } else { file.put("file_id", existFile.getString("file_id")); @@ -3116,18 +3117,41 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public JSONObject getCheckClientInfo(JSONObject account) { JSONObject result = clientContractService.getClientContractExpire(account.getIntValue("client_id")); - if(PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER){ - result.put("is_ordinary",true); - boolean expire = result.getBoolean("rate_expire"); - boolean waring = result.getBoolean("rate_waring"); - if(!expire && waring){ - + JSONObject config = sysConfigManager.getSysConfig(); + boolean expire = result.getBoolean("rate_expire"); + boolean waring = result.getBoolean("rate_waring"); + 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,config.getString("sys_contract_ordinary_waring"))); + } + if (expire) { + result.put("contract_info",config.getString("sys_contract_ordinary_info")); } return result; } + result.put("is_ordinary", false); + if (!expire && waring) { + String [] key = {result.getString("expire_days")}; + result.put("contract_info",editContractOrdinaryWaring(key,config.getString("sys_contract_waring"))); + } + if (expire) { + result.put("contract_info",config.getString("sys_contract_info")); + } JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id")); result.put("file_url", file.getString("file_value")); - result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); + result.put("contract_info", config.getString("sys_contract_info")); return result; } + + private String editContractOrdinaryWaring(String[] key, String sourceStr) { + if(StringUtils.isEmpty(sourceStr) || ArrayUtils.isEmpty(key)){ + return ""; + } + for (int i = 0; i < key.length; i++) { + sourceStr = sourceStr.replace("{" + i + "}", key[i]); + } + return sourceStr; + } } 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 60daf37a0..19ed571f6 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 @@ -110,6 +110,7 @@ public class ClientContractServiceImpl implements ClientContractService { p.put("create_time",now); p.put("active_time",now); p.put("expiry_time",DateUtils.addYears(now,1)); + clientRateMapper.saveRate(p); }); } if(!expire && waring){ @@ -118,6 +119,7 @@ public class ClientContractServiceImpl implements ClientContractService { p.put("create_time",now); p.put("active_time",DateUtils.addYears(p.getDate("active_time"),1)); p.put("expiry_time",DateUtils.addYears(p.getDate("expiry_time"),1)); + clientRateMapper.saveRate(p); }); } @@ -161,6 +163,7 @@ public class ClientContractServiceImpl implements ClientContractService { result.put("rate_waring", true); } }); + result.put("expire_days",(int)(rateInfo.get(0).getDate("expiry_time").getTime()-now.getTime())/(1000*60*60*24)); return result; } } From 81ecb15c05d60e1935ace3ad71b9dd909285e4eb Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 18:37:53 +0800 Subject: [PATCH 12/30] update --- .../merchants/core/impls/ClientManagerImpl.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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 4c8bd226c..87d19dbf5 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 @@ -3131,13 +3131,16 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } return result; } - result.put("is_ordinary", false); - if (!expire && waring) { - String [] key = {result.getString("expire_days")}; - result.put("contract_info",editContractOrdinaryWaring(key,config.getString("sys_contract_waring"))); - } - if (expire) { - result.put("contract_info",config.getString("sys_contract_info")); + if (!(PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER)) { + result.put("is_ordinary", false); + if (!expire && waring) { + String[] key = {result.getString("expire_days")}; + result.put("contract_info", editContractOrdinaryWaring(key, config.getString("sys_contract_waring"))); + } + if (expire) { + result.put("contract_info", config.getString("sys_contract_info")); + } + return result; } JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id")); result.put("file_url", file.getString("file_value")); From 1e380cc65a9dd9bc3638d2a6640f74c934b3f28d Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 18:44:29 +0800 Subject: [PATCH 13/30] update --- .../manage/system/core/impl/ClientContractServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 19ed571f6..0e7beed7d 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 @@ -93,13 +93,13 @@ public class ClientContractServiceImpl implements ClientContractService { JSONObject rateExpire = getClientContractExpire(client_id); boolean expire = rateExpire.getBoolean("rate_expire"); boolean waring = rateExpire.getBoolean("rate_waring"); - if(!(expire && waring)){ - return; - } JSONObject contract = clientsContractMapper.findByClientId(client_id); if (contract == null) { throw new BadRequestException("generate contract first"); } + if(contract.getBoolean("has_sign")){ + return; + } contract.put("has_sign", 1); clientsContractMapper.update(contract); Date now = new Date(); From 759c752455b87117cdba0272472dfdf46f56c103 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 18:49:54 +0800 Subject: [PATCH 14/30] update --- .../core/impls/ClientManagerImpl.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 87d19dbf5..887f2150f 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 @@ -3123,33 +3123,32 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid 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,config.getString("sys_contract_ordinary_waring"))); + String[] key = { result.getString("expire_days") }; + result.put("contract_info", editContractOrdinaryWaring(key, config.getString("sys_contract_ordinary_waring"))); } if (expire) { - result.put("contract_info",config.getString("sys_contract_ordinary_info")); + result.put("contract_info", config.getString("sys_contract_ordinary_info")); } return result; - } - if (!(PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER)) { + } else { + result.put("contract_info", config.getString("sys_contract_info")); result.put("is_ordinary", false); if (!expire && waring) { - String[] key = {result.getString("expire_days")}; + String[] key = { result.getString("expire_days") }; result.put("contract_info", editContractOrdinaryWaring(key, config.getString("sys_contract_waring"))); } if (expire) { result.put("contract_info", config.getString("sys_contract_info")); } + JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id")); + result.put("file_url", file.getString("file_value")); return result; } - JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id")); - result.put("file_url", file.getString("file_value")); - result.put("contract_info", config.getString("sys_contract_info")); - return result; + } private String editContractOrdinaryWaring(String[] key, String sourceStr) { - if(StringUtils.isEmpty(sourceStr) || ArrayUtils.isEmpty(key)){ + if (StringUtils.isEmpty(sourceStr) || ArrayUtils.isEmpty(key)) { return ""; } for (int i = 0; i < key.length; i++) { From 7de1eed4567eac052599a934f6d67d6ace657fc6 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Thu, 8 Mar 2018 19:01:02 +0800 Subject: [PATCH 15/30] update --- .../system/core/impl/ClientContractServiceImpl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 0e7beed7d..41ab4124c 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 @@ -117,8 +117,8 @@ public class ClientContractServiceImpl implements ClientContractService { rateInfo.forEach((p)->{ p.remove("client_rate_id"); p.put("create_time",now); - p.put("active_time",DateUtils.addYears(p.getDate("active_time"),1)); - p.put("expiry_time",DateUtils.addYears(p.getDate("expiry_time"),1)); + p.put("active_time",DateUtils.addDays(p.getDate("active_time"),1)); + p.put("expiry_time",DateUtils.addYears(p.getDate("active_time"),1)); clientRateMapper.saveRate(p); }); } @@ -163,7 +163,14 @@ public class ClientContractServiceImpl implements ClientContractService { result.put("rate_waring", true); } }); - result.put("expire_days",(int)(rateInfo.get(0).getDate("expiry_time").getTime()-now.getTime())/(1000*60*60*24)); + int expireDay = 0; + long expireSS = (rateInfo.get(0).getDate("expiry_time").getTime()-now.getTime()); + expireDay = (int)expireSS/(1000*60*60*24); + + if(expireSS%(1000*60*60*24)>1){ + ++expireDay; + } + result.put("expire_days",expireDay); return result; } } From 15fd0edfc536681f756d68e54322db39ae91f18c Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 09:24:38 +0800 Subject: [PATCH 16/30] update --- .../core/impls/RetailAppServiceImp.java | 42 +++++++++++++++---- .../core/impl/ClientContractServiceImpl.java | 17 ++++---- 2 files changed, 44 insertions(+), 15 deletions(-) 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 39aaaa78c..8b946e3b1 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 @@ -53,6 +53,7 @@ import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; @@ -1339,15 +1340,33 @@ public class RetailAppServiceImp implements RetailAppService { @Override public JSONObject getCheckClientInfo(JSONObject device) { JSONObject result = clientContractService.getClientContractExpire(device.getIntValue("client_id")); - JSONObject account = clientAccountMapper.findById(device.getString("account_id")); - if(PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER){ - result.put("is_ordinary",true); + JSONObject config = sysConfigManager.getSysConfig(); + boolean expire = result.getBoolean("rate_expire"); + boolean waring = result.getBoolean("rate_waring"); + if (PartnerRole.getRole(device.getIntValue("role")) == PartnerRole.CASHIER) { + result.put("is_ordinary", true); + if (!expire && waring) { + String[] key = { result.getString("expire_days") }; + result.put("contract_info", editContractOrdinaryWaring(key, config.getString("sys_contract_ordinary_waring"))); + } + if (expire) { + result.put("contract_info", config.getString("sys_contract_ordinary_info")); + } + return result; + } else { + result.put("contract_info", config.getString("sys_contract_info")); + result.put("is_ordinary", false); + if (!expire && waring) { + String[] key = { result.getString("expire_days") }; + result.put("contract_info", editContractOrdinaryWaring(key, config.getString("sys_contract_waring"))); + } + if (expire) { + result.put("contract_info", config.getString("sys_contract_info")); + } + JSONObject file = clientContractService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); + result.put("file_url", file.getString("file_value")); return result; } - JSONObject file = clientContractService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); - result.put("file_url", file.getString("file_value")); - result.put("contract_info",sysConfigManager.getSysConfig().getString("sys_contract_info")); - return result; } private static boolean mathchLetterorNum(String str) { @@ -1355,4 +1374,13 @@ public class RetailAppServiceImp implements RetailAppService { return str.matches(regex); } + private String editContractOrdinaryWaring(String[] key, String sourceStr) { + if (StringUtils.isEmpty(sourceStr) || ArrayUtils.isEmpty(key)) { + return ""; + } + for (int i = 0; i < key.length; i++) { + sourceStr = sourceStr.replace("{" + i + "}", key[i]); + } + return sourceStr; + } } 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 41ab4124c..e4a59299d 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 @@ -47,14 +47,9 @@ public class ClientContractServiceImpl implements ClientContractService { throw new NotFoundException("merchant not found"); } JSONObject expireInfo = getClientContractExpire(client_id); - if(expireInfo.getBoolean("rate_waring")){ - List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); - return files.get(0); - } - JSONObject contract = clientsContractMapper.findByClientId(client_id); Date now = new Date(); - if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0 ) { + if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) { try { clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null); } catch (Exception e) { @@ -90,6 +85,10 @@ public class ClientContractServiceImpl implements ClientContractService { @Override @Transactional public void confirmSourceAgreement(int client_id) { + JSONObject client = clientManager.getClientInfo(client_id); + 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"); @@ -109,6 +108,7 @@ public class ClientContractServiceImpl implements ClientContractService { p.remove("client_rate_id"); p.put("create_time",now); p.put("active_time",now); + p.put("update_time",now); p.put("expiry_time",DateUtils.addYears(now,1)); clientRateMapper.saveRate(p); }); @@ -117,12 +117,13 @@ public class ClientContractServiceImpl implements ClientContractService { rateInfo.forEach((p)->{ p.remove("client_rate_id"); p.put("create_time",now); + p.put("update_time",now); p.put("active_time",DateUtils.addDays(p.getDate("active_time"),1)); - p.put("expiry_time",DateUtils.addYears(p.getDate("active_time"),1)); + p.put("expiry_time",DateUtils.addYears(p.getDate("expiry_time"),1)); clientRateMapper.saveRate(p); }); } - + clientManager.setClientTaxInSurcharge(client.getString("client_moniker"),true); } @Override From 65975c4f6e8177ea4854262c14945ecc28cc6ae5 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 10:20:19 +0800 Subject: [PATCH 17/30] update --- .../manage/appclient/web/RetailAppController.java | 2 +- .../merchants/web/PartnerManageController.java | 2 +- .../manage/system/core/ClientContractService.java | 2 +- .../system/core/impl/ClientContractServiceImpl.java | 13 ++++++++++--- 4 files changed, 13 insertions(+), 6 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 dcab8dfbf..e3806f093 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 @@ -345,6 +345,6 @@ public class RetailAppController { @RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST) public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - clientContractService.confirmSourceAgreement(device.getIntValue("client_id")); + clientContractService.confirmSourceAgreement(device.getIntValue("client_id"),device.getString("account_id")); } } 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 a6d19ba52..379016e93 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 @@ -532,6 +532,6 @@ public class PartnerManageController { @PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST) public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { - clientContractService.confirmSourceAgreement(account.getIntValue("client_id")); + clientContractService.confirmSourceAgreement(account.getIntValue("client_id"),account.getString("account_id")); } } 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 ca4eacb0f..3b7804ee1 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 @@ -6,7 +6,7 @@ public interface ClientContractService { JSONObject getOrGenerateSourceAgreement(int client_id); - void confirmSourceAgreement(int client_id); + void confirmSourceAgreement(int client_id,String account_id); JSONObject getSourceAgreement(int client_id); 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 e4a59299d..f053245a4 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 @@ -1,5 +1,6 @@ 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; @@ -38,6 +39,8 @@ public class ClientContractServiceImpl implements ClientContractService { private ClientRateMapper clientRateMapper; @Resource private SysConfigManager sysConfigManager; + @Resource + private ClientAccountMapper clientAccountMapper; @Override @Transactional @@ -84,7 +87,7 @@ public class ClientContractServiceImpl implements ClientContractService { @Override @Transactional - public void confirmSourceAgreement(int client_id) { + public void confirmSourceAgreement(int client_id,String account_id) { JSONObject client = clientManager.getClientInfo(client_id); if (client == null) { throw new NotFoundException("merchant not found"); @@ -99,7 +102,11 @@ public class ClientContractServiceImpl implements ClientContractService { if(contract.getBoolean("has_sign")){ return; } + JSONObject account = clientAccountMapper.findById(account_id); + contract.put("has_sign", 1); + contract.put("sign_account_id",account_id); + contract.put("signatory",account.getString("display_name")); clientsContractMapper.update(contract); Date now = new Date(); List rateInfo = clientRateMapper.minExpiryTime(client_id, null); @@ -118,8 +125,8 @@ public class ClientContractServiceImpl implements ClientContractService { p.remove("client_rate_id"); p.put("create_time",now); p.put("update_time",now); - p.put("active_time",DateUtils.addDays(p.getDate("active_time"),1)); - p.put("expiry_time",DateUtils.addYears(p.getDate("expiry_time"),1)); + p.put("active_time",DateUtils.addDays(p.getDate("expiry_time"),1)); + p.put("expiry_time",DateUtils.addYears(p.getDate("active_time"),1)); clientRateMapper.saveRate(p); }); } From e772fef8c3866e55f666a778f12e9f5c70e44560 Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Fri, 9 Mar 2018 10:29:59 +0800 Subject: [PATCH 18/30] new act --- src/main/ui/static/boot/indexMainApp.js | 33 ++++++++++++++++--- .../static/commons/templates/ag_detail.html | 6 ++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/main/ui/static/boot/indexMainApp.js b/src/main/ui/static/boot/indexMainApp.js index 412e25bce..8f9c2e399 100644 --- a/src/main/ui/static/boot/indexMainApp.js +++ b/src/main/ui/static/boot/indexMainApp.js @@ -115,10 +115,11 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo ag: ag }, size: 'lg', + type:'info', backdrop:'static', keyboard:false }).result.then(function () { - $scope.loadPartnerNotice(); + // $scope.loadPartnerNotice(); }) }; @@ -127,9 +128,27 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo // $scope.rate_expire = resp.data.rate_expire; $scope.rate_waring = resp.data.rate_waring; // $scope.file_url = resp.data.file_url; - if($scope.rate_waring){ - $scope.showAG(resp.data); + if (resp.data.is_ordinary){ + if($scope.rate_waring){ + commonDialog.alert({ + title: 'Contract expiration notice', + content: resp.data.contract_info, + size:'lg', + type:'info' + + }).then(function () { + if (resp.data.rate_expire){ + location.href = 'login.html' + } + }) + } + + }else { + if($scope.rate_waring){ + $scope.showAG(resp.data); + } } + }); }; $scope.getAgStatus(); @@ -307,8 +326,9 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo $scope.agreeCheck = false; $scope.agree = function () { $http.post('/sys/partners/agree/confirm').then(function () { - }, function (resp) { $scope.$close(); + }, function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}); }) }; $scope.notAgree = function () { @@ -548,6 +568,11 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo return roles.indexOf($rootScope.currentUser.role) >= 0; } }]); + app.filter("trustUrl", ['$sce', function ($sce) { + return function (recordingUrl) { + return $sce.trustAsResourceUrl(recordingUrl); + }; + }]); app.constant('uiDatetimePickerConfig', { dateFormat: 'yyyy-MM-dd HH:mm', diff --git a/src/main/ui/static/commons/templates/ag_detail.html b/src/main/ui/static/commons/templates/ag_detail.html index 883e43529..90ffdca31 100644 --- a/src/main/ui/static/commons/templates/ag_detail.html +++ b/src/main/ui/static/commons/templates/ag_detail.html @@ -1,10 +1,12 @@ @@ -13,7 +15,7 @@ - + From e7785b46994f1a9c841bc452e4f2d557b867e55a Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 11:08:28 +0800 Subject: [PATCH 19/30] update --- .../manage/system/core/impl/ClientContractServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 f053245a4..acf759073 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 @@ -164,15 +164,15 @@ public class ClientContractServiceImpl implements ClientContractService { } int waringDays = sysConfigManager.getSysConfig().getIntValue("rate_warning_days"); rateInfo.forEach((p) -> { - if (now.compareTo(p.getDate("expiry_time")) > -1) { + if (now.compareTo(DateUtils.addDays(p.getDate("expiry_time"),1)) > -1) { result.put("rate_expire", true); } - if (DateUtils.addDays(now, waringDays).compareTo(p.getDate("expiry_time")) > -1) { + if (DateUtils.addDays(now, waringDays).compareTo(DateUtils.addDays(p.getDate("expiry_time"),1)) > -1) { result.put("rate_waring", true); } }); int expireDay = 0; - long expireSS = (rateInfo.get(0).getDate("expiry_time").getTime()-now.getTime()); + long expireSS = (DateUtils.addDays(rateInfo.get(0).getDate("expiry_time"),1).getTime()-now.getTime()); expireDay = (int)expireSS/(1000*60*60*24); if(expireSS%(1000*60*60*24)>1){ From 8f5e2db5a5500f61ca52d2df56af2a60179a4a09 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 12:08:15 +0800 Subject: [PATCH 20/30] update --- .../manage/system/core/impl/ClientContractServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 acf759073..6bad0c751 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 @@ -130,7 +130,7 @@ public class ClientContractServiceImpl implements ClientContractService { clientRateMapper.saveRate(p); }); } - clientManager.setClientTaxInSurcharge(client.getString("client_moniker"),true); + clientManager.setClientTaxInSurcharge(client.getString("client_moniker"),false); } @Override From 900f31a2c6b204d441547eeb6789850b901739f0 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 13:57:40 +0800 Subject: [PATCH 21/30] update --- .../core/impls/RetailAppServiceImp.java | 30 +------------------ .../manage/merchants/core/ClientManager.java | 2 +- .../core/impls/ClientManagerImpl.java | 7 +++-- .../web/PartnerManageController.java | 2 +- .../system/core/ClientContractService.java | 2 +- .../core/impl/ClientContractServiceImpl.java | 8 ++--- 6 files changed, 12 insertions(+), 39 deletions(-) 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 8b946e3b1..dfc439376 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 @@ -1339,36 +1339,8 @@ public class RetailAppServiceImp implements RetailAppService { @Override public JSONObject getCheckClientInfo(JSONObject device) { - JSONObject result = clientContractService.getClientContractExpire(device.getIntValue("client_id")); - JSONObject config = sysConfigManager.getSysConfig(); - boolean expire = result.getBoolean("rate_expire"); - boolean waring = result.getBoolean("rate_waring"); - if (PartnerRole.getRole(device.getIntValue("role")) == PartnerRole.CASHIER) { - result.put("is_ordinary", true); - if (!expire && waring) { - String[] key = { result.getString("expire_days") }; - result.put("contract_info", editContractOrdinaryWaring(key, config.getString("sys_contract_ordinary_waring"))); - } - if (expire) { - result.put("contract_info", config.getString("sys_contract_ordinary_info")); - } - return result; - } else { - result.put("contract_info", config.getString("sys_contract_info")); - result.put("is_ordinary", false); - if (!expire && waring) { - String[] key = { result.getString("expire_days") }; - result.put("contract_info", editContractOrdinaryWaring(key, config.getString("sys_contract_waring"))); - } - if (expire) { - result.put("contract_info", config.getString("sys_contract_info")); - } - JSONObject file = clientContractService.getOrGenerateSourceAgreement(device.getIntValue("client_id")); - result.put("file_url", file.getString("file_value")); - return result; - } + clientManager.getCheckClientInfo(device.getIntValue("client_id"), device.getString("account_id")); } - private static boolean mathchLetterorNum(String str) { String regex = "[A-Za-z0-9]{8}"; return str.matches(regex); 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 41947c5ec..41a9240aa 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 @@ -284,5 +284,5 @@ public interface ClientManager { void clearCacheSubMerchantIdApplices(String clientMoniker); - JSONObject getCheckClientInfo(JSONObject account); + JSONObject getCheckClientInfo(int client_id,String account_id); } 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 887f2150f..4623b9302 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 @@ -3115,9 +3115,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } @Override - public JSONObject getCheckClientInfo(JSONObject account) { - JSONObject result = clientContractService.getClientContractExpire(account.getIntValue("client_id")); + public JSONObject getCheckClientInfo(int client_id,String account_id) { + JSONObject result = clientContractService.getClientContractExpire(client_id); JSONObject config = sysConfigManager.getSysConfig(); + JSONObject account = clientAccountMapper.findById(account_id); boolean expire = result.getBoolean("rate_expire"); boolean waring = result.getBoolean("rate_waring"); if (PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) { @@ -3140,7 +3141,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (expire) { result.put("contract_info", config.getString("sys_contract_info")); } - JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id")); + JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id"),"pc"); result.put("file_url", file.getString("file_value")); return result; } 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 379016e93..105b0aa42 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 @@ -527,7 +527,7 @@ public class PartnerManageController { @PartnerMapping(value = "/check", method = RequestMethod.GET) public JSONObject getCheckClientInfo(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { - return clientManager.getCheckClientInfo(account); + return clientManager.getCheckClientInfo(account.getIntValue("client_id"),account.getString("account_id")); } @PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST) 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 3b7804ee1..83989dd62 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 @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject; public interface ClientContractService { - JSONObject getOrGenerateSourceAgreement(int client_id); + JSONObject getOrGenerateSourceAgreement(int client_id,String channel); void confirmSourceAgreement(int client_id,String account_id); 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 6bad0c751..400f5d8c1 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 @@ -44,7 +44,7 @@ public class ClientContractServiceImpl implements ClientContractService { @Override @Transactional - public JSONObject getOrGenerateSourceAgreement(int client_id) { + public JSONObject getOrGenerateSourceAgreement(int client_id,String channel) { JSONObject client = clientManager.getClientInfo(client_id); if (client == null) { throw new NotFoundException("merchant not found"); @@ -60,7 +60,7 @@ public class ClientContractServiceImpl implements ClientContractService { throw new ServerErrorException("System error"); } List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); - saveContract(client_id, now); + saveContract(client_id, now,channel); return files.get(0); } else { List files = clientFilesMapper.findFileByClientAndType(client_id, "source_agree_file"); @@ -75,11 +75,11 @@ public class ClientContractServiceImpl implements ClientContractService { } - private void saveContract(int client_id, Date now) { + private void saveContract(int client_id, Date now,String channel) { JSONObject newContract = new JSONObject(); newContract.put("create_time", now); newContract.put("expiry_date", DateUtils.addYears(now, 1)); - newContract.put("sign_channel", "App"); + newContract.put("sign_channel", channel); newContract.put("client_id", client_id); newContract.put("has_sign", false); clientsContractMapper.save(newContract); From ff32f2cad2b26a09a67275ee86288a3dca30b733 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 13:59:05 +0800 Subject: [PATCH 22/30] update --- .../manage/appclient/core/impls/RetailAppServiceImp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 dfc439376..824135e54 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 @@ -1339,7 +1339,7 @@ public class RetailAppServiceImp implements RetailAppService { @Override public JSONObject getCheckClientInfo(JSONObject device) { - clientManager.getCheckClientInfo(device.getIntValue("client_id"), device.getString("account_id")); + return clientManager.getCheckClientInfo(device.getIntValue("client_id"), device.getString("account_id")); } private static boolean mathchLetterorNum(String str) { String regex = "[A-Za-z0-9]{8}"; From 55bad532b4bb5a8fd11382da9f6bffd9ae2b7fcb Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 14:22:01 +0800 Subject: [PATCH 23/30] sign channel --- .../payment/manage/appclient/web/RetailAppController.java | 2 +- .../payment/manage/merchants/web/PartnerManageController.java | 3 +-- .../payment/manage/system/core/ClientContractService.java | 2 +- .../manage/system/core/impl/ClientContractServiceImpl.java | 3 ++- 4 files changed, 5 insertions(+), 5 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 e3806f093..bc6589931 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 @@ -345,6 +345,6 @@ public class RetailAppController { @RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST) public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - clientContractService.confirmSourceAgreement(device.getIntValue("client_id"),device.getString("account_id")); + clientContractService.confirmSourceAgreement(device.getIntValue("client_id"),device.getString("account_id"),"App"); } } 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 105b0aa42..0f929319f 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 @@ -20,7 +20,6 @@ import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; -import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import com.alibaba.fastjson.JSONObject; @@ -532,6 +531,6 @@ public class PartnerManageController { @PartnerMapping(value = "/agree/confirm", method = RequestMethod.POST) public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { - clientContractService.confirmSourceAgreement(account.getIntValue("client_id"),account.getString("account_id")); + clientContractService.confirmSourceAgreement(account.getIntValue("client_id"),account.getString("account_id"),"PC"); } } 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 83989dd62..9f57b23ea 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 @@ -6,7 +6,7 @@ public interface ClientContractService { JSONObject getOrGenerateSourceAgreement(int client_id,String channel); - void confirmSourceAgreement(int client_id,String account_id); + void confirmSourceAgreement(int client_id,String account_id,String channel); JSONObject getSourceAgreement(int client_id); 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 400f5d8c1..df8c4a87b 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 @@ -87,7 +87,7 @@ public class ClientContractServiceImpl implements ClientContractService { @Override @Transactional - public void confirmSourceAgreement(int client_id,String account_id) { + public void confirmSourceAgreement(int client_id,String account_id,String channel) { JSONObject client = clientManager.getClientInfo(client_id); if (client == null) { throw new NotFoundException("merchant not found"); @@ -106,6 +106,7 @@ public class ClientContractServiceImpl implements ClientContractService { contract.put("has_sign", 1); contract.put("sign_account_id",account_id); + contract.put("sign_channel",channel); contract.put("signatory",account.getString("display_name")); clientsContractMapper.update(contract); Date now = new Date(); From f79085be543f04e3c6143003124f821470629a40 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 16:48:59 +0800 Subject: [PATCH 24/30] update --- .../manage/system/core/impl/ClientContractServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) 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 df8c4a87b..2d926d0ad 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 @@ -118,6 +118,7 @@ public class ClientContractServiceImpl implements ClientContractService { p.put("active_time",now); p.put("update_time",now); p.put("expiry_time",DateUtils.addYears(now,1)); + p.put("manager_name","merchant"+account_id+account.getString("display_name")); clientRateMapper.saveRate(p); }); } @@ -126,6 +127,7 @@ public class ClientContractServiceImpl implements ClientContractService { p.remove("client_rate_id"); p.put("create_time",now); p.put("update_time",now); + p.put("manager_name","merchant"+account_id+account.getString("display_name")); p.put("active_time",DateUtils.addDays(p.getDate("expiry_time"),1)); p.put("expiry_time",DateUtils.addYears(p.getDate("active_time"),1)); clientRateMapper.saveRate(p); From c2b9fc64241824b13073f8d30704bb0a9df65ce9 Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 17:00:57 +0800 Subject: [PATCH 25/30] update --- .../manage/merchants/core/ClientManager.java | 4 ++-- .../merchants/core/impls/ClientManagerImpl.java | 14 ++++++++------ .../merchants/web/PartnerManageController.java | 4 ++-- .../core/impl/ClientContractServiceImpl.java | 2 +- 4 files changed, 13 insertions(+), 11 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 41a9240aa..3e0825e09 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 @@ -256,11 +256,11 @@ public interface ClientManager { void getAgreeFile(String clientMoniker, JSONObject manager) throws Exception; - void getAggregateAgreeFile(String clientMoniker, JSONObject manager) throws Exception; + void getAggregateAgreeFile(String clientMoniker, JSONObject manager,boolean renewal) throws Exception; void temporaryExportPdf(String clientMoniker, JSONObject manager, HttpServletResponse httpResponse) throws Exception; - void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile); + void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile,boolean renewal); void completeAgree(String clientMoniker, JSONObject manager); 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 4623b9302..6f3c2c799 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 @@ -1865,7 +1865,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid ByteArrayOutputStream bos = pdu.templetPdfBos(file); stream = new ByteArrayInputStream(bos.toByteArray()); JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker + "_agreement.pdf", false); - importAgreeFile(clientMoniker, manager, fileRes.getString("url")); + importAgreeFile(clientMoniker, manager, fileRes.getString("url"),false); } catch (Exception e) { logger.error("合同制作出现问题:", e); } finally { @@ -1875,7 +1875,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override @Transactional - public void getAggregateAgreeFile(String clientMoniker, JSONObject manager) throws Exception { + public void getAggregateAgreeFile(String clientMoniker, JSONObject manager,boolean renewal) throws Exception { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); @@ -1933,7 +1933,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid InputStream stream = new ByteArrayInputStream(bos.toByteArray()); JSONObject fileRes = attachmentClient.uploadFile(stream, clientMoniker + "_" + System.currentTimeMillis() + "_agreement.pdf", false); if (fileRes != null) { - importAgreeFile(clientMoniker, manager, fileRes.getString("url")); + importAgreeFile(clientMoniker, manager, fileRes.getString("url"),renewal); } stream.close(); } catch (Exception e) { @@ -2019,7 +2019,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override @Transactional - public void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile) { + public void importAgreeFile(String clientMoniker, JSONObject manager, String sourceFile,boolean renewal) { JSONObject client = getClientInfoByMoniker(clientMoniker); if (client == null) { throw new InvalidShortIdException(); @@ -2048,8 +2048,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid file.put("file_id", existFile.getString("file_id")); clientFilesMapper.update(file); } - client.put("open_status", 2); - clientMapper.update(client); + if(!renewal) { + client.put("open_status", 2); + clientMapper.update(client); + } if (manager != null) { saveClientAuditProcess(client.getIntValue("client_id"), 1, 2, "Compliance合同制作中", manager); 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 0f929319f..5343e2075 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 @@ -439,7 +439,7 @@ public class PartnerManageController { @ManagerMapping(value = "/{clientMoniker}/export/aggregate/agreepdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR}) public void exportAggregateAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) throws Exception { - clientManager.getAggregateAgreeFile(clientMoniker, manager); + clientManager.getAggregateAgreeFile(clientMoniker, manager,false); } @ManagerMapping(value = "/{clientMoniker}/temp/export/pdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.DIRECTOR, ManagerRole.OPERATOR}) @@ -449,7 +449,7 @@ public class PartnerManageController { @ManagerMapping(value = "/{clientMoniker}/import/agreepdf", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR}) public void importAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody JSONObject source) throws Exception { - clientManager.importAgreeFile(clientMoniker, manager, source.getString("source_agree_file")); + clientManager.importAgreeFile(clientMoniker, manager, source.getString("source_agree_file"),false); } @ManagerMapping(value = "/{clientMoniker}/notify/completeAgree", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR}) 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 2d926d0ad..5d6fb081a 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 @@ -54,7 +54,7 @@ public class ClientContractServiceImpl implements ClientContractService { Date now = new Date(); if (contract == null || now.compareTo(contract.getDate("expiry_date")) > 0) { try { - clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null); + clientManager.getAggregateAgreeFile(client.getString("client_moniker"), null,true); } catch (Exception e) { logger.info("App generate PDF failed"); throw new ServerErrorException("System error"); From b10606486bb89d6cbb7efc792e0c6f0ba1705cee Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 17:18:20 +0800 Subject: [PATCH 26/30] update sql --- src/db/modify.sql | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/db/modify.sql b/src/db/modify.sql index ad0031246..e8884c049 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -236,4 +236,29 @@ alter table statistics_customer_order add column refund_orders int(10) DEFAULT N alter table statistics_customer_order add column refund_amount DECIMAL(20,2) DEFAULT NULL COMMENT '' AFTER `total`; ALTER TABLE `financial_bd_prize_log` - MODIFY COLUMN `manager_id` varchar(50) NOT NULL COMMENT 'bd user id' AFTER `record_id`; \ No newline at end of file + MODIFY COLUMN `manager_id` varchar(50) NOT NULL COMMENT 'bd user id' AFTER `record_id`; + + + + + +ALTER TABLE sys_files DROP INDEX UK_sys_files; + +create table sys_clients_contract( +id varchar(50) not null, +client_id int(11) not null, +create_time datetime not null, +expiry_date date not null, +has_sign TINYINT(1) DEFAULT 0 not null, +sign_channel varchar(10) not null , +sign_account_id varchar(50) DEFAULT null, +signatory varchar(20) DEFAULT null, +PRIMARY key (`id`) +); + +insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'sys_contract_info', '您与RoyalPay的合约到期'); +insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'sys_contract_waring', '您与RoyalPay的合约还有{0}到期'); +insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'sys_contract_ordinary_waring', '您与RoyalPay的合约还有{0}到期 +请联系管理员重新签订合同'); +insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'sys_contract_ordinary_info', '您与RoyalPay的合约已经到期 +请联系管理员重新签订合同'); \ No newline at end of file From 81fb75377f591711187110d4640d9d204a17c0ae Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 17:31:39 +0800 Subject: [PATCH 27/30] update --- .../manage/system/core/impl/ClientContractServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 5d6fb081a..502d87bc2 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 @@ -117,8 +117,9 @@ public class ClientContractServiceImpl implements ClientContractService { 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")); + p.put("manager_name","merchant_"+account_id+"_"+account.getString("display_name")); clientRateMapper.saveRate(p); }); } @@ -126,8 +127,9 @@ public class ClientContractServiceImpl implements ClientContractService { rateInfo.forEach((p)->{ p.remove("client_rate_id"); p.put("create_time",now); + p.put("manager_id","0"); p.put("update_time",now); - p.put("manager_name","merchant"+account_id+account.getString("display_name")); + p.put("manager_name","merchant_"+account_id+"_"+account.getString("display_name")); p.put("active_time",DateUtils.addDays(p.getDate("expiry_time"),1)); p.put("expiry_time",DateUtils.addYears(p.getDate("active_time"),1)); clientRateMapper.saveRate(p); From 7ab8a06feb4c3f1ad899535a45bf5bc944c73f5f Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 18:11:56 +0800 Subject: [PATCH 28/30] updateupdate --- .../merchants/core/impls/ClientManagerImpl.java | 13 ++++++++----- src/main/resources/i18n/msg_en.properties | 4 ++++ src/main/resources/i18n/msg_zh.properties | 7 ++++++- 3 files changed, 18 insertions(+), 6 deletions(-) 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 6f3c2c799..386be760f 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 @@ -50,6 +50,7 @@ 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; @@ -93,6 +94,7 @@ import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; +import org.springframework.context.MessageSource; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -212,6 +214,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private ClientsContractMapper clientsContractMapper; @Resource private ClientContractService clientContractService; + @Resource + private MessageSource messageSource; private static final String SOURCE_AGREE_FILE = "source_agree_file"; private static final String CLIENT_BANK_FILE = "client_bank_file"; @@ -3127,21 +3131,20 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid result.put("is_ordinary", true); if (!expire && waring) { String[] key = { result.getString("expire_days") }; - result.put("contract_info", editContractOrdinaryWaring(key, config.getString("sys_contract_ordinary_waring"))); + result.put("contract_info", editContractOrdinaryWaring(key, messageSource.getMessage("sys.contract.ordinary.waring", null, RequestEnvironment.getLocale()))); } if (expire) { - result.put("contract_info", config.getString("sys_contract_ordinary_info")); + result.put("contract_info", messageSource.getMessage("sys.contract.ordinary.info", null, RequestEnvironment.getLocale())); } return result; } else { - result.put("contract_info", config.getString("sys_contract_info")); result.put("is_ordinary", false); if (!expire && waring) { String[] key = { result.getString("expire_days") }; - result.put("contract_info", editContractOrdinaryWaring(key, config.getString("sys_contract_waring"))); + result.put("contract_info", messageSource.getMessage("sys.contract.waring", null, RequestEnvironment.getLocale())); } if (expire) { - result.put("contract_info", config.getString("sys_contract_info")); + result.put("contract_info", messageSource.getMessage("sys.contract.info", null, RequestEnvironment.getLocale())); } JSONObject file = clientContractService.getOrGenerateSourceAgreement(account.getIntValue("client_id"),"pc"); result.put("file_url", file.getString("file_value")); diff --git a/src/main/resources/i18n/msg_en.properties b/src/main/resources/i18n/msg_en.properties index 4eed85d8e..1ea334469 100644 --- a/src/main/resources/i18n/msg_en.properties +++ b/src/main/resources/i18n/msg_en.properties @@ -101,3 +101,7 @@ app.label.close=Close app.label.coupons=Available Coupons +sys.contract.ordinary.info=Dear merchant, your service contract with ROYALPAY has expired. In order not to affect your normal use, please contact your supervisor or use your administrator account as soon as possible for service renewal. +sys.contract.ordinary.waring=Dear merchant, your service contract with ROYALPAY expires in {0} days. In order not to affect your normal use, please contact your supervisor or use your administrator account as soon as possible in order to renew your service contract. +sys.contract.waring=Dear merchant, your service contract with ROYALPAY is due to expire in {0} days. In order not to affect your normal use, please see the latest service agreement for renewal. +sys.contract.info=Dear merchant, your service contract with ROYALPAY has expired. Please check the latest service agreement to renew your contract so as not to affect your normal use. \ No newline at end of file diff --git a/src/main/resources/i18n/msg_zh.properties b/src/main/resources/i18n/msg_zh.properties index e91b8532e..a2a041316 100644 --- a/src/main/resources/i18n/msg_zh.properties +++ b/src/main/resources/i18n/msg_zh.properties @@ -93,4 +93,9 @@ app.label.pay=支付 app.label.remark=备注 app.label.creating-order=... app.label.close=关闭 -app.label.coupons=可用优惠券 \ No newline at end of file +app.label.coupons=可用优惠券 + +sys.contract.ordinary.info=尊敬的商户,您与ROYALPAY的服务合同已到期,为了不影响您的正常使用,请尽快联系您的主管或使用管理员账户登录以便进行服务续约 +sys.contract.ordinary.waring=尊敬的商户,您与ROYALPAY的服务合同还有{0}天到期,为了不影响您的正常使用,请尽快联系您的主管或使用管理员账户登录以便进行服务续约 +sys.contract.waring=尊敬的商户,您与ROYALPAY的服务合同还有{0}天到期,为了不影响您的正常使用,请查看最新服务协议进行续约。 +sys.contract.info=尊敬的商户,您与ROYALPAY的服务合同已到期,为了不影响您的正常使用,请查看最新服务协议进行续约。 \ No newline at end of file From ab94d6051226875e6521c03b68913e963f6b09be Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 9 Mar 2018 18:14:46 +0800 Subject: [PATCH 29/30] update --- src/db/modify.sql | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/db/modify.sql b/src/db/modify.sql index e8884c049..c9c30fa27 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -254,11 +254,4 @@ sign_channel varchar(10) not null , sign_account_id varchar(50) DEFAULT null, signatory varchar(20) DEFAULT null, PRIMARY key (`id`) -); - -insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'sys_contract_info', '您与RoyalPay的合约到期'); -insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'sys_contract_waring', '您与RoyalPay的合约还有{0}到期'); -insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'sys_contract_ordinary_waring', '您与RoyalPay的合约还有{0}到期 -请联系管理员重新签订合同'); -insert into `royalpay_production`.`sys_configs` ( `config_key`, `config_value`) values ( 'sys_contract_ordinary_info', '您与RoyalPay的合约已经到期 -请联系管理员重新签订合同'); \ No newline at end of file +); \ No newline at end of file From bce19956337d3bf451db2ec9c6ff35da2c8c79d2 Mon Sep 17 00:00:00 2001 From: "eason.qian" Date: Fri, 9 Mar 2018 18:25:42 +0800 Subject: [PATCH 30/30] fix --- .../payment/manage/merchants/core/impls/ClientManagerImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 386be760f..3cfb5f1cd 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 @@ -3123,7 +3123,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public JSONObject getCheckClientInfo(int client_id,String account_id) { JSONObject result = clientContractService.getClientContractExpire(client_id); - JSONObject config = sysConfigManager.getSysConfig(); JSONObject account = clientAccountMapper.findById(account_id); boolean expire = result.getBoolean("rate_expire"); boolean waring = result.getBoolean("rate_waring"); @@ -3141,7 +3140,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid result.put("is_ordinary", false); if (!expire && waring) { String[] key = { result.getString("expire_days") }; - result.put("contract_info", messageSource.getMessage("sys.contract.waring", null, RequestEnvironment.getLocale())); + 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()));