|
|
|
@ -2098,6 +2098,7 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
throw new BadRequestException("Captcha has been sent.Please check your email or try again in 5 minutes.");
|
|
|
|
|
}
|
|
|
|
|
String codeKeyValue = RandomStringUtils.random(6, false, true);
|
|
|
|
|
logger.debug("send sms code : {} ", codeKeyValue);
|
|
|
|
|
Context ctx = new Context();
|
|
|
|
|
JSONObject account = clientAccountMapper.findById(device.getString("account_id"));
|
|
|
|
|
ctx.setVariable("account", account);
|
|
|
|
@ -2133,13 +2134,14 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void bindAccountPhone(JSONObject device, JSONObject phone) {
|
|
|
|
|
public void sendBindAccountPhone(JSONObject device, JSONObject phone) {
|
|
|
|
|
String codeKey = device.getString("account_id");
|
|
|
|
|
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).get();
|
|
|
|
|
if (StringUtils.isNotEmpty(codeKeyValueRedis)) {
|
|
|
|
|
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 1 minutes.");
|
|
|
|
|
}
|
|
|
|
|
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 phoneNumber = phone.getString("contact_phone");
|
|
|
|
|
ArrayList<String> param = new ArrayList<>();
|
|
|
|
@ -2155,6 +2157,30 @@ 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");
|
|
|
|
|
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).get();
|
|
|
|
|
if (StringUtils.isNotEmpty(codeKeyValueRedis)) {
|
|
|
|
|
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 1 minutes.");
|
|
|
|
|
}
|
|
|
|
|
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 phoneNumber = client.getString("contact_phone");
|
|
|
|
|
ArrayList<String> param = new ArrayList<>();
|
|
|
|
|
param.add("解綁绑定手机号");
|
|
|
|
|
param.add(codeKeyValue);
|
|
|
|
|
String expireMin = "1";
|
|
|
|
|
param.add(expireMin);
|
|
|
|
|
try {
|
|
|
|
|
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", "");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
throw new BadRequestException("Phone number is wrong.Please try again.");
|
|
|
|
|
}
|
|
|
|
|
stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject updateAccountPhone(JSONObject device, JSONObject params) {
|
|
|
|
@ -2169,7 +2195,7 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
if (!StringUtils.equals(captcha, params.getString("captcha"))) {
|
|
|
|
|
throw new BadRequestException("Verification code is wrong");
|
|
|
|
|
}
|
|
|
|
|
JSONObject account = clientAccountMapper.findByPhone(contactPhone, "+" + nationCode);
|
|
|
|
|
List<JSONObject> account = clientAccountMapper.findByPhone(contactPhone, "+" + nationCode);
|
|
|
|
|
if (account != null) {
|
|
|
|
|
throw new BadRequestException("Mobile phone number has been bound to other users, please unbind it before binding");
|
|
|
|
|
}
|
|
|
|
@ -2270,7 +2296,7 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
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("naticon_code",account.getString("nation_code"));
|
|
|
|
|
result.put("nation_code",account.getString("nation_code"));
|
|
|
|
|
}
|
|
|
|
|
result.put("wechat_bind_status",account.containsKey("wechat_openid"));
|
|
|
|
|
if(account.containsKey("wechat_openid")){
|
|
|
|
|