master
taylor.dang 5 years ago
parent e76ab9af54
commit a838820de2

@ -12,9 +12,9 @@ public interface AliforexcelService {
void registerWechatMerchant(); void registerWechatMerchant();
JSONObject registerRangeAlipayOnlineMerchant(int start,int end); void registerRangeAlipayOnlineMerchant(int start,int end);
JSONObject registerAlipayMerchant(); void registerAlipayMerchant();
JSONObject registerInsertAlipayMerchant(String partners); JSONObject registerInsertAlipayMerchant(String partners);

@ -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.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper; 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.threadpool.RoyalThreadPoolExecutor;
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;
@ -52,6 +53,8 @@ public class AliforexcelServiceImpl implements AliforexcelService {
@Resource @Resource
private SysWxMerchantApplyMapper sysWxMerchantApplyMapper; private SysWxMerchantApplyMapper sysWxMerchantApplyMapper;
private Logger logger = LoggerFactory.getLogger(getClass()); private Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private RoyalThreadPoolExecutor royalThreadPoolExecutor;
@Override @Override
@ -170,64 +173,112 @@ public class AliforexcelServiceImpl implements AliforexcelService {
@Override @Override
public void registerWechatMerchant() { public void registerWechatMerchant() {
List<JSONObject> apClients = clientMapper.findApClient(); royalThreadPoolExecutor.execute(() -> {
apClients.forEach(client -> { List<JSONObject> apClients = clientMapper.findApClient();
JSONObject params = new JSONObject(); apClients.forEach(client -> {
params.put("merchant_name", client.getString("company_name")); JSONObject params = new JSONObject();
params.put("merchant_shortname", client.getString("short_name")); params.put("merchant_name", client.getString("company_name"));
params.put("office_phone", client.getString("contact_phone")); params.put("merchant_shortname", client.getString("short_name"));
params.put("contact_phone", client.getString("contact_phone")); params.put("office_phone", client.getString("contact_phone"));
params.put("contact_email", client.getString("contact_email")); params.put("contact_phone", client.getString("contact_phone"));
params.put("business_category", "392"); params.put("contact_email", client.getString("contact_email"));
params.put("merchant_remark", client.getString("client_moniker")); params.put("business_category", "392");
params.put("website", client.getString("website")); params.put("merchant_remark", client.getString("client_moniker"));
SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params, SubMerchantInfo.class); params.put("website", client.getString("website"));
params.put("merchant_id", client.getString("merchant_id")); SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params, SubMerchantInfo.class);
params.put("client_id", client.getString("client_id")); params.put("merchant_id", client.getString("merchant_id"));
params.put("create_time", new Date()); params.put("client_id", client.getString("client_id"));
params.put("operator", "System"); params.put("create_time", new Date());
Element elem = wxPayClient.subMerchantApplication(client.getString("merchant_id"), subMerchantInfo); params.put("operator", "System");
String sub_merchant_id = elem.elementText("sub_mch_id"); Element elem = wxPayClient.subMerchantApplication(client.getString("merchant_id"), subMerchantInfo);
if (StringUtils.isNotEmpty(sub_merchant_id)) { String sub_merchant_id = elem.elementText("sub_mch_id");
params.put("sub_merchant_id", sub_merchant_id); if (StringUtils.isNotEmpty(sub_merchant_id)) {
sysWxMerchantApplyMapper.insertWxMerchantApply(params); params.put("sub_merchant_id", sub_merchant_id);
} else { sysWxMerchantApplyMapper.insertWxMerchantApply(params);
throw new BadRequestException(elem.elementText("return_msg")); } else {
} throw new BadRequestException(elem.elementText("return_msg"));
}
});
}); });
} }
@Override @Override
public JSONObject registerRangeAlipayOnlineMerchant(int start, int end) { public void registerRangeAlipayOnlineMerchant(int start, int end) {
JSONObject result = new JSONObject(); royalThreadPoolExecutor.execute(() -> {
List<String> needRegisterMerchant = new ArrayList<>(); List<String> needRegisterMerchant = new ArrayList<>();
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<JSONObject> alipayApClients = clientMapper.findApClient(); List<JSONObject> alipayApClients = clientMapper.findApClient();
alipayApClients.forEach(client -> { alipayApClients.forEach(client -> {
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"))) {
client.put("company_website", client.getString("ali_sub_merchant_id") + ".royalpay.com.au"); 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"))) { try {
client.put("alipayindustry", "5311"); 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"); AlipayConfig.AlipayMerchant mch = AlipayEnvironment.getEnv().getAlipayRetailMerchant();
} catch (InvalidParameterException e) { Element resultElement = alipayClient.registerGmsPortal(mch.getPid(), client);
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);
if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) { if (!StringUtils.equalsIgnoreCase("T", resultElement.elementText("is_success"))) {
JSONObject exception = new JSONObject(); JSONObject exception = new JSONObject();
exception.put("client_moniker", client.getString("client_moniker")); exception.put("client_moniker", client.getString("client_moniker"));
@ -242,62 +293,12 @@ public class AliforexcelServiceImpl implements AliforexcelService {
registerFailMerchant.add(exception); registerFailMerchant.add(exception);
} }
registerSuccessMerchant.add(client.getString("client_moniker")); registerSuccessMerchant.add(client.getString("client_moniker"));
} catch (Exception e) { });
JSONObject exception = new JSONObject(); result.put("need_register_merchant", needRegisterMerchant);
exception.put("client_moniker", client.getString("client_moniker")); result.put("success_register_merchant", registerSuccessMerchant);
exception.put("return_msg", e.getMessage()); result.put("fail_register_merchant", registerFailMerchant);
registerFailMerchant.add(exception); 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);
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);
return result;
} }
@Override @Override

@ -500,20 +500,20 @@ public class TestController implements ApplicationEventPublisherAware {
return aliforexcelService.registerAlipayOnlineMerchant(); return aliforexcelService.registerAlipayOnlineMerchant();
} }
@ManagerMapping(value = "/register/wechatGms", role = ManagerRole.DEVELOPER, method = RequestMethod.GET) @GetMapping(value = "/register/wechatGms")
public void registerWechatMerchant() { public void registerWechatMerchant() {
aliforexcelService.registerWechatMerchant(); aliforexcelService.registerWechatMerchant();
} }
@ManagerMapping(value = "/register/alipayOnlineGms", role = ManagerRole.DEVELOPER, method = RequestMethod.GET) @GetMapping(value = "/register/alipayOnlineGms")
public JSONObject registerRangeAlipayOnlineMerchant(@RequestParam int start, @RequestParam int end) { public void registerRangeAlipayOnlineMerchant(@RequestParam int start, @RequestParam int end) {
return aliforexcelService.registerRangeAlipayOnlineMerchant(start, end); aliforexcelService.registerRangeAlipayOnlineMerchant(start, end);
} }
@ManagerMapping(value = "/register/alipayGms", role = ManagerRole.DEVELOPER, method = RequestMethod.GET) @GetMapping(value = "/register/alipayGms")
public JSONObject registerAlipayMerchant() { public void registerAlipayMerchant() {
return aliforexcelService.registerAlipayMerchant(); aliforexcelService.registerAlipayMerchant();
} }
@ManagerMapping(value = "/register/alipayGms/insert_partner", role = ManagerRole.DEVELOPER, method = RequestMethod.POST) @ManagerMapping(value = "/register/alipayGms/insert_partner", role = ManagerRole.DEVELOPER, method = RequestMethod.POST)

@ -24,7 +24,7 @@ public interface ClientMapper {
JSONObject findClient(@Param("client_id") int clientId); JSONObject findClient(@Param("client_id") int clientId);
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1 and length( client_moniker ) > 5") @AdvanceSelect(addonWhereClause = "is_valid=1 and length( client_moniker ) > 5 and sub_merchant_id='321888408'")
List<JSONObject> findApClient(); List<JSONObject> findApClient();
List<JSONObject> listValidClient(); List<JSONObject> listValidClient();

Loading…
Cancel
Save