From f19155dcda0413563963d545eed3045364814c0d Mon Sep 17 00:00:00 2001 From: jiangqs <jiangqs> Date: 星期六, 12 八月 2023 05:14:27 +0800 Subject: [PATCH] bug --- ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java | 76 +++++++++++++++++++++++++++---------- 1 files changed, 55 insertions(+), 21 deletions(-) diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java index 45e1ce1..01c24c5 100644 --- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java +++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java @@ -1,8 +1,21 @@ 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.bean.media.ImageUploadResult; import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.EcommerceService; +import com.github.binarywang.wxpay.service.MerchantMediaService; +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.io.InputStream; +import java.util.ArrayList; +import java.util.List; /** * 微信支付 @@ -11,13 +24,20 @@ @AllArgsConstructor public class WechatPayUtils { - /*private final WxPayService wxService; + private final WxPayService wxService; - *//** - * 电商二级商户进件(提交申请单) - *//* - public ApplymentsResult ecommerceApply(ShopAuthentication shopAuthentication, String applyNumber, Shop shop) throws WxPayException { + /** + * @description 电商二级商户进件(提交申请单) + * @author jqs + * @date 2023/8/11 10:04 + * @param shopAuthentication + * @param applyNumber + * @param shop + * @return ApplymentsResult + */ + public ApplymentsResult ecommerceApply(ShopAuthentication shopAuthentication, String applyNumber, Shop shop) throws Exception { EcommerceService ecommerceService = wxService.getEcommerceService(); + MerchantMediaService merchantMediaService = wxService.getMerchantMediaService(); ApplymentsRequest request = new ApplymentsRequest(); //生成提交类 request.setOutRequestNo(applyNumber); @@ -28,7 +48,10 @@ } //营业执照 ApplymentsRequest.BusinessLicenseInfo business_license_info = new ApplymentsRequest.BusinessLicenseInfo(); - business_license_info.setBusinessLicenseCopy(shopAuthentication.getBlImage()); + InputStream blImageIO = OBSUploadUtils.getOSSInputStream(shopAuthentication.getBlImage()); + ImageUploadResult blImageIR = merchantMediaService.imageUploadV3(blImageIO,applyNumber+"blimage"); + business_license_info.setBusinessLicenseCopy(blImageIR.getMediaId()); + blImageIO.close(); business_license_info.setBusinessLicenseNumber(shopAuthentication.getBlNumber()); business_license_info.setMerchantName(shopAuthentication.getBlShopName()); business_license_info.setLegalPerson(shopAuthentication.getBlCorporateName()); @@ -38,8 +61,14 @@ //法人证件 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()); + InputStream lpIcFrontIO = OBSUploadUtils.getOSSInputStream(shopAuthentication.getLpIcFront()); + ImageUploadResult lpIcFrontIR = merchantMediaService.imageUploadV3(lpIcFrontIO,applyNumber+"lpIcFront"); + id_card_info.setIdCardCopy(lpIcFrontIR.getMediaId()); + lpIcFrontIO.close(); + InputStream lpIcBackIO = OBSUploadUtils.getOSSInputStream(shopAuthentication.getLpIcBack()); + ImageUploadResult lpIcBackIR = merchantMediaService.imageUploadV3(lpIcBackIO,applyNumber+"lpIcBack"); + id_card_info.setIdCardNational(lpIcBackIR.getMediaId()); + lpIcBackIO.close(); id_card_info.setIdCardName(shopAuthentication.getLpCorporateName()); id_card_info.setIdCardNumber(shopAuthentication.getLpIdCard()); id_card_info.setIdCardValidTimeBegin(shopAuthentication.getLpIcStartDate()); @@ -55,13 +84,18 @@ 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()); + InputStream uboIcFrontIO = OBSUploadUtils.getOSSInputStream(shopAuthentication.getUboIcFront()); + ImageUploadResult uboIcFrontIR = merchantMediaService.imageUploadV3(uboIcFrontIO,applyNumber+"uboIcFront"); + uboInfo.setUboIdDocCopy(uboIcFrontIR.getMediaId()); + uboIcFrontIO.close(); + InputStream uboIcBackIO = OBSUploadUtils.getOSSInputStream(shopAuthentication.getUboIcBack()); + ImageUploadResult uboIcBackIR = merchantMediaService.imageUploadV3(uboIcBackIO,applyNumber+"uboIcBack"); + uboInfo.setUboIdDocCopyBack(uboIcBackIR.getMediaId()); + uboIcBackIO.close(); 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); } @@ -89,25 +123,25 @@ //店铺信息 ApplymentsRequest.SalesSceneInfo salesSceneInfo = new ApplymentsRequest.SalesSceneInfo(); salesSceneInfo.setStoreName(shop.getShopName()); - salesSceneInfo.setStoreUrl(""); - salesSceneInfo.setStoreQrCode(""); + salesSceneInfo.setStoreQrCode("https://wxapp.hhhrt.cn/mini/shop?id="+shop.getShopId()); + salesSceneInfo.setMiniProgramSubAppid("wxb7f0ea286fc4e535"); 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 - *//* + /** + * @description 查询申请审核状态 + * @author jqs + * @date 2023/8/11 10:04 + * @param applymentId + * @return ApplymentsStatusResult + */ public ApplymentsStatusResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException { return wxService.getEcommerceService().queryApplyStatusByApplymentId(applymentId); - }*/ + } } -- Gitblit v1.7.1