|
|
|
@ -1,8 +1,12 @@
|
|
|
|
|
package au.com.royalpay.payment.manage.dev.web;
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfoInheritance;
|
|
|
|
|
import au.com.royalpay.payment.channels.wechat.runtime.impls.WxPayMerchantRegister;
|
|
|
|
|
import au.com.royalpay.payment.channels.wechat.runtime.mappers.PaymentChannelMccGoodMapper;
|
|
|
|
|
import au.com.royalpay.payment.core.PaymentApi;
|
|
|
|
|
import au.com.royalpay.payment.core.PaymentDevHelper;
|
|
|
|
|
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
|
|
|
|
|
import au.com.royalpay.payment.core.impls.MerchantChannelApplicationManager;
|
|
|
|
|
import au.com.royalpay.payment.core.mappers.PmtCustomReportMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.analysis.core.ATOReportService;
|
|
|
|
|
import au.com.royalpay.payment.manage.analysis.core.DashboardService;
|
|
|
|
@ -15,9 +19,8 @@ import au.com.royalpay.payment.manage.dev.core.AliforexcelService;
|
|
|
|
|
import au.com.royalpay.payment.manage.dev.core.WechatMessageService;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.RefundMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.SysClientLegalPersonMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.*;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.beans.NewSubMerchantIdApply;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
|
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
|
|
|
|
|
import au.com.royalpay.payment.manage.pos.datasource.ReadOnlyConnection;
|
|
|
|
@ -30,15 +33,19 @@ import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
|
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
|
import au.com.royalpay.payment.tools.http.HttpUtils;
|
|
|
|
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.PdfUtils;
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.apache.http.util.TextUtils;
|
|
|
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
|
|
|
import org.joda.time.DateTime;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -61,6 +68,7 @@ import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by yixian on 2016-07-06.
|
|
|
|
@ -112,6 +120,15 @@ public class TestController {
|
|
|
|
|
private PaymentDevHelper paymentDevHelper;
|
|
|
|
|
@Resource
|
|
|
|
|
private PmtCustomReportMapper pmtCustomReportsMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private SysWxMerchantApplyMapper sysWxMerchantApplyMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private PaymentChannelMccGoodMapper paymentChannelMccGoodMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientConfigMapper clientConfigMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private MerchantChannelApplicationManager merchantChannelApplicationManager;
|
|
|
|
|
|
|
|
|
|
@ManagerMapping(value = "/{clientMoniker}/export/agreepdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
|
|
|
|
|
public void exportAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, HttpServletResponse httpResponse) throws Exception {
|
|
|
|
@ -500,4 +517,93 @@ public class TestController {
|
|
|
|
|
String lastDay = sdf.format(calendar2.getTime());
|
|
|
|
|
tradeSecureService.sendSecurePayInvoiceFile(firstDay, lastDay);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ManagerMapping(value = "/batch_update_wxsubmerchantId", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR, ManagerRole.DEVELOPER})
|
|
|
|
|
// @GetMapping(value = "/batch_update_wxsubmerchantId")
|
|
|
|
|
public void batchUpdateWxSubmerchantId() {
|
|
|
|
|
List<JSONObject> findSubMerchantIdHistorys=sysWxMerchantApplyMapper.findSubMerchantIdHistorys();
|
|
|
|
|
if(findSubMerchantIdHistorys==null)return;
|
|
|
|
|
logger.info("=========>batchUpdateWxSubmerchantId:"+findSubMerchantIdHistorys.size());
|
|
|
|
|
findSubMerchantIdHistorys.parallelStream().forEach(jsonObject -> {
|
|
|
|
|
JSONObject clientJson = clientMapper.findClient(jsonObject.getInteger("client_id"));
|
|
|
|
|
JSONObject wechatMcc = paymentChannelMccGoodMapper.findWechatPayMccByClientId(jsonObject.getIntValue("client_id"));
|
|
|
|
|
JSONObject clientConfig = clientConfigMapper.find(jsonObject.getIntValue("client_id"));
|
|
|
|
|
if(clientJson==null){
|
|
|
|
|
logger.info("=========>没有查询到client:"+jsonObject.getInteger("client_id"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(wechatMcc==null){
|
|
|
|
|
logger.info("=========>没有查询到mcc:"+jsonObject.getInteger("client_id"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NewSubMerchantIdApply newSubMerchantIdApply=new NewSubMerchantIdApply();
|
|
|
|
|
newSubMerchantIdApply.setMerchant_id(jsonObject.getString("merchant_id"));
|
|
|
|
|
newSubMerchantIdApply.setSub_mch_id(jsonObject.getString("sub_merchant_id"));
|
|
|
|
|
newSubMerchantIdApply.setMerchantRemark(jsonObject.getString("merchant_remark"));
|
|
|
|
|
newSubMerchantIdApply.setMerchant_name(cutLength(jsonObject.getString("merchant_name"),50));
|
|
|
|
|
newSubMerchantIdApply.setAddress(cutLength(clientJson.getString("address"),128));
|
|
|
|
|
newSubMerchantIdApply.setMerchant_shortname(cutLength(clientJson.getString("short_name"),20));
|
|
|
|
|
newSubMerchantIdApply.setBusiness_category(clientJson.getString("industry"));
|
|
|
|
|
newSubMerchantIdApply.setWebsite(cutLength(clientJson.getString("company_website"),128));
|
|
|
|
|
newSubMerchantIdApply.setOffice_phone(cutLength(clientJson.getString("company_phone"),20));
|
|
|
|
|
newSubMerchantIdApply.setContact_phone(cutLength(clientJson.getString("contact_phone"),16));
|
|
|
|
|
newSubMerchantIdApply.setContact_name(cutLength(clientJson.getString("contact_person"),32));
|
|
|
|
|
newSubMerchantIdApply.setContact_email(cutLength(clientJson.getString("contact_email"),128));
|
|
|
|
|
newSubMerchantIdApply.setMcc_code(cutLength(wechatMcc.getString("mc_code"),10));
|
|
|
|
|
|
|
|
|
|
if(!TextUtils.isEmpty(clientConfig.getString("client_pay_type"))){
|
|
|
|
|
if(clientConfig.getString("client_pay_type").indexOf("1")>=0
|
|
|
|
|
&&clientConfig.getString("client_pay_type").indexOf("2")>=0){
|
|
|
|
|
newSubMerchantIdApply.setBusiness_type("BOTH");
|
|
|
|
|
}else if(clientConfig.getString("client_pay_type").indexOf("1")>=0){
|
|
|
|
|
newSubMerchantIdApply.setBusiness_type("ONLINE");
|
|
|
|
|
}
|
|
|
|
|
else if(clientConfig.getString("client_pay_type").indexOf("1")>=0){
|
|
|
|
|
newSubMerchantIdApply.setBusiness_type("OFFLINE");
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
newSubMerchantIdApply.setBusiness_type("BOTH");
|
|
|
|
|
}
|
|
|
|
|
if (!TextUtils.isEmpty(clientJson.getString("business_structure"))) {
|
|
|
|
|
newSubMerchantIdApply.setMerchant_type(clientJson.getString("business_structure").equals("Registered body(Sole Trader)")?"INDIVIDUAL":"ENTERPRISE") ;
|
|
|
|
|
}else{
|
|
|
|
|
newSubMerchantIdApply.setMerchant_type("INDIVIDUAL") ;
|
|
|
|
|
}
|
|
|
|
|
newSubMerchantIdApply.setCompany_register_no(cutLength(TextUtils.isEmpty(clientJson.getString("acn"))?clientJson.getString("abn"):clientJson.getString("abn"),50));
|
|
|
|
|
newSubMerchantIdApply.setCertificat_expire_date("PERMANENT");
|
|
|
|
|
JSONObject params = newSubMerchantIdApply.insertObject(clientJson);
|
|
|
|
|
params.put("merchant_app_id", jsonObject.getString("merchant_app_id"));
|
|
|
|
|
SubMerchantInfoInheritance subMerchantInfo = JSON.toJavaObject(params, SubMerchantInfoInheritance.class);
|
|
|
|
|
params.put("operator","System");
|
|
|
|
|
|
|
|
|
|
WxPayMerchantRegister register = Optional.ofNullable(merchantChannelApplicationManager.getRegister(WxPayMerchantRegister.class))
|
|
|
|
|
.orElseThrow(() -> new ServerErrorException("No Register found for wechat"));
|
|
|
|
|
|
|
|
|
|
JSONObject manager=new JSONObject();
|
|
|
|
|
manager.put("display_name","System");
|
|
|
|
|
register.modifyForBatch(jsonObject.getString("merchant_app_id"), clientJson, subMerchantInfo, manager);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(20);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String declareResp = paymentDevHelper.devQueryCustomsReport(reportId);
|
|
|
|
|
// JSONObject res = new JSONObject();
|
|
|
|
|
// res.put("xml", declareResp);
|
|
|
|
|
}
|
|
|
|
|
public String cutLength(String str,int maxlen){
|
|
|
|
|
if(TextUtils.isEmpty(str))return "";
|
|
|
|
|
if(str.length()>maxlen){
|
|
|
|
|
return str.substring(0,maxlen);
|
|
|
|
|
}else{
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|