|
|
@ -1,7 +1,9 @@
|
|
|
|
package au.com.royalpay.payment.manage.application.core.impls;
|
|
|
|
package au.com.royalpay.payment.manage.application.core.impls;
|
|
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
|
|
|
|
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment;
|
|
|
|
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
|
|
|
|
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.core.mappers.PmtSubMerchantIdMapper;
|
|
|
|
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
|
|
|
|
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
|
|
|
|
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionPartnerManager;
|
|
|
|
import au.com.royalpay.payment.manage.management.sysconfig.core.PermissionPartnerManager;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.preapply.SysClientPreMapperMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.preapply.SysClientPreMapperMapper;
|
|
|
@ -14,6 +16,7 @@ import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
|
|
|
|
import au.com.royalpay.payment.manage.support.sms.SmsSender;
|
|
|
|
import au.com.royalpay.payment.manage.support.sms.SmsSender;
|
|
|
|
import au.com.royalpay.payment.manage.system.core.MailGunService;
|
|
|
|
import au.com.royalpay.payment.manage.system.core.MailGunService;
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.env.RequestEnvironment;
|
|
|
|
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
|
|
|
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
@ -47,6 +50,7 @@ import java.util.Random;
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
@ -85,7 +89,8 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
private ClientRateMapper clientRateMapper;
|
|
|
|
private ClientRateMapper clientRateMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ClientConfigMapper clientConfigMapper;
|
|
|
|
private ClientConfigMapper clientConfigMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private PmtSubMerchantIdMapper pmtSubMerchantIdMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
|
|
|
|
|
|
|
@ -259,21 +264,16 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//todo
|
|
|
|
private void applyerToClient(String username) {
|
|
|
|
private void applyerToClient(String username) {
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
String arr[] = sysConfig.getString("temp_sub_mch_id").split(",");
|
|
|
|
String arr[] = sysConfig.getString("temp_sub_mch_id").split(",");
|
|
|
|
String tempSubMerchantId =null;
|
|
|
|
List<String> availableMerchants = WechatPayEnvironment.getEnv().getWechatMerchantConfigs().stream()
|
|
|
|
WeChatPayConfig.Merchant availableMerchant = null;
|
|
|
|
.filter(mch->StringUtils.equals(mch.getMpId(),"globalpay"))
|
|
|
|
int errorReCounts = 6;
|
|
|
|
.map(WeChatPayConfig.Merchant::getMerchantId)
|
|
|
|
for (int i = 0; i < errorReCounts; i++) {
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
try{
|
|
|
|
JSONObject subMerchant = pmtSubMerchantIdMapper.randomOne(availableMerchants);
|
|
|
|
tempSubMerchantId =arr[new Random().nextInt(arr.length)];
|
|
|
|
if(subMerchant==null){
|
|
|
|
availableMerchant = mpPaymentApi.determineMerchant(tempSubMerchantId);
|
|
|
|
|
|
|
|
i=errorReCounts;
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(availableMerchant==null){
|
|
|
|
|
|
|
|
throw new BadRequestException("System is busy Please try again");
|
|
|
|
throw new BadRequestException("System is busy Please try again");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Date now = new Date();
|
|
|
|
Date now = new Date();
|
|
|
@ -320,8 +320,8 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
sysClient.put("creator", 0);
|
|
|
|
sysClient.put("creator", 0);
|
|
|
|
sysClient.put("business_name", apply.getString("short_name"));
|
|
|
|
sysClient.put("business_name", apply.getString("short_name"));
|
|
|
|
sysClient.put("industry", 331);
|
|
|
|
sysClient.put("industry", 331);
|
|
|
|
sysClient.put("merchant_id", availableMerchant.getMerchantId());
|
|
|
|
sysClient.put("merchant_id", subMerchant.getString("merchant_id"));
|
|
|
|
sysClient.put("sub_merchant_id", tempSubMerchantId);
|
|
|
|
sysClient.put("sub_merchant_id", subMerchant.getString("sub_merchant_id"));
|
|
|
|
sysClient.put("common_sub_merchant_id", 1);
|
|
|
|
sysClient.put("common_sub_merchant_id", 1);
|
|
|
|
sysClient.put("skip_clearing", 1);
|
|
|
|
sysClient.put("skip_clearing", 1);
|
|
|
|
sysClient.put("clean_days", apply.getIntValue("clean_days"));
|
|
|
|
sysClient.put("clean_days", apply.getIntValue("clean_days"));
|
|
|
@ -330,15 +330,15 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
sysClient.put("ali_sub_merchant_id", clientMoniker);
|
|
|
|
sysClient.put("ali_sub_merchant_id", clientMoniker);
|
|
|
|
clientMapper.save(sysClient);
|
|
|
|
clientMapper.save(sysClient);
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject client_bd = new JSONObject();
|
|
|
|
JSONObject clientBd = new JSONObject();
|
|
|
|
client_bd.put("client_id", sysClient.getIntValue("client_id"));
|
|
|
|
clientBd.put("client_id", sysClient.getIntValue("client_id"));
|
|
|
|
client_bd.put("bd_id", followBd.getString("manager_id"));
|
|
|
|
clientBd.put("bd_id", followBd.getString("manager_id"));
|
|
|
|
client_bd.put("bd_name", followBd.getString("display_name"));
|
|
|
|
clientBd.put("bd_name", followBd.getString("display_name"));
|
|
|
|
client_bd.put("create_time", new Date());
|
|
|
|
clientBd.put("create_time", new Date());
|
|
|
|
client_bd.put("create_id","0");
|
|
|
|
clientBd.put("create_id","0");
|
|
|
|
client_bd.put("start_date", new Date());
|
|
|
|
clientBd.put("start_date", new Date());
|
|
|
|
client_bd.put("proportion", 1);
|
|
|
|
clientBd.put("proportion", 1);
|
|
|
|
clientBDMapper.saveBD(client_bd);
|
|
|
|
clientBDMapper.saveBD(clientBd);
|
|
|
|
|
|
|
|
|
|
|
|
int clientId = sysClient.getIntValue("client_id");
|
|
|
|
int clientId = sysClient.getIntValue("client_id");
|
|
|
|
|
|
|
|
|
|
|
|