package com.ruoyi.shop.util;
|
|
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsRequest;
|
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult;
|
import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.service.EcommerceService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.ruoyi.shop.domain.pojo.shop.ShopAuthentication;
|
import com.ruoyi.system.api.domain.poji.shop.Shop;
|
import lombok.AllArgsConstructor;
|
import org.springframework.stereotype.Component;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* 微信支付
|
*/
|
@Component
|
@AllArgsConstructor
|
public class WechatPayUtils {
|
|
private final WxPayService wxService;
|
|
/**
|
* 电商二级商户进件(提交申请单)
|
*/
|
public ApplymentsResult ecommerceApply(ShopAuthentication shopAuthentication, String applyNumber, Shop shop) throws WxPayException {
|
EcommerceService ecommerceService = wxService.getEcommerceService();
|
ApplymentsRequest request = new ApplymentsRequest();
|
//生成提交类
|
request.setOutRequestNo(applyNumber);
|
if(shopAuthentication.getMainType()==2){
|
request.setOrganizationType("2");
|
}else{
|
request.setOrganizationType("4");
|
}
|
//营业执照
|
ApplymentsRequest.BusinessLicenseInfo business_license_info = new ApplymentsRequest.BusinessLicenseInfo();
|
business_license_info.setBusinessLicenseCopy(shopAuthentication.getBlImage());
|
business_license_info.setBusinessLicenseNumber(shopAuthentication.getBlNumber());
|
business_license_info.setMerchantName(shopAuthentication.getBlShopName());
|
business_license_info.setLegalPerson(shopAuthentication.getBlCorporateName());
|
business_license_info.setCompanyAddress(shopAuthentication.getBlRegisteredAddress());
|
business_license_info.setBusinessTime(shopAuthentication.getBlBusinessDeanline());
|
request.setBusinessLicenseInfo(business_license_info);
|
//法人证件
|
request.setIdDocType("IDENTIFICATION_TYPE_MAINLAND_IDCARD");
|
ApplymentsRequest.IdCardInfo id_card_info = new ApplymentsRequest.IdCardInfo();
|
id_card_info.setIdCardCopy(shopAuthentication.getLpIcFront());
|
id_card_info.setIdCardNational(shopAuthentication.getLpIcBack());
|
id_card_info.setIdCardName(shopAuthentication.getLpCorporateName());
|
id_card_info.setIdCardNumber(shopAuthentication.getLpIdCard());
|
id_card_info.setIdCardValidTimeBegin(shopAuthentication.getLpIcStartDate());
|
id_card_info.setIdCardValidTime(shopAuthentication.getLpIcEndDate());
|
request.setIdCardInfo(id_card_info);
|
//企业填写
|
if(shopAuthentication.getMainType()==2){
|
//受益人
|
if(shopAuthentication.getOwner()==1){
|
request.setOwner(true);
|
}else{
|
request.setOwner(false);
|
List<ApplymentsRequest.UboInfo> ubo_info_list = new ArrayList<>();
|
ApplymentsRequest.UboInfo uboInfo = new ApplymentsRequest.UboInfo();
|
uboInfo.setUboIdDocType("IDENTIFICATION_TYPE_MAINLAND_IDCARD");
|
uboInfo.setUboIdDocCopy(shopAuthentication.getUboIcFront());
|
uboInfo.setUboIdDocCopyBack(shopAuthentication.getUboIcBack());
|
uboInfo.setUboIdDocName(shopAuthentication.getUboName());
|
uboInfo.setUboIdDocNumber(shopAuthentication.getUboIdCard());
|
uboInfo.setUboIdDocAddress(shopAuthentication.getUboIcAddress());
|
uboInfo.setUboIdDocPeriodBegin(shopAuthentication.getUboIcStartDate());
|
uboInfo.setUboIdDocCopyBack(shopAuthentication.getUboIcEndDate());
|
ubo_info_list.add(uboInfo);
|
request.setUboInfoList(ubo_info_list);
|
}
|
}
|
//结算账户信息
|
ApplymentsRequest.AccountInfo accountInfo = new ApplymentsRequest.AccountInfo();
|
if(shopAuthentication.getSettlementAccountType().equals("1")){
|
accountInfo.setBankAccountType("74");
|
}else{
|
accountInfo.setBankAccountType("75");
|
}
|
accountInfo.setAccountBank(shopAuthentication.getSaBank());
|
accountInfo.setAccountName(shopAuthentication.getSaAccountName());
|
accountInfo.setBankAddressCode(shopAuthentication.getSaBankCityCode());
|
accountInfo.setBankName(shopAuthentication.getSaBankName());
|
accountInfo.setAccountNumber(shopAuthentication.getSaNumber());
|
request.setAccountInfo(accountInfo);
|
ApplymentsRequest.ContactInfo contactInfo = new ApplymentsRequest.ContactInfo();
|
contactInfo.setContactType("65");
|
contactInfo.setContactName(shopAuthentication.getLpCorporateName());
|
contactInfo.setContactIdCardNumber(shopAuthentication.getLpIdCard());
|
contactInfo.setMobilePhone(shopAuthentication.getLpMobilePhone());
|
contactInfo.setContactEmail(shopAuthentication.getLpContactEmail());
|
request.setContactInfo(contactInfo);
|
//店铺信息
|
ApplymentsRequest.SalesSceneInfo salesSceneInfo = new ApplymentsRequest.SalesSceneInfo();
|
salesSceneInfo.setStoreName(shop.getShopName());
|
salesSceneInfo.setStoreUrl("");
|
salesSceneInfo.setStoreQrCode("");
|
request.setSalesSceneInfo(salesSceneInfo);
|
request.setMerchantShortname(shop.getShopName());
|
request.setBusinessAdditionPics(shopAuthentication.getBaPics());
|
request.setBusinessAdditionDesc(shopAuthentication.getBaDesc());
|
|
return ecommerceService.createApply(request);
|
}
|
|
|
/**
|
* 通过查询申请状态API查询二级商户入驻申请结果
|
* @param applymentId 微信支付申请单号
|
* @return 申请状态
|
* @throws WxPayException
|
*/
|
public ApplymentsStatusResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException {
|
return wxService.getEcommerceService().queryApplyStatusByApplymentId(applymentId);
|
}
|
|
}
|