diff --git a/pom.xml b/pom.xml index 5b827ddb1..aec08dcbd 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.3.12 + 1.3.13 UTF-8 1.4.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/beans/RetailAppMessage.java b/src/main/java/au/com/royalpay/payment/manage/appclient/beans/RetailAppMessage.java index 908149737..2a2e45986 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/beans/RetailAppMessage.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/beans/RetailAppMessage.java @@ -4,7 +4,6 @@ import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder; import au.com.royalpay.payment.manage.pushMessage.bean.AppMessageType; import au.com.royalpay.payment.tools.device.message.AppMessage; import au.com.royalpay.payment.tools.env.RequestEnvironment; -import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.StringUtils; @@ -16,13 +15,13 @@ import java.util.Date; public class RetailAppMessage { private String title; private String body; - private PartnerRole role = PartnerRole.ADMIN; + private JSONObject data; public JSONObject forSave(String appid, int clientId) { JSONObject msg = new JSONObject(); msg.put("appid", appid); msg.put("client_id", clientId); - msg.put("role", role.getCode()); + msg.put("role", "admin"); msg.put("title", title); msg.put("body", body); msg.put("send_time", new Date()); @@ -38,7 +37,7 @@ public class RetailAppMessage { managerMsg.put("title", title); managerMsg.put("body", body); managerMsg.put("type", sendType); - managerMsg.put("data", new JSONObject()); + managerMsg.put("data", data == null ? new JSONObject() : data); managerMsg.put("msgType", AppMessageType.MESSAGE.name()); return new AppManagerMessageBuilder(managerMsg).buildMessage(); } @@ -61,16 +60,12 @@ public class RetailAppMessage { return this; } - public PartnerRole getRole() { - return role; + public JSONObject getData() { + return data; } - public RetailAppMessage setRole(PartnerRole role) { - this.role = role; + public RetailAppMessage setData(JSONObject data) { + this.data = data; return this; } - - public boolean acceptRole(int roleNumber) { - return role.getCode() <= roleNumber; - } } 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 ef2ead78d..5e311c721 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 @@ -1423,7 +1423,7 @@ public class RetailAppServiceImp implements RetailAppService { if (token == null) { continue; } - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "notice", token,remark); + JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "notice", token, remark); try { JSONObject type = new JSONObject(); type.put("send_type", "notice"); @@ -2206,7 +2206,7 @@ public class RetailAppServiceImp implements RetailAppService { } String codeKeyValue = RandomStringUtils.random(6, false, true); logger.debug("send sms code : {} ", codeKeyValue); - String nationCode = phone.getString("nation_code").contains("+")?phone.getString("nation_code").substring(1):phone.getString("nation_code"); + String nationCode = phone.getString("nation_code").contains("+") ? phone.getString("nation_code").substring(1) : phone.getString("nation_code"); String phoneNumber = phone.getString("contact_phone"); ArrayList param = new ArrayList<>(); param.add("绑定手机号"); @@ -2221,6 +2221,7 @@ public class RetailAppServiceImp implements RetailAppService { } stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES); } + @Override public void sendUnbindAccountPhone(JSONObject device) { String codeKey = device.getString("account_id"); @@ -2230,7 +2231,7 @@ public class RetailAppServiceImp implements RetailAppService { } JSONObject client = clientAccountMapper.findById(device.getString("account_id")); String codeKeyValue = RandomStringUtils.random(6, false, true); - String nationCode = client.getString("nation_code").contains("+")?client.getString("nation_code").substring(1):client.getString("nation_code"); + String nationCode = client.getString("nation_code").contains("+") ? client.getString("nation_code").substring(1) : client.getString("nation_code"); String phoneNumber = client.getString("contact_phone"); ArrayList param = new ArrayList<>(); param.add("解綁绑定手机号"); @@ -2260,7 +2261,7 @@ public class RetailAppServiceImp implements RetailAppService { throw new BadRequestException("Verification code is wrong"); } List account = clientAccountMapper.findByPhone(contactPhone, "+" + nationCode); - if (account != null && account.size()>0) { + if (account != null && account.size() > 0) { throw new BadRequestException("Mobile phone number has been bound to other users, please unbind it before binding"); } @@ -2332,19 +2333,19 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject bindAccountWechat(JSONObject device, JSONObject params) { JSONObject user = mpClientAppWechatApiProvider.getApi("merchant-app").appLoginUser(params.getString("code")); if (user == null) { - throw new BadRequestException("WeChat users do not exist"); + throw new BadRequestException("WeChat users do not exist"); } String openId = user.getString("openid"); JSONObject account = clientAccountMapper.findByOpenId(openId); if (account != null) { throw new BadRequestException("WeChat ID has been bound to other accounts, please unbind it before binding"); } - JSONObject wechatUserInfo = mpClientAppWechatApiProvider.getApi("merchant-app").appUserInfo(openId,user.getString("access_token")); + JSONObject wechatUserInfo = mpClientAppWechatApiProvider.getApi("merchant-app").appUserInfo(openId, user.getString("access_token")); JSONObject updateAccount = new JSONObject(); updateAccount.put("account_id", device.getString("account_id")); updateAccount.put("wechat_openid", openId); - updateAccount.put("wechat_name",wechatUserInfo.getString("nickname")); - updateAccount.put("wx_unionid",wechatUserInfo.getString("unionid")); + updateAccount.put("wechat_name", wechatUserInfo.getString("nickname")); + updateAccount.put("wx_unionid", wechatUserInfo.getString("unionid")); clientAccountMapper.update(updateAccount); JSONObject result = new JSONObject(); result.put("status", "success"); @@ -2355,16 +2356,16 @@ public class RetailAppServiceImp implements RetailAppService { public JSONObject getAccountBindInfos(JSONObject device) { JSONObject account = clientAccountMapper.findById(device.getString("account_id")); JSONObject result = new JSONObject(); - result.put("phone_bind_status",account.containsKey("contact_phone")); - if(account.containsKey("contact_phone")){ - result.put("contact_phone",account.getString("contact_phone")); - String contact_phone = account.getString("contact_phone").replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2"); - result.put("remark_contact_phone",contact_phone); - result.put("nation_code",account.getString("nation_code")); + result.put("phone_bind_status", account.containsKey("contact_phone")); + if (account.containsKey("contact_phone")) { + result.put("contact_phone", account.getString("contact_phone")); + String contact_phone = account.getString("contact_phone").replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"); + result.put("remark_contact_phone", contact_phone); + result.put("nation_code", account.getString("nation_code")); } - result.put("wechat_bind_status",account.containsKey("wx_unionid")); - if(account.containsKey("wx_unionid")){ - result.put("wechat_name",account.getString("wechat_name")); + result.put("wechat_bind_status", account.containsKey("wx_unionid")); + if (account.containsKey("wx_unionid")) { + result.put("wechat_name", account.getString("wechat_name")); } return result; } @@ -2514,8 +2515,8 @@ public class RetailAppServiceImp implements RetailAppService { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); JSONObject client = clientMapper.findClient(device.getIntValue("client_id")); - if(!("PINE".equals(client.getString("client_moniker")) - || "LEOH".equals(client.getString("client_moniker"))) ){ + if (!("PINE".equals(client.getString("client_moniker")) + || "LEOH".equals(client.getString("client_moniker")))) { return null; } JSONObject account = clientAccountMapper.findById(device.getString("account_id")); @@ -2527,18 +2528,26 @@ public class RetailAppServiceImp implements RetailAppService { List supplement_array = new ArrayList<>(); JSONObject complianceFilesNotice = complianceFilesNotice(client,account); JSONObject kycFilesNotice = kycFilesNotice(client,account); + + if(complianceFilesNotice != null && kycFilesNotice != null){ + if( !kycFilesNotice.getBoolean("client_less_file") && !complianceFilesNotice.getBoolean("client_less_file")){ + authFileStatus.put("isNeedShowKycAlert",false); + }else{ + authFileStatus.put("isNeedShowKycAlert",true); + } + } if (PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) { return null; } - if(complianceFilesNotice != null){ + if (complianceFilesNotice != null) { JSONObject complianceStatus = retailAppService.getClientAuthFileStatus(device); complianceFilesNotice.putAll(complianceStatus); supplement_array.add(complianceFilesNotice); } - if(kycFilesNotice != null){ - supplement_array.add(kycFilesNotice); + if (kycFilesNotice != null) { + supplement_array.add(kycFilesNotice); } - authFileStatus.put("supplement_array",supplement_array); + authFileStatus.put("supplement_array", supplement_array); return authFileStatus; } @@ -2555,7 +2564,7 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject file = checkKycFileStatusForApp(client); JSONObject compliance = clientComplianceCompanyMapper.findKycFileByClientId(device.getIntValue("client_id")); file.put("file_company", compliance); - if(compliance != null){ + if (compliance != null) { file.put("id_type", compliance.getString("id_type")); } return file; @@ -2565,9 +2574,9 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject result = new JSONObject(); boolean lessKycFiles = true; JSONObject kycFilesAuth = clientComplianceCompanyMapper.findKycFileComplete(client.getIntValue("client_id")); - if(kycFilesAuth != null + if (kycFilesAuth != null || !("PINE".equals(client.getString("client_moniker")) - || "LEOH".equals(client.getString("client_moniker")))){ + || "LEOH".equals(client.getString("client_moniker")))) { lessKycFiles = false; } result.put("help_confirm", messageSource.getMessage("client.auth.file.help_confirm", null, RequestEnvironment.getLocale())); @@ -2577,7 +2586,7 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject compliance = clientComplianceCompanyMapper.findKycFileByClientId(client.getIntValue("client_id")); if (lessKycFiles || compliance != null) { List kycFiles = new ArrayList<>(); - kycFiles = clientFilesMapper.findKycClientFileByClient(client.getIntValue("client_id")); + kycFiles = clientFilesMapper.findKycClientFileByClient(client.getIntValue("client_id")); for (JSONObject file : kycFiles) { result.put(file.getString("file_name"), file.getString("file_value")); } @@ -2600,19 +2609,19 @@ public class RetailAppServiceImp implements RetailAppService { } - - - public JSONObject complianceFilesNotice(JSONObject client,JSONObject account){ + public JSONObject complianceFilesNotice(JSONObject client, JSONObject account) { JSONObject complianceFilesNotice = new JSONObject(); JSONObject complianceFileStatus = signInAccountService.checkAuthFileStatus(client); JSONObject compliance = clientComplianceCompanyMapper.findFileByClientId(account.getIntValue("client_id")); - complianceFilesNotice.put("auth_type",FilesAuthTypeEnum.COMPLIANCE.getAuthType()); + complianceFilesNotice.put("auth_type", FilesAuthTypeEnum.COMPLIANCE.getAuthType()); complianceFilesNotice.put("type", messageSource.getMessage("client.auth.file.compliance.type", null, RequestEnvironment.getLocale())); complianceFilesNotice.put("client_less_file",complianceFileStatus.getBoolean("client_less_file")); if(compliance != null){ - complianceFilesNotice.put("client_refuse_reason",compliance.getString("description")); + if(complianceFileStatus.getBoolean("client_less_file")){ + complianceFilesNotice.put("client_refuse_reason",compliance.getString("description")); + } complianceFilesNotice.put("status",compliance.getString("status")); complianceFilesNotice.put( "status_type", FilesAuthStatusEnum.STATUS.getAuthStatus(compliance.getIntValue("status")) ); }else if( !complianceFileStatus.getBoolean("client_less_file")){ @@ -2620,31 +2629,33 @@ public class RetailAppServiceImp implements RetailAppService { }else{ complianceFilesNotice.put( "status_type", FilesAuthStatusEnum.STATUS.getAuthStatus(-1) ); } - complianceFilesNotice.put("status_type_description", messageSource.getMessage("client.auth.file.status."+ complianceFilesNotice.getString( "status_type").toLowerCase(), null, RequestEnvironment.getLocale())); + complianceFilesNotice.put("status_type_description", messageSource.getMessage("client.auth.file.status." + complianceFilesNotice.getString("status_type").toLowerCase(), null, RequestEnvironment.getLocale())); return complianceFilesNotice; } - public JSONObject kycFilesNotice(JSONObject client,JSONObject account){ + public JSONObject kycFilesNotice(JSONObject client, JSONObject account) { JSONObject kycFilesNotice = new JSONObject(); - JSONObject kycFileStatus = signInAccountService.checkKycFileStatusForApp(client,account); + JSONObject kycFileStatus = signInAccountService.checkKycFileStatusForApp(client, account); JSONObject compliance = clientComplianceCompanyMapper.findKycFileByClientId(account.getIntValue("client_id")); /* if(!kycFileStatus.getBoolean("client_less_file")){ return null; }*/ - kycFilesNotice.put("auth_type",FilesAuthTypeEnum.KYC.getAuthType()); + kycFilesNotice.put("auth_type", FilesAuthTypeEnum.KYC.getAuthType()); kycFilesNotice.put("type", messageSource.getMessage("client.auth.file.kyc.type", null, RequestEnvironment.getLocale())); kycFilesNotice.put("client_less_file",kycFileStatus.getBoolean("client_less_file")); if(compliance != null){ - kycFilesNotice.put("client_refuse_reason",compliance.getString("description")); + if(kycFilesNotice.getBoolean("client_less_file")){ + kycFilesNotice.put("client_refuse_reason",compliance.getString("description")); + } kycFilesNotice.put("status",compliance.getString("status")); kycFilesNotice.put( "status_type", FilesAuthStatusEnum.STATUS.getAuthStatus(compliance.getIntValue("status")) ); }else{ kycFilesNotice.put( "status_type", FilesAuthStatusEnum.STATUS.getAuthStatus(-1) ); } - kycFilesNotice.put("status_type_description", messageSource.getMessage("client.auth.file.status."+ kycFilesNotice.getString( "status_type").toLowerCase(), null, RequestEnvironment.getLocale())); + kycFilesNotice.put("status_type_description", messageSource.getMessage("client.auth.file.status." + kycFilesNotice.getString("status_type").toLowerCase(), null, RequestEnvironment.getLocale())); return kycFilesNotice; } @@ -2777,7 +2788,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.uploadKycFilesForWaitComplianceForApp(account, client.getString("client_moniker"), filesInfo,fileType); + clientManager.uploadKycFilesForWaitComplianceForApp(account, client.getString("client_moniker"), filesInfo, fileType); } @@ -2799,7 +2810,7 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void commitAuthFilesToKyc(JSONObject device,String idType) { + public void commitAuthFilesToKyc(JSONObject device, String idType) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); @@ -2855,14 +2866,9 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject msg = message.forSave(appid, clientId); authAppMessageMapper.save(msg); String msgId = msg.getString("message_id"); - List tokens = clientDeviceTokenMapper.listTokensByClient_id(clientId); + List tokens = clientDeviceTokenMapper.listTokensByAccountId(device.getString("account_id")); final String[] supportedClientTypes = {"android", "iphone", "ipad"}; long successCount = tokens.parallelStream().filter(devToken -> ArrayUtils.contains(supportedClientTypes, devToken.getString("client_type"))) - .filter(devToken -> StringUtils.isNoneEmpty(devToken.getString("account_id"), devToken.getString("token"))) - .filter(devToken -> { - JSONObject account = clientAccountMapper.findById(devToken.getString("account_id")); - return account != null && message.acceptRole(account.getIntValue("role")); - }) .filter(devToken -> { String token = devToken.getString("token"); JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), AppMessageType.MESSAGE.name(), token, @@ -2965,7 +2971,7 @@ public class RetailAppServiceImp implements RetailAppService { res.put("base_info_lack", true); } clientLegalInfo = sysClientLegalPersonMapper.findRepresentativeInfo(res.getIntValue("client_id")); - if (clientLegalInfo == null||StringUtils.isEmpty(clientLegalInfo.getString("representative_person")) || StringUtils.isEmpty(clientLegalInfo.getString("job_title")) + if (clientLegalInfo == null || StringUtils.isEmpty(clientLegalInfo.getString("representative_person")) || StringUtils.isEmpty(clientLegalInfo.getString("job_title")) || StringUtils.isEmpty(clientLegalInfo.getString("phone")) || StringUtils.isEmpty(clientLegalInfo.getString("email")) || StringUtils.isEmpty(clientLegalInfo.getString("address")) diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.java index dd583710d..f9aaec11f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.java @@ -24,6 +24,8 @@ public interface ClientDeviceTokenMapper { List listTokensByClient_id(@Param("client_id") int client_id); + List listTokensByAccountId(@Param("client_id") String accountId); + List listAllTokens(JSONObject devToken); @AutoSql(type = SqlType.SELECT) diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.xml index 4ff113942..7ffa9c3b2 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientDeviceTokenMapper.xml @@ -13,6 +13,16 @@ GROUP BY token + +