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 9522dc305..5efe41b4d 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 @@ -206,9 +206,11 @@ public class RetailAppServiceImp implements RetailAppService { @Resource private AttachmentClient attachmentClient; @Resource + private ClientBankAccountMapper clientBankAccountMapper; + @Resource private StringRedisTemplate stringRedisTemplate; private final String CBBANK_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/05/1564972204689_uwZvpTBjtLUMcN8c540xcZvux1Rd3O.pdf"; - private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/16/1565936989217_WDSAGRKhBHTD6s6HGcZPeirOXCyzbn.pdf"; + private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/22/1566440384256_R7Jc3cl5JPZsmVznKffzStwVMELwsl.pdf"; @Resource private SmsSender smsSender; @@ -2204,7 +2206,7 @@ public class RetailAppServiceImp implements RetailAppService { client.put("bank_account_number", bankAccount.getString("account_no")); client.put("bank_account_name", bankAccount.getString("account_name")); } - exportAggregateFile(client, httpResponse); + exportCBBankAggregateFile(client, httpResponse); } @Override @@ -2220,32 +2222,69 @@ public class RetailAppServiceImp implements RetailAppService { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); - client.put("now", DateFormatUtils.format(new Date(), "yyyy-MM-dd")); - String clientName = ""; - clientName = client.getString("business_name"); - if (StringUtils.isNotBlank(client.getString("acn"))) { - clientName += "(" + client.getString("acn") + ")"; - client.put("client_acn", client.getString("acn")); - } - client.put("client_name", clientName); - client.put("bd_name", client.getString("bd_user_name")); - client.put("client_phone", client.getString("contact_phone")); - client.put("client_email", client.getString("contact_email")); - client.put("client_address", (client.getString("address") + "\n" + client.getString("suburb") + ' ' + client.getString("state") + ' ' + client.getString("postcode"))); - JSONObject rate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay"); - if (rate != null) { - client.put("client_rate", (rate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN).toPlainString() + "%")); - int cleanDays = rate.getIntValue("clean_days"); - client.put("clean_days", ("T+" + cleanDays)); - client.put("days", cleanDays); + String address = client.getString("address").trim(); + if (address.contains(",")) { + client.put("address", address.substring(0, address.lastIndexOf(",")).trim()); + client.put("address_sub", address.substring(address.lastIndexOf(",") + 1).trim()); + } + if (client.getString("acn") != null && !client.getString("acn").equals("")) { + client.put("acn_type", "ACN: (" + client.getString("acn") + ")"); + client.put("company_name_acn", client.getString("company_name") + " (ACN " + client.getString("acn") + ")"); + } else { + client.put("acn_type", "ABN: (" + client.getString("abn") + ")"); + client.put("company_name_acn", client.getString("company_name") + " (ABN " + client.getString("abn") + ")"); } - JSONObject bankAccount = clientManager.getBankAccountByClientId(client.getIntValue("client_id")); - if (bankAccount != null) { - client.put("bank_name", bankAccount.getString("bank")); - client.put("bank_country", bankAccount.getString("city")); - client.put("bank_account_number", bankAccount.getString("account_no")); - client.put("bank_account_name", bankAccount.getString("account_name")); + + 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)); + } + + JSONObject cbBankPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay"); + if (cbBankPayRate != null) { + client.put("cbbank_rate", cbBankPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + } + } catch (Exception ignored) { + throw new BadRequestException("Merchant Rate Not Configure"); + } + + JSONObject bankAccount = getBankAccountByClientId(client.getIntValue("client_id")); + if (bankAccount == null || bankAccount.size() <= 0) { + throw new BadRequestException("The Partner's Account is not config!"); + } + client.put("bank", bankAccount.getString("bank")); + client.put("bsb_no", bankAccount.getString("bsb_no")); + client.put("account_no", bankAccount.getString("account_no")); + client.put("account_name", bankAccount.getString("account_name")); + String start_date = DateFormatUtils.format(new Date(), "dd/MM/yyyy"); + client.put("start_date", start_date); + Date endDate = TimeZoneUtils.nextYearByCurrDay(); + String end_date = DateFormatUtils.format(endDate, "dd/MM/yyyy"); + client.put("end_date", end_date); return exportClientAggregateFile(client); } @@ -2253,34 +2292,75 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject getClientAggregateFile(JSONObject device, MultipartFile file) throws IOException{ String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); + if (StringUtils.isBlank(file.getOriginalFilename())) { + throw new BadRequestException("Please Enter Full Name"); + } JSONObject account = clientAccountMapper.findById(device.getString("account_id")); JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); - client.put("now", DateFormatUtils.format(new Date(), "yyyy-MM-dd")); - String clientName = ""; - clientName = client.getString("business_name"); - if (StringUtils.isNotBlank(client.getString("acn"))) { - clientName += "(" + client.getString("acn") + ")"; - client.put("client_acn", client.getString("acn")); - } - client.put("client_name", clientName); - client.put("bd_name", client.getString("bd_user_name")); - client.put("client_phone", client.getString("contact_phone")); - client.put("client_email", client.getString("contact_email")); - client.put("client_address", (client.getString("address") + "\n" + client.getString("suburb") + ' ' + client.getString("state") + ' ' + client.getString("postcode"))); - JSONObject rate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay"); - if (rate != null) { - client.put("client_rate", (rate.getBigDecimal("rate_value").setScale(2, RoundingMode.DOWN).toPlainString() + "%")); - int cleanDays = rate.getIntValue("clean_days"); - client.put("clean_days", ("T+" + cleanDays)); - client.put("days", cleanDays); + String address = client.getString("address").trim(); + if (address.contains(",")) { + client.put("address", address.substring(0, address.lastIndexOf(",")).trim()); + client.put("address_sub", address.substring(address.lastIndexOf(",") + 1).trim()); + } + if (client.getString("acn") != null && !client.getString("acn").equals("")) { + client.put("acn_type", "ACN: (" + client.getString("acn") + ")"); + client.put("company_name_acn", client.getString("company_name") + " (ACN " + client.getString("acn") + ")"); + } else { + client.put("acn_type", "ABN: (" + client.getString("abn") + ")"); + client.put("company_name_acn", client.getString("company_name") + " (ABN " + client.getString("abn") + ")"); } - JSONObject bankAccount = clientManager.getBankAccountByClientId(client.getIntValue("client_id")); - if (bankAccount != null) { - client.put("bank_name", bankAccount.getString("bank")); - client.put("bank_country", bankAccount.getString("city")); - client.put("bank_account_number", bankAccount.getString("account_no")); - client.put("bank_account_name", bankAccount.getString("account_name")); + + 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)); + } + + JSONObject cbBankPayRate = merchantInfoProvider.clientCurrentRate(client.getIntValue("client_id"), new Date(), "CB_BankPay"); + if (cbBankPayRate != null) { + client.put("cbbank_rate", cbBankPayRate.getBigDecimal("rate_value").setScale(2, BigDecimal.ROUND_DOWN)); + } + } catch (Exception ignored) { + throw new BadRequestException("Merchant Rate Not Configure"); + } + + JSONObject bankAccount = getBankAccountByClientId(client.getIntValue("client_id")); + if (bankAccount == null || bankAccount.size() <= 0) { + throw new BadRequestException("The Partner's Account is not config!"); + } + client.put("bank", bankAccount.getString("bank")); + client.put("bsb_no", bankAccount.getString("bsb_no")); + client.put("account_no", bankAccount.getString("account_no")); + client.put("account_name", bankAccount.getString("account_name")); + String start_date = DateFormatUtils.format(new Date(), "dd/MM/yyyy"); + client.put("start_date", start_date); + Date endDate = TimeZoneUtils.nextYearByCurrDay(); + String end_date = DateFormatUtils.format(endDate, "dd/MM/yyyy"); + client.put("end_date", end_date); + client.put("full_name", file.getOriginalFilename()); BufferedImage img = ImageIO.read(file.getInputStream()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(img, "png", out); @@ -2313,7 +2393,7 @@ public class RetailAppServiceImp implements RetailAppService { deviceSupport.findRegister(clientType); JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); JSONObject account = clientAccountMapper.findById(device.getString("account_id")); - clientManager.commitAuthFilesToCompliance(client.getString("client_moniker"), account); + clientManager.commitAuthFilesToCompliance(client.getString("client_moniker"), account,"App"); } private JSONObject exportImgAggregateFile(JSONObject account, JSONObject client) throws IOException{ @@ -2324,9 +2404,9 @@ public class RetailAppServiceImp implements RetailAppService { pdu.setTemplatePdfPath(IMG_AGGREGATE_FILE); pdu.setPdfTemplate(client); File file = new File(client.getString("client_moniker") + "_agreement.pdf"); - ByteArrayOutputStream bos = pdu.templetPdfBos(file); + ByteArrayOutputStream bos = pdu.templetPdfBos(file,"STSong-Light","UniGB-UCS2-H"); stream = new ByteArrayInputStream(bos.toByteArray()); - JSONObject fileInfo = attachmentClient.uploadFile(stream, client.getString("client_moniker") + "_agreement.pdf", false); + JSONObject fileInfo = attachmentClient.uploadFile(stream, client.getString("client_moniker") + "_" + System.currentTimeMillis() + "_agreement.pdf", false); ClientAuthFilesInfo clientAuthFilesInfo = new ClientAuthFilesInfo(); clientAuthFilesInfo.setFile_agreement_info(fileInfo.getString("url")); clientAuthFilesInfo.setFile_apply_info(null); @@ -2343,7 +2423,7 @@ public class RetailAppServiceImp implements RetailAppService { return result; } - private void exportAggregateFile(JSONObject client, HttpServletResponse httpResponse) { + private void exportCBBankAggregateFile(JSONObject client, HttpServletResponse httpResponse) { httpResponse.setContentType("application/pdf"); httpResponse.setHeader("content-disposition", "attachment;filename=" + client.getString("client_moniker") + "_AGREEMENT_" + new Date() + ".pdf"); ServletOutputStream sos = null; @@ -2366,12 +2446,12 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject result = new JSONObject(); try { PdfUtils pdu = new PdfUtils(); - pdu.setTemplatePdfPath(CBBANK_AGGREGATE_FILE); + pdu.setTemplatePdfPath(IMG_AGGREGATE_FILE); pdu.setPdfTemplate(client); File file = new File(client.getString("client_moniker") + "_agreement.pdf"); ByteArrayOutputStream bos = pdu.templetPdfBos(file); stream = new ByteArrayInputStream(bos.toByteArray()); - JSONObject fileInfo = attachmentClient.uploadFile(stream, client.getString("client_moniker") + "_agreement_source.pdf", false); + JSONObject fileInfo = attachmentClient.uploadFile(stream, client.getString("client_moniker") + "_" + System.currentTimeMillis() + "_agreement_source.pdf", false); result.put("file_value", fileInfo.getString("url")); } catch (Exception e) { throw new BadRequestException("获取合同文件失败"); @@ -2395,4 +2475,8 @@ public class RetailAppServiceImp implements RetailAppService { return BIND_ACCOUNT_PHONE_PREFIX+codeKey; } + private JSONObject getBankAccountByClientId(int client_id) { + List list = clientBankAccountMapper.clientBankAccounts(client_id); + return list.isEmpty() ? new JSONObject() : list.get(0); + } } 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 4b753b492..0a30d20b6 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 @@ -735,7 +735,6 @@ public class RetailAppController { */ @RequestMapping(value = "/client/aggregate_file", method = RequestMethod.GET) public JSONObject getSourceAggregateFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - //todo 后面需替换成正式合同 return retailAppService.getSourceAggregateFile(device); } @@ -744,9 +743,8 @@ public class RetailAppController { * @param device * @param file 签名的url图片 */ - @RequestMapping(value = "/client/aggregate_file", method = RequestMethod.PUT) + @RequestMapping(value = "/client/aggregate_file", method = RequestMethod.POST) public JSONObject getClientAggregateFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@RequestParam MultipartFile file) throws IOException { - //todo 后面需替换成正式合同 return retailAppService.getClientAggregateFile(device, 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 687ae6a32..20008e2d6 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,8 +25,12 @@ public interface ClientFilesMapper { List findClientFile(@Param("client_id") int clientId); @AutoSql(type = SqlType.SELECT) - @AdvanceSelect(addonWhereClause = "is_valid = 1 and status = 0") - List findClientFileCommit(@Param("client_id") int clientId); + @AdvanceSelect(addonWhereClause = "is_valid = 1 and (status = 1 or status = 2) and file_name='client_agree_file'") + List findClientPassAggreeFile(@Param("client_id") int clientId); + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "is_valid = 1 and (status = 0 or status = 3) and file_name='client_agree_file'") + List findClientAggreeFileCommit(@Param("client_id") int clientId); @AutoSql(type = SqlType.SELECT) @AdvanceSelect(addonWhereClause = "is_valid = 1") @@ -37,7 +41,9 @@ public interface ClientFilesMapper { List findFileByClientAndType(@Param("client_id") int client_id, @Param("file_name") String file_name); - void deleteByClientAndType(@Param("file_id") String file_id); + void deleteByClientAndFileId(@Param("file_id") String file_id); + + void deleteAggreeByClientId(@Param("client_id") int file_id); void confirmAgreeFile(@Param("client_id") int client_id); 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 f53aeb008..18497c7d1 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -245,7 +245,7 @@ public interface ClientManager { List uploadAuthFilesForWaitCompliance(JSONObject manager, String clientMoniker, ClientAuthFilesInfo filesInfo); - void commitAuthFilesToCompliance(String clientMoniker, JSONObject account); + void commitAuthFilesToCompliance(String clientMoniker, JSONObject account, String source); JSONObject getClientsAnalysis(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 585ec53e0..a22024471 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 @@ -1994,22 +1994,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - JSONObject file = signInAccountService.checkAuthFileStatusByWEB(client); - file.put("file_company",clientComplianceCompanyMapper.findFileByClientId(account.getIntValue("client_id"))); + JSONObject file = signInAccountService.checkAuthFileStatus(client); + file.put("file_company", clientComplianceCompanyMapper.findFileByClientId(account.getIntValue("client_id"))); return file; } @Override - public JSONObject getComplianceFilesForBD(JSONObject account) - { + public JSONObject getComplianceFilesForBD(JSONObject account) { JSONObject client = getClientInfo(account.getIntValue("client_id")); if (client == null) { throw new InvalidShortIdException(); } JSONObject file = clientComplianceApply.complianceAuthFile(client); - file.put("file_company",clientComplianceCompanyMapper.findFileByClientId(account.getIntValue("client_id"))); - file.put("client",client); + file.put("file_company", clientComplianceCompanyMapper.findFileByClientId(account.getIntValue("client_id"))); + file.put("client", client); return file; } @@ -3110,8 +3109,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override - public JSONObject getClientViewAuthFiles(JSONObject manager, String clientMoniker) - { + public JSONObject getClientViewAuthFiles(JSONObject manager, String clientMoniker) { JSONObject client = getClientInfoByMoniker(clientMoniker); String[] fileKeys = {"client_bank_file", "client_company_file", "client_id_file", "client_agree_file", "client_apply_file"}; if (client == null) { @@ -3139,12 +3137,17 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } return fileJson; - }; + } + + ; @Override - public void deleteAuthFiles(String fileId) - { - clientFilesMapper.deleteByClientAndType(fileId); + public void deleteAuthFiles(String fileId) { + JSONObject file = clientFilesMapper.findFileById(fileId); + if (file.getIntValue("status") == 1 || file.getIntValue("status") == 2) { + throw new BadRequestException("The file has passed and cannot be deleted"); + } + clientFilesMapper.deleteByClientAndFileId(fileId); } @Override @@ -3181,11 +3184,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } int clientId = client.getIntValue("client_id"); try { - updateSysClientFilesForWaitCompliance(manager, clientId, CLIENT_AGREE_FILE, filesInfo.getFile_agreement_info(),fileResult); - updateSysClientFilesForWaitCompliance(manager, clientId, CLIENT_APPLY_FILE, filesInfo.getFile_apply_info(),fileResult); - updateSysClientFilesForWaitCompliance(manager, clientId, CLIENT_BANK_FILE, filesInfo.getFile_bank_info(),fileResult); - updateSysClientFilesForWaitCompliance(manager, clientId, CLIENT_COMPANY_FILE, filesInfo.getFile_company_info(),fileResult); - updateSysClientFilesForWaitCompliance(manager, clientId, CLIENT_ID_FILE, filesInfo.getFile_id_info(),fileResult); + updateAggregateFilesForWaitCompliance(manager, clientId, CLIENT_AGREE_FILE, filesInfo.getFile_agreement_info(), fileResult); + updateSysClientFilesForWaitCompliance(manager, clientId, CLIENT_APPLY_FILE, filesInfo.getFile_apply_info(), fileResult); + updateSysClientFilesForWaitCompliance(manager, clientId, CLIENT_BANK_FILE, filesInfo.getFile_bank_info(), fileResult); + updateSysClientFilesForWaitCompliance(manager, clientId, CLIENT_COMPANY_FILE, filesInfo.getFile_company_info(), fileResult); + updateSysClientFilesForWaitCompliance(manager, clientId, CLIENT_ID_FILE, filesInfo.getFile_id_info(), fileResult); } catch (Exception e) { logger.error("上传合规文件失败", e); } @@ -3199,8 +3202,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override @Transactional - public void commitAuthFilesToCompliance(String clientMoniker, JSONObject account) { + public void commitAuthFilesToCompliance(String clientMoniker, JSONObject account, String source) { JSONObject client = getClientInfoByMoniker(clientMoniker); + int sourceEnum = 2; if (client == null) { throw new InvalidShortIdException(); } @@ -3214,22 +3218,29 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new BadRequestException("Please check the information is uploaded completely"); } } + if ("app".equals(source.toLowerCase())) { + sourceEnum = 1; + } JSONObject fileComp = clientComplianceCompanyMapper.findFileByClientId(client.getIntValue("client_id")); - if(fileComp == null) { + if (fileComp == null) { fileComp = new JSONObject(); - fileComp.put("client_id",client.getIntValue("client_id")); - fileComp.put("submit_time",new Date()); - fileComp.put("status",0); - fileComp.put("commit_by_id",account.getString("account_id")); + fileComp.put("client_id", client.getIntValue("client_id")); + fileComp.put("submit_time", new Date()); + fileComp.put("status", 0); + fileComp.put("source", sourceEnum); + fileComp.put("commit_by_id", account.getString("account_id")); clientComplianceCompanyMapper.save(fileComp); clientFilesMapper.updateBeforeCompliance(client.getIntValue("client_id")); - } else { - fileComp.put("status",0); - fileComp.put("submit_time",new Date()); - fileComp.put("commit_by_id",account.getString("account_id")); + } else if (fileComp.getIntValue("status") == 2) { + fileComp.put("status", 0); + fileComp.put("submit_time", new Date()); + fileComp.put("source", sourceEnum); + fileComp.put("commit_by_id", account.getString("account_id")); clientComplianceCompanyMapper.update(fileComp); clientFilesMapper.updateBeforeCompliance(client.getIntValue("client_id")); + } else { + throw new BadRequestException("please do not repeat submission!"); } } @@ -3285,7 +3296,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } } - public void updateSysClientFilesForWaitCompliance(JSONObject manager, int clientId, String fileType, String fileValue,List fileResult) { + public void updateSysClientFilesForWaitCompliance(JSONObject manager, int clientId, String fileType, String fileValue, List fileResult) { if (fileValue != null) { String[] values = fileValue.split(","); for (String value : values) { @@ -3307,6 +3318,33 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } } + public void updateAggregateFilesForWaitCompliance(JSONObject manager, int clientId, String fileType, String fileValue, List fileResult) { + if (fileValue != null) { + List passAggregateFiles = clientFilesMapper.findClientPassAggreeFile(clientId); + if (passAggregateFiles != null && passAggregateFiles.size() > 0) { + throw new BadRequestException("合同已提交或审核通过,请勿重复签订合同"); + } + List aggregateFiles = clientFilesMapper.findClientAggreeFileCommit(clientId); + if (aggregateFiles != null && aggregateFiles.size() > 0) { + clientFilesMapper.deleteAggreeByClientId(clientId); + } + JSONObject fileJson = new JSONObject(); + fileJson.put("client_id", clientId); + fileJson.put("last_update_date", new Date()); + fileJson.put("last_update_by", manager.getString("display_name")); + fileJson.put("file_name", fileType); + fileJson.put("file_value", fileValue); + fileJson.put("status", 0); + fileJson.put("is_valid", 1); + clientFilesMapper.save(fileJson); + logger.info(clientId + "的合同文件上传成功" + fileJson.getString("file_id")); + JSONObject file = new JSONObject(); + file.put("file_id", fileJson.getString("file_id")); + file.put("file_value", fileJson.getString("file_value")); + fileResult.add(file); + + } + } @Override diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java index d07f5092a..55c39b29d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java @@ -574,7 +574,7 @@ public class PartnerViewController { @PartnerMapping(value = "/clientCompliance/{clientMoniker}/viewCommit", method = RequestMethod.POST) @ResponseBody public void clientComplianceViewCommit(@PathVariable String clientMoniker ,@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { - clientManager.commitAuthFilesToCompliance(clientMoniker, account); + clientManager.commitAuthFilesToCompliance(clientMoniker, account, "Web"); } @PartnerMapping(value = "/auth_file/{fileId}/delete", method = RequestMethod.PUT, roles = {PartnerRole.ADMIN, PartnerRole.MANAGER}) diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/SignInAccountService.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/SignInAccountService.java index 695e204cd..8d18e669e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/SignInAccountService.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/SignInAccountService.java @@ -58,7 +58,5 @@ public interface SignInAccountService { void deleteManagerCodeKey(String codekey); - JSONObject checkAuthFileStatusByWEB(JSONObject client); - JSONObject checkAuthFileStatus(JSONObject client); } diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java index d5c8b85e2..1ba04d1aa 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java @@ -87,6 +87,9 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati private SmsSender smsSender; private final String RESET_CLIENT_ACCOUNT_PREFIX = "RESET_CLIENT_ACCOUNT"; private final String RESET_MANAGER_ACCOUNT_PREFIX = "RESET_MANAGER_ACCOUNT"; + private final String[] FILE_KEYS = {"client_bank_file", "client_company_file", "client_id_file", "client_agree_file"}; + private final String[] PUT_KEYS = {"file_bank_info", "file_company_info", "file_id_info", "file_agreement_info"}; + private final String[] FILE_NAMES = {"* bank statement", "* Certificate of Registration", "* ID", "* Agreement"}; private final int RESET_PASSWORD_TEMPLID = 126978; private ApplicationEventPublisher publisher; private static final List tags = new ArrayList<>(); @@ -632,81 +635,15 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati return RESET_MANAGER_ACCOUNT_PREFIX + codeKey; } - @Override - public JSONObject checkAuthFileStatusByWEB(JSONObject client) { - JSONObject result = new JSONObject(); - result.put("client_less_file", false); - if (client.getIntValue("approve_result") == 2 || client.getIntValue("open_status") == 10) { - List clientFiles = clientFilesMapper.findAllClientFile(client.getIntValue("client_id")); - String[] fileKeys = {"client_bank_file", "client_company_file", "client_id_file", "client_agree_file"}; - String[] putKeys = {"file_bank_info", "file_company_info", "file_id_info", "file_agreement_info"}; - String[] fileNames = {"* bank statement", "* Certificate of Registration", "* ID", "* Agreement"}; - boolean clientFilesIsLess = false; - JSONObject resultFile = new JSONObject(); - for (int i = 0; i < fileKeys.length; i++) { - String fileKey = fileKeys[i]; - if (clientFiles != null && clientFiles.size() > 0) { - List clientFileUrl = clientFiles.stream() - .filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status") == 1 || fileJson.getIntValue("status") == 2))) - .sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date"))) - .map(json -> { - JSONObject params = new JSONObject(); - params.put("file_id", json.getString("file_id")); - params.put("file_value", json.getString("file_value")); - return params; - }) - .collect(Collectors.toList()); - if (clientFileUrl != null && clientFileUrl.size() > 0) { - JSONObject fileJson = new JSONObject(); - fileJson.put("key", putKeys[i]); - fileJson.put("name", fileNames[i]); - fileJson.put("file_value", clientFileUrl); - fileJson.put("file_write", false); - resultFile.put(fileKey,fileJson); - } else { - List clientBackToFileUrl = clientFiles.stream() - .filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status") == 0 || fileJson.getIntValue("status") == 3))) - .sorted((log1, log2) -> log2.getDate("last_update_date").compareTo(log1.getDate("last_update_date"))) - .map(json -> { - JSONObject params = new JSONObject(); - params.put("file_id", json.getString("file_id")); - params.put("file_value", json.getString("file_value")); - return params; - }) - .collect(Collectors.toList()); - JSONObject fileJson = new JSONObject(); - fileJson.put("key", putKeys[i]); - fileJson.put("name", fileNames[i]); - if (clientBackToFileUrl != null && clientBackToFileUrl.size() > 0) { - fileJson.put("file_value", clientBackToFileUrl); - } - fileJson.put("file_write", true); - resultFile.put(fileKey,fileJson); - clientFilesIsLess = true; - } - } - result.put("client_less_file", clientFilesIsLess); - if (clientFilesIsLess) { - result.put("client_files", resultFile); - } - } - } - return result; - } - @Override public JSONObject checkAuthFileStatus(JSONObject client) { JSONObject result = new JSONObject(); result.put("client_less_file", false); if (client.getIntValue("approve_result") == 2 || client.getIntValue("open_status") == 10) { List clientFiles = clientFilesMapper.findAllClientFile(client.getIntValue("client_id")); - String[] fileKeys = {"client_bank_file", "client_company_file", "client_id_file", "client_agree_file"}; - String[] putKeys = {"file_bank_info", "file_company_info", "file_id_info", "file_agreement_info"}; - String[] fileNames = {"* bank statement", "* Certificate of Registration", "* ID", "* Agreement"}; boolean clientFilesIsLess = false; - List resultFile = new ArrayList<>(); - for (int i = 0; i < fileKeys.length; i++) { - String fileKey = fileKeys[i]; + for (int i = 0; i < FILE_KEYS.length; i++) { + String fileKey = FILE_KEYS[i]; if (clientFiles != null && clientFiles.size() > 0) { List clientFileUrl = clientFiles.stream() .filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status") == 1 || fileJson.getIntValue("status") == 2))) @@ -720,11 +657,11 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati .collect(Collectors.toList()); if (clientFileUrl != null && clientFileUrl.size() > 0) { JSONObject fileJson = new JSONObject(); - fileJson.put("key", putKeys[i]); - fileJson.put("name", fileNames[i]); + fileJson.put("key", PUT_KEYS[i]); + fileJson.put("name", FILE_NAMES[i]); fileJson.put("file_value", clientFileUrl); fileJson.put("file_write", false); - resultFile.add(fileJson); + result.put(fileKey,fileJson); } else { List clientBackToFileUrl = clientFiles.stream() .filter(fileJson -> (fileKey.equals(fileJson.getString("file_name")) && (fileJson.getIntValue("status") == 0 || fileJson.getIntValue("status") == 3))) @@ -737,23 +674,29 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati }) .collect(Collectors.toList()); JSONObject fileJson = new JSONObject(); - fileJson.put("key", putKeys[i]); - fileJson.put("name", fileNames[i]); + fileJson.put("key", PUT_KEYS[i]); + fileJson.put("name", FILE_NAMES[i]); if (clientBackToFileUrl != null && clientBackToFileUrl.size() > 0) { - fileJson.put("file_value", clientBackToFileUrl); + if ("client_agree_file".equals(fileKey)) { + List agreeFile = new ArrayList<>(); + agreeFile.add(clientBackToFileUrl.get(0)); + fileJson.put("file_value", agreeFile); + fileJson.put("file_write", true); + }else { + fileJson.put("file_value", clientBackToFileUrl); + fileJson.put("file_write", true); + } + }else { + fileJson.put("file_write", true); } - fileJson.put("file_write", true); - resultFile.add(fileJson); + result.put(fileKey,fileJson); clientFilesIsLess = true; } } result.put("client_less_file", clientFilesIsLess); - if (clientFilesIsLess) { - result.put("client_files", resultFile); - } + result.put("client_refuse_reason", "测试驳回!!!"); } } return result; } - } 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 index d10e69c8c..25c6a1df3 100644 --- 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 @@ -9,10 +9,16 @@ and is_valid = 1 order by last_update_date desc - update sys_files set is_valid = 0 where file_id = #{file_id} + update sys_files set state = 2 diff --git a/src/main/ui/static/payment/partner/partner.js b/src/main/ui/static/payment/partner/partner.js index 7e93477de..a31a60863 100644 --- a/src/main/ui/static/payment/partner/partner.js +++ b/src/main/ui/static/payment/partner/partner.js @@ -762,7 +762,6 @@ define(['angular', 'decimal', 'uiRouter', 'ngBootSwitch', 'ngFileUpload','uiBoot app.controller('clientCommitToComplianceFilesCtrl', ['$scope', '$http', '$rootScope', 'commonDialog', '$state', 'Upload', 'file', function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) { $scope.file = file.data || {}; - $scope.client_files = file.data.client_files; //audit files $scope.uploadBankFile = function (file) { if (file != null) { diff --git a/src/main/ui/static/payment/partner/templates/client_compliance_to_auth.html b/src/main/ui/static/payment/partner/templates/client_compliance_to_auth.html index d2799c41a..217120d09 100644 --- a/src/main/ui/static/payment/partner/templates/client_compliance_to_auth.html +++ b/src/main/ui/static/payment/partner/templates/client_compliance_to_auth.html @@ -13,7 +13,7 @@ Partner Detail
  • - Compliance_Audit + Compliance Audit
  • @@ -71,8 +71,12 @@
    - -
    + +
    @@ -89,8 +93,12 @@
    - -
    + +
    @@ -106,8 +114,12 @@
    - -
    + +
    @@ -123,8 +135,12 @@
    - -
    + +
    diff --git a/src/main/ui/static/payment/partner/templates/client_compliance_to_perfect.html b/src/main/ui/static/payment/partner/templates/client_compliance_to_perfect.html index c9f6d0b7b..6594de632 100644 --- a/src/main/ui/static/payment/partner/templates/client_compliance_to_perfect.html +++ b/src/main/ui/static/payment/partner/templates/client_compliance_to_perfect.html @@ -20,10 +20,10 @@
    - +
    @@ -33,12 +33,12 @@ -->
    - + @@ -61,7 +61,7 @@
    @@ -71,12 +71,12 @@
    1 - +
    - +
    1 - +
    @@ -104,7 +104,7 @@
    @@ -115,12 +115,12 @@ --> - +
    1 - +
    @@ -149,7 +149,7 @@
    @@ -160,12 +160,12 @@ --> - +
    1 - +
    diff --git a/src/main/ui/static/payment/partner/templates/partner_detail_for_compliance.html b/src/main/ui/static/payment/partner/templates/partner_detail_for_compliance.html index cd8174b42..8b8b7d8a6 100644 --- a/src/main/ui/static/payment/partner/templates/partner_detail_for_compliance.html +++ b/src/main/ui/static/payment/partner/templates/partner_detail_for_compliance.html @@ -51,7 +51,7 @@ Partner Detail
  • - Compliance_Audit + Compliance Audit
  • diff --git a/src/main/ui/static/sys/templates/partner_compliance_for_client.html b/src/main/ui/static/sys/templates/partner_compliance_for_client.html index 5e17ec8cd..1149bacd0 100644 --- a/src/main/ui/static/sys/templates/partner_compliance_for_client.html +++ b/src/main/ui/static/sys/templates/partner_compliance_for_client.html @@ -45,6 +45,7 @@ BD AuthFile Status Submit Time + Source Operation @@ -74,6 +75,10 @@ 打回 + + App + Web + Detail