|
|
@ -3,16 +3,16 @@ package au.com.royalpay.payment.manage.dev.core.impl;
|
|
|
|
import au.com.royalpay.payment.channels.alipay.config.AlipayConfig;
|
|
|
|
import au.com.royalpay.payment.channels.alipay.config.AlipayConfig;
|
|
|
|
import au.com.royalpay.payment.channels.alipay.config.AlipayEnvironment;
|
|
|
|
import au.com.royalpay.payment.channels.alipay.config.AlipayEnvironment;
|
|
|
|
import au.com.royalpay.payment.channels.alipay.runtime.AlipayClient;
|
|
|
|
import au.com.royalpay.payment.channels.alipay.runtime.AlipayClient;
|
|
|
|
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
|
|
|
|
import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient;
|
|
|
|
import au.com.royalpay.payment.core.mappers.PmtOrderMapper;
|
|
|
|
import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo;
|
|
|
|
import au.com.royalpay.payment.manage.dev.bean.AliExcel;
|
|
|
|
import au.com.royalpay.payment.manage.dev.bean.AliExcel;
|
|
|
|
import au.com.royalpay.payment.manage.dev.core.AliforexcelService;
|
|
|
|
import au.com.royalpay.payment.manage.dev.core.AliforexcelService;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
|
|
|
|
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.ClientMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.yeepay.shade.org.apache.commons.lang3.StringUtils;
|
|
|
|
import com.yeepay.shade.org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
@ -32,6 +32,7 @@ import java.io.OutputStream;
|
|
|
|
import java.security.InvalidParameterException;
|
|
|
|
import java.security.InvalidParameterException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
@ -46,6 +47,10 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
private AlipayClient alipayClient;
|
|
|
|
private AlipayClient alipayClient;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
private OrderMapper orderMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private WxPayClient wxPayClient;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private SysWxMerchantApplyMapper sysWxMerchantApplyMapper;
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -163,6 +168,35 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject registerRangeAlipayOnlineMerchant(int start, int end) {
|
|
|
|
public JSONObject registerRangeAlipayOnlineMerchant(int start, int end) {
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
@ -170,12 +204,8 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
List<String> registerSuccessMerchant = new ArrayList<>();
|
|
|
|
List<String> registerSuccessMerchant = new ArrayList<>();
|
|
|
|
List<JSONObject> registerFailMerchant = new ArrayList<>();
|
|
|
|
List<JSONObject> registerFailMerchant = new ArrayList<>();
|
|
|
|
List<JSONObject> lessInfoMerchant = new ArrayList<>();
|
|
|
|
List<JSONObject> lessInfoMerchant = new ArrayList<>();
|
|
|
|
List<Integer> useAlipayOnlineMerchant = clientMapper.listUseAlipayMerchant(start,end);
|
|
|
|
List<JSONObject> alipayApClients = clientMapper.findApClient();
|
|
|
|
for (int clientId : useAlipayOnlineMerchant) {
|
|
|
|
alipayApClients.forEach(client -> {
|
|
|
|
JSONObject client = clientMapper.findClient(clientId);
|
|
|
|
|
|
|
|
if (client == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
needRegisterMerchant.add(client.getString("client_moniker"));
|
|
|
|
needRegisterMerchant.add(client.getString("client_moniker"));
|
|
|
|
if (StringUtils.isBlank(client.getString("company_website"))) {
|
|
|
|
if (StringUtils.isBlank(client.getString("company_website"))) {
|
|
|
@ -194,7 +224,6 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
exception.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
exception.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
lessInfoMerchant.add(exception);
|
|
|
|
lessInfoMerchant.add(exception);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant();
|
|
|
|
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayOnlineMerchant();
|
|
|
@ -204,7 +233,6 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Element responseElement = resultElement.element("response").element("alipay");
|
|
|
|
Element responseElement = resultElement.element("response").element("alipay");
|
|
|
|
if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) {
|
|
|
|
if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) {
|
|
|
@ -212,7 +240,6 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
registerSuccessMerchant.add(client.getString("client_moniker"));
|
|
|
|
registerSuccessMerchant.add(client.getString("client_moniker"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
@ -221,7 +248,7 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
result.put("need_register_merchant", needRegisterMerchant);
|
|
|
|
result.put("need_register_merchant", needRegisterMerchant);
|
|
|
|
result.put("success_register_merchant", registerSuccessMerchant);
|
|
|
|
result.put("success_register_merchant", registerSuccessMerchant);
|
|
|
|
result.put("fail_register_merchant", registerFailMerchant);
|
|
|
|
result.put("fail_register_merchant", registerFailMerchant);
|
|
|
@ -237,13 +264,8 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
List<String> registerSuccessMerchant = new ArrayList<>();
|
|
|
|
List<String> registerSuccessMerchant = new ArrayList<>();
|
|
|
|
List<JSONObject> registerFailMerchant = new ArrayList<>();
|
|
|
|
List<JSONObject> registerFailMerchant = new ArrayList<>();
|
|
|
|
List<JSONObject> lessInfoMerchant = new ArrayList<>();
|
|
|
|
List<JSONObject> lessInfoMerchant = new ArrayList<>();
|
|
|
|
String alipayOfflineMerchantsStr = "FORE,RAYI,AASO,BGWI,HYMQ,LIFE,TWTA,AMYW,CCTM,JCYA,JICH,ADGJ,MAGL,TOMA,MCNE,LILC,YOTR,PENG,CASM,SHAO,SWCG,TMCF,BPAR,DNLG,OVAU,SJZH,VWPA,BCOL,MOLI,LIYA,TST3,AUKN,MMEK,GINF,EZE2,GOTR,CJKD,QR12,NJHI,WHAP,HOTO,OMNI,UGGM,JJTV,HHPL,BSPL,TOUR,AUMG,AYUC,BFLI,WAOR,SUTR,LTEA,BRAV,BTTC,FATT,VFPL,LEOH,BHHO,ISSP,JOLP,SUNH,NEVC,QR56,GNH9,SHFO,4UBW,ZZAO,B12H,QUMA,MAYH,FMPS,OWPL,CUDE,I2MI,FAGO,FADA,ZHHS,MANT,DOMU,NTTB,SDCN,8QNF,BHLW,KNIT,U4N9,WNNN";
|
|
|
|
List<JSONObject> alipayApClients = clientMapper.findApClient();
|
|
|
|
String[] alipayOfflineMerchants = alipayOfflineMerchantsStr.split(",");
|
|
|
|
alipayApClients.forEach(client -> {
|
|
|
|
for (String clientMoniker : alipayOfflineMerchants) {
|
|
|
|
|
|
|
|
JSONObject client = clientMapper.findClientByMoniker(clientMoniker);
|
|
|
|
|
|
|
|
if (client == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
needRegisterMerchant.add(client.getString("client_moniker"));
|
|
|
|
needRegisterMerchant.add(client.getString("client_moniker"));
|
|
|
|
checkPartnerInfo(client, "offline");
|
|
|
|
checkPartnerInfo(client, "offline");
|
|
|
@ -253,7 +275,6 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
exception.put("return_msg", e.getMessage());
|
|
|
|
exception.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
exception.put("bd_name", client.getString("bd_user_name"));
|
|
|
|
lessInfoMerchant.add(exception);
|
|
|
|
lessInfoMerchant.add(exception);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant();
|
|
|
|
AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant();
|
|
|
|
Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client);
|
|
|
|
Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client);
|
|
|
@ -262,7 +283,6 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Element responseElement = resultElement.element("response").element("alipay");
|
|
|
|
Element responseElement = resultElement.element("response").element("alipay");
|
|
|
|
if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) {
|
|
|
|
if (!StringUtils.equalsIgnoreCase("SUCCESS", responseElement.elementText("result_code"))) {
|
|
|
@ -270,10 +290,9 @@ public class AliforexcelServiceImpl implements AliforexcelService {
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
exception.put("client_moniker", client.getString("client_moniker"));
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
exception.put("return_msg", resultElement.elementText("error"));
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
registerFailMerchant.add(exception);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
registerSuccessMerchant.add(client.getString("client_moniker"));
|
|
|
|
registerSuccessMerchant.add(client.getString("client_moniker"));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
result.put("need_register_merchant", needRegisterMerchant);
|
|
|
|
result.put("need_register_merchant", needRegisterMerchant);
|
|
|
|
result.put("success_register_merchant", registerSuccessMerchant);
|
|
|
|
result.put("success_register_merchant", registerSuccessMerchant);
|
|
|
|
result.put("fail_register_merchant", registerFailMerchant);
|
|
|
|
result.put("fail_register_merchant", registerFailMerchant);
|
|
|
|