ソースを参照

app支付相关

yh 1 週間 前
コミット
c7da97e1cc

+ 2 - 0
fs-service/src/main/java/com/fs/app/service/AppPayService.java

@@ -18,4 +18,6 @@ public interface AppPayService {
      * 微信支付回调
      */
     String wxNotify(WxPayOrderNotifyResult result);
+
+    R getPayConfig(String appId);
 }

+ 10 - 1
fs-service/src/main/java/com/fs/app/service/impl/AppPayServiceImpl.java

@@ -15,7 +15,6 @@ import com.fs.app.service.AppPayService;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.ServletUtils;
-import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.ip.IpUtils;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
@@ -44,6 +43,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.google.gson.Gson;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -136,4 +136,13 @@ public class AppPayServiceImpl implements AppPayService {
         return WxPayNotifyResponse.success("OK");
     }
 
+    @Override
+    public R getPayConfig(String appId) {
+        MerchantAppConfig merchantAppConfig = sysConfigMapper.getPayConfig(appId);
+        if (merchantAppConfig == null || StringUtils.isEmpty(merchantAppConfig.getMerchantType())) {
+            return R.error("商户信息不存在");
+        }
+        return R.ok(merchantAppConfig.getMerchantType());
+    }
+
 }

+ 1 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCourseProductOrderServiceImpl.java

@@ -436,6 +436,7 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
                 storePayment.setOpenId(openId);
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(courseProductOrder.getCourseOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单

+ 2 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseOrderServiceImpl.java

@@ -451,6 +451,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                 storePayment.setOpenId(openId);
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
@@ -622,6 +623,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
 //                storePayment.setOpenId(user.getMpOpenId());
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
                     if (merchantAppConfig.getMerchantType().equals("yb")) {

+ 2 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserVipOrderServiceImpl.java

@@ -304,6 +304,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                 storePayment.setOpenId(openId);
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
@@ -468,6 +469,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
 //                storePayment.setOpenId(user.getMpOpenId());
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
                     if (merchantAppConfig.getMerchantType().equals("yb")) {

+ 9 - 0
fs-service/src/main/java/com/fs/his/domain/FsStorePayment.java

@@ -96,6 +96,15 @@ public class FsStorePayment extends BaseEntity
     private BigDecimal shareMoney;
     private Integer isShare;
 
+    private Long merchantId;
+
+    public Long getMerchantId() {
+        return merchantId;
+    }
+
+    public void setMerchantId(Long merchantId) {
+        this.merchantId = merchantId;
+    }
 
     //小程序appId
     private String appId;

+ 28 - 18
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -1009,37 +1009,44 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
         }
         MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
         FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
-//        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
 
         //金牛多小程序支付
         String openId = null;
         String appId = param.getAppId();
-        if (StringUtils.isNotBlank(appId)) {
-            //查询fs_user_wx的openId
-            Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
-                    .eq(FsUserWx::getFsUserId, param.getUserId())
-                    .eq(FsUserWx::getAppId, appId);
-            FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
-            if (fsUserWx != null) {
-                openId = fsUserWx.getOpenId();
-            }
+        if (request.getHeader("sourcetype") != null && "APP".equals(request.getHeader("sourcetype"))) {
+            FsUser fsUser = fsUserService.selectFsUserByUserId(param.getUserId().longValue());
+            openId = fsUser.getAppOpenId();
         } else {
-            appId = fsCoursePlaySourceConfig.getAppid();
-            openId = Objects.isNull(user) ? "" : user.getMaOpenId();
-            if (StringUtils.isBlank(openId)){
+            if (StringUtils.isNotBlank(appId)) {
+                //查询fs_user_wx的openId
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
                         .eq(FsUserWx::getFsUserId, param.getUserId())
                         .eq(FsUserWx::getAppId, appId);
                 FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
-                if (Objects.nonNull(fsUserWx)){
+                if (fsUserWx != null) {
                     openId = fsUserWx.getOpenId();
                 }
+            } else {
+                appId = fsCoursePlaySourceConfig.getAppid();
+                openId = Objects.isNull(user) ? "" : user.getMaOpenId();
+                if (StringUtils.isBlank(openId)){
+                    Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
+                            .eq(FsUserWx::getFsUserId, param.getUserId())
+                            .eq(FsUserWx::getAppId, appId);
+                    FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
+                    if (Objects.nonNull(fsUserWx)){
+                        openId = fsUserWx.getOpenId();
+                    }
+                }
             }
         }
 
         if (user != null
-                && ( "appPay".equals(merchantAppConfig.getMerchantType()) // appPay类型:跳过openId校验
-                || StringUtils.isNotEmpty(openId) )) {
+                && (
+                StringUtils.isNotEmpty(openId)
+                        || "appPay".equals(merchantAppConfig.getMerchantType())
+                        || ("hf".equals(merchantAppConfig.getMerchantType()) && "ali".equals(param.getPayType()))
+        )) {
             if(fsPackageOrder.getPayMoney().compareTo(new BigDecimal(0))==1){
                 String payCode =  OrderCodeUtils.getOrderSn();
                 if(StringUtils.isEmpty(payCode)){
@@ -1061,6 +1068,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
@@ -1138,7 +1146,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                     }else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         logger.info("创建汇付订单");
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
-                        o.setTradeType("T_MINIAPP");
+                        o.setTradeType(StringUtils.isEmpty(param.getPayType()) || param.getPayType().equals("wx") ? "T_MINIAPP" : "A_NATIVE");
                         o.setOpenid(openId);
                         o.setReqSeqId("package-"+storePayment.getPayCode());
                         o.setTransAmt(storePayment.getPayMoney().toString());
@@ -1189,7 +1197,6 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         }
                     } else if (merchantAppConfig.getMerchantType().equals("appPay") && "ali".equals(param.getPayType())) {
                         // 实例化客户端
-                        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
                         AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", fsPayConfig.getAliAppId(), fsPayConfig.getAliPrivateKey(), "json", "utf-8", fsPayConfig.getAliPublicKey(), "RSA2");
 
                         // 构造请求参数以调用接口
@@ -1349,6 +1356,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
                     if (merchantAppConfig.getMerchantType().equals("yb")) {
@@ -1478,6 +1486,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
                     if (merchantAppConfig.getMerchantType().equals("yb")) {
                         return R.error("支付暂不可用!");
@@ -1609,6 +1618,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
                     if (merchantAppConfig.getMerchantType().equals("yb")) {

+ 2 - 4
fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java

@@ -619,7 +619,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
                 }
             } else if ("appPay".equals(payment.getPayMode()) && "wx".equals(payment.getPayTypeCode())) {
                 // 处理微信退款
-                WxPayService wxPayService = getWxPayService();
+                WxPayService wxPayService = getWxPayService(fsPayConfig);
                 WxPayRefundRequest refundRequest = new WxPayRefundRequest();
                 refundRequest.setOutTradeNo(orderType+"-"+payment.getPayCode());
                 refundRequest.setOutRefundNo(orderType+"-"+payment.getPayCode());
@@ -711,9 +711,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         return i;
     }
 
-    private WxPayService getWxPayService(){
-        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-        FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+    private WxPayService getWxPayService(FsPayConfig fsPayConfig){
         WxPayConfig payConfig = new WxPayConfig();
         payConfig.setAppId(fsPayConfig.getWxAppAppId());
         payConfig.setMchId(fsPayConfig.getWxAppMchId());

+ 9 - 2
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -3021,7 +3021,12 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
             }
         }
 
-        if (user != null && StringUtils.isNotEmpty(openId)) {
+        if (user != null
+                && (
+                StringUtils.isNotEmpty(openId)
+                        || "appPay".equals(merchantAppConfig.getMerchantType())
+                        || ("hf".equals(merchantAppConfig.getMerchantType()) && "ali".equals(param.getPayType()))
+        )) {
 
             if (order.getPayMoney().compareTo(new BigDecimal(0)) == 0) {
                 this.payConfirm(order.getOrderCode(), "", "", "", 2,null,null);
@@ -3047,6 +3052,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 storePayment.setCompanyUserId(order.getCompanyUserId());
                 storePayment.setStoreId(order.getStoreId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
 
                     if (merchantAppConfig.getMerchantType().equals("wx")) {
@@ -3124,7 +3130,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
                     } else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
-                        o.setTradeType("T_MINIAPP");
+                        o.setTradeType(StringUtils.isEmpty(param.getPayType()) || param.getPayType().equals("wx") ? "T_MINIAPP" : "A_NATIVE");
                         o.setOpenid(openId);
                         o.setReqSeqId("store-" + storePayment.getPayCode());
                         o.setTransAmt(storePayment.getPayMoney().toString());
@@ -3283,6 +3289,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 storePayment.setCompanyUserId(order.getCompanyUserId());
                 storePayment.setStoreId(order.getStoreId());
                 storePayment.setBusinessId(order.getOrderId().toString());
+                storePayment.setMerchantId(merchantAppConfig.getId());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
                     if (merchantAppConfig.getMerchantType().equals("yb")) {
                         return R.error("支付暂不可用!");

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsStorePaymentServiceImpl.java

@@ -2024,7 +2024,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
         storePayment.setOpenId(openId);
         storePayment.setUserId(user.getUserId());
         storePayment.setPayMode(merchantAppConfig.getMerchantType());
-
+        storePayment.setMerchantId(merchantAppConfig.getId());
         if (fsStorePaymentMapper.insertFsStorePayment(storePayment) > 0) {
             if (merchantAppConfig.getMerchantType().equals("wx")) {
                 //创建微信订单

+ 4 - 0
fs-service/src/main/java/com/fs/system/mapper/SysConfigMapper.java

@@ -1,6 +1,8 @@
 package com.fs.system.mapper;
 
 import java.util.List;
+
+import com.fs.his.domain.MerchantAppConfig;
 import com.fs.system.domain.SysConfig;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
@@ -71,4 +73,6 @@ public interface SysConfigMapper
 
     @Select("select * from sys_config where config_key=#{configKey}")
     SysConfig selectConfigByConfigKey(String configKey);
+
+    MerchantAppConfig getPayConfig(String appId);
 }

+ 2 - 0
fs-service/src/main/resources/mapper/his/FsStorePaymentMapper.xml

@@ -97,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareMoney != null">share_money,</if>
             <if test="isShare != null">is_share,</if>
             <if test="appId != null">app_id,</if>
+            <if test="merchantId != null">merchant_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="payCode != null">#{payCode},</if>
@@ -125,6 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareMoney != null">#{shareMoney},</if>
             <if test="isShare != null">#{isShare},</if>
             <if test="appId != null">#{appId},</if>
+            <if test="merchantId != null">#{merchantId},</if>
          </trim>
     </insert>
 

+ 11 - 1
fs-service/src/main/resources/mapper/system/SysConfigMapper.xml

@@ -63,7 +63,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectConfigVo"/>
         where config_key = #{configKey} limit 1
     </select>
-    
+
+    <select id="getPayConfig" resultType="com.fs.his.domain.MerchantAppConfig">
+        SELECT
+            b.*
+        FROM
+            `fs_course_play_source_config` a
+                LEFT JOIN merchant_app_config b ON a.merchant_config_id = b.id
+        WHERE
+            a.appid = #{appId}
+    </select>
+
     <insert id="insertConfig" parameterType="SysConfig">
         insert into sys_config (
 			<if test="configName != null and configName != '' ">config_name,</if>

+ 9 - 4
fs-user-app/src/main/java/com/fs/app/controller/AppPayController.java

@@ -2,6 +2,7 @@ package com.fs.app.controller;
 
 
 import com.fs.app.service.AppPayService;
+import com.fs.common.core.domain.R;
 import com.fs.his.domain.FsPayConfig;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
@@ -15,10 +16,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
@@ -65,6 +63,13 @@ public class AppPayController extends AppBaseController {
         return appPayService.wxNotify(result);
     }
 
+    @ApiOperation("获取支付配置")
+    @GetMapping("/getPayConfig")
+    public R getPayConfig(@RequestParam String appId){
+        return appPayService.getPayConfig(appId);
+    }
+
+
     private WxPayService getWxPayService(){
         SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
         FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);

+ 31 - 21
fs-user-app/src/main/java/com/fs/app/controller/InquiryOrderController.java

@@ -129,6 +129,8 @@ public class InquiryOrderController extends  AppBaseController {
     private ISysConfigService configService;
     @Autowired
     private IFsUserWxService userWxService;
+    @Autowired
+    private IFsUserService fsUserService;
     @Login
     @ApiOperation("确认订单")
     @PostMapping("/confirm")
@@ -304,28 +306,34 @@ public class InquiryOrderController extends  AppBaseController {
 
         String openId = null;
         String appId = param.getAppId();
-        if (StringUtils.isNotBlank(appId)) {
-            //查询fs_user_wx的openId
-            Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
-                    .eq(FsUserWx::getFsUserId, param.getUserId())
-                    .eq(FsUserWx::getAppId, appId);
-            FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
-            if (fsUserWx != null) {
-                openId = fsUserWx.getOpenId();
-            }
+        if (request.getHeader("sourcetype") != null && "APP".equals(request.getHeader("sourcetype"))) {
+            FsUser fsUser = fsUserService.selectFsUserByUserId(param.getUserId().longValue());
+            openId = fsUser.getAppOpenId();
         } else {
-            appId = merchantAppConfig.getAppId();
-            openId = Objects.isNull(user) ? "" : user.getMaOpenId();
-            if (StringUtils.isBlank(openId)){
+            if (StringUtils.isNotBlank(appId)) {
+                //查询fs_user_wx的openId
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
                         .eq(FsUserWx::getFsUserId, param.getUserId())
                         .eq(FsUserWx::getAppId, appId);
                 FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
-                if (Objects.nonNull(fsUserWx)){
+                if (fsUserWx != null) {
                     openId = fsUserWx.getOpenId();
                 }
+            } else {
+                appId = merchantAppConfig.getAppId();
+                openId = Objects.isNull(user) ? "" : user.getMaOpenId();
+                if (StringUtils.isBlank(openId)){
+                    Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
+                            .eq(FsUserWx::getFsUserId, param.getUserId())
+                            .eq(FsUserWx::getAppId, appId);
+                    FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
+                    if (Objects.nonNull(fsUserWx)){
+                        openId = fsUserWx.getOpenId();
+                    }
+                }
             }
         }
+
         //String json=configService.selectConfigByKey("his.pay");
         //PayConfigDTO payConfigDTO= JSONUtil.toBean(json, PayConfigDTO.class);
 
@@ -344,7 +352,7 @@ public class InquiryOrderController extends  AppBaseController {
 //            }
 //        }
 
-        if ((!"appPay".equals(merchantAppConfig.getMerchantType()) && StringUtils.isBlank(openId))) {
+        if ((!"appPay".equals(merchantAppConfig.getMerchantType()) && (StringUtils.isBlank(openId) || ("hf".equals(merchantAppConfig.getMerchantType()) && "wx".equals(param.getPayType())) ))) {
             return R.error("用户OPENID不存在");
         }
 
@@ -359,7 +367,7 @@ public class InquiryOrderController extends  AppBaseController {
             }
             FsStorePayment storePayment=new FsStorePayment();
             storePayment.setStatus(0);
-            storePayment.setPayMode(merchantAppConfig.getMerchantId());
+            storePayment.setPayMode(merchantAppConfig.getMerchantType());
             storePayment.setPayCode(payCode);
             storePayment.setCompanyId(order.getCompanyId());
             storePayment.setCompanyUserId(order.getCompanyUserId());
@@ -372,8 +380,9 @@ public class InquiryOrderController extends  AppBaseController {
             storePayment.setOpenId(openId);
             storePayment.setUserId(user.getUserId());
             storePayment.setBusinessId(order.getOrderId().toString());
+            storePayment.setMerchantId(merchantAppConfig.getId());
             if(storePaymentService.insertFsStorePayment(storePayment)>0){
-                if(merchantAppConfig.getMerchantId().equals("wx")){
+                if(merchantAppConfig.getMerchantType().equals("wx")){
                     //创建微信订单
                     WxPayConfig payConfig = new WxPayConfig();
                     payConfig.setAppId(appId);
@@ -401,7 +410,7 @@ public class InquiryOrderController extends  AppBaseController {
                         throw new CustomException("支付失败"+e.getMessage());
                     }
                 }
-                else if(merchantAppConfig.getMerchantId().equals("yb")){
+                else if(merchantAppConfig.getMerchantType().equals("yb")){
                     WxJspayDTO p = new WxJspayDTO();
                     // 使用setter方法为对象赋值
                     p.setPayMoney(storePayment.getPayMoney().toString());
@@ -423,7 +432,7 @@ public class InquiryOrderController extends  AppBaseController {
                         throw new CustomException("支付失败");
                     }
                 }
-                else if(merchantAppConfig.getMerchantId().equals("tz")){
+                else if(merchantAppConfig.getMerchantType().equals("tz")){
                     PayCreateOrder o = new PayCreateOrder();
                     o.setOrderNo("inquiry"+storePayment.getPayCode()); // 业务系统订单号
                     o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -448,9 +457,9 @@ public class InquiryOrderController extends  AppBaseController {
                     mt.setTradeNo(result.getBody().getOrderFlowNo());
                     storePaymentService.updateFsStorePayment(mt);
                     return R.ok().put("isPay",0).put("data",result).put("type","tz");
-                }else if(merchantAppConfig.getMerchantId().equals("hf")){
+                }else if(merchantAppConfig.getMerchantType().equals("hf")){
                     HuiFuCreateOrder o = new HuiFuCreateOrder();
-                    o.setTradeType("T_MINIAPP");
+                    o.setTradeType(StringUtils.isEmpty(param.getPayType()) || param.getPayType().equals("wx") ? "T_MINIAPP" : "A_NATIVE");
                     o.setOpenid(openId);
                     o.setAppId(appId);
                     o.setReqSeqId("inquiry-"+storePayment.getPayCode());
@@ -498,7 +507,7 @@ public class InquiryOrderController extends  AppBaseController {
                     AlipayTradeAppPayRequest aliRequest = new AlipayTradeAppPayRequest();
                     AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
                     // 商户订单号
-                    model.setOutTradeNo("package-" + storePayment.getPayCode());
+                    model.setOutTradeNo("inquiry-" + storePayment.getPayCode());
                     // 订单总金额
                     model.setTotalAmount(storePayment.getPayMoney().toString());
                     // 订单标题r
@@ -605,6 +614,7 @@ public class InquiryOrderController extends  AppBaseController {
             storePayment.setOpenId(openId);
             storePayment.setUserId(user.getUserId());
             storePayment.setBusinessId(order.getOrderId().toString());
+            storePayment.setMerchantId(merchantAppConfig.getId());
             if(storePaymentService.insertFsStorePayment(storePayment)>0){
                 if (merchantAppConfig.getMerchantType().equals("yb")) {
                     return R.error("支付暂不可用!");