[Y] 自助申请商户分配NAP商户号

master
taylor.dang 6 years ago
parent db42e22648
commit 1eafeb7a98

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

Loading…
Cancel
Save