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", "购买产品");