sms服务替换

master
yixian 4 years ago
parent 8214e507e6
commit f799b86c4d

@ -21,7 +21,8 @@ import au.com.royalpay.payment.manage.product.beans.ProductBean;
import au.com.royalpay.payment.manage.product.core.ClientProduct; import au.com.royalpay.payment.manage.product.core.ClientProduct;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.support.sms.SmsSenderQcloudImpl; import au.com.royalpay.payment.manage.support.sms.SmsSender;
import au.com.royalpay.payment.manage.support.sms.msg.AuthCodeMessage;
import au.com.royalpay.payment.tools.device.ManageDeviceSupport; import au.com.royalpay.payment.tools.device.ManageDeviceSupport;
import au.com.royalpay.payment.tools.device.support.DeviceRegister; import au.com.royalpay.payment.tools.device.support.DeviceRegister;
import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.PlatformEnvironment;
@ -44,6 +45,7 @@ import org.thymeleaf.spring5.SpringTemplateEngine;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.Duration;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -87,10 +89,9 @@ public class ManageAppServiceImp implements ManageAppService {
@Resource @Resource
private SpringTemplateEngine thymeleaf; private SpringTemplateEngine thymeleaf;
@Resource @Resource
private SmsSenderQcloudImpl smsSender; private SmsSender smsSender;
private final String BIND_MANAGE_EMAIL_PREFIX = "BIND_MANAGE_EMAIL"; private final String BIND_MANAGE_EMAIL_PREFIX = "BIND_MANAGE_EMAIL";
private final String BIND_MANAGE_PHONE_PREFIX = "BIND_MANAGE_PHONE"; private final String BIND_MANAGE_PHONE_PREFIX = "BIND_MANAGE_PHONE";
private final int BIND_PHONE_TEMPLID = 126978;
@Override @Override
@ -515,18 +516,13 @@ public class ManageAppServiceImp implements ManageAppService {
logger.debug("send sms code : {} ", codeKeyValue); logger.debug("send sms code : {} ", codeKeyValue);
String nationCode = phone.getString("nation_code"); String nationCode = phone.getString("nation_code");
String phoneNumber = phone.getString("contact_phone"); String phoneNumber = phone.getString("contact_phone");
ArrayList<String> param = new ArrayList<>();
param.add("绑定手机号");
param.add(codeKeyValue);
String expireMin = "5";
param.add(expireMin);
try { try {
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", ""); smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("绑定手机号", codeKeyValue, 5));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new ServerErrorException("Phone number is wrong.Please try again."); throw new ServerErrorException("Phone number is wrong.Please try again.");
} }
stringRedisTemplate.boundValueOps(getUpdateManagePhoneKey(codeKey)).set(codeKeyValue+"&"+nationCode+"&"+phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES); stringRedisTemplate.boundValueOps(getUpdateManagePhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Duration.ofMinutes(5));
} }
@Override @Override

@ -46,7 +46,8 @@ import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum;
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService; import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl; import au.com.royalpay.payment.manage.signin.core.impls.SignInAccountServiceImpl;
import au.com.royalpay.payment.manage.support.sms.SmsSenderQcloudImpl; import au.com.royalpay.payment.manage.support.sms.SmsSender;
import au.com.royalpay.payment.manage.support.sms.msg.AuthCodeMessage;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.manage.tradelog.refund.RefundService; import au.com.royalpay.payment.manage.tradelog.refund.RefundService;
@ -106,6 +107,7 @@ import java.math.RoundingMode;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.*; import java.util.*;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
@ -234,11 +236,10 @@ public class RetailAppServiceImp implements RetailAppService {
private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2020/04/08/1586313342533_41vI3w9R8OHrhAVYWvdv7S2IyQra4z.pdf"; private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2020/04/08/1586313342533_41vI3w9R8OHrhAVYWvdv7S2IyQra4z.pdf";
@Resource @Resource
private SmsSenderQcloudImpl smsSender; private SmsSender smsSender;
private final String BIND_ACCOUNT_EMAIL_PREFIX = "BIND_ACCOUNT_EMAIL"; private final String BIND_ACCOUNT_EMAIL_PREFIX = "BIND_ACCOUNT_EMAIL";
private final String BIND_ACCOUNT_PHONE_PREFIX = "BIND_ACCOUNT_PHONE"; private final String BIND_ACCOUNT_PHONE_PREFIX = "BIND_ACCOUNT_PHONE";
private final String UNBIND_ACCOUNT_PHONE_PREFIX = "UHBIND_ACCOUNT_PHONE"; private final String UNBIND_ACCOUNT_PHONE_PREFIX = "UHBIND_ACCOUNT_PHONE";
private final int BIND_PHONE_TEMPLID = 126978;
private Map<String, AppMsgSender> senderMap = new HashMap<>(); private Map<String, AppMsgSender> senderMap = new HashMap<>();
private final String fileName[] = {"client_bank_file", "client_id_file", "client_company_file"}; private final String fileName[] = {"client_bank_file", "client_id_file", "client_company_file"};
@ -2234,18 +2235,13 @@ public class RetailAppServiceImp implements RetailAppService {
logger.debug("send sms code : {} ", codeKeyValue); 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"); String phoneNumber = phone.getString("contact_phone");
ArrayList<String> param = new ArrayList<>();
param.add("绑定手机号");
param.add(codeKeyValue);
String expireMin = "1";
param.add(expireMin);
try { try {
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", ""); smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("绑定手机号", codeKeyValue, 1));
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
throw new BadRequestException("Phone number is wrong.Please try again."); throw new BadRequestException("Phone number is wrong.Please try again.");
} }
stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES); stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Duration.ofMinutes(1));
} }
@Override @Override
@ -2259,18 +2255,13 @@ public class RetailAppServiceImp implements RetailAppService {
String codeKeyValue = RandomStringUtils.random(6, false, true); 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"); String phoneNumber = client.getString("contact_phone");
ArrayList<String> param = new ArrayList<>();
param.add("解綁绑定手机号");
param.add(codeKeyValue);
String expireMin = "1";
param.add(expireMin);
try { try {
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", ""); smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("解綁绑定手机号", codeKeyValue, 1));
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
throw new BadRequestException("Phone number is wrong.Please try again."); throw new BadRequestException("Phone number is wrong.Please try again.");
} }
stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES); stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Duration.ofMinutes(1));
} }
@Override @Override

@ -23,7 +23,6 @@ public class SmsSenderQcloudImpl implements SmsSender {
private static final int REGISTER_CLIENT_TEMPLID_ZH = 126978; private static final int REGISTER_CLIENT_TEMPLID_ZH = 126978;
private static final int REGISTER_CLIENT_TEMPLID_EN = 346078; private static final int REGISTER_CLIENT_TEMPLID_EN = 346078;
private static final int REFUSE_CLIENT_TEMPLID = 166108; private static final int REFUSE_CLIENT_TEMPLID = 166108;
private static final int RESET_PASSWORD_TEMPLID = 126978;
private final SmsSingleSender sender; private final SmsSingleSender sender;
private final String sign; private final String sign;

Loading…
Cancel
Save