diff --git a/pom.xml b/pom.xml index 7944e31da..6dafecfa8 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ 4.0.0 manage - 1.2.59 + 1.2.60 UTF-8 diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index 782c9d590..5836b9e72 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -189,7 +189,9 @@ public interface RetailAppService { void updateAccountEmail(JSONObject device, JSONObject codekey); - void bindAccountPhone(JSONObject device); + void sendBindAccountPhone(JSONObject device,JSONObject phone); + + void sendUnbindAccountPhone(JSONObject device); JSONObject updateAccountPhone(JSONObject device,JSONObject codekey); 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 e162f3ce1..bd7a62c6f 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 @@ -2133,7 +2133,30 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public void bindAccountPhone(JSONObject device) { + 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); + 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("绑定手机号"); + 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 void sendUnbindAccountPhone(JSONObject device) { String codeKey = device.getString("account_id"); String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).get(); if (StringUtils.isNotEmpty(codeKeyValueRedis)) { @@ -2144,7 +2167,7 @@ public class RetailAppServiceImp implements RetailAppService { 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("绑定手机号"); + param.add("解綁绑定手机号"); param.add(codeKeyValue); String expireMin = "1"; param.add(expireMin); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index 24553e60c..9d7bae19e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -725,12 +725,25 @@ public class RetailAppController { * 接收关联手机的验证码 * * @param device + * @param phone contact_phone * @throws Exception */ - @PutMapping("/account/phone") - public JSONObject bindAccountPhone(@ModelAttribute(RETAIL_DEVICE) JSONObject device) throws Exception { - retailAppService.bindAccountPhone(device); - return new JSONObject(); + @PutMapping("/account/phone/bind") + public JSONObject sendBindAccountPhone(@ModelAttribute(RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject phone) throws Exception { + retailAppService.sendBindAccountPhone(device, phone); + return new JSONObject(); + } + + /** + * 接收解绑手机的验证码 + * + * @param device + * @throws Exception + */ + @PutMapping("/account/phone/unbind") + public JSONObject unBindAccountPhone(@ModelAttribute(RETAIL_DEVICE) JSONObject device) throws Exception { + retailAppService.sendUnbindAccountPhone(device); + return new JSONObject(); } /**