微信子商户号 修改

master
dalong306 4 years ago
parent f315edac4f
commit 24c89321f9

@ -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;
}
}
}

@ -38,4 +38,8 @@ public interface SysWxMerchantApplyMapper {
@AutoSql(SqlType.UPDATE)
void updateSubMerchantInfoByMerchantAppId(JSONObject updateSubMerchantInfo);
@Select("SELECT * FROM sys_wx_merchant_apply where is_valid = 1 and ( business_type is null or business_type ='')")
List<JSONObject> findSubMerchantIdHistorys();
}

@ -89,6 +89,8 @@ public class NewSubMerchantIdApply {
private String sub_mch_id;
private String merchantRemark;
public JSONObject insertObject(JSONObject client) {
JSONObject params = new JSONObject();
if(StringUtils.isNotEmpty(merchant_name)){
@ -142,7 +144,7 @@ public class NewSubMerchantIdApply {
}
params.put("merchant_country_code","036");//固定值036-澳大利亚国家编码
params.put("merchant_remark",client.getString("client_moniker"));
params.put("merchant_remark",merchantRemark);
if(StringUtils.isNotEmpty(sub_mch_id)) {
params.put("sub_mch_id", sub_mch_id);
}
@ -178,6 +180,14 @@ public class NewSubMerchantIdApply {
public NewSubMerchantIdApply() {
}
public String getMerchantRemark() {
return merchantRemark;
}
public void setMerchantRemark(String merchantRemark) {
this.merchantRemark = merchantRemark;
}
public String getMerchant_name() {
return this.merchant_name;
}

@ -5687,8 +5687,14 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
subMerchantApply.setMerchantRemark(client.getString("client_moniker") + "_" + RandomStringUtils.random(8, true, true));
JSONObject params = subMerchantApply.insertObject(client);
client.put("merchant_id", subMerchantApply.getMerchant_id());
params.put("merchant_id", subMerchantApply.getMerchant_id());
params.put("client_id", client.getString("client_id"));
params.put("create_time", new Date());
params.put("operator", manager.getString("display_name"));
params.put("is_valid","1");
SubMerchantInfoInheritance subMerchantInfo = JSON.toJavaObject(params, SubMerchantInfoInheritance.class);
MerchantApplicationResult res = Optional.ofNullable(merchantChannelApplicationManager.getRegister(WxPayMerchantRegister.class))
.map(channel -> channel.apply(client, subMerchantInfo, manager))

@ -6900,30 +6900,63 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
$scope.merchantIds = merchantIds.data
$scope.businessTypesMap = businessTypesMap.configs()
if ($scope.subMerchantInfo.extra_merchant_type) {
$scope.subMerchantInfo.merchant_type = $scope.subMerchantInfo.extra_merchant_type
$scope.subMerchantInfo.company_register_no = $scope.merchantInfo.abn ? $scope.merchantInfo.abn : $scope.merchantInfo.acn
$scope.subMerchantInfo.short_name=$scope.merchantInfo.short_name;
$scope.subMerchantInfo.industry=$scope.merchantInfo.industry;
$scope.subMerchantInfo.company_website=$scope.merchantInfo.company_website;
$scope.subMerchantInfo.address=$scope.merchantInfo.address;
$scope.subMerchantInfo.company_phone=$scope.merchantInfo.company_phone;
$scope.subMerchantInfo.contact_person=$scope.merchantInfo.contact_person;
$scope.subMerchantInfo.contact_phone=$scope.merchantInfo.contact_phone;
$scope.subMerchantInfo.contact_email=$scope.merchantInfo.contact_email;
if ($scope.merchantInfo.client_pay_type) {
if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0 && $scope.merchantInfo.client_pay_type.indexOf('2') >= 0) {
$scope.subMerchantInfo.business_type = 'BOTH'
} else if ($scope.merchantInfo.client_pay_type.indexOf('1') >= 0) {
$scope.subMerchantInfo.business_type = 'ONLINE'
} else if ($scope.merchantInfo.client_pay_type.indexOf('2') >= 0) {
$scope.subMerchantInfo.business_type = 'OFFLINE'
}
if ($scope.subMerchantInfo.industry) {
$scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.subMerchantInfo.industry)
} else {
$scope.subMerchantInfo.business_type = 'BOTH'
}
if ($scope.merchantInfo.industry) {
$scope.subMerchantInfo.industry = $filter('newWxMerchantsFilter')($scope.merchantInfo.industry)
}
if ($scope.subMerchantInfo.mcc_code) {
$scope.subMerchantInfo.mcc_code = parseInt($scope.subMerchantInfo.mcc_code)
if ($scope.merchantInfo.mc_code) {
$scope.subMerchantInfo.mcc_code = $scope.merchantInfo.mc_code
}
// if($scope.subMerchantInfo.certificat_expire_date) {
// // var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/');
// $scope.subMerchantInfo.certificat_expire_date=new Date($scope.subMerchantInfo.certificat_expire_date);
// }
if ($scope.subMerchantInfo.certificat_expire_date) {
if ($scope.subMerchantInfo.certificat_expire_date == 'PERMANENT') {
if ($scope.merchantInfo.business_structure) {
$scope.subMerchantInfo.merchant_type = $scope.merchantInfo.business_structure != 'Registered body(Sole Trader)' ? 'ENTERPRISE' : 'INDIVIDUAL'
}
if ($scope.merchantInfo.certificat_expire_date) {
if ($scope.merchantInfo.certificat_expire_date == 'PERMANENT') {
$scope.subMerchantInfo.certificat_expire_date_premanent = true
} else if ($scope.subMerchantInfo.certificat_expire_date == 'N/A') {
} else if ($scope.merchantInfo.certificat_expire_date == 'N/A') {
$scope.subMerchantInfo.certificat_expire_date_NA = true
} else {
var datestr = $scope.subMerchantInfo.certificat_expire_date.replace(/-/g, '/')
var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/')
$scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr)
}
}
// if($scope.subMerchantInfo.certificat_expire_date) {
// // var datestr = subMerchantInfo.certificat_expire_date.replace(/-/g, '/');
// $scope.subMerchantInfo.certificat_expire_date=new Date($scope.subMerchantInfo.certificat_expire_date);
// }
// if ($scope.subMerchantInfo.certificat_expire_date) {
// if ($scope.subMerchantInfo.certificat_expire_date == 'PERMANENT') {
// $scope.subMerchantInfo.certificat_expire_date_premanent = true
// } else if ($scope.subMerchantInfo.certificat_expire_date == 'N/A') {
// $scope.subMerchantInfo.certificat_expire_date_NA = true
// } else {
// var datestr = $scope.subMerchantInfo.certificat_expire_date.replace(/-/g, '/')
// $scope.subMerchantInfo.certificat_expire_date_d = new Date(datestr)
// }
// }
$scope.checkExpriedate = function (value) {
if (value) {
$scope.subMerchantInfo.certificat_expire_date_premanent = false

Loading…
Cancel
Save