|
|
|
@ -21,7 +21,8 @@ import au.com.royalpay.payment.manage.product.beans.ProductBean;
|
|
|
|
|
import au.com.royalpay.payment.manage.product.core.ClientProduct;
|
|
|
|
|
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
|
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
|
|
|
|
|
import au.com.royalpay.payment.manage.support.sms.SmsSenderQcloudImpl;
|
|
|
|
|
import au.com.royalpay.payment.manage.support.sms.SmsSender;
|
|
|
|
|
import au.com.royalpay.payment.manage.support.sms.msg.AuthCodeMessage;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.ManageDeviceSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.support.DeviceRegister;
|
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
@ -44,6 +45,7 @@ import org.thymeleaf.spring5.SpringTemplateEngine;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -87,10 +89,9 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
@Resource
|
|
|
|
|
private SpringTemplateEngine thymeleaf;
|
|
|
|
|
@Resource
|
|
|
|
|
private SmsSenderQcloudImpl smsSender;
|
|
|
|
|
private SmsSender smsSender;
|
|
|
|
|
private final String BIND_MANAGE_EMAIL_PREFIX = "BIND_MANAGE_EMAIL";
|
|
|
|
|
private final String BIND_MANAGE_PHONE_PREFIX = "BIND_MANAGE_PHONE";
|
|
|
|
|
private final int BIND_PHONE_TEMPLID = 126978;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -121,7 +122,7 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
public List<JSONObject> getReferrerList(JSONObject device) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
return orgMapper.listOrgs(1,new PageBounds());
|
|
|
|
|
return orgMapper.listOrgs(1, new PageBounds());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -137,7 +138,7 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
|
|
|
|
|
if (StringUtils.isNotBlank(info.getClient_pay_type())&& StringUtils.isNotBlank(info.getClient_pay_desc())) {
|
|
|
|
|
if (StringUtils.isNotBlank(info.getClient_pay_type()) && StringUtils.isNotBlank(info.getClient_pay_desc())) {
|
|
|
|
|
info.setClient_pay_type("");
|
|
|
|
|
info.setClient_pay_desc("");
|
|
|
|
|
}
|
|
|
|
@ -149,7 +150,7 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
|
|
|
|
|
clientManager.disableClient(clientMoniker,manager);
|
|
|
|
|
clientManager.disableClient(clientMoniker, manager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -215,7 +216,7 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
List<JSONObject> rates = clientManager.clientRates(clientMoniker, true);
|
|
|
|
|
return rates.stream().collect(Collectors.groupingBy(e -> e.getString("rate_name"),HashMap::new,Collectors.toList()));
|
|
|
|
|
return rates.stream().collect(Collectors.groupingBy(e -> e.getString("rate_name"), HashMap::new, Collectors.toList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -270,7 +271,7 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
|
|
|
|
|
clientManager.uploadAuthFiles(manager, clientMoniker,filesInfo);
|
|
|
|
|
clientManager.uploadAuthFiles(manager, clientMoniker, filesInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -373,7 +374,7 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
Calendar monthCal = Calendar.getInstance();
|
|
|
|
|
monthCal.setTime(new Date());
|
|
|
|
|
monthCal.set(Calendar.MONTH, (monthCal.get(Calendar.MONTH) - 1));
|
|
|
|
|
JSONObject total = financialPartnerCommissionMapper.findTotalByOrg(monthCal.get(Calendar.YEAR), monthCal.get(Calendar.MONTH)+1, manager.getString("org_id"));
|
|
|
|
|
JSONObject total = financialPartnerCommissionMapper.findTotalByOrg(monthCal.get(Calendar.YEAR), monthCal.get(Calendar.MONTH) + 1, manager.getString("org_id"));
|
|
|
|
|
if (total == null) {
|
|
|
|
|
total = new JSONObject();
|
|
|
|
|
total.put("total_amount", BigDecimal.ZERO);
|
|
|
|
@ -404,7 +405,7 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<JSONObject> getBdPrizeList(JSONObject device) {
|
|
|
|
|
public List<JSONObject> getBdPrizeList(JSONObject device) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
|
|
|
|
@ -465,15 +466,15 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
public void bindAccountEmail(JSONObject device, JSONObject email) {
|
|
|
|
|
String codeKey = device.getString("manager_id");
|
|
|
|
|
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateManageEmailKey(codeKey)).get();
|
|
|
|
|
if(StringUtils.isNotEmpty(codeKeyValueRedis)){
|
|
|
|
|
if (StringUtils.isNotEmpty(codeKeyValueRedis)) {
|
|
|
|
|
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 manager = managerMapper.findById(device.getString("manager_id"));
|
|
|
|
|
ctx.setVariable("account",manager);
|
|
|
|
|
ctx.setVariable("captcha",codeKeyValue);
|
|
|
|
|
ctx.setVariable("account", manager);
|
|
|
|
|
ctx.setVariable("captcha", codeKeyValue);
|
|
|
|
|
final String content = thymeleaf.process("mail/account_bind_email.html", ctx);
|
|
|
|
|
royalThreadPoolExecutor.execute(() -> {
|
|
|
|
|
try {
|
|
|
|
@ -483,23 +484,23 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
throw new EmailException("Email Sending Failed", e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
stringRedisTemplate.boundValueOps(getUpdateManageEmailKey(codeKey)).set(codeKeyValue+"&"+email.getString("contact_email"), 5, TimeUnit.MINUTES);
|
|
|
|
|
stringRedisTemplate.boundValueOps(getUpdateManageEmailKey(codeKey)).set(codeKeyValue + "&" + email.getString("contact_email"), 5, TimeUnit.MINUTES);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateAccountEmail(JSONObject device, JSONObject params) {
|
|
|
|
|
String key = stringRedisTemplate.boundValueOps(getUpdateManageEmailKey(device.getString("manager_id"))).get();
|
|
|
|
|
if(key == null){
|
|
|
|
|
if (key == null) {
|
|
|
|
|
throw new BadRequestException("Captcha has expired");
|
|
|
|
|
}
|
|
|
|
|
String captcha = key.split("&")[0];
|
|
|
|
|
String email = key.split("&")[1];
|
|
|
|
|
if(!StringUtils.equals(captcha,params.getString("captcha"))){
|
|
|
|
|
if (!StringUtils.equals(captcha, params.getString("captcha"))) {
|
|
|
|
|
throw new BadRequestException("Verification code is wrong");
|
|
|
|
|
}
|
|
|
|
|
JSONObject account = new JSONObject();
|
|
|
|
|
account.put("manager_id",device.getString("manager_id"));
|
|
|
|
|
account.put("email",email);
|
|
|
|
|
JSONObject account = new JSONObject();
|
|
|
|
|
account.put("manager_id", device.getString("manager_id"));
|
|
|
|
|
account.put("email", email);
|
|
|
|
|
managerMapper.update(account);
|
|
|
|
|
deleteManageEmailKey(device.getString("manager_id"));
|
|
|
|
|
}
|
|
|
|
@ -508,60 +509,55 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
public void bindAccountPhone(JSONObject device, JSONObject phone) {
|
|
|
|
|
String codeKey = device.getString("manager_id");
|
|
|
|
|
String codeKeyValueRedis = stringRedisTemplate.boundValueOps(getUpdateManagePhoneKey(codeKey)).get();
|
|
|
|
|
if(StringUtils.isNotEmpty(codeKeyValueRedis)){
|
|
|
|
|
if (StringUtils.isNotEmpty(codeKeyValueRedis)) {
|
|
|
|
|
throw new BadRequestException("Captcha has been sent.Please check your phone or try again in 5 minutes.");
|
|
|
|
|
}
|
|
|
|
|
String codeKeyValue = RandomStringUtils.random(6, false, true);
|
|
|
|
|
logger.debug("send sms code : {} ", codeKeyValue);
|
|
|
|
|
String nationCode = phone.getString("nation_code");
|
|
|
|
|
String phoneNumber = phone.getString("contact_phone");
|
|
|
|
|
ArrayList<String> param = new ArrayList<>();
|
|
|
|
|
param.add("绑定手机号");
|
|
|
|
|
param.add(codeKeyValue);
|
|
|
|
|
String expireMin = "5";
|
|
|
|
|
param.add(expireMin);
|
|
|
|
|
try {
|
|
|
|
|
smsSender.getSender().sendWithParam(nationCode.trim(), phoneNumber, BIND_PHONE_TEMPLID, param, "RoyalPay", "", "");
|
|
|
|
|
smsSender.sendAuthCodeMessage(nationCode.trim(), phoneNumber, Locale.ENGLISH, new AuthCodeMessage("绑定手机号", codeKeyValue, 5));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
throw new ServerErrorException("Phone number is wrong.Please try again.");
|
|
|
|
|
}
|
|
|
|
|
stringRedisTemplate.boundValueOps(getUpdateManagePhoneKey(codeKey)).set(codeKeyValue+"&"+nationCode+"&"+phoneNumber, Long.parseLong(expireMin), TimeUnit.MINUTES);
|
|
|
|
|
stringRedisTemplate.boundValueOps(getUpdateManagePhoneKey(codeKey)).set(codeKeyValue + "&" + nationCode + "&" + phoneNumber, Duration.ofMinutes(5));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateAccountPhone(JSONObject device, JSONObject params) {
|
|
|
|
|
String key = stringRedisTemplate.boundValueOps(getUpdateManagePhoneKey(device.getString("manager_id"))).get();
|
|
|
|
|
if(key == null){
|
|
|
|
|
if (key == null) {
|
|
|
|
|
throw new BadRequestException("Captcha has expired");
|
|
|
|
|
}
|
|
|
|
|
String captcha = key.split("&")[0];
|
|
|
|
|
String nation_code = key.split("&")[1];
|
|
|
|
|
String contact_phone = key.split("&")[2];
|
|
|
|
|
if(!StringUtils.equals(captcha,params.getString("captcha"))){
|
|
|
|
|
if (!StringUtils.equals(captcha, params.getString("captcha"))) {
|
|
|
|
|
throw new BadRequestException("Verification code is wrong");
|
|
|
|
|
}
|
|
|
|
|
JSONObject account = new JSONObject();
|
|
|
|
|
account.put("manager_id",device.getString("manager_id"));
|
|
|
|
|
account.put("contact_phone",contact_phone);
|
|
|
|
|
account.put("nation_code","+" + nation_code);
|
|
|
|
|
JSONObject account = new JSONObject();
|
|
|
|
|
account.put("manager_id", device.getString("manager_id"));
|
|
|
|
|
account.put("contact_phone", contact_phone);
|
|
|
|
|
account.put("nation_code", "+" + nation_code);
|
|
|
|
|
managerMapper.update(account);
|
|
|
|
|
deleteManagePhoneKey(device.getString("manager_id"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deleteManageEmailKey(String codeKey){
|
|
|
|
|
private void deleteManageEmailKey(String codeKey) {
|
|
|
|
|
stringRedisTemplate.delete(getUpdateManageEmailKey(codeKey));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deleteManagePhoneKey(String codeKey){
|
|
|
|
|
private void deleteManagePhoneKey(String codeKey) {
|
|
|
|
|
stringRedisTemplate.delete(getUpdateManagePhoneKey(codeKey));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getUpdateManageEmailKey(String codeKey){
|
|
|
|
|
return BIND_MANAGE_EMAIL_PREFIX+codeKey;
|
|
|
|
|
private String getUpdateManageEmailKey(String codeKey) {
|
|
|
|
|
return BIND_MANAGE_EMAIL_PREFIX + codeKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getUpdateManagePhoneKey(String codeKey){
|
|
|
|
|
return BIND_MANAGE_PHONE_PREFIX+codeKey;
|
|
|
|
|
private String getUpdateManagePhoneKey(String codeKey) {
|
|
|
|
|
return BIND_MANAGE_PHONE_PREFIX + codeKey;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|