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 0343422aa..62dbf09e8 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 @@ -15,10 +15,32 @@ import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService; import au.com.royalpay.payment.manage.device.core.DeviceManager; import au.com.royalpay.payment.manage.management.sysconfig.core.impls.PermissionPartnerManagerImpl; import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; -import au.com.royalpay.payment.manage.mappers.log.*; +import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper; +import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper; +import au.com.royalpay.payment.manage.mappers.log.ClientsOperationLogMapper; +import au.com.royalpay.payment.manage.mappers.log.LogClientSubMerchantIdMapper; +import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper; 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.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.ClientConfigMapper; +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.MailSendMapper; +import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper; +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.PermissionClientModuleMapper; +import au.com.royalpay.payment.manage.mappers.system.PermissionPartnerModuleMapper; +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; @@ -273,8 +295,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Resource private PermissionPartnerManagerImpl permissionPartnerManagerImpl; - - 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"; @@ -331,12 +351,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkClientOrg(manager, client); } client.putAll(clientConfigService.find(client.getIntValue("client_id"))); - client.put("unsubscribe",mailUnsubMapper.findOneByClientMoniker(clientMoniker) == null?false:true); + client.put("unsubscribe", mailUnsubMapper.findOneByClientMoniker(clientMoniker) == null ? false : true); client.put("show_all_permission", true); int role = manager != null ? manager.getIntValue("role") : 0; if (manager != null) { if (ManagerRole.OPERATOR.hasRole(role)) { - List log = logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc"))); + List log = logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"), + new PageBounds(Order.formString("create_time.desc"))); client.put("sub_merchant_id_log", log.size() > 0 ? true : false); } if (ManagerRole.BD_USER.hasRole(role)) { @@ -573,7 +594,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid clientConfig.put("client_id", partner.getIntValue("client_id")); clientConfig.put("client_moniker", partner.getString("client_moniker")); clientConfigService.save(clientConfig); - permissionPartnerManagerImpl.permissionClientModuleSave(partner.getIntValue("client_id"),partner.getString("client_moniker")); + permissionPartnerManagerImpl.permissionClientModuleSave(partner.getIntValue("client_id"), partner.getString("client_moniker")); } catch (Exception e) { throw new BadRequestException("error.partner.valid.dumplicate_client_moniker"); } @@ -684,11 +705,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (!oldClient.getString("contact_email").equals(newClient.getString("contact_email"))) { List exceptClientIds = new ArrayList<>(); exceptClientIds.add(newClient.getString("client_id")); - JSONObject sameMailClients = getByEmail(oldClient.getString("contact_email"),1,1,exceptClientIds); - if(sameMailClients.getJSONArray("data").size()<1) { + JSONObject sameMailClients = getByEmail(oldClient.getString("contact_email"), 1, 1, exceptClientIds); + if (sameMailClients.getJSONArray("data").size() < 1) { mailGunService.updateClientOfMailList(newClient, oldClient); - }else { - oldClient.put("contact_email",newClient.getString("contact_email")); + } else { + oldClient.put("contact_email", newClient.getString("contact_email")); mailGunService.addClientToMailList(oldClient); } } @@ -756,20 +777,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid int clientId = client.getIntValue("client_id"); update.put("client_id", clientId); String wechatInstitutionMerchantId = RandomStringUtils.random(6, true, true).toUpperCase(); - if(StringUtils.isEmpty(refreshWechatInstitutionMerchantId.getString("wechat_institution_merchant_id"))){ - update.put("wechat_institution_merchant_id",wechatInstitutionMerchantId); - }else { - update.put("wechat_institution_merchant_id",createWechatInstitutionMerchantId(wechatInstitutionMerchantId)) ; + if (StringUtils.isEmpty(refreshWechatInstitutionMerchantId.getString("wechat_institution_merchant_id"))) { + update.put("wechat_institution_merchant_id", wechatInstitutionMerchantId); + } else { + update.put("wechat_institution_merchant_id", createWechatInstitutionMerchantId(wechatInstitutionMerchantId)); } clientMapper.update(update); clientInfoCacheSupport.clearClientCache(clientId); } - private String createWechatInstitutionMerchantId(String wechatInstitutionMerchantId){ + + private String createWechatInstitutionMerchantId(String wechatInstitutionMerchantId) { JSONObject client = clientMapper.findByWechatInstitutionMerchantId(wechatInstitutionMerchantId); - if(client == null){ + if (client == null) { return wechatInstitutionMerchantId; - }else { - return createWechatInstitutionMerchantId(RandomStringUtils.random(6, true, true).toUpperCase()); + } else { + return createWechatInstitutionMerchantId(RandomStringUtils.random(6, true, true).toUpperCase()); } } @@ -810,10 +832,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid List accounts = clientAccountMapper.listAdminAccounts(client.getIntValue("client_id")); JSONObject account = accounts.get(0); sendInitEmail(client, account.getString("username"), "*****"); -// sendInitEmail(manager, client, account.getString("username"), "*****"); + // sendInitEmail(manager, client, account.getString("username"), "*****"); saveClientAuditProcess(client.getIntValue("client_id"), open_status, 5, "合规通过", manager); - clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager,clientMoniker,"skip_clearing",false)); - clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager,clientMoniker,"common_sub_merchant_id",false)); + clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "skip_clearing", false)); + clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "common_sub_merchant_id", false)); } else if (checkGreenChannel && client.getIntValue("open_status") == 5) { // 绿色通道通过后不发邮件 logger.info("PASS 绿色通道:" + clientMoniker); @@ -867,7 +889,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } } sendInitEmail(client, username, pwd); -// sendInitEmail(manager, client, username, pwd); + // sendInitEmail(manager, client, username, pwd); } @Override @@ -891,7 +913,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid List accounts = clientAccountMapper.listAdminAccounts(clientId); if (client.getIntValue("source") == 4) { JSONObject account = accounts.get(0); -// sendInitEmail(manager, client, account.getString("username"), "*****"); + // sendInitEmail(manager, client, account.getString("username"), "*****"); sendInitEmail(client, account.getString("username"), "*****"); } else { if (accounts.size() == 0) { @@ -900,7 +922,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid JSONObject account = accounts.get(0); String pwd = RandomStringUtils.random(8, true, true); resetAccountPwd(manager, clientMoniker, account.getString("account_id"), pwd); -// sendInitEmail(manager, client, account.getString("username"), pwd); + // sendInitEmail(manager, client, account.getString("username"), pwd); sendInitEmail(client, account.getString("username"), pwd); } } @@ -959,62 +981,33 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } }.start(); } - /** - * public void sendInitEmail(JSONObject account, final JSONObject client, String username, String pwd) { - logger.debug("sending email after comply"); - JSONObject model = new JSONObject(); - model.put("username", username); - model.put("password", pwd); - model.put("client_moniker", client.getString("client_moniker")); - model.put("contact_person", client.getString("contact_person")); - model.put("credential_code", client.getString("credential_code")); - List bds = clientBDMapper.listClientBDInfoAvailable(client.getIntValue("client_id"), new Date()); - // todo Velocity - Context ctx = new Context(); - ctx.setVariable("bds", bds); - ctx.setVariable("password", pwd); - ctx.setVariable("username", username); - ctx.setVariable("client_moniker", client.getString("client_moniker")); - ctx.setVariable("contact_person", client.getString("contact_person")); - ctx.setVariable("credential_code", client.getString("credential_code")); - ctx.setVariable("short_name", client.getString("short_name")); - final String content = thymeleaf.process("mail/new_client_notice", ctx); - // final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/new_client_notice.vm", - // "utf-8", model); - final String mailTo = client.getString("contact_email"); - if (StringUtils.isEmpty(mailTo)) { - throw new EmailException("Client Contact Email is invalid"); - } - final Set emails = new HashSet<>(); - for (JSONObject bd : bds) { - String email = bd.getString("email"); - if (StringUtils.isNotEmpty(email)) { - emails.add(email); - } - } - new Thread() { - @Override - public void run() { - try { - SendMail sendMail = new SendMail(); - Set to = new HashSet<>(); - to.add(mailTo); - sendMail.setFrom("info@mail.royalpay.com.au"); - sendMail.setMailTos(to); - sendMail.setMailCcs(emails); - sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up"); - sendMail.setContent(content); - sendMail.setTags(tags); - JSONObject mailResult = mailGunService.sendMail(sendMail); - clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 3, mailResult.getString("mail_id"))); - } catch (Exception e) { - clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 0, null)); - throw new EmailException("Email Sending Failed", e); - } - } - }.start(); - } + /** + * public void sendInitEmail(JSONObject account, final JSONObject client, String username, String pwd) { + * logger.debug("sending email after comply"); JSONObject model = new JSONObject(); model.put("username", username); + * model.put("password", pwd); model.put("client_moniker", client.getString("client_moniker")); + * model.put("contact_person", client.getString("contact_person")); model.put("credential_code", + * client.getString("credential_code")); List bds = + * clientBDMapper.listClientBDInfoAvailable(client.getIntValue("client_id"), new Date()); // todo Velocity Context + * ctx = new Context(); ctx.setVariable("bds", bds); ctx.setVariable("password", pwd); ctx.setVariable("username", + * username); ctx.setVariable("client_moniker", client.getString("client_moniker")); + * ctx.setVariable("contact_person", client.getString("contact_person")); ctx.setVariable("credential_code", + * client.getString("credential_code")); ctx.setVariable("short_name", client.getString("short_name")); final String + * content = thymeleaf.process("mail/new_client_notice", ctx); // final String content = + * VelocityEngineUtils.mergeTemplateIntoString(null, "mail/new_client_notice.vm", // "utf-8", model); final String + * mailTo = client.getString("contact_email"); if (StringUtils.isEmpty(mailTo)) { throw new EmailException("Client + * Contact Email is invalid"); } final Set emails = new HashSet<>(); for (JSONObject bd : bds) { String + * email = bd.getString("email"); if (StringUtils.isNotEmpty(email)) { emails.add(email); } } new Thread() { + * + * @Override public void run() { try { SendMail sendMail = new SendMail(); Set to = new HashSet<>(); + * to.add(mailTo); sendMail.setFrom("info@mail.royalpay.com.au"); sendMail.setMailTos(to); + * sendMail.setMailCcs(emails); sendMail.setTitle("Your RoyalPay Cross-border Payment has been set up"); + * sendMail.setContent(content); sendMail.setTags(tags); JSONObject mailResult = + * mailGunService.sendMail(sendMail); clientModifySupport.processClientModify(new EmailModify(account, + * client.getString("client_moniker"), 3, mailResult.getString("mail_id"))); } catch (Exception e) { + * clientModifySupport.processClientModify(new EmailModify(account, client.getString("client_moniker"), 0, + * null)); throw new EmailException("Email Sending Failed", e); } } }.start(); } + * */ public void sendAuthInitEmail(JSONObject account, final JSONObject client) { @@ -2608,8 +2601,8 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid clientModifySupport.processClientModify(new DisableModify(manager, clientMoniker, false)); List exceptClientIds = new ArrayList<>(); exceptClientIds.add(client.getString("client_id")); - JSONObject sameMailClients = getByEmail(client.getString("contact_email"),1,1,exceptClientIds); - if(sameMailClients.getJSONArray("data").size()<1) { + JSONObject sameMailClients = getByEmail(client.getString("contact_email"), 1, 1, exceptClientIds); + if (sameMailClients.getJSONArray("data").size() < 1) { mailGunService.removeMailList(client); } } @@ -2700,12 +2693,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (query.getPage() == 1) { if (!logs.isEmpty() && logs.size() > 0) { JSONObject clearingDetail = clearingDetailMapper.findByDetailId(logs.get(0).getIntValue("clear_detail_id")); - if (clearingDetail!=null){ + if (clearingDetail != null) { JSONObject clearingLog = clearingLogMapper.findById(clearingDetail.getIntValue("clearing_id")); - if(clearingLog.getBooleanValue("editable")){ + if (clearingLog.getBooleanValue("editable")) { result.put("padding", true); - logs.get(0).put("padding",true); - logger.info("##editable"+clearingLog.getBooleanValue("editable")); + logs.get(0).put("padding", true); + logger.info("##editable" + clearingLog.getBooleanValue("editable")); } } } @@ -3008,8 +3001,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - clientModifySupport - .processClientConfigModify(new SwitchPermissionModify(account, client.getString("client_moniker"), "require_remark", requireRemark)); + clientModifySupport.processClientConfigModify(new SwitchPermissionModify(account, client.getString("client_moniker"), "require_remark", requireRemark)); } @@ -3058,12 +3050,21 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } saveClientAuditProcess(client.getIntValue("client_id"), open_status, client.getInteger("open_status"), "打回," + refuse_remark, manager); clientModifySupport.processClientModify(auditModify); - if(client.getIntValue("source") == 4){ - client.getString("contact_phone"); - } try { sendMessageToBD(client, refuse_remark); + if (client.getIntValue("source") == 4) { + String contact_phone = client.getString("contact_phone"); + if (contact_phone.startsWith("+61")) { + ArrayList param = new ArrayList<>(); + param.add(refuse_remark); + try { + SmsSender.getSender().sendWithParam("+61", contact_phone.replace("+61", ""), REFUSE_CLIENT_TEMPLID, param, "RoyalPay", "", ""); + } catch (Exception ignore) { + throw new ServerErrorException("Phone number is wrong :" + contact_phone); + } + } + } } catch (Exception e) { logger.error("RefusePartnerError=======:" + clientMoniker + "," + e.getMessage()); } @@ -3615,7 +3616,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new InvalidShortIdException(); } checkOrgPermission(manager, client); - return logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc"))); + return logClientSubMerchantIdMapper.listLogsByClientId(client.getInteger("client_id"), new PageBounds(Order.formString("create_time.desc"))); } @Override @@ -3624,7 +3625,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid if (client == null) { throw new InvalidShortIdException(); } - if(client.getIntValue("approve_result")==1){ + if (client.getIntValue("approve_result") == 1) { throw new BadRequestException("The merchant has been passed"); } client.putAll(clientConfigService.find(client.getIntValue("client_id"))); @@ -3685,11 +3686,11 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } @Override - public JSONObject getByEmail(String email, int page, int limit,List exceptClientIds) { + public JSONObject getByEmail(String email, int page, int limit, List exceptClientIds) { JSONObject param = new JSONObject(); - param.put("contact_email",email); - param.put("except_client_ids",exceptClientIds); - return PageListUtils.buildPageListResult(clientMapper.simpleQuery(param,new PageBounds(page, limit))); + param.put("contact_email", email); + param.put("except_client_ids", exceptClientIds); + return PageListUtils.buildPageListResult(clientMapper.simpleQuery(param, new PageBounds(page, limit))); } @Override @@ -3709,10 +3710,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid throw new InvalidShortIdException(); } checkOrgPermission(manager, client); - JSONObject sub = mailUnsubMapper.findOneByClientMoniker(client_moniker); - if(sub == null){ - throw new BadRequestException(); - } + JSONObject sub = mailUnsubMapper.findOneByClientMoniker(client_moniker); + if (sub == null) { + throw new BadRequestException(); + } mailService.removeUnsub(sub.getLong("id")); } @@ -3724,25 +3725,24 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } checkOrgPermission(manager, client); - if(allow){ - if(StringUtils.isEmpty(client.getString("hf_pay_url"))){ + if (allow) { + if (StringUtils.isEmpty(client.getString("hf_pay_url"))) { String hf_pay_url = getShortLink(clientMoniker); - client.put("hf_pay_url",hf_pay_url); + client.put("hf_pay_url", hf_pay_url); JSONObject clientConfig = new JSONObject(); - clientConfig.put("hf_pay_url",hf_pay_url); - clientConfig.put("client_id",client.getIntValue("client_id")); + clientConfig.put("hf_pay_url", hf_pay_url); + clientConfig.put("client_id", client.getIntValue("client_id")); clientConfigMapper.update(clientConfig); clientMapper.update(client); } } clientModifySupport.processClientConfigModify(new SwitchPermissionModify(manager, clientMoniker, "enable_link", allow)); - } @Override - public String getShortLink(String client_moniker){ - String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/"+client_moniker+"/jump"); + public String getShortLink(String client_moniker) { + String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/" + client_moniker + "/jump"); MpWechatApi api = mpWechatApiProvider.getNewPaymentApi(); return api.registerShortUrl(longUrl); }