|
|
|
@ -3,7 +3,6 @@ package au.com.royalpay.payment.manage.appclient.core.impls;
|
|
|
|
|
import au.com.royalpay.payment.core.exceptions.EmailException;
|
|
|
|
|
import au.com.royalpay.payment.manage.appclient.beans.AppMerchantBean;
|
|
|
|
|
import au.com.royalpay.payment.manage.appclient.core.ManageAppService;
|
|
|
|
|
import au.com.royalpay.payment.manage.bdprize.core.BDPrizeService;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeLogMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeRecordMapper;
|
|
|
|
@ -15,16 +14,14 @@ import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
|
import au.com.royalpay.payment.manage.notice.core.MailService;
|
|
|
|
|
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.ManagerAccountsService;
|
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
|
|
|
|
|
import au.com.royalpay.payment.manage.support.sms.SmsSender;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.DeviceSupport;
|
|
|
|
|
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;
|
|
|
|
@ -37,7 +34,6 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
@ -48,13 +44,14 @@ 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;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ManageDeviceSupport manageDeviceSupport;
|
|
|
|
@ -77,8 +74,6 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
@Resource
|
|
|
|
|
private FinancialPartnerCommissionMapper financialPartnerCommissionMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private BDPrizeService bdPrizeService;
|
|
|
|
|
@Resource
|
|
|
|
|
private FinancialBDConfigMapper financialBDConfigMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientProduct clientProduct;
|
|
|
|
@ -94,7 +89,6 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
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
|
|
|
|
@ -125,7 +119,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
|
|
|
|
@ -141,7 +135,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("");
|
|
|
|
|
}
|
|
|
|
@ -153,7 +147,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
|
|
|
|
@ -219,7 +213,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
|
|
|
|
@ -274,7 +268,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
|
|
|
|
@ -377,7 +371,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);
|
|
|
|
@ -408,7 +402,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"));
|
|
|
|
@ -469,15 +463,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 {
|
|
|
|
@ -487,23 +481,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"));
|
|
|
|
|
}
|
|
|
|
@ -512,60 +506,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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|