|
|
|
@ -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;
|
|
|
|
@ -200,6 +201,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";
|
|
|
|
|
|
|
|
|
@ -2113,11 +2116,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");
|
|
|
|
@ -2128,35 +2134,133 @@ 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 = 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
|
|
|
|
|
<<<<<<< Updated upstream
|
|
|
|
|
=======
|
|
|
|
|
public JSONObject unbindAccountPhone(JSONObject device, JSONObject phone) {
|
|
|
|
|
|
|
|
|
|
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateAccountPhoneKey(device.getString("account_id"))).get();
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
if (codeKeyValueRedis == null) {
|
|
|
|
|
result.put("status","error");
|
|
|
|
|
result.put("message","Captcha has expired");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
String captcha = codeKeyValueRedis.split("&")[0];
|
|
|
|
|
if (!StringUtils.equals(captcha, phone.getString("captcha"))) {
|
|
|
|
|
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);
|
|
|
|
|
account.put("contact_phone", null);
|
|
|
|
|
account.put("nation_code", null);
|
|
|
|
|
clientAccountMapper.update(account);
|
|
|
|
|
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
|
|
|
|
|
>>>>>>> Stashed changes
|
|
|
|
|
public void verifyRefundPassword(JSONObject device, JSONObject json) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
deviceSupport.findRegister(clientType);
|
|
|
|
|