wangning 7 years ago
parent 09976bbab9
commit 48cc6509c0

@ -4,11 +4,13 @@ import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import com.alibaba.fastjson.JSONObject;
public interface SimpleClientApplyService {
String getSMSVerifyCode(String codeKey,String phoneNumber,String nationCode);
String getSMSVerifyCode(String codeKey);
JSONObject newAccount(NewAccountBean accountBean);
void deleteSMSVerifyCodeKey(String codeKey);
String partnerSignIn(JSONObject account);
String getSmsCodeAndSend();
}

@ -1,12 +1,22 @@
package au.com.royalpay.payment.manage.application.core.impls;
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.tools.utils.sms.SmsSingleSender;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.alibaba.fastjson.JSONObject;
import javax.annotation.Resource;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import com.alibaba.fastjson.JSONObject;
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.utils.sms.SmsSingleSender;
public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
@ -14,13 +24,18 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
private int appId;
@Value("${royalpay.sms.appkey}")
private String appKey;
@Resource
private SysConfigManager sysConfigManager;
@Resource
private StringRedisTemplate stringRedisTemplate;
private final SmsSingleSender smsSingleSender = new SmsSingleSender(appId,appKey);
// TODO: 2018/5/23 kira 模板申请通过后修改
private final int REGISTER_CLIENT_TEMPLID = 123;
private final String REGISTER_CLIENT_PREFIX = "REGISTER_CLIENT";
@Override
String getSMSVerifyCode(String codeKey,String phoneNumber,String nationCode){
// smsSingleSender.sendWithParam();
return null;
public String getSMSVerifyCode(String codeKey){
return null;
}
@Override
@ -37,4 +52,19 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
public String partnerSignIn(JSONObject account) {
return null;
}
@Override
public String getSmsCodeAndSend(String phoneNumber,String nationCode) {
JSONObject sysConfig = sysConfigManager.getSysConfig();
List<String> param = new ArrayList<>();
String register_client_key = REGISTER_CLIENT_PREFIX+RandomStringUtils.random(6, true, true);
param.add(register_client_key);
String expireMin = (String) sysConfig.getOrDefault("sms.verification.code.expire",3);
param.add(expireMin);
stringRedisTemplate.boundValueOps(register_client_key).set(register_client_key, Long.parseLong(expireMin), TimeUnit.MINUTES);
param.add(DateFormatUtils.format(coupon.getDate("expiry"), "yyyy-MM-dd"));
smsSingleSender.sendWithParam(nationCode,phoneNumber,REGISTER_CLIENT_TEMPLID,,"","","");
return register_client_key;
}
}

@ -21,7 +21,7 @@ public class SimpleClientApplyController {
@RequestMapping(value = "/account/{codeKey}", method = RequestMethod.POST)
public void registerAccount(@PathVariable String codeKey, @RequestBody @Valid NewAccountBean accountBean, Errors errors, HttpServletResponse response) throws Exception {
HttpUtils.handleValidErrors(errors);
String codeValue = simpleClientApplyService.getSMSVerifyCode(codeKey,accountBean.getContactPhone(),accountBean.getNation_code());
String codeValue = simpleClientApplyService.getSMSVerifyCode(codeKey);
if (codeValue == null || !codeValue.equals(accountBean.getUsername())) {
throw new Exception("Verification code has expired or is not correct");
}

Loading…
Cancel
Save