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