From e3fcabc4e1419423491c7678c56602ee3870e948 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 23 Jul 2024 10:19:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/order/controller/OrderPayController.java | 10 ++++++++-- .../main/java/com/hfkj/service/pay/HuiPayService.java | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/order/src/main/java/com/order/controller/OrderPayController.java b/order/src/main/java/com/order/controller/OrderPayController.java index d43218b..3ffed80 100644 --- a/order/src/main/java/com/order/controller/OrderPayController.java +++ b/order/src/main/java/com/order/controller/OrderPayController.java @@ -6,6 +6,7 @@ import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.config.CommonSysConst; import com.hfkj.entity.BsMerPayConfig; import com.hfkj.entity.BsOrderOutside; import com.hfkj.entity.BsUserCard; @@ -103,8 +104,13 @@ public class OrderPayController { if (merPay == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付"); } + // appIdType 1: 公众号 2:小程序 + if (body.getInteger("appIdType") != null && body.getInteger("appIdType") == 2) { + body.put("appId", CommonSysConst.getSysConfig().getWechatMaAppid()); + } + // 请求支付渠道 - Map preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), body.getString("openId"), order); + Map preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), body.getString("appId"), body.getString("openId"), order); for (OrderChildModel orderChild : order.getOrderChildList()) { orderChild.setSettleAccount(merPay.getPayMerNo()); orderChild.setSettleAccountKey(merPay.getPayMerKey()); @@ -146,7 +152,7 @@ public class OrderPayController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付"); } // 请求支付渠道 - Map preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), body.getString("openId"), order); + Map preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), null, body.getString("openId"), order); for (OrderChildModel orderChild : order.getOrderChildList()) { orderChild.setSettleAccount(merPay.getPayMerNo()); orderChild.setSettleAccountKey(merPay.getPayMerKey()); diff --git a/service/src/main/java/com/hfkj/service/pay/HuiPayService.java b/service/src/main/java/com/hfkj/service/pay/HuiPayService.java index 11b5525..79fe887 100644 --- a/service/src/main/java/com/hfkj/service/pay/HuiPayService.java +++ b/service/src/main/java/com/hfkj/service/pay/HuiPayService.java @@ -9,6 +9,7 @@ import com.hfkj.common.utils.HttpsUtils; import com.hfkj.config.CommonSysConst; import com.hfkj.model.order.OrderModel; import com.hfkj.sysenum.order.OrderPayTypeEnum; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -38,7 +39,7 @@ public class HuiPayService { * @return * @throws Exception */ - public static Map preorder(String merNo,String merKey,String openId,OrderModel order) throws Exception { + public static Map preorder(String merNo,String merKey,String appId,String openId,OrderModel order) throws Exception { try { log.info("=============== start 惠支付 start =================="); Map param = new HashMap<>(); @@ -50,6 +51,9 @@ public class HuiPayService { } else if (OrderPayTypeEnum.type2.getCode() == order.getPayType()) { param.put("payMode", "ALIPAY"); } + if (StringUtils.isNotBlank(appId)) { + param.put("subAppid", appId); + } param.put("totalAmount", order.getPayRealPrice()); param.put("profitSharing", "0"); param.put("subject", "购买产品");