|
|
|
@ -44,6 +44,7 @@ import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
|
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.refund.RefundService;
|
|
|
|
|
import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpClientAppWechatApiProvider;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.DeviceSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMessage;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMsgSender;
|
|
|
|
@ -203,6 +204,8 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
private SysClientLegalPersonMapper sysClientLegalPersonMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
@Resource
|
|
|
|
|
private MpClientAppWechatApiProvider mpClientAppWechatApiProvider;
|
|
|
|
|
private final String CBBANK_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/08/05/1564972204689_uwZvpTBjtLUMcN8c540xcZvux1Rd3O.pdf";
|
|
|
|
|
private final String IMG_AGGREGATE_FILE = "https://file.royalpay.com.au/open/2019/09/06/1567741055646_qeWC7kwqEwsJjRHisJSyAjqnB9nnnh.pdf";
|
|
|
|
|
|
|
|
|
@ -2119,11 +2122,14 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void bindAccountPhone(JSONObject device, JSONObject phone) {
|
|
|
|
|
public JSONObject bindAccountPhone(JSONObject device, JSONObject phone) {
|
|
|
|
|
String codeKey = device.getString("account_id");
|
|
|
|
|
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).get();
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
if (StringUtils.isNotEmpty(codeKeyValueRedis)) {
|
|
|
|
|
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 5 minutes.");
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","Captcha has been sent.Please check your phone or try again in 5 minutes.");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
String codeKeyValue = RandomStringUtils.random(6, false, true);
|
|
|
|
|
String nationCode = phone.getString("nation_code");
|
|
|
|
@ -2134,50 +2140,127 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
String expireMin = "5";
|
|
|
|
|
param.add(expireMin);
|
|
|
|
|
try {
|
|
|
|
|
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", "");
|
|
|
|
|
// smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", "");
|
|
|
|
|
stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
|
|
|
|
|
result.put("status","success");
|
|
|
|
|
result.put("code_Key_Value",codeKeyValue);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
throw new ServerErrorException("Phone number is wrong.Please try again.");
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","Phone number is wrong.Please try again.");
|
|
|
|
|
}
|
|
|
|
|
stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateAccountPhone(JSONObject device, JSONObject params) {
|
|
|
|
|
public JSONObject updateAccountPhone(JSONObject device, JSONObject params) {
|
|
|
|
|
String key = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(device.getString("account_id"))).get();
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
if (key == null) {
|
|
|
|
|
throw new BadRequestException("Captcha has expired");
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","Captcha has expired");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
String captcha = key.split("&")[0];
|
|
|
|
|
String nation_code = key.split("&")[1];
|
|
|
|
|
String contact_phone = key.split("&")[2];
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.equals(captcha, params.getString("captcha"))) {
|
|
|
|
|
throw new BadRequestException("Verification code is wrong");
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","Verification code is wrong");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
JSONObject account = new JSONObject();
|
|
|
|
|
account.put("account_id", device.getString("account_id"));
|
|
|
|
|
account.put("contact_phone", contact_phone);
|
|
|
|
|
account.put("nation_code", "+" + nation_code);
|
|
|
|
|
clientAccountMapper.update(account);
|
|
|
|
|
JSONObject account = clientAccountMapper.findByPhone(contact_phone, "+"+nation_code);
|
|
|
|
|
if(account!=null){
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","Mobile phone number has been bound to other users, please unbind it before binding");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject updateAccount = new JSONObject();
|
|
|
|
|
updateAccount.put("account_id", device.getString("account_id"));
|
|
|
|
|
updateAccount.put("contact_phone", contact_phone);
|
|
|
|
|
updateAccount.put("nation_code", "+" + nation_code);
|
|
|
|
|
clientAccountMapper.update(updateAccount);
|
|
|
|
|
deleteAccountPhoneKey(device.getString("account_id"));
|
|
|
|
|
result.put("status","success");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateLoginClientAccountPhone(JSONObject account, String contactPhone, String nationCode){
|
|
|
|
|
JSONObject updateAccount = new JSONObject();
|
|
|
|
|
updateAccount.put("account_id",account.getString("account_id"));
|
|
|
|
|
updateAccount.put("contact_phone",contactPhone);
|
|
|
|
|
updateAccount.put("nation_code","+" + nationCode);
|
|
|
|
|
clientAccountMapper.update(updateAccount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateLoginClientAccountOpenId(JSONObject account,JSONObject params){
|
|
|
|
|
JSONObject updateAccount = new JSONObject();
|
|
|
|
|
JSONObject queryAccount = account.getJSONObject("account");
|
|
|
|
|
updateAccount.put("account_id",queryAccount.getString("account_id"));
|
|
|
|
|
updateAccount.put("wechat_openid",params.getString("wechat_openid"));
|
|
|
|
|
clientAccountMapper.update(updateAccount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void unbindAccountPhone(JSONObject device, JSONObject phone) {
|
|
|
|
|
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUnbindAccountPhoneKey(device.getString("account_id"))).get();
|
|
|
|
|
public JSONObject unbindAccountPhone(JSONObject device, JSONObject phone) {
|
|
|
|
|
|
|
|
|
|
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(device.getString("account_id"))).get();
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
if (codeKeyValueRedis == null) {
|
|
|
|
|
throw new BadRequestException("Captcha has expired");
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","Captcha has expired");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
String captcha = codeKeyValueRedis.split("&")[0];
|
|
|
|
|
if (!StringUtils.equals(captcha, phone.getString("captcha"))) {
|
|
|
|
|
throw new BadRequestException("Verification code is wrong");
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","Verification code is wrong");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
JSONObject account = new JSONObject();
|
|
|
|
|
account.put("account_id", device.getString("account_id"));
|
|
|
|
|
account.put("contact_phone", "");
|
|
|
|
|
account.put("nation_code", "");
|
|
|
|
|
account.put("contact_phone", null);
|
|
|
|
|
account.put("nation_code", null);
|
|
|
|
|
clientAccountMapper.update(account);
|
|
|
|
|
deleteUnbindAccountPhoneKey(device.getString("account_id"));
|
|
|
|
|
deleteAccountPhoneKey(device.getString("account_id"));
|
|
|
|
|
result.put("status","success");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void unbindAccountWechat(JSONObject device) {
|
|
|
|
|
JSONObject account = new JSONObject();
|
|
|
|
|
account.put("account_id", device.getString("account_id"));
|
|
|
|
|
account.put("wechat_openid", null);
|
|
|
|
|
clientAccountMapper.update(account);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject bindAccountWechat(JSONObject device, JSONObject params){
|
|
|
|
|
JSONObject user = mpClientAppWechatApiProvider.getApi("merchant-app").appLoginUser(params.getString("code"));
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
if(user==null){
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","WeChat users do not exist");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
String openId = user.getString("openid");
|
|
|
|
|
JSONObject account = clientAccountMapper.findByOpenId(openId);
|
|
|
|
|
if(account!=null){
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","WeChat ID has been bound to other accounts, please unbind it before binding");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
JSONObject updateAccount = new JSONObject();
|
|
|
|
|
updateAccount.put("account_id", device.getString("account_id"));
|
|
|
|
|
updateAccount.put("wechat_openid", openId);
|
|
|
|
|
clientAccountMapper.update(updateAccount);
|
|
|
|
|
result.put("status","success");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -2540,14 +2623,6 @@ public class RetailAppServiceImp implements RetailAppService {
|
|
|
|
|
return BIND_ACCOUNT_PHONE_PREFIX + codeKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getUnbindAccountPhoneKey(String codeKey) {
|
|
|
|
|
return UNBIND_ACCOUNT_PHONE_PREFIX + codeKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deleteUnbindAccountPhoneKey(String codeKey) {
|
|
|
|
|
stringRedisTemplate.delete(getUnbindAccountPhoneKey(codeKey));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject getBankAccountByClientId(int client_id) {
|
|
|
|
|
List<JSONObject> list = clientBankAccountMapper.clientBankAccounts(client_id);
|
|
|
|
|
return list.isEmpty() ? new JSONObject() : list.get(0);
|
|
|
|
|