|
|
|
@ -13,6 +13,7 @@ import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.yeepay.shade.org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
@ -52,6 +53,8 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
|
@Resource
|
|
|
|
|
private SysWxMerchantApplyMapper sysWxMerchantApplyMapper;
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
@Resource
|
|
|
|
|
private RoyalThreadPoolExecutor royalThreadPoolExecutor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -170,64 +173,112 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void registerWechatMerchant() {
|
|
|
|
|
List<JSONObject> apClients = clientMapper.findApClient();
|
|
|
|
|
apClients.forEach(client -> {
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
|
params.put("merchant_name", client.getString("company_name"));
|
|
|
|
|
params.put("merchant_shortname", client.getString("short_name"));
|
|
|
|
|
params.put("office_phone", client.getString("contact_phone"));
|
|
|
|
|
params.put("contact_phone", client.getString("contact_phone"));
|
|
|
|
|
params.put("contact_email", client.getString("contact_email"));
|
|
|
|
|
params.put("business_category", "392");
|
|
|
|
|
params.put("merchant_remark", client.getString("client_moniker"));
|
|
|
|
|
params.put("website", client.getString("website"));
|
|
|
|
|
SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params, SubMerchantInfo.class);
|
|
|
|
|
params.put("merchant_id", client.getString("merchant_id"));
|
|
|
|
|
params.put("client_id", client.getString("client_id"));
|
|
|
|
|
params.put("create_time", new Date());
|
|
|
|
|
params.put("operator", "System");
|
|
|
|
|
Element elem = wxPayClient.subMerchantApplication(client.getString("merchant_id"), subMerchantInfo);
|
|
|
|
|
String sub_merchant_id = elem.elementText("sub_mch_id");
|
|
|
|
|
if (StringUtils.isNotEmpty(sub_merchant_id)) {
|
|
|
|
|
params.put("sub_merchant_id", sub_merchant_id);
|
|
|
|
|
sysWxMerchantApplyMapper.insertWxMerchantApply(params);
|
|
|
|
|
} else {
|
|
|
|
|
throw new BadRequestException(elem.elementText("return_msg"));
|
|
|
|
|
}
|
|
|
|
|
royalThreadPoolExecutor.execute(() -> {
|
|
|
|
|
List<JSONObject> apClients = clientMapper.findApClient();
|
|
|
|
|
apClients.forEach(client -> {
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
|
params.put("merchant_name", client.getString("company_name"));
|
|
|
|
|
params.put("merchant_shortname", client.getString("short_name"));
|
|
|
|
|
params.put("office_phone", client.getString("contact_phone"));
|
|
|
|
|
params.put("contact_phone", client.getString("contact_phone"));
|
|
|
|
|
params.put("contact_email", client.getString("contact_email"));
|
|
|
|
|
params.put("business_category", "392");
|
|
|
|
|
params.put("merchant_remark", client.getString("client_moniker"));
|
|
|
|
|
params.put("website", client.getString("website"));
|
|
|
|
|
SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params, SubMerchantInfo.class);
|
|
|
|
|
params.put("merchant_id", client.getString("merchant_id"));
|
|
|
|
|
params.put("client_id", client.getString("client_id"));
|
|
|
|
|
params.put("create_time", new Date());
|
|
|
|
|
params.put("operator", "System");
|
|
|
|
|
Element elem = wxPayClient.subMerchantApplication(client.getString("merchant_id"), subMerchantInfo);
|
|
|
|
|
String sub_merchant_id = elem.elementText("sub_mch_id");
|
|
|
|
|
if (StringUtils.isNotEmpty(sub_merchant_id)) {
|
|
|
|
|
params.put("sub_merchant_id", sub_merchant_id);
|
|
|
|
|
sysWxMerchantApplyMapper.insertWxMerchantApply(params);
|
|
|
|
|
} else {
|
|
|
|
|
throw new BadRequestException(elem.elementText("return_msg"));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject registerRangeAlipayOnlineMerchant(int start, int end) {
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
List<String> needRegisterMerchant = new ArrayList<>();
|
|
|
|
|
List<String> registerSuccessMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> registerFailMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> lessInfoMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> alipayApClients = clientMapper.findApClient();
|
|
|
|
|
alipayApClients.forEach(client -> {
|
|
|
|
|
try {
|
|
|
|
|
needRegisterMerchant.add(client.getString("client_moniker"));
|
|
|
|
|
if (StringUtils.isBlank(client.getString("company_website"))) {
|
|
|
|
|
client.put("company_website", client.getString("ali_sub_merchant_id") + ".royalpay.com.au");
|
|
|
|
|
public void registerRangeAlipayOnlineMerchant(int start, int end) {
|
|
|
|
|
royalThreadPoolExecutor.execute(() -> {
|
|
|
|
|
List<String> needRegisterMerchant = new ArrayList<>();
|
|
|
|
|
List<String> registerSuccessMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> registerFailMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> lessInfoMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> alipayApClients = clientMapper.findApClient();
|
|
|
|
|
alipayApClients.forEach(client -> {
|
|
|
|
|
try {
|
|
|
|
|
needRegisterMerchant.add(client.getString("client_moniker"));
|
|
|
|
|
if (StringUtils.isBlank(client.getString("company_website"))) {
|
|
|
|
|
client.put("company_website", client.getString("ali_sub_merchant_id") + ".royalpay.com.au");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(client.getString("alipayindustry"))) {
|
|
|
|
|
client.put("alipayindustry", "5311");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(client.getString("business_structure"))) {
|
|
|
|
|
client.put("business_structure", "da");
|
|
|
|
|
}
|
|
|
|
|
checkPartnerInfo(client, "online");
|
|
|
|
|
} catch (InvalidParameterException e) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
|
exception.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
|
lessInfoMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(client.getString("alipayindustry"))) {
|
|
|
|
|
client.put("alipayindustry", "5311");
|
|
|
|
|
try {
|
|
|
|
|
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant();
|
|
|
|
|
Element resultElement = alipayClient.registerOnlineGmsPortal(mch.getPid(), client);
|
|
|
|
|
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
Element responseElement = resultElement.element("response").element("alipay");
|
|
|
|
|
if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
registerSuccessMerchant.add(client.getString("client_moniker"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(client.getString("business_structure"))) {
|
|
|
|
|
client.put("business_structure", "da");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void registerAlipayMerchant() {
|
|
|
|
|
royalThreadPoolExecutor.execute(() -> {
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
List<String> needRegisterMerchant = new ArrayList<>();
|
|
|
|
|
List<String> registerSuccessMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> registerFailMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> lessInfoMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> alipayApClients = clientMapper.findApClient();
|
|
|
|
|
alipayApClients.forEach(client -> {
|
|
|
|
|
try {
|
|
|
|
|
needRegisterMerchant.add(client.getString("client_moniker"));
|
|
|
|
|
checkPartnerInfo(client, "offline");
|
|
|
|
|
} catch (InvalidParameterException e) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
|
exception.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
|
lessInfoMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
checkPartnerInfo(client, "online");
|
|
|
|
|
} catch (InvalidParameterException e) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
|
exception.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
|
lessInfoMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant();
|
|
|
|
|
Element resultElement = alipayClient.registerOnlineGmsPortal(mch.getPid(), client);
|
|
|
|
|
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant();
|
|
|
|
|
Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client);
|
|
|
|
|
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
@ -242,62 +293,12 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
registerSuccessMerchant.add(client.getString("client_moniker"));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
result.put("need_register_merchant", needRegisterMerchant);
|
|
|
|
|
result.put("success_register_merchant", registerSuccessMerchant);
|
|
|
|
|
result.put("fail_register_merchant", registerFailMerchant);
|
|
|
|
|
result.put("less_info_merchant", lessInfoMerchant);
|
|
|
|
|
logger.info("-------AlipayOnline Gms end----fail_register_merchant" + registerFailMerchant.toString());
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject registerAlipayMerchant() {
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
List<String> needRegisterMerchant = new ArrayList<>();
|
|
|
|
|
List<String> registerSuccessMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> registerFailMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> lessInfoMerchant = new ArrayList<>();
|
|
|
|
|
List<JSONObject> alipayApClients = clientMapper.findApClient();
|
|
|
|
|
alipayApClients.forEach(client -> {
|
|
|
|
|
try {
|
|
|
|
|
needRegisterMerchant.add(client.getString("client_moniker"));
|
|
|
|
|
checkPartnerInfo(client, "offline");
|
|
|
|
|
} catch (InvalidParameterException e) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
|
exception.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
|
lessInfoMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant();
|
|
|
|
|
Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client);
|
|
|
|
|
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
Element responseElement = resultElement.element("response").element("alipay");
|
|
|
|
|
if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) {
|
|
|
|
|
JSONObject exception = new JSONObject();
|
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
|
}
|
|
|
|
|
registerSuccessMerchant.add(client.getString("client_moniker"));
|
|
|
|
|
});
|
|
|
|
|
result.put("need_register_merchant", needRegisterMerchant);
|
|
|
|
|
result.put("success_register_merchant", registerSuccessMerchant);
|
|
|
|
|
result.put("fail_register_merchant", registerFailMerchant);
|
|
|
|
|
result.put("less_info_merchant", lessInfoMerchant);
|
|
|
|
|
});
|
|
|
|
|
result.put("need_register_merchant", needRegisterMerchant);
|
|
|
|
|
result.put("success_register_merchant", registerSuccessMerchant);
|
|
|
|
|
result.put("fail_register_merchant", registerFailMerchant);
|
|
|
|
|
result.put("less_info_merchant", lessInfoMerchant);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|