|
|
|
@ -48,6 +48,8 @@ import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
@ -56,11 +58,9 @@ import javax.annotation.Resource;
|
|
|
|
|
import cn.yixblog.platform.http.HttpRequestGenerator;
|
|
|
|
|
import cn.yixblog.platform.http.HttpRequestResult;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${royalpay.sms.appid:1400094878}")
|
|
|
|
|
private int appId;
|
|
|
|
|
@Value("${royalpay.sms.appkey:43390d81e20c5191c278fbf4cd275be2}")
|
|
|
|
@ -97,6 +97,8 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
private ClientConfigMapper clientConfigMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private PmtSubMerchantIdMapper pmtSubMerchantIdMapper;
|
|
|
|
|
private ThreadPoolExecutor pool = new ThreadPoolExecutor(1, 10, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
@ -140,7 +142,6 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
if (StringUtils.isNotEmpty(value)) {
|
|
|
|
|
throw new BadRequestException("SMS has been sent,Please check your messages or try again in 3 minutes.");
|
|
|
|
|
}
|
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
|
ArrayList<String> param = new ArrayList<>();
|
|
|
|
|
String registerClientCode = RandomStringUtils.random(6, false, true);
|
|
|
|
|
param.add("RoyalPay");
|
|
|
|
@ -158,17 +159,17 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sendVerifyEmail(String address, int client_id,String username) {
|
|
|
|
|
public void sendVerifyEmail(String address, int client_id, String username) {
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(client_id);
|
|
|
|
|
if (client == null) {
|
|
|
|
|
throw new BadRequestException("Merchant not found");
|
|
|
|
|
}
|
|
|
|
|
if(client.getBooleanValue("mail_confirm")){
|
|
|
|
|
throw new BadRequestException("mail address has been verified");
|
|
|
|
|
if (client.getBooleanValue("mail_confirm")) {
|
|
|
|
|
throw new BadRequestException("mail address has been verified");
|
|
|
|
|
}
|
|
|
|
|
String key = checkOrGenerateVerifyMailKey(address, null);
|
|
|
|
|
Context ctx = new Context();
|
|
|
|
|
ctx.setVariable("url", PlatformEnvironment.getEnv().concatUrl("/register/account/mail/" + address + "/verify/" + key + "/jump?username="+username));
|
|
|
|
|
ctx.setVariable("url", PlatformEnvironment.getEnv().concatUrl("/register/account/mail/" + address + "/verify/" + key + "/jump?username=" + username));
|
|
|
|
|
final String content = thymeleaf.process("mail/register_application", ctx);
|
|
|
|
|
SendMail sendMail = new SendMail();
|
|
|
|
|
Set<String> to = new HashSet<>();
|
|
|
|
@ -226,13 +227,13 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void checkAccountName(String contact_phone,String nation_code) {
|
|
|
|
|
public void checkAccountName(String contact_phone, String nation_code) {
|
|
|
|
|
nation_code = nation_code.trim();
|
|
|
|
|
if(!nation_code.startsWith("+")){
|
|
|
|
|
nation_code ="+"+nation_code;
|
|
|
|
|
if (!nation_code.startsWith("+")) {
|
|
|
|
|
nation_code = "+" + nation_code;
|
|
|
|
|
}
|
|
|
|
|
JSONObject account = clientAccountMapper.findByPhone(contact_phone,nation_code);
|
|
|
|
|
if (account != null){
|
|
|
|
|
JSONObject account = clientAccountMapper.findByPhone(contact_phone, nation_code);
|
|
|
|
|
if (account != null) {
|
|
|
|
|
throw new ForbiddenException("用户名已被注册");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -241,125 +242,125 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
@Transactional
|
|
|
|
|
public void saveOrUpdateApplyInfo(JSONObject applyInfo, String username) {
|
|
|
|
|
JSONObject apply = sysClientPreMapperMapper.findByUserName(username);
|
|
|
|
|
if (apply == null ){
|
|
|
|
|
if (apply == null) {
|
|
|
|
|
sysClientPreMapperMapper.save(applyInfo);
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
applyInfo.put("client_pre_apply_id", apply.getIntValue("client_pre_apply_id"));
|
|
|
|
|
applyInfo.put("update_time", new Date());
|
|
|
|
|
sysClientPreMapperMapper.update(applyInfo);
|
|
|
|
|
if(applyInfo.getBooleanValue("agree")){
|
|
|
|
|
if (applyInfo.getBooleanValue("agree")) {
|
|
|
|
|
applyerToClient(username);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void applyerToClient(String username){
|
|
|
|
|
private void applyerToClient(String username) {
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
JSONObject param = new JSONObject();
|
|
|
|
|
param.put("begin_time",DateFormatUtils.format(now,"YYYYMMdd"));
|
|
|
|
|
param.put("end_time",DateFormatUtils.format(DateUtils.addDays(now,1),"YYYYMMdd"));
|
|
|
|
|
param.put("agree",true);
|
|
|
|
|
List<JSONObject> existCount = sysClientPreMapperMapper.query(param);
|
|
|
|
|
if(existCount.size()>30){
|
|
|
|
|
param.put("begin_time", DateFormatUtils.format(now, "YYYYMMdd"));
|
|
|
|
|
param.put("end_time", DateFormatUtils.format(DateUtils.addDays(now, 1), "YYYYMMdd"));
|
|
|
|
|
param.put("agree", true);
|
|
|
|
|
List<JSONObject> existCount = sysClientPreMapperMapper.query(param);
|
|
|
|
|
if (existCount.size() > 30) {
|
|
|
|
|
throw new BadRequestException("New merchant over limit,Please contact us");
|
|
|
|
|
}
|
|
|
|
|
JSONObject apply = sysClientPreMapperMapper.findByUserName(username);
|
|
|
|
|
|
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
|
|
|
|
|
|
String arr [] = sysConfig.getString("temp_sub_mch_id").split(",");
|
|
|
|
|
String tempSubMerchantId = arr[new Random().nextInt(arr.length)];
|
|
|
|
|
String arr[] = sysConfig.getString("temp_sub_mch_id").split(",");
|
|
|
|
|
String tempSubMerchantId = arr[new Random().nextInt(arr.length)];
|
|
|
|
|
WeChatPayConfig.Merchant availableMerchant = mpPaymentApi.determineMerchant(tempSubMerchantId);
|
|
|
|
|
String clientMoniker = generateClientMoniker();
|
|
|
|
|
JSONObject sysClient = new JSONObject();
|
|
|
|
|
sysClient.put("company_name",apply.getString("company_name"));
|
|
|
|
|
sysClient.put("abn",apply.getString("abn"));
|
|
|
|
|
sysClient.put("short_name",apply.getString("short_name"));
|
|
|
|
|
sysClient.put("address",apply.getString("address"));
|
|
|
|
|
sysClient.put("suburb",apply.getString("suburb"));
|
|
|
|
|
sysClient.put("state",apply.getString("state"));
|
|
|
|
|
sysClient.put("postcode",apply.getString("postcode"));
|
|
|
|
|
sysClient.put("royalpayindustry",apply.getString("industry"));
|
|
|
|
|
sysClient.put("contact_person",apply.getString("contact_person"));
|
|
|
|
|
sysClient.put("contact_email",apply.getString("contact_email"));
|
|
|
|
|
sysClient.put("contact_phone",apply.getString("contact_phone"));
|
|
|
|
|
sysClient.put("company_phone",apply.getString("company_phone"));
|
|
|
|
|
sysClient.put("client_moniker",clientMoniker);
|
|
|
|
|
sysClient.put("create_time",new Date());
|
|
|
|
|
sysClient.put("source",4);
|
|
|
|
|
sysClient.put("org_id",1);
|
|
|
|
|
sysClient.put("approve_result",2);
|
|
|
|
|
sysClient.put("approve_time",new Date());
|
|
|
|
|
sysClient.put("creator",0);
|
|
|
|
|
sysClient.put("business_name",apply.getString("short_name"));
|
|
|
|
|
sysClient.put("industry",331);
|
|
|
|
|
sysClient.put("company_name", apply.getString("company_name"));
|
|
|
|
|
sysClient.put("abn", apply.getString("abn"));
|
|
|
|
|
sysClient.put("short_name", apply.getString("short_name"));
|
|
|
|
|
sysClient.put("address", apply.getString("address"));
|
|
|
|
|
sysClient.put("suburb", apply.getString("suburb"));
|
|
|
|
|
sysClient.put("state", apply.getString("state"));
|
|
|
|
|
sysClient.put("postcode", apply.getString("postcode"));
|
|
|
|
|
sysClient.put("royalpayindustry", apply.getString("industry"));
|
|
|
|
|
sysClient.put("contact_person", apply.getString("contact_person"));
|
|
|
|
|
sysClient.put("contact_email", apply.getString("contact_email"));
|
|
|
|
|
sysClient.put("contact_phone", apply.getString("contact_phone"));
|
|
|
|
|
sysClient.put("company_phone", apply.getString("company_phone"));
|
|
|
|
|
sysClient.put("client_moniker", clientMoniker);
|
|
|
|
|
sysClient.put("create_time", new Date());
|
|
|
|
|
sysClient.put("source", 4);
|
|
|
|
|
sysClient.put("org_id", 1);
|
|
|
|
|
sysClient.put("approve_result", 2);
|
|
|
|
|
sysClient.put("approve_time", new Date());
|
|
|
|
|
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("common_sub_merchant_id",1);
|
|
|
|
|
sysClient.put("skip_clearing",1);
|
|
|
|
|
sysClient.put("country","AUS");
|
|
|
|
|
sysClient.put("sub_merchant_id", tempSubMerchantId);
|
|
|
|
|
sysClient.put("common_sub_merchant_id", 1);
|
|
|
|
|
sysClient.put("skip_clearing", 1);
|
|
|
|
|
sysClient.put("country", "AUS");
|
|
|
|
|
sysClient.put("credential_code", RandomStringUtils.random(32, true, true));
|
|
|
|
|
clientMapper.save(sysClient);
|
|
|
|
|
|
|
|
|
|
int clientId = sysClient.getIntValue("client_id");
|
|
|
|
|
|
|
|
|
|
JSONObject sysAccount = new JSONObject();
|
|
|
|
|
sysAccount.put("username",apply.getString("username"));
|
|
|
|
|
sysAccount.put("display_name",apply.getString("username"));
|
|
|
|
|
sysAccount.put("username", apply.getString("username"));
|
|
|
|
|
sysAccount.put("display_name", apply.getString("username"));
|
|
|
|
|
String salt = PasswordUtils.newSalt();
|
|
|
|
|
sysAccount.put("salt", salt);
|
|
|
|
|
sysAccount.put("role", 1);
|
|
|
|
|
sysAccount.put("password_hash", PasswordUtils.hashPwd(apply.getString("password"), salt));
|
|
|
|
|
sysAccount.put("password_aes", PasswordUtils.encryptAESPwd(apply.getString("password")));
|
|
|
|
|
sysAccount.put("creator",0);
|
|
|
|
|
sysAccount.put("contact_phone",apply.getString("contact_phone"));
|
|
|
|
|
sysAccount.put("client_id",clientId);
|
|
|
|
|
sysAccount.put("create_time",new Date());
|
|
|
|
|
sysAccount.put("is_password_expired",0);
|
|
|
|
|
sysAccount.put("nation_code","+61");
|
|
|
|
|
sysAccount.put("creator", 0);
|
|
|
|
|
sysAccount.put("contact_phone", apply.getString("contact_phone"));
|
|
|
|
|
sysAccount.put("client_id", clientId);
|
|
|
|
|
sysAccount.put("create_time", new Date());
|
|
|
|
|
sysAccount.put("is_password_expired", 0);
|
|
|
|
|
sysAccount.put("nation_code", "+61");
|
|
|
|
|
clientAccountMapper.save(sysAccount);
|
|
|
|
|
|
|
|
|
|
JSONObject sysBank = new JSONObject();
|
|
|
|
|
sysBank.put("client_id",clientId);
|
|
|
|
|
sysBank.put("account_no",apply.getString("bank_no"));
|
|
|
|
|
sysBank.put("account_name",apply.getString("bank_name"));
|
|
|
|
|
sysBank.put("bsb_no",apply.getString("bsb_no"));
|
|
|
|
|
sysBank.put("client_id", clientId);
|
|
|
|
|
sysBank.put("account_no", apply.getString("bank_no"));
|
|
|
|
|
sysBank.put("account_name", apply.getString("bank_name"));
|
|
|
|
|
sysBank.put("bsb_no", apply.getString("bsb_no"));
|
|
|
|
|
JSONObject bankInfo = getBankInfo(apply.getString("bsb_no"));
|
|
|
|
|
sysBank.put("bank",bankInfo.getString("bank"));
|
|
|
|
|
sysBank.put("city",bankInfo.getString("city"));
|
|
|
|
|
sysBank.put("address",bankInfo.getString("address"));
|
|
|
|
|
sysBank.put("system",bankInfo.getString("system"));
|
|
|
|
|
sysBank.put("postcode",bankInfo.getString("postcode"));
|
|
|
|
|
sysBank.put("state",bankInfo.getString("state"));
|
|
|
|
|
sysBank.put("branch",bankInfo.getString("branch"));
|
|
|
|
|
sysBank.put("bank", bankInfo.getString("bank"));
|
|
|
|
|
sysBank.put("city", bankInfo.getString("city"));
|
|
|
|
|
sysBank.put("address", bankInfo.getString("address"));
|
|
|
|
|
sysBank.put("system", bankInfo.getString("system"));
|
|
|
|
|
sysBank.put("postcode", bankInfo.getString("postcode"));
|
|
|
|
|
sysBank.put("state", bankInfo.getString("state"));
|
|
|
|
|
sysBank.put("branch", bankInfo.getString("branch"));
|
|
|
|
|
clientBankAccountMapper.save(sysBank);
|
|
|
|
|
|
|
|
|
|
JSONObject clientConfig = new JSONObject();
|
|
|
|
|
clientConfig.put("client_id",clientId);
|
|
|
|
|
clientConfig.put("skip_clearing",1);
|
|
|
|
|
clientConfig.put("client_moniker",clientMoniker);
|
|
|
|
|
clientConfig.put("clean_days",apply.getIntValue("clean_days"));
|
|
|
|
|
clientConfig.put("common_sub_merchant_id",1);
|
|
|
|
|
clientConfig.put("client_id", clientId);
|
|
|
|
|
clientConfig.put("skip_clearing", 1);
|
|
|
|
|
clientConfig.put("client_moniker", clientMoniker);
|
|
|
|
|
clientConfig.put("clean_days", apply.getIntValue("clean_days"));
|
|
|
|
|
clientConfig.put("common_sub_merchant_id", 1);
|
|
|
|
|
clientConfigMapper.save(clientConfig);
|
|
|
|
|
|
|
|
|
|
JSONObject sysRate = new JSONObject();
|
|
|
|
|
sysRate.put("client_id",clientId);
|
|
|
|
|
sysRate.put("clean_days",apply.getIntValue("clean_days"));
|
|
|
|
|
sysRate.put("remark","自主申请");
|
|
|
|
|
sysRate.put("client_id", clientId);
|
|
|
|
|
sysRate.put("clean_days", apply.getIntValue("clean_days"));
|
|
|
|
|
sysRate.put("remark", "自主申请");
|
|
|
|
|
sysRate.put("create_time", new Date());
|
|
|
|
|
sysRate.put("update_time", new Date());
|
|
|
|
|
sysRate.put("active_time", DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
|
|
|
|
|
sysRate.put("expiry_time", DateFormatUtils.format(DateUtils.addYears(new Date(),1), "yyyy-MM-dd"));
|
|
|
|
|
sysRate.put("expiry_time", DateFormatUtils.format(DateUtils.addYears(new Date(), 1), "yyyy-MM-dd"));
|
|
|
|
|
|
|
|
|
|
JSONObject rateConfig = clientManager.getSysRateConfig();
|
|
|
|
|
JSONObject chooseRate = new JSONObject();
|
|
|
|
|
if (apply.getIntValue("clean_days") == 1){
|
|
|
|
|
if (apply.getIntValue("clean_days") == 1) {
|
|
|
|
|
chooseRate = rateConfig.getJSONObject("t1");
|
|
|
|
|
}
|
|
|
|
|
if (apply.getIntValue("clean_days") == 2){
|
|
|
|
|
if (apply.getIntValue("clean_days") == 2) {
|
|
|
|
|
chooseRate = rateConfig.getJSONObject("t2");
|
|
|
|
|
}
|
|
|
|
|
if (apply.getIntValue("clean_days") == 3){
|
|
|
|
|
if (apply.getIntValue("clean_days") == 3) {
|
|
|
|
|
chooseRate = rateConfig.getJSONObject("t3");
|
|
|
|
|
}
|
|
|
|
|
sysRate.putAll(chooseRate);
|
|
|
|
@ -369,23 +370,25 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
configNewClientRate(sysRate, clientId, "AlipayOnline", "AlipayOnline");
|
|
|
|
|
configNewClientRate(sysRate, clientId, "Bestpay", "Bestpay");
|
|
|
|
|
configNewClientRate(sysRate, clientId, "jd", "JDpay");
|
|
|
|
|
try {
|
|
|
|
|
clientManager.getNewAggregateAgreeFile(clientMoniker,null,false);
|
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
|
}
|
|
|
|
|
Runnable task2 = () -> {
|
|
|
|
|
try {
|
|
|
|
|
clientManager.getNewAggregateAgreeFile(clientMoniker, null, false);
|
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
pool.execute(task2);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String generateClientMoniker(){
|
|
|
|
|
private String generateClientMoniker() {
|
|
|
|
|
String clientMoniker = RandomStringUtils.random(4, true, true).toUpperCase();
|
|
|
|
|
JSONObject client = clientMapper.findClientByMoniker(clientMoniker);
|
|
|
|
|
if (client != null){
|
|
|
|
|
if (client != null) {
|
|
|
|
|
generateClientMoniker();
|
|
|
|
|
}
|
|
|
|
|
return clientMoniker;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void configNewClientRate(JSONObject config, int clientId, String channel, String rateKey) {
|
|
|
|
|
if (config.containsKey(rateKey)) {
|
|
|
|
|
JSONObject newConfig = new JSONObject();
|
|
|
|
@ -430,13 +433,13 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
|
|
|
|
|
throw new BadRequestException(LocaleSupport.localeMessage("error.login.password"));
|
|
|
|
|
}
|
|
|
|
|
JSONObject record = new JSONObject();
|
|
|
|
|
record.put("client_id",client.getIntValue("client_id"));
|
|
|
|
|
record.put("mail_confirm",true);
|
|
|
|
|
record.put("client_id", client.getIntValue("client_id"));
|
|
|
|
|
record.put("mail_confirm", true);
|
|
|
|
|
clientMapper.update(record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getRegisterClientRedisKey(String phoneNumber){
|
|
|
|
|
return REGISTER_CLIENT_PREFIX +phoneNumber;
|
|
|
|
|
private String getRegisterClientRedisKey(String phoneNumber) {
|
|
|
|
|
return REGISTER_CLIENT_PREFIX + phoneNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getRegisterClientProcessRedisKey(String codeKey) {
|
|
|
|
|