Jelajahi Sumber

除去直播订单,其他订单多支付合并

yfh 1 hari lalu
induk
melakukan
e69fff42c4
19 mengubah file dengan 602 tambahan dan 205 penghapusan
  1. 58 12
      fs-admin/src/main/java/com/fs/hisStore/controller/FsStorePaymentScrmController.java
  2. 0 1
      fs-ipad-task/src/main/java/com/fs/app/service/IpadSendServer.java
  3. 7 0
      fs-service/src/main/java/com/fs/course/service/IFsCoursePlaySourceConfigService.java
  4. 5 0
      fs-service/src/main/java/com/fs/course/service/impl/FsCoursePlaySourceConfigServiceImpl.java
  5. 41 16
      fs-service/src/main/java/com/fs/course/service/impl/FsCourseProductOrderServiceImpl.java
  6. 41 17
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseOrderServiceImpl.java
  7. 45 25
      fs-service/src/main/java/com/fs/course/service/impl/FsUserVipOrderServiceImpl.java
  8. 5 0
      fs-service/src/main/java/com/fs/his/param/PayOrderParam.java
  9. 81 32
      fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java
  10. 20 3
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java
  11. 41 16
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java
  12. 36 6
      fs-service/src/main/java/com/fs/his/service/impl/FsStorePaymentServiceImpl.java
  13. 19 6
      fs-service/src/main/java/com/fs/his/service/impl/FsUserInformationCollectionServiceImpl.java
  14. 2 0
      fs-service/src/main/java/com/fs/hisStore/domain/FsPayConfigScrm.java
  15. 36 4
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java
  16. 72 12
      fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java
  17. 48 22
      fs-user-app/src/main/java/com/fs/app/controller/InquiryOrderController.java
  18. 43 23
      fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java
  19. 2 10
      fs-user-app/src/main/java/com/fs/app/controller/store/CompanyUserScrmController.java

+ 58 - 12
fs-admin/src/main/java/com/fs/hisStore/controller/FsStorePaymentScrmController.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.controller;
 
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alipay.api.AlipayApiException;
@@ -12,15 +13,20 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.CloudHostUtils;
+import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.ParseUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.common.utils.spring.SpringUtils;
 import com.fs.company.service.ICompanyService;
 import com.fs.config.cloud.CloudHostProper;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.service.IFsCoursePlaySourceConfigService;
 import com.fs.his.domain.FsHfpayConfig;
+import com.fs.his.domain.FsPayConfig;
+import com.fs.his.domain.MerchantAppConfig;
 import com.fs.his.mapper.FsHfpayConfigMapper;
-import com.fs.hisStore.domain.FsPayConfigScrm;
+import com.fs.his.service.IMerchantAppConfigService;
 import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
@@ -32,6 +38,13 @@ import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import com.fs.hisStore.service.IFsStorePaymentScrmService;
 import com.fs.hisStore.vo.FsStorePaymentVO;
 import com.fs.system.service.ISysConfigService;
+import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
+import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
+import com.github.binarywang.wxpay.bean.result.WxPayRefundQueryResult;
+import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
+import com.github.binarywang.wxpay.config.WxPayConfig;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.WxPayService;
 import com.ijpay.alipay.AliPayApi;
 import com.ijpay.alipay.AliPayApiConfig;
 import com.ijpay.alipay.AliPayApiConfigKit;
@@ -63,10 +76,16 @@ public class FsStorePaymentScrmController extends BaseController
     private IFsStorePaymentScrmService fsStorePaymentService;
     @Autowired
     private AliPayBean aliPayBean;
-
+    @Autowired
+    private WxPayService wxPayService;
     @Autowired
     private ICompanyService companyService;
-
+    @Autowired
+    private IFsCoursePlaySourceConfigService fsCoursePlaySourceConfigService;
+    @Autowired
+    private IMerchantAppConfigService merchantAppConfigService;
+    @Autowired
+    IFsStorePaymentScrmService paymentService;
     @Autowired
     private IFsStoreOrderScrmService orderService;
     @Autowired
@@ -193,16 +212,14 @@ public class FsStorePaymentScrmController extends BaseController
         }
 
         if(payment.getPayTypeCode().equals("weixin")){
-            String json;
-//            if (CloudHostUtils.hasCloudHostName("康年堂")){
-                json = configService.selectConfigByKey("his.pay");
-//            } else {
-//                json = configService.selectConfigByKey("store.pay");
-//            }
-            if (StringUtils.isBlank(json)) {
+            FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigService.selectCoursePlaySourceConfigByAppId(fsStorePayment.getAppId());
+            MerchantAppConfig merchantAppConfig = merchantAppConfigService.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+
+            if (ObjectUtil.isEmpty(merchantAppConfig)) {
                 return R.error("缺少支付相关配置");
             }
-            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+
             if (payment.getPayMode()!=null&&payment.getPayMode().equals("hf")){
                 String huifuId="";
                 FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
@@ -246,7 +263,36 @@ public class FsStorePaymentScrmController extends BaseController
 
             }
             else if (payment.getPayMode()!=null&&payment.getPayMode().equals("wx")){
-
+                WxPayConfig payConfig = new WxPayConfig();
+                payConfig.setAppId(fsPayConfig.getAppId());
+                payConfig.setMchId(fsPayConfig.getWxMchId());
+                payConfig.setMchKey(fsPayConfig.getWxMchKey());
+                payConfig.setKeyPath(fsPayConfig.getKeyPath());
+                payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                wxPayService.setConfig(payConfig);
+                WxPayRefundRequest refundRequest = new WxPayRefundRequest();
+                refundRequest.setOutTradeNo("store-"+payment.getPayCode());
+                refundRequest.setOutRefundNo("store-"+payment.getPayCode());
+                refundRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(payment.getPayMoney().toString()));
+                refundRequest.setRefundFee(WxPayUnifiedOrderRequest.yuanToFen(fsStorePayment.getRefundMoney().toString()));
+                try {
+                    WxPayRefundResult refundResult = wxPayService.refund(refundRequest);
+                    WxPayRefundQueryResult refundQueryResult = wxPayService.refundQuery("", refundResult.getOutTradeNo(), refundResult.getOutRefundNo(), refundResult.getRefundId());
+                    if(refundQueryResult!=null&&refundQueryResult.getResultCode().equals("SUCCESS")){
+                        FsStorePaymentScrm paymentMap=new FsStorePaymentScrm();
+                        paymentMap.setPaymentId(payment.getPaymentId());
+                        paymentMap.setStatus(-1);
+                        paymentMap.setRefundTime(DateUtils.getNowDate());
+                        paymentMap.setRefundMoney(fsStorePayment.getRefundMoney());
+                        paymentService.updateFsStorePayment(paymentMap);
+                    }
+                    else {
+                        return R.error("退款请求失败"+refundQueryResult.getErrCodeDes());
+                    }
+                } catch (WxPayException e) {
+                    return R.error("退款请求失败"+e.getErrCodeDes());
+                }
             }
 
             //小雨点退款

+ 0 - 1
fs-ipad-task/src/main/java/com/fs/app/service/IpadSendServer.java

@@ -12,7 +12,6 @@ import com.fs.company.domain.CompanyMiniapp;
 import com.fs.company.service.ICompanyMiniappService;
 import com.fs.course.domain.FsCoursePlaySourceConfig;
 import com.fs.course.domain.FsCourseWatchLog;
-import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.course.service.IFsCoursePlaySourceConfigService;
 import com.fs.course.service.IFsCourseWatchLogService;
 import com.fs.his.domain.FsUser;

+ 7 - 0
fs-service/src/main/java/com/fs/course/service/IFsCoursePlaySourceConfigService.java

@@ -15,4 +15,11 @@ public interface IFsCoursePlaySourceConfigService extends IService<FsCoursePlayS
     List<FsCoursePlaySourceConfigVO> selectCoursePlaySourceConfigVOListByMap(Map<String, Object> params);
 
     List<FsCoursePlaySourceConfig> selectByAppIds(List<String> miniAppList);
+
+    /**
+     * 根据appId查询
+     * @param appId
+     * @return
+     */
+    FsCoursePlaySourceConfig selectCoursePlaySourceConfigByAppId(String appId);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsCoursePlaySourceConfigServiceImpl.java

@@ -30,4 +30,9 @@ public class FsCoursePlaySourceConfigServiceImpl extends ServiceImpl<FsCoursePla
     public List<FsCoursePlaySourceConfig> selectByAppIds(List<String> miniAppList) {
         return baseMapper.selectList(new QueryWrapper<FsCoursePlaySourceConfig>().in("appid", miniAppList));
     }
+
+    @Override
+    public FsCoursePlaySourceConfig selectCoursePlaySourceConfigByAppId(String appId) {
+        return baseMapper.selectCoursePlaySourceConfigByAppId(appId);
+    }
 }

+ 41 - 16
fs-service/src/main/java/com/fs/course/service/impl/FsCourseProductOrderServiceImpl.java

@@ -18,7 +18,9 @@ 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;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
 import com.fs.course.domain.FsCourseProduct;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.course.mapper.FsCourseProductMapper;
 import com.fs.course.param.FsCourseProductOrderCreateParam;
 import com.fs.course.param.FsCourseProductOrderListParam;
@@ -30,6 +32,7 @@ import com.fs.his.dto.PayConfigDTO;
 import com.fs.his.enums.FsCourseProductOrderStatusEnum;
 import com.fs.his.mapper.FsStorePaymentMapper;
 import com.fs.his.mapper.FsUserWxMapper;
+import com.fs.his.mapper.MerchantAppConfigMapper;
 import com.fs.his.param.ApplyCourseProductOrderRefundParam;
 import com.fs.his.param.FsCourseProductOrderComputeParam;
 import com.fs.his.param.FsCourseProductOrderDoPayParam;
@@ -38,6 +41,7 @@ import com.fs.his.service.IFsStorePaymentService;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.service.IFsUserWxService;
 import com.fs.his.utils.PhoneUtil;
+import com.fs.hisStore.domain.FsPayConfigScrm;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
@@ -94,6 +98,11 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
 
     @Autowired FsCourseProductOrderMapper courseProductOrderMapper;
 
+    @Autowired
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
+
     @Autowired
     private IFsUserService userService;
 
@@ -277,9 +286,18 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
             return R.error("订单状态不正确");
         }
         FsUser user = userService.selectFsUserByUserId(courseProductOrder.getUserId());
-
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
         String openId = null;
         String appId = param.getAppId();
         if (StringUtils.isNotBlank(appId)) {
@@ -293,7 +311,7 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -354,8 +372,19 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
         FsUser user = userService.selectFsUserByUserId(param.getUserId());
         logger.info("用户信息==============={}",user);
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
         String openId = null;
         String appId = param.getAppId();
         if (StringUtils.isNotBlank(appId)) {
@@ -369,7 +398,7 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -388,15 +417,13 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
 //        if (user != null && fsUserWx != null && StringUtils.isNotEmpty(fsUserWx.getOpenId())) {
         if (user != null && StringUtils.isNotEmpty(openId)) {
             if (courseProduct.getProductPrice().compareTo(new BigDecimal(0))==1) {
-//                String json = configService.selectConfigByKey("his.pay");
-//                PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
                 String payCode =  OrderCodeUtils.getOrderSn();
                 if(StringUtils.isEmpty(payCode)){
                     return R.error("订单生成失败,请重试");
                 }
                 FsStorePayment storePayment=new FsStorePayment();
                 storePayment.setStatus(0);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setBusinessCode(courseProductOrder.getOrderCode());
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(courseProduct.getProductPrice());
@@ -410,11 +437,9 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(courseProductOrder.getCourseOrderId().toString());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
-                    if (payConfigDTO.getType().equals("wx")) {
+                    if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
                         WxPayConfig payConfig = new WxPayConfig();
-                        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                        FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
                         payConfig.setAppId(appId);
                         payConfig.setMchId(fsPayConfig.getWxMchId());
                         payConfig.setMchKey(fsPayConfig.getWxMchKey());
@@ -439,7 +464,7 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
                             e.printStackTrace();
                             throw new CustomException("支付失败" + e.getMessage());
                         }
-                    } else if (payConfigDTO.getType().equals("yb")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("yb")) {
                         WxJspayDTO p = new WxJspayDTO();
                         // 使用setter方法为对象赋值
                         p.setPayMoney(storePayment.getPayMoney().toString());
@@ -460,7 +485,7 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
                         } else {
                             throw new CustomException("支付失败");
                         }
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("product" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -485,7 +510,7 @@ public class FsCourseProductOrderServiceImpl extends ServiceImpl<FsCourseProduct
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    }else if (payConfigDTO.getType().equals("hf")) {
+                    }else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         logger.info("创建汇付订单");
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("T_MINIAPP");

+ 41 - 17
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseOrderServiceImpl.java

@@ -80,6 +80,10 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
     @Autowired
     private FsUserCourseOrderMapper fsUserCourseOrderMapper;
     @Autowired
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
+    @Autowired
     private FsUserMapper fsUserMapper;
     @Autowired
     private FsUserCourseMapper fsUserCourseMapper;
@@ -374,8 +378,20 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
         }
         FsUser user=fsUserMapper.selectFsUserByUserId(param.getUserId());
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+//        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
 
 //        String openId = Objects.isNull(user) ? "" : user.getMaOpenId();
 //        if (StringUtils.isBlank(openId)){
@@ -400,7 +416,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -424,7 +440,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                 }
                 FsStorePayment storePayment = new FsStorePayment();
                 storePayment.setStatus(0);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setBusinessCode(order.getOrderCode());
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(order.getPayMoney());
@@ -436,11 +452,9 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
-                    if (payConfigDTO.getType().equals("wx")) {
+                    if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
                         WxPayConfig payConfig = new WxPayConfig();
-                        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                        FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
                         payConfig.setAppId(fsPayConfig.getAppId());
                         payConfig.setMchId(fsPayConfig.getWxMchId());
                         payConfig.setMchKey(fsPayConfig.getWxMchKey());
@@ -465,7 +479,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                             e.printStackTrace();
                             throw new CustomException("支付失败" + e.getMessage());
                         }
-                    } else if (payConfigDTO.getType().equals("yb")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("yb")) {
                         WxJspayDTO p = new WxJspayDTO();
                         // 使用setter方法为对象赋值
                         p.setPayMoney(storePayment.getPayMoney().toString());
@@ -485,7 +499,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                         } else {
                             throw new CustomException("支付失败");
                         }
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("course" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -505,7 +519,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    } else if (payConfigDTO.getType().equals("hf")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("T_MINIAPP");
                         o.setOpenid(openId);
@@ -550,8 +564,18 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
 //        }
         FsUser user=fsUserMapper.selectFsUserByUserId(param.getUserId());
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
         String openId = null;
         String appId = param.getAppId();
         if (StringUtils.isNotBlank(appId)) {
@@ -564,7 +588,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -587,7 +611,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
 //                PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
                 FsStorePayment storePayment=new FsStorePayment();
                 storePayment.setStatus(0);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setBusinessCode(order.getOrderCode());
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(order.getPayMoney());
@@ -600,9 +624,9 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                 storePayment.setBusinessId(order.getOrderId().toString());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
-                    if (payConfigDTO.getType().equals("yb")) {
+                    if (merchantAppConfig.getMerchantType().equals("yb")) {
                         return R.error("支付暂不可用!");
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("course" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -623,7 +647,7 @@ public class FsUserCourseOrderServiceImpl implements IFsUserCourseOrderService
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    }else if (payConfigDTO.getType().equals("hf")) {
+                    }else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("A_NATIVE");
 //                        o.setOpenid(user.getMaOpenId());

+ 45 - 25
fs-service/src/main/java/com/fs/course/service/impl/FsUserVipOrderServiceImpl.java

@@ -10,6 +10,7 @@ import java.util.Objects;
 
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fs.common.core.domain.R;
@@ -20,8 +21,10 @@ 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;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
 import com.fs.course.domain.FsUserCourseOrder;
 import com.fs.course.domain.FsUserVipPackage;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.course.mapper.FsUserVipPackageMapper;
 import com.fs.course.param.FsUserVipOrderCreateUParam;
 import com.fs.course.param.FsUserVipOrderParam;
@@ -29,11 +32,9 @@ import com.fs.course.param.FsUserVipOrderPayUParam;
 import com.fs.course.vo.FsUserVipOrderListPVO;
 import com.fs.his.domain.*;
 import com.fs.his.dto.PayConfigDTO;
-import com.fs.his.mapper.FsStorePaymentErrorMapper;
-import com.fs.his.mapper.FsStorePaymentMapper;
-import com.fs.his.mapper.FsUserMapper;
-import com.fs.his.mapper.FsUserWxMapper;
+import com.fs.his.mapper.*;
 import com.fs.his.service.IFsStorePaymentService;
+import com.fs.hisStore.domain.FsPayConfigScrm;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.service.HuiFuService;
@@ -81,12 +82,10 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
     private FsUserVipPackageMapper fsUserVipPackageMapper;
     @Autowired
     private FsUserMapper userMapper;
-
     @Autowired
-    private ISysConfigService configService;
-
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
     @Autowired
-    private SysConfigMapper sysConfigMapper;
+    private MerchantAppConfigMapper merchantAppConfigMapper;
 
     @Autowired
     private IFsStorePaymentService storePaymentService;
@@ -233,8 +232,20 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
         }
         FsUser user = userMapper.selectFsUserByUserId(param.getUserId());
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+//        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
 
 //        String openId = Objects.isNull(user) ? "" : user.getMaOpenId();
 //        if (StringUtils.isBlank(openId)){
@@ -258,7 +269,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -282,7 +293,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                 }
                 FsStorePayment storePayment = new FsStorePayment();
                 storePayment.setStatus(0);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setBusinessCode(order.getOrderCode());
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(order.getPayMoney());
@@ -294,11 +305,9 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                 storePayment.setUserId(user.getUserId());
                 storePayment.setBusinessId(order.getOrderId().toString());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
-                    if (payConfigDTO.getType().equals("wx")) {
+                    if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
                         WxPayConfig payConfig = new WxPayConfig();
-                        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                        FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
                         payConfig.setAppId(fsPayConfig.getAppId());
                         payConfig.setMchId(fsPayConfig.getWxMchId());
                         payConfig.setMchKey(fsPayConfig.getWxMchKey());
@@ -323,7 +332,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                             e.printStackTrace();
                             throw new CustomException("支付失败" + e.getMessage());
                         }
-                    } else if (payConfigDTO.getType().equals("yb")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("yb")) {
                         WxJspayDTO p = new WxJspayDTO();
                         // 使用setter方法为对象赋值
                         p.setPayMoney(storePayment.getPayMoney().toString());
@@ -343,7 +352,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                         } else {
                             throw new CustomException("支付失败");
                         }
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("appvip" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -363,7 +372,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    } else if (payConfigDTO.getType().equals("hf")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("T_MINIAPP");
                         o.setOpenid(openId);
@@ -399,8 +408,19 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
         }
         FsUser user = userMapper.selectFsUserByUserId(param.getUserId());
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+//        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
 
         String openId = null;
         String appId = param.getAppId();
@@ -414,7 +434,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -437,7 +457,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
 //                PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
                 FsStorePayment storePayment=new FsStorePayment();
                 storePayment.setStatus(0);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setBusinessCode(order.getOrderCode());
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(order.getPayMoney());
@@ -450,9 +470,9 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                 storePayment.setBusinessId(order.getOrderId().toString());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
-                    if (payConfigDTO.getType().equals("yb")) {
+                    if (merchantAppConfig.getMerchantType().equals("yb")) {
                         return R.error("支付暂不可用!");
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("appvip" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -473,7 +493,7 @@ public class FsUserVipOrderServiceImpl implements IFsUserVipOrderService
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    }else if (payConfigDTO.getType().equals("hf")) {
+                    }else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("A_NATIVE");
 //                        o.setOpenid(user.getMaOpenId());

+ 5 - 0
fs-service/src/main/java/com/fs/his/param/PayOrderParam.java

@@ -36,6 +36,11 @@ public class PayOrderParam {
      * 用户ID
      */
     private Long userId;
+
+    /**
+     * appId
+     */
+    private String appId;
     /**
      * 支付方式
      */

+ 81 - 32
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -33,6 +33,8 @@ import com.fs.config.cloud.CloudHostProper;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.dto.PackageConfigDTO;
@@ -47,6 +49,7 @@ import com.fs.his.utils.ConfigUtil;
 import com.fs.his.utils.HttpUtil;
 import com.fs.his.utils.PhoneUtil;
 import com.fs.his.vo.*;
+import com.fs.hisStore.domain.FsPayConfigScrm;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
@@ -98,6 +101,11 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
     private WxPayService wxPayService;
     @Autowired
     private WxPayProperties wxPayProperties;
+
+    @Autowired
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
     @Autowired
     IPayService payService;
     @Autowired
@@ -866,7 +874,6 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
             List<FsStorePayment> payments = fsStorePaymentMapper.selectFsStorePaymentByPay(3,orderId);
             if(payments!=null&&payments.size()==1){
                 FsStorePayment payment=payments.get(0);
-                String json=configService.selectConfigByKey("his.pay");
                 if(payment.getPayMode().equals("wx")){
                     WxPayConfig payConfig = new WxPayConfig();
                     payConfig.setAppId(wxPayProperties.getAppId());
@@ -979,8 +986,20 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
 
         FsUser user=userService.selectFsUserByUserId(param.getUserId());
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+//        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
 
         //金牛多小程序支付
         String openId = null;
@@ -995,7 +1014,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = fsPayConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -1016,7 +1035,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 }
                 FsStorePayment storePayment=new FsStorePayment();
                 storePayment.setStatus(0);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setBusinessCode(fsPackageOrder.getOrderSn());
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(fsPackageOrder.getPayMoney());
@@ -1031,11 +1050,9 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
-                    if (payConfigDTO.getType().equals("wx")) {
+                    if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
                         WxPayConfig payConfig = new WxPayConfig();
-                        SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                        FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
                         payConfig.setAppId(appId);
                         payConfig.setMchId(fsPayConfig.getWxMchId());
                         payConfig.setMchKey(fsPayConfig.getWxMchKey());
@@ -1060,7 +1077,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                             e.printStackTrace();
                             throw new CustomException("支付失败" + e.getMessage());
                         }
-                    } else if (payConfigDTO.getType().equals("yb")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("yb")) {
                         WxJspayDTO p = new WxJspayDTO();
                         // 使用setter方法为对象赋值
                         p.setPayMoney(storePayment.getPayMoney().toString());
@@ -1081,7 +1098,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         } else {
                             throw new CustomException("支付失败");
                         }
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("package" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -1106,7 +1123,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    }else if (payConfigDTO.getType().equals("hf")) {
+                    }else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         logger.info("创建汇付订单");
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("T_MINIAPP");
@@ -1211,8 +1228,18 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 if(StringUtils.isEmpty(payCode)){
                     return R.error("订单生成失败,请重试");
                 }
-                String json = configService.selectConfigByKey("his.pay");
-                PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+                if (StringUtils.isBlank(param.getAppId())) {
+                    throw new IllegalArgumentException("appId不能为空");
+                }
+                FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+                if (fsCoursePlaySourceConfig == null) {
+                    throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+                }
+                Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                if (merchantConfigId == null || merchantConfigId <= 0) {
+                    throw new CustomException("小程序没有配置商户信息");
+                }
+                MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
                 String openId = null;
                 String appId = param.getAppId();
                 if (StringUtils.isNotBlank(appId)) {
@@ -1225,7 +1252,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         openId = fsUserWx.getOpenId();
                     }
                 } else {
-                    appId = payConfigDTO.getAppId();
+                    appId = merchantAppConfig.getAppId();
                     openId = Objects.isNull(user) ? "" : user.getMaOpenId();
                     if (StringUtils.isBlank(openId)){
                         Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -1240,7 +1267,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
 
                 FsStorePayment storePayment=new FsStorePayment();
                 storePayment.setStatus(0);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setBusinessCode(fsPackageOrder.getOrderSn());
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(fsPackageOrder.getPayMoney());
@@ -1256,9 +1283,9 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
-                    if (payConfigDTO.getType().equals("yb")) {
+                    if (merchantAppConfig.getMerchantType().equals("yb")) {
                         return R.error("支付暂不可用!");
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("package" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -1279,7 +1306,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    }else if (payConfigDTO.getType().equals("hf")) {
+                    }else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         logger.info("创建汇付订单");
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("A_NATIVE");
@@ -1320,8 +1347,19 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
         //如果存在优惠券  判断优惠券是否已使用
         FsUser user=userService.selectFsUserByUserId(param.getUserId());
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+//        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
 
         String openId = null;
         String appId = param.getAppId();
@@ -1335,7 +1373,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -1358,7 +1396,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 }
                 FsStorePayment storePayment=new FsStorePayment();
                 storePayment.setStatus(0);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setBusinessCode(fsPackageOrder.getOrderSn());
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(fsPackageOrder.getPayMoney());
@@ -1373,9 +1411,9 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setStoreId(fsPackageOrder.getStoreId());
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
-                    if (payConfigDTO.getType().equals("yb")) {
+                    if (merchantAppConfig.getMerchantType().equals("yb")) {
                         return R.error("支付暂不可用!");
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("package" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -1396,7 +1434,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    }else if (payConfigDTO.getType().equals("hf")) {
+                    }else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         logger.info("创建汇付订单");
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("T_JSAPI");
@@ -1439,8 +1477,19 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
         //如果存在优惠券  判断优惠券是否已使用
         FsUser user=userService.selectFsUserByUserId(param.getUserId());
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+//        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
 
         //金牛多小程序支付
         String openId = null;
@@ -1455,7 +1504,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -1478,7 +1527,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
 //                PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
                 FsStorePayment storePayment=new FsStorePayment();
                 storePayment.setStatus(0);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setBusinessCode(fsPackageOrder.getOrderSn());
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(fsPackageOrder.getPayMoney());
@@ -1494,9 +1543,9 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                 storePayment.setBusinessId(fsPackageOrder.getOrderId().toString());
                 if(storePaymentService.insertFsStorePayment(storePayment)>0){
 
-                    if (payConfigDTO.getType().equals("yb")) {
+                    if (merchantAppConfig.getMerchantType().equals("yb")) {
                         return R.error("支付暂不可用!");
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("package" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -1517,7 +1566,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    }else if (payConfigDTO.getType().equals("hf")) {
+                    }else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         logger.info("创建汇付订单");
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("A_NATIVE");

+ 20 - 3
fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java

@@ -31,6 +31,8 @@ import com.fs.company.service.impl.CompanyServiceImpl;
 import com.fs.company.vo.FsStoreOrderStatisticsVO;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.config.StoreConfig;
 import com.fs.erp.dto.BaseResponse;
@@ -48,6 +50,7 @@ import com.fs.his.param.*;
 import com.fs.his.service.*;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.*;
+import com.fs.hisStore.domain.FsPayConfigScrm;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
@@ -96,6 +99,10 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     @Autowired
     private FsStoreAfterSalesLogsMapper fsStoreAfterSalesLogsMapper;
     @Autowired
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
+    @Autowired
     private FsStoreOrderMapper fsStoreOrderMapper;
     @Autowired
     private FsStoreOrderLogsMapper fsStoreOrderLogsMapper;
@@ -475,11 +482,21 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
             if (reMoney.compareTo(payment.getPayMoney()) > 0) {
                 throw new CustomException("退款金额不能大于实际支付金额"); //退款金额不能大于实际支付金额
             }
-            String json = configService.selectConfigByKey("his.pay");
+            if (StringUtils.isBlank(payment.getAppId())) {
+                throw new IllegalArgumentException("appId不能为空");
+            }
+            FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
+            if (fsCoursePlaySourceConfig == null) {
+                throw new CustomException("未找到appId对应的小程序配置: " + payment.getAppId());
+            }
+            Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+            if (merchantConfigId == null || merchantConfigId <= 0) {
+                throw new CustomException("小程序没有配置商户信息");
+            }
+            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
             if (payment.getPayMode().equals("wx")) {
                 WxPayConfig payConfig = new WxPayConfig();
-                SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
                 payConfig.setAppId(fsPayConfig.getAppId());
                 payConfig.setMchId(fsPayConfig.getWxMchId());
                 payConfig.setMchKey(fsPayConfig.getWxMchKey());

+ 41 - 16
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -28,6 +28,8 @@ import com.fs.config.ai.AiHostProper;
 import com.fs.config.cloud.CloudHostProper;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.erp.domain.*;
 import com.fs.erp.dto.*;
 import com.fs.erp.dto.df.*;
@@ -45,6 +47,7 @@ import com.fs.his.service.*;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.utils.PhoneUtil;
 import com.fs.his.vo.*;
+import com.fs.hisStore.domain.FsPayConfigScrm;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
@@ -153,7 +156,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
     private FsStoreOrderMapper fsStoreOrderMapper;
 
     @Autowired
-    private FsStoreOrderScrmMapper fsStoreOrderScrmMapper;
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
 
     @Autowired
     private FsStoreOrderItemMapper fsStoreOrderItemMapper;
@@ -2960,8 +2965,18 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
 //        }
         FsUser user = userService.selectFsUserByUserId(param.getUserId());
         //在线支付
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
         String openId = null;
         String appId = param.getAppId();
         if (StringUtils.isNotBlank(appId)) {
@@ -2974,7 +2989,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -3000,7 +3015,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 FsStorePayment storePayment = new FsStorePayment();
                 storePayment.setStatus(0);
                 storePayment.setPayCode(payCode);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setPayMoney(order.getPayMoney());
                 storePayment.setBusinessCode(order.getOrderCode());
                 storePayment.setCreateTime(new Date());
@@ -3015,7 +3030,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 storePayment.setBusinessId(order.getOrderId().toString());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
 
-                    if (payConfigDTO.getType().equals("wx")) {
+                    if (merchantAppConfig.getMerchantType().equals("wx")) {
                         //创建微信订单
                         WxPayConfig payConfig = new WxPayConfig();
                         SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
@@ -3044,7 +3059,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                             e.printStackTrace();
                             throw new CustomException("支付失败" + e.getMessage());
                         }
-                    } else if (payConfigDTO.getType().equals("yb")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("yb")) {
                         WxJspayDTO p = new WxJspayDTO();
                         // 使用setter方法为对象赋值
                         p.setPayMoney(storePayment.getPayMoney().toString());
@@ -3064,7 +3079,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                         } else {
                             throw new CustomException("支付失败");
                         }
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("store" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -3089,7 +3104,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    } else if (payConfigDTO.getType().equals("hf")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("T_MINIAPP");
                         o.setOpenid(openId);
@@ -3126,8 +3141,18 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
 
         FsUser user = userService.selectFsUserByUserId(param.getUserId());
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
 
         String openId = null;
         String appId = param.getAppId();
@@ -3141,7 +3166,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -3171,7 +3196,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 FsStorePayment storePayment = new FsStorePayment();
                 storePayment.setStatus(0);
                 storePayment.setPayCode(payCode);
-                storePayment.setPayMode(payConfigDTO.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setPayMoney(order.getPayMoney());
                 storePayment.setBusinessCode(order.getOrderCode());
                 storePayment.setCreateTime(new Date());
@@ -3185,9 +3210,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                 storePayment.setStoreId(order.getStoreId());
                 storePayment.setBusinessId(order.getOrderId().toString());
                 if (storePaymentService.insertFsStorePayment(storePayment) > 0) {
-                    if (payConfigDTO.getType().equals("yb")) {
+                    if (merchantAppConfig.getMerchantType().equals("yb")) {
                         return R.error("支付暂不可用!");
-                    } else if (payConfigDTO.getType().equals("tz")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                         PayCreateOrder o = new PayCreateOrder();
                         o.setOrderNo("store" + storePayment.getPayCode()); // 业务系统订单号
                         o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -3207,7 +3232,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
                         mt.setTradeNo(result.getBody().getOrderFlowNo());
                         fsStorePaymentMapper.updateFsStorePayment(mt);
                         return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
-                    } else if (payConfigDTO.getType().equals("hf")) {
+                    } else if (merchantAppConfig.getMerchantType().equals("hf")) {
                         HuiFuCreateOrder o = new HuiFuCreateOrder();
                         o.setTradeType("A_NATIVE");
                         o.setOpenid(openId);

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

@@ -41,6 +41,8 @@ import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
 import com.fs.course.config.RedPacketConfig;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.course.service.IFsCourseRedPacketLogService;
 import com.fs.course.service.IFsUserCourseOrderService;
 import com.fs.course.service.IFsUserVipOrderService;
@@ -61,6 +63,7 @@ import com.fs.his.service.IFsStorePaymentService;
 import com.fs.his.utils.PhoneUtil;
 import com.fs.his.vo.FsStorePaymentExcelVO;
 import com.fs.his.vo.FsStorePaymentVO;
+import com.fs.hisStore.domain.FsPayConfigScrm;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.hisStore.param.FsStorePaymentGetWxaCodeParam;
@@ -136,6 +139,11 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
     private FsStorePaymentMapper fsStorePaymentMapper;
     @Autowired
     private FsStorePaymentScrmMapper fsStorePaymentScrmMapper;
+
+    @Autowired
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
     @Autowired
     private TzBankService tzBankService;
     @Autowired
@@ -1195,9 +1203,21 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
             throw new CustomException("用户不存在");
         }
 
-        String json = configService.selectConfigByKey("his.pay");
-        logger.debug("支付配置 his.pay: {}", json);
-        FsPayConfig payConfig = JSONUtil.toBean(json, FsPayConfig.class);
+        if (StringUtils.isBlank(payOrderParam.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payOrderParam.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + payOrderParam.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());        FsPayConfig payConfig =JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+        payConfig.setType(merchantAppConfig.getMerchantType());
+        logger.debug("支付配置 his.pay: {}", payConfig);
+//        FsPayConfig payConfig = JSONUtil.toBean(json, FsPayConfig.class);
 
         if (isWechatPayment(payOrderParam.getPaymentMethod())) {
             String openId = getOpenIdForPaymentMethod(user, payOrderParam.getPaymentMethod(), payConfig);
@@ -1625,8 +1645,18 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
             return R.error("用户不存在!");
         }
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
         String openId = null;
         String appId = param.getAppId();
         if (StringUtils.isNotBlank(appId)) {
@@ -1639,7 +1669,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()

+ 19 - 6
fs-service/src/main/java/com/fs/his/service/impl/FsUserInformationCollectionServiceImpl.java

@@ -22,6 +22,8 @@ import com.fs.company.service.ICompanyUserService;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.dto.FsUserInformationCollectionDTO;
@@ -32,6 +34,7 @@ import com.fs.his.param.*;
 import com.fs.his.service.*;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.*;
+import com.fs.hisStore.domain.FsPayConfigScrm;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentDelaytransConfirmrefundRequest;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
@@ -80,11 +83,11 @@ import java.util.stream.Collectors;
 public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserInformationCollectionMapper, FsUserInformationCollection> implements IFsUserInformationCollectionService {
     Logger logger= LoggerFactory.getLogger(getClass());
 
-    @Autowired
-    private ISysConfigService configService;
 
     @Autowired
-    SysConfigMapper sysConfigMapper;
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
 
     @Autowired
     private WxPayProperties wxPayProperties;
@@ -827,11 +830,21 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
 
         if (payments != null && !payments.isEmpty()) {
             FsStorePayment payment = payments.get(0);
-            String json = configService.selectConfigByKey("his.pay");
             if (payment.getPayMode().equals("wx")) {
                 WxPayConfig payConfig = new WxPayConfig();
-                SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
+                if (StringUtils.isBlank(payment.getAppId())) {
+                    throw new IllegalArgumentException("appId不能为空");
+                }
+                FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
+                if (fsCoursePlaySourceConfig == null) {
+                    throw new CustomException("未找到appId对应的小程序配置: " + payment.getAppId());
+                }
+                Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                if (merchantConfigId == null || merchantConfigId <= 0) {
+                    throw new CustomException("小程序没有配置商户信息");
+                }
+                MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+                FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
                 payConfig.setAppId(fsPayConfig.getAppId());
                 payConfig.setMchId(fsPayConfig.getWxMchId());
                 payConfig.setMchKey(fsPayConfig.getWxMchKey());

+ 2 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsPayConfigScrm.java

@@ -35,4 +35,6 @@ public class FsPayConfigScrm {
     private String notifyUrlScrm;
     private String publicKeyPath;
     private String publicKeyId;
+
+
 }

+ 36 - 4
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java

@@ -20,6 +20,8 @@ import com.fs.company.service.ICompanyService;
 import com.fs.config.cloud.CloudHostProper;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.erp.constant.AfterSalesOrderStatusEnum;
 import com.fs.erp.domain.FsJstAftersalePush;
 import com.fs.erp.dto.BaseResponse;
@@ -105,6 +107,12 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
     private ICompanyService companyService;
     @Autowired
     private FsStoreAfterSalesScrmMapper fsStoreAfterSalesMapper;
+
+
+    @Autowired
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
     @Autowired
     private IFsStoreAfterSalesItemScrmService afterSalesItemService;
     @Autowired
@@ -783,9 +791,22 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
         if(order.getPayMoney().compareTo(BigDecimal.ZERO)==1){
             List<FsStorePaymentScrm> payments=paymentService.selectFsStorePaymentByOrderId(order.getId());
             if(payments!=null){
-                String json = configService.selectConfigByKey("his.pay");
-                FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+
                 for(FsStorePaymentScrm payment:payments){
+                    if (StringUtils.isBlank(payment.getAppId())) {
+                        throw new IllegalArgumentException("appId不能为空");
+                    }
+                    FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
+                    if (fsCoursePlaySourceConfig == null) {
+                        throw new CustomException("未找到appId对应的小程序配置: " + payment.getAppId());
+                    }
+                    Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                    if (merchantConfigId == null || merchantConfigId <= 0) {
+                        throw new CustomException("小程序没有配置商户信息");
+                    }
+                    MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+                    FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+
                     if (payment.getPayMode()==null||payment.getPayMode().equals("wx")){
                         WxPayConfig payConfig = new WxPayConfig();
                         payConfig.setAppId(fsPayConfig.getAppId());
@@ -1466,8 +1487,19 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
         if (payments != null && payments.size() > 0) {
             FsStorePaymentScrm payment = payments.get(0);
 //            String json = configService.selectConfigByKey("store.pay");
-            String json = configService.selectConfigByKey("his.pay");
-            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            if (StringUtils.isBlank(payment.getAppId())) {
+                throw new IllegalArgumentException("appId不能为空");
+            }
+            FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
+            if (fsCoursePlaySourceConfig == null) {
+                throw new CustomException("未找到appId对应的小程序配置: " + payment.getAppId());
+            }
+            Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+            if (merchantConfigId == null || merchantConfigId <= 0) {
+                throw new CustomException("小程序没有配置商户信息");
+            }
+            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
             if (payment.getPayMode().equals("wx")) {
                 WxPayConfig payConfig = new WxPayConfig();
                 //SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");

+ 72 - 12
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -48,8 +48,10 @@ import com.fs.config.cloud.CloudHostProper;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
 import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.course.dto.OrderOpenIdTransDTO;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.erp.domain.*;
 import com.fs.erp.dto.*;
 import com.fs.erp.dto.df.*;
@@ -179,7 +181,6 @@ import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
 @EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
 @Slf4j
 public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
-    private static final String STORE_PAY_CONF = "his.pay";
 
     Logger logger = LoggerFactory.getLogger(getClass());
     @Autowired
@@ -188,6 +189,10 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     @Autowired
     private CompanyUserUserMapper companyUserUserMapper;
     @Autowired
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
+    @Autowired
     private IFsStoreOrderStatusScrmService orderStatusService;
     @Autowired
     private FsStoreCartScrmMapper cartMapper;
@@ -2444,10 +2449,21 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             //将钱退还给用户
             List<FsStorePaymentScrm> payments = paymentService.selectFsStorePaymentByOrderId(order.getId());
             if (payments != null) {
-                String json = configService.selectConfigByKey("his.pay");
-
-                FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
                 for (FsStorePaymentScrm payment : payments) {
+                    if (StringUtils.isBlank(payment.getAppId())) {
+                        throw new IllegalArgumentException("appId不能为空");
+                    }
+                    FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
+                    if (fsCoursePlaySourceConfig == null) {
+                        throw new CustomException("未找到appId对应的小程序配置: " + payment.getAppId());
+                    }
+                    Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                    if (merchantConfigId == null || merchantConfigId <= 0) {
+                        throw new CustomException("小程序没有配置商户信息");
+                    }
+                    MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+                    FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+
                     if (payment.getPayMode() == null || payment.getPayMode().equals("wx")) {
                         WxPayConfig payConfig = new WxPayConfig();
                         payConfig.setAppId(fsPayConfig.getAppId());
@@ -4189,8 +4205,19 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             }
             String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
             if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
-                String json = configService.selectConfigByKey(STORE_PAY_CONF);
-                FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+                if (StringUtils.isBlank(param.getAppId())) {
+                    throw new IllegalArgumentException("appId不能为空");
+                }
+                FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+                if (fsCoursePlaySourceConfig == null) {
+                    throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+                }
+                Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                if (merchantConfigId == null || merchantConfigId <= 0) {
+                    throw new CustomException("小程序没有配置商户信息");
+                }
+                MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+                FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
                 FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
                 storePayment.setCompanyId(order.getCompanyId());
                 storePayment.setCompanyUserId(order.getCompanyUserId());
@@ -4327,8 +4354,19 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 return R.error("此订单已支付");
             }
             String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
-            String json = configService.selectConfigByKey(STORE_PAY_CONF);
-            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            if (StringUtils.isBlank(param.getAppId())) {
+                throw new IllegalArgumentException("appId不能为空");
+            }
+            FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+            if (fsCoursePlaySourceConfig == null) {
+                throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+            }
+            Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+            if (merchantConfigId == null || merchantConfigId <= 0) {
+                throw new CustomException("小程序没有配置商户信息");
+            }
+            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
             FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
             storePayment.setCompanyId(order.getCompanyId());
             storePayment.setCompanyUserId(order.getCompanyUserId());
@@ -4443,8 +4481,19 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 return R.error("正在支付中...");
             }
 
-            String json = configService.selectConfigByKey(STORE_PAY_CONF);
-            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            if (StringUtils.isBlank(param.getAppId())) {
+                throw new IllegalArgumentException("appId不能为空");
+            }
+            FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+            if (fsCoursePlaySourceConfig == null) {
+                throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+            }
+            Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+            if (merchantConfigId == null || merchantConfigId <= 0) {
+                throw new CustomException("小程序没有配置商户信息");
+            }
+            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
             String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
             //易宝支付
             FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
@@ -4545,8 +4594,19 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         FsUserScrm user=userService.selectFsUserById(order.getUserId());
         if(user!=null){
             String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
-            String json = configService.selectConfigByKey(STORE_PAY_CONF);
-            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            if (StringUtils.isBlank(param.getAppId())) {
+                throw new IllegalArgumentException("appId不能为空");
+            }
+            FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+            if (fsCoursePlaySourceConfig == null) {
+                throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+            }
+            Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+            if (merchantConfigId == null || merchantConfigId <= 0) {
+                throw new CustomException("小程序没有配置商户信息");
+            }
+            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
             FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
             storePayment.setCompanyId(order.getCompanyId());
             storePayment.setCompanyUserId(order.getCompanyUserId());

+ 48 - 22
fs-user-app/src/main/java/com/fs/app/controller/InquiryOrderController.java

@@ -2,6 +2,7 @@ package com.fs.app.controller;
 
 
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fs.app.annotation.Login;
@@ -15,6 +16,8 @@ import com.fs.common.utils.ip.IpUtils;
 import com.fs.company.service.ICompanyService;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.service.IFsCoursePlaySourceConfigService;
 import com.fs.his.domain.*;
 import com.fs.his.dto.FsInquiryOrderPatientDTO;
 import com.fs.his.dto.PayConfigDTO;
@@ -26,6 +29,7 @@ import com.fs.his.utils.PhoneUtil;
 import com.fs.his.vo.FsInquiryOrderListUVO;
 import com.fs.his.vo.FsInquiryOrderPingListUVO;
 import com.fs.his.vo.FsInquiryOrderReportUVO;
+import com.fs.hisStore.domain.FsPayConfigScrm;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.service.HuiFuService;
@@ -93,8 +97,11 @@ public class InquiryOrderController extends  AppBaseController {
     private IFsInquiryTempService inquiryTempService;
     @Autowired
     private IFsInquiryOrderReportService orderReportService;
+
+    @Autowired
+    private IFsCoursePlaySourceConfigService fsCoursePlaySourceConfigService;
     @Autowired
-    private IFsInquiryOrderLogsService fsInquiryOrderLogsService;
+    private IMerchantAppConfigService merchantAppConfigService;
     @Autowired
     private IFsStorePaymentService storePaymentService;
     @Autowired
@@ -173,9 +180,6 @@ public class InquiryOrderController extends  AppBaseController {
     )
     {
         logger.info("支付"+param.getOrderId()+":"+param.getAppId());
-        String json=configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO= JSONUtil.toBean(json, PayConfigDTO.class);
-
         FsInquiryOrder order=inquiryOrderService.selectFsInquiryOrderByOrderId(param.getOrderId());
         if(order==null){
             return R.error("订单不存在");
@@ -256,8 +260,20 @@ public class InquiryOrderController extends  AppBaseController {
         param.setUserId(userId);
         FsUser user = userService.selectFsUserByUserId(userId);
         //在线支付
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigService.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigService.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+//        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
 //        String openId = "";
 //        if (StringUtils.isNotEmpty(param.getAppId())) {
 //            FsUserWx fsUserWx = userWxService.selectByAppIdAndUserId(param.getAppId(), param.getUserId(), 1);
@@ -289,7 +305,7 @@ public class InquiryOrderController extends  AppBaseController {
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = merchantAppConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -334,7 +350,7 @@ public class InquiryOrderController extends  AppBaseController {
             }
             FsStorePayment storePayment=new FsStorePayment();
             storePayment.setStatus(0);
-            storePayment.setPayMode(payConfigDTO.getType());
+            storePayment.setPayMode(merchantAppConfig.getMerchantId());
             storePayment.setPayCode(payCode);
             storePayment.setCompanyId(order.getCompanyId());
             storePayment.setCompanyUserId(order.getCompanyUserId());
@@ -348,11 +364,9 @@ public class InquiryOrderController extends  AppBaseController {
             storePayment.setUserId(user.getUserId());
             storePayment.setBusinessId(order.getOrderId().toString());
             if(storePaymentService.insertFsStorePayment(storePayment)>0){
-                if(payConfigDTO.getType().equals("wx")){
+                if(merchantAppConfig.getMerchantId().equals("wx")){
                     //创建微信订单
                     WxPayConfig payConfig = new WxPayConfig();
-                    SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
-                    FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
                     payConfig.setAppId(appId);
                     payConfig.setMchId(fsPayConfig.getWxMchId());
                     payConfig.setMchKey(fsPayConfig.getWxMchKey());
@@ -378,7 +392,7 @@ public class InquiryOrderController extends  AppBaseController {
                         throw new CustomException("支付失败"+e.getMessage());
                     }
                 }
-                else if(payConfigDTO.getType().equals("yb")){
+                else if(merchantAppConfig.getMerchantId().equals("yb")){
                     WxJspayDTO p = new WxJspayDTO();
                     // 使用setter方法为对象赋值
                     p.setPayMoney(storePayment.getPayMoney().toString());
@@ -400,7 +414,7 @@ public class InquiryOrderController extends  AppBaseController {
                         throw new CustomException("支付失败");
                     }
                 }
-                else if(payConfigDTO.getType().equals("tz")){
+                else if(merchantAppConfig.getMerchantId().equals("tz")){
                     PayCreateOrder o = new PayCreateOrder();
                     o.setOrderNo("inquiry"+storePayment.getPayCode()); // 业务系统订单号
                     o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -425,7 +439,7 @@ 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(payConfigDTO.getType().equals("hf")){
+                }else if(merchantAppConfig.getMerchantId().equals("hf")){
                     HuiFuCreateOrder o = new HuiFuCreateOrder();
                     o.setTradeType("T_MINIAPP");
                     o.setOpenid(openId);
@@ -460,8 +474,20 @@ public class InquiryOrderController extends  AppBaseController {
         FsInquiryOrder order=inquiryOrderService.selectFsInquiryOrderByOrderId(param.getOrderId());
         FsUser user=userService.selectFsUserByUserId(Long.parseLong(getUserId()));
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
+        if (StringUtils.isBlank(param.getAppId())) {
+            throw new IllegalArgumentException("appId不能为空");
+        }
+        FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigService.selectCoursePlaySourceConfigByAppId(param.getAppId());
+        if (fsCoursePlaySourceConfig == null) {
+            throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+        }
+        Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+        if (merchantConfigId == null || merchantConfigId <= 0) {
+            throw new CustomException("小程序没有配置商户信息");
+        }
+        MerchantAppConfig merchantAppConfig = merchantAppConfigService.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();
@@ -475,7 +501,7 @@ public class InquiryOrderController extends  AppBaseController {
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = payConfigDTO.getAppId();
+            appId = fsPayConfig.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
@@ -501,7 +527,7 @@ public class InquiryOrderController extends  AppBaseController {
 //            PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
             FsStorePayment storePayment=new FsStorePayment();
             storePayment.setStatus(0);
-            storePayment.setPayMode(payConfigDTO.getType());
+            storePayment.setPayMode(merchantAppConfig.getMerchantType());
             storePayment.setPayCode(payCode);
             storePayment.setCompanyId(order.getCompanyId());
             storePayment.setCompanyUserId(order.getCompanyUserId());
@@ -515,9 +541,9 @@ public class InquiryOrderController extends  AppBaseController {
             storePayment.setUserId(user.getUserId());
             storePayment.setBusinessId(order.getOrderId().toString());
             if(storePaymentService.insertFsStorePayment(storePayment)>0){
-                if (payConfigDTO.getType().equals("yb")) {
+                if (merchantAppConfig.getMerchantType().equals("yb")) {
                     return R.error("支付暂不可用!");
-                } else if (payConfigDTO.getType().equals("tz")) {
+                } else if (merchantAppConfig.getMerchantType().equals("tz")) {
                     PayCreateOrder o = new PayCreateOrder();
                     o.setOrderNo("inquiry" + storePayment.getPayCode()); // 业务系统订单号
                     o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
@@ -537,7 +563,7 @@ 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 (payConfigDTO.getType().equals("hf")) {
+                }else if (merchantAppConfig.getMerchantType().equals("hf")) {
                     HuiFuCreateOrder o = new HuiFuCreateOrder();
                     o.setTradeType("A_NATIVE");
                     o.setOpenid(openId);
@@ -548,7 +574,7 @@ public class InquiryOrderController extends  AppBaseController {
                     if (o.getAppId()!=null&& !o.getAppId().isEmpty()){
                         Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
                                 .eq(FsUserWx::getFsUserId, Long.parseLong(getUserId()))
-                                .eq(FsUserWx::getAppId, payConfigDTO.getAppId());
+                                .eq(FsUserWx::getAppId, fsPayConfig.getAppId());
                         FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
                         if (fsUserWx!=null){
                             o.setOpenid(fsUserWx.getOpenId());

+ 43 - 23
fs-user-app/src/main/java/com/fs/app/controller/live/LiveOrderController.java

@@ -4,13 +4,11 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.TypeReference;
 import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
-import com.fs.app.utils.JwtUtils;
 import com.fs.common.annotation.Log;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.domain.AjaxResult;
@@ -22,29 +20,27 @@ import com.fs.common.utils.ParseUtils;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.ip.IpUtils;
-import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.core.config.WxMaConfiguration;
-import com.fs.erp.service.IErpOrderService;
-import com.fs.his.dto.ExpressInfoDTO;
-import com.fs.his.enums.ShipperCodeEnum;
-import com.fs.his.service.IFsExpressService;
-import com.fs.his.utils.ConfigUtil;
-import com.fs.hisStore.domain.*;
-import com.fs.hisStore.dto.FsStoreOrderComputeDTO;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
+import com.fs.his.domain.FsPayConfig;
+import com.fs.his.domain.MerchantAppConfig;
+import com.fs.his.mapper.MerchantAppConfigMapper;
+import com.fs.hisStore.domain.FsUserScrm;
 import com.fs.hisStore.enums.OrderInfoEnum;
-import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.IFsUserScrmService;
-import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.domain.LiveOrderPayment;
 import com.fs.live.dto.LiveOrderComputeDTO;
-import com.fs.live.enums.LiveOrderCancleReason;
 import com.fs.live.mapper.LiveOrderPaymentMapper;
-import com.fs.live.param.*;
+import com.fs.live.param.FsMyLiveOrderQueryParam;
+import com.fs.live.param.LiveOrderComputedParam;
+import com.fs.live.param.LiveOrderConfirmParam;
+import com.fs.live.param.LiveOrderPayParam;
 import com.fs.live.service.ILiveAfterSalesService;
 import com.fs.live.service.ILiveOrderItemService;
 import com.fs.live.service.ILiveOrderService;
@@ -72,7 +68,6 @@ import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -126,7 +121,10 @@ public class LiveOrderController extends AppBaseController
     IPayService ybPayService;
     @Autowired
     private HuiFuService huiFuService;
-
+    @Autowired
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
+    @Autowired
+    private MerchantAppConfigMapper merchantAppConfigMapper;
 
     /**
      * 查询订单列表
@@ -953,8 +951,19 @@ public class LiveOrderController extends AppBaseController
                 return R.error("正在支付中...");
             }
 
-            String json = configService.selectConfigByKey("his.pay");
-            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            if (StringUtils.isBlank(param.getAppId())) {
+                throw new IllegalArgumentException("appId不能为空");
+            }
+            FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+            if (fsCoursePlaySourceConfig == null) {
+                throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+            }
+            Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+            if (merchantConfigId == null || merchantConfigId <= 0) {
+                throw new CustomException("小程序没有配置商户信息");
+            }
+            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
             String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
             //易宝支付
             LiveOrderPayment storePayment=new LiveOrderPayment();
@@ -962,7 +971,7 @@ public class LiveOrderController extends AppBaseController
             storePayment.setCompanyUserId(order.getCompanyUserId());
             storePayment.setStatus(0);
             storePayment.setPayCode(payCode);
-            storePayment.setPayMode(fsPayConfig.getType());
+            storePayment.setPayMode(merchantAppConfig.getMerchantType());
             storePayment.setPayMoney(order.getPayMoney());
             storePayment.setCreateTime(new Date());
             storePayment.setPayTypeCode("weixin");
@@ -973,7 +982,7 @@ public class LiveOrderController extends AppBaseController
             storePayment.setBusinessId(order.getOrderId().toString());
             liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
 
-            if (fsPayConfig.getType().equals("hf")){
+            if (merchantAppConfig.getMerchantType().equals("hf")){
                 HuiFuCreateOrder o = new HuiFuCreateOrder();
                 o.setTradeType("T_MINIAPP");
                 o.setOpenid(user.getMaOpenId());
@@ -996,7 +1005,7 @@ public class LiveOrderController extends AppBaseController
                 else{
                     return R.error(result.getResp_desc());
                 }
-            }else  if (fsPayConfig.getType().equals("wx")){
+            }else  if (merchantAppConfig.getMerchantType().equals("wx")){
                 //创建微信订单
                 WxPayConfig payConfig = new WxPayConfig();
                 payConfig.setAppId(fsPayConfig.getAppId());
@@ -1070,8 +1079,19 @@ public class LiveOrderController extends AppBaseController
             }
 
             String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
-            String json = configService.selectConfigByKey("his.pay");
-            FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
+            if (StringUtils.isBlank(param.getAppId())) {
+                throw new IllegalArgumentException("appId不能为空");
+            }
+            FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
+            if (fsCoursePlaySourceConfig == null) {
+                throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
+            }
+            Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+            if (merchantConfigId == null || merchantConfigId <= 0) {
+                throw new CustomException("小程序没有配置商户信息");
+            }
+            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
             LiveOrderPayment storePayment=new LiveOrderPayment();
             storePayment.setCompanyId(order.getCompanyId());
             storePayment.setCompanyUserId(order.getCompanyUserId());

+ 2 - 10
fs-user-app/src/main/java/com/fs/app/controller/store/CompanyUserScrmController.java

@@ -34,8 +34,6 @@ import com.fs.fastGpt.mapper.FastgptChatVoiceHomoMapper;
 import com.fs.fastgptApi.util.AudioUtils;
 import com.fs.fastgptApi.vo.AudioVO;
 import com.fs.framework.security.SecurityUtils;
-import com.fs.his.dto.PayConfigDTO;
-import com.fs.his.service.IFsPrescribeService;
 import com.fs.sop.domain.QwSopTempVoice;
 import com.fs.sop.service.IQwSopTempVoiceService;
 import com.fs.system.oss.CloudStorageService;
@@ -76,7 +74,6 @@ public class CompanyUserScrmController extends AppBaseController {
     private FSConfig fsConfig;
     @Autowired
     RedisCache redisCache;
-
     @Autowired
     private ICompanyUserService companyUserService;
     @Autowired
@@ -89,8 +86,6 @@ public class CompanyUserScrmController extends AppBaseController {
     @Autowired
     private CompanyUserMapper companyUserMapper;
 
-    @Autowired
-    private IFsPrescribeService fsPrescribeService;
     @Autowired
     private IQwSopTempVoiceService voiceService;
     @Autowired
@@ -262,13 +257,10 @@ public class CompanyUserScrmController extends AppBaseController {
     @GetMapping("/getCompanyWxaCodeByPayment")
     public R getCompanyWxaCodeByPayment(@RequestParam("companyId")Long companyId,
                                         @RequestParam(value = "appId", required = false) String appId,
-                                        @RequestParam(required = false) Long companyUserId,
-                                        HttpServletRequest request){
+                                        @RequestParam(required = false) Long companyUserId){
 
-        String json = configService.selectConfigByKey("his.pay");
-        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
         if (appId == null || appId.trim().isEmpty() ) {
-            appId = payConfigDTO.getAppId();
+            return R.error("请联系管理员更新版本!");
         }
         //获取用户码
         String WxaCode;