master
wangning 7 years ago
parent 3f03b2aa18
commit 45c8e9248c

@ -136,7 +136,11 @@
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>druid</artifactId> <artifactId>druid</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.qcloudsms</groupId>
<artifactId>qcloudsms</artifactId>
<version>1.0.3</version>
</dependency>
<!--jpush start --> <!--jpush start -->
<dependency> <dependency>
<groupId>cn.jpush.api</groupId> <groupId>cn.jpush.api</groupId>

@ -12,10 +12,9 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.locale.LocaleSupport; import au.com.royalpay.payment.tools.locale.LocaleSupport;
import au.com.royalpay.payment.tools.mail.SendMail; import au.com.royalpay.payment.tools.mail.SendMail;
import au.com.royalpay.payment.tools.utils.sms.SmsSingleSender;
import au.com.royalpay.payment.tools.utils.sms.SmsSingleSenderResult;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.qcloudsms.SmsSingleSender;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -55,9 +54,9 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
private final SmsSingleSender smsSingleSender = new SmsSingleSender(appId, appKey); private final SmsSingleSender ssender = new SmsSingleSender(appId, appKey);
// private final int REGISTER_CLIENT_TEMPLID = 126008;//正式 // TODO: 2018/5/24 kira
private final int REGISTER_CLIENT_TEMPLID = 110449; private final int REGISTER_CLIENT_TEMPLID = 126008;
private final String REGISTER_CLIENT_PREFIX = "REGISTER_CLIENT"; private final String REGISTER_CLIENT_PREFIX = "REGISTER_CLIENT";
private final String REGISTER_CLIENT_PROCESS_PREFIX = "REGISTER_CLIENT_PROCESS"; private final String REGISTER_CLIENT_PROCESS_PREFIX = "REGISTER_CLIENT_PROCESS";
private final String VERIFY_MAIL_PREFIX = "VERIFY_MAIL"; private final String VERIFY_MAIL_PREFIX = "VERIFY_MAIL";
@ -95,7 +94,6 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
if (StringUtils.isNotEmpty(value)) { if (StringUtils.isNotEmpty(value)) {
throw new BadRequestException("SMS has been sentPlease check your messages or try again in 3 minutes."); throw new BadRequestException("SMS has been sentPlease check your messages or try again in 3 minutes.");
} }
JSONObject sysConfig = sysConfigManager.getSysConfig(); JSONObject sysConfig = sysConfigManager.getSysConfig();
ArrayList<String> param = new ArrayList<>(); ArrayList<String> param = new ArrayList<>();
String registerClientCode = RandomStringUtils.random(6, true, true); String registerClientCode = RandomStringUtils.random(6, true, true);
@ -103,10 +101,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
String expireMin = (String) sysConfig.getOrDefault("sms.verification.code.expire", 3); String expireMin = (String) sysConfig.getOrDefault("sms.verification.code.expire", 3);
param.add(expireMin); param.add(expireMin);
try { try {
SmsSingleSenderResult result = smsSingleSender.sendWithParam(nationCode, phoneNumber, REGISTER_CLIENT_TEMPLID, param, "", "", ""); ssender.sendWithParam(nationCode, phoneNumber, REGISTER_CLIENT_TEMPLID, param, "RoyalPay", "", ""); //
System.out.println(result);
System.out.println(result);
System.out.println(result);
} catch (Exception e) { } catch (Exception e) {
throw new ServerErrorException("System Error"); throw new ServerErrorException("System Error");
} }

@ -28,34 +28,12 @@ public class SimpleClientApplyServiceImplTest {
@Test @Test
public void partnerSignIn() { public void partnerSignIn() {
simpleClientApplyService.partnerSignIn(null);
} }
@Test @Test
public void getAndSendSmsCode() { public void getAndSendSmsCode() {
String phone = "17626011667"; simpleClientApplyService.getAndSendSmsCode("0451120326","61");
String nationCode = "+86";
String code = simpleClientApplyService.getAndSendSmsCode(phone, nationCode);
System.out.println(code);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
}
try {
simpleClientApplyService.getAndSendSmsCode(phone, nationCode);
} catch (Exception e) {
System.out.println("之前应当报错,短信已经发送");
}
simpleClientApplyService.verifyRegisterSMSCode(code, phone);
try {
simpleClientApplyService.verifyRegisterSMSCode(code, phone);
System.out.println(code);
} catch (Exception e) {
System.out.println("报错 无法验证");
}
} }
@Test @Test

Loading…
Cancel
Save