瀏覽代碼

调整二维码支付

yfh 9 小時之前
父節點
當前提交
1114c0954c

+ 2 - 2
fs-admin/src/main/java/com/fs/his/controller/FsStorePaymentController.java

@@ -131,10 +131,10 @@ public class FsStorePaymentController extends BaseController
     }
     @PreAuthorize("@ss.hasPermi('his:storePayment:refund')")
     @GetMapping(value = "refund/{paymentId}")
-    public R refund(@PathVariable("paymentId") Long paymentId)
+    public R refund(@PathVariable("paymentId") Long paymentId,String appId)
     {
         log.info("sysUserId: {} 提交退款", getUserId());
-        return fsStorePaymentService.refundFsStorePayment(paymentId);
+        return fsStorePaymentService.refundFsStorePayment(paymentId,appId);
     }
 
     /**

+ 4 - 0
fs-service/src/main/java/com/fs/his/domain/FsPayConfig.java

@@ -17,6 +17,10 @@ public class FsPayConfig {
     private String wxMchKey;
     private String keyPath;
     private String wxApiV3Key;
+
+    /**
+     * 微信回调地址
+     */
     private String notifyUrlScrm;
 
     private String ybNotifyUrl;

+ 1 - 2
fs-service/src/main/java/com/fs/his/service/IFsStorePaymentService.java

@@ -15,7 +15,6 @@ import com.fs.his.vo.FsStorePaymentExcelVO;
 import com.fs.his.vo.FsStorePaymentVO;
 import com.fs.hisStore.param.FsStorePaymentGetWxaCodeParam;
 import com.fs.hisStore.param.FsStorePaymentPayParam;
-import me.chanjar.weixin.common.error.WxErrorException;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -91,7 +90,7 @@ public interface IFsStorePaymentService
 
     String updateFsStorePaymentByDecryptForm(Long paymentId);
 
-    R refundFsStorePayment(Long paymentId);
+    R refundFsStorePayment(Long paymentId, String appId);
 
     R sendRedPacket(WxSendRedPacketParam param);
 

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

@@ -38,7 +38,6 @@ import com.fs.company.service.ICompanyUserService;
 import com.fs.company.vo.FsStorePaymentStatisticsVO;
 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.config.RedPacketConfig;
 import com.fs.course.domain.FsCoursePlaySourceConfig;
@@ -47,7 +46,6 @@ import com.fs.course.service.IFsCourseRedPacketLogService;
 import com.fs.course.service.IFsUserCourseOrderService;
 import com.fs.course.service.IFsUserVipOrderService;
 import com.fs.his.domain.*;
-import com.fs.his.dto.PayConfigDTO;
 import com.fs.his.enums.PaymentMethodEnum;
 import com.fs.his.mapper.*;
 import com.fs.his.param.FsStorePaymentParam;
@@ -55,15 +53,12 @@ import com.fs.his.param.PayOrderParam;
 import com.fs.his.param.WxSendRedPacketParam;
 import com.fs.his.service.IFsInquiryOrderService;
 
-import com.fs.his.param.WxSendRedPacketParam;
-import com.fs.his.service.IFsInquiryOrderService;
 import com.fs.his.service.IFsPackageOrderService;
 import com.fs.his.service.IFsStoreOrderService;
 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;
@@ -162,8 +157,8 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
     private IFsUserVipOrderService vipOrderService;
     @Autowired
     SysConfigMapper sysConfigMapper;
-    @Autowired
-    private WxPayProperties wxPayProperties;
+//    @Autowired
+//    private WxPayProperties wxPayProperties;
     @Autowired
     private WxPayService wxPayService;
     @Autowired
@@ -426,7 +421,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
     @Autowired
     IPayService payService;
     @Override
-    public R refundFsStorePayment(Long paymentId) {
+    public R refundFsStorePayment(Long paymentId, String appId) {
         FsStorePayment fsStorePayment = fsStorePaymentMapper.selectFsStorePaymentByPaymentId(paymentId);
         if(fsStorePayment!=null){
             String orderType="";
@@ -446,12 +441,23 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
 
             if(fsStorePayment.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(appId)) {
+                    throw new IllegalArgumentException("appId不能为空");
+                }
+                FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(appId);
+                if (fsCoursePlaySourceConfig == null) {
+                    throw new CustomException("未找到appId对应的小程序配置: " + appId);
+                }
+                Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
+                if (merchantConfigId == null || merchantConfigId <= 0) {
+                    throw new CustomException("小程序没有配置商户信息");
+                }
+                MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
+                FsPayConfig fsPayConfig = com.alibaba.fastjson.JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
                 payConfig.setAppId(fsPayConfig.getAppId());
                 payConfig.setMchId(fsPayConfig.getWxMchId());
                 payConfig.setMchKey(fsPayConfig.getWxMchKey());
-                payConfig.setKeyPath(wxPayProperties.getKeyPath());
+                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);
@@ -1214,7 +1220,8 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
         if (merchantConfigId == null || merchantConfigId <= 0) {
             throw new CustomException("小程序没有配置商户信息");
         }
-        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());        FsPayConfig payConfig =JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+        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);
@@ -1456,7 +1463,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
         payConfig.setSubAppId(StringUtils.trimToNull(null));
         payConfig.setSubMchId(StringUtils.trimToNull(null));
         payConfig.setKeyPath(null);
-        payConfig.setNotifyUrl(wxPayProperties.getNotifyUrl());
+        payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
         return payConfig;
     }
 
@@ -1727,7 +1734,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
                 payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
                 payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
                 payConfig.setKeyPath(null);
-                payConfig.setNotifyUrl(wxPayProperties.getNotifyUrl());
+                payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
                 wxPayService.setConfig(payConfig);
                 WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
                 orderRequest.setOpenid(openId);//公众号支付提供用户openid

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

@@ -4222,7 +4222,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
                 storePayment.setCompanyId(order.getCompanyId());
                 storePayment.setCompanyUserId(order.getCompanyUserId());
-                storePayment.setPayMode(fsPayConfig.getType());
+                storePayment.setPayMode(merchantAppConfig.getMerchantType());
                 storePayment.setStatus(0);
                 storePayment.setPayCode(payCode);
                 storePayment.setPayMoney(order.getPayMoney());
@@ -4237,7 +4237,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 storePayment.setAppId(fsPayConfig.getAppId() == null ? "" : fsPayConfig.getAppId());
                 fsStorePaymentMapper.insertFsStorePayment(storePayment);
 
-                if (fsPayConfig.getType().equals("hf")){
+                if (merchantAppConfig.getMerchantType().equals("hf")){
                     HuiFuCreateOrder o = new HuiFuCreateOrder();
                     o.setTradeType("T_MINIAPP");
                     o.setOpenid(user.getMaOpenId());
@@ -4269,7 +4269,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                     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());
                     payConfig.setMchId(fsPayConfig.getWxMchId());
@@ -4372,7 +4372,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             storePayment.setCompanyId(order.getCompanyId());
             storePayment.setCompanyUserId(order.getCompanyUserId());
             storePayment.setStatus(0);
-            storePayment.setPayMode(fsPayConfig.getType());
+            storePayment.setPayMode(merchantAppConfig.getMerchantType());
             storePayment.setPayCode(payCode);
             storePayment.setPayMoney(order.getPayDelivery());
             storePayment.setCreateTime(new Date());
@@ -4386,7 +4386,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             storePayment.setIsPayRemain(1);
             fsStorePaymentMapper.insertFsStorePayment(storePayment);
 
-            if (fsPayConfig.getType().equals("hf")){
+            if (merchantAppConfig.getMerchantType().equals("hf")){
                 HuiFuCreateOrder o = new HuiFuCreateOrder();
                 o.setTradeType("T_MINIAPP");
                 o.setOpenid(user.getMaOpenId());
@@ -4409,7 +4409,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 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());
@@ -4502,7 +4502,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             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");
@@ -4514,7 +4514,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             storePayment.setOrderId(order.getId());
             fsStorePaymentMapper.insertFsStorePayment(storePayment);
 
-            if (fsPayConfig.getType().equals("hf")){
+            if (merchantAppConfig.getMerchantType().equals("hf")){
                 HuiFuCreateOrder o = new HuiFuCreateOrder();
                 o.setTradeType("T_MINIAPP");
                 o.setOpenid(user.getMaOpenId());
@@ -4537,7 +4537,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 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());
@@ -4612,7 +4612,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             storePayment.setCompanyId(order.getCompanyId());
             storePayment.setCompanyUserId(order.getCompanyUserId());
             storePayment.setStatus(0);
-            storePayment.setPayMode(fsPayConfig.getType());
+            storePayment.setPayMode(merchantAppConfig.getMerchantType());
             storePayment.setPayCode(payCode);
             storePayment.setPayMoney(order.getPayDelivery());
             storePayment.setCreateTime(new Date());
@@ -4626,7 +4626,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
             storePayment.setIsPayRemain(1);
             fsStorePaymentMapper.insertFsStorePayment(storePayment);
 
-            if (fsPayConfig.getType().equals("hf")){
+            if (merchantAppConfig.getMerchantType().equals("hf")){
                 HuiFuCreateOrder o = new HuiFuCreateOrder();
                 o.setTradeType("T_MINIAPP");
                 o.setOpenid(user.getMaOpenId());
@@ -4650,7 +4650,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 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());
                 payConfig.setMchId(fsPayConfig.getWxMchId());

+ 92 - 36
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java

@@ -24,9 +24,12 @@ import com.fs.common.annotation.DataScope;
 import com.fs.common.config.FSSysConfig;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.exception.CustomException;
 import com.fs.common.utils.CloudHostUtils;
 import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.common.utils.ip.IpUtils;
 import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.mapper.CompanyConfigMapper;
@@ -35,13 +38,15 @@ import com.fs.company.service.ICompanyUserService;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.utils.OrderCodeUtils;
 import com.fs.course.config.RedPacketConfig;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
 import com.fs.course.domain.FsCourseRedPacketLog;
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
 import com.fs.course.service.IFsCourseRedPacketLogService;
 import com.fs.his.config.FsSysConfig;
-import com.fs.his.domain.FsUser;
-import com.fs.his.domain.FsUserWx;
+import com.fs.his.domain.*;
 import com.fs.his.mapper.FsUserWxMapper;
+import com.fs.his.mapper.MerchantAppConfigMapper;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.service.IFsUserWxService;
 import com.fs.his.utils.ConfigUtil;
@@ -70,6 +75,7 @@ import com.fs.ybPay.domain.CreateWxOrderResult;
 import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
 import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
 import com.github.binarywang.wxpay.bean.notify.WxPayTransferBatchesNotifyV3Result;
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
 import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
 import com.github.binarywang.wxpay.bean.transfer.*;
 import com.github.binarywang.wxpay.config.WxPayConfig;
@@ -105,11 +111,12 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
 {
     Logger logger = LoggerFactory.getLogger(getClass());
     @Autowired
-    private WxMaProperties properties;
+    private WxPayService wxPayService;
+
     @Autowired
-    private IPayService payService;
+    private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
     @Autowired
-    private FSSysConfig sysConfig;
+    private MerchantAppConfigMapper merchantAppConfigMapper;
     @Autowired
     private FsStorePaymentScrmMapper fsStorePaymentMapper;
     @Autowired
@@ -886,7 +893,19 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
                 return R.error("注册失败客服已停用,或不存在!");
             }
         }
-
+        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 = com.hc.openapi.tool.fastjson.JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
         //生成支付流水
         String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
 
@@ -927,37 +946,74 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
         storePayment.setPayMode("hf");//目前微信收款仅支持汇付
         storePayment.setAppId(param.getAppId());
         fsStorePaymentMapper.insertFsStorePayment(storePayment);
-
-        //汇付支付
-        HuiFuCreateOrder o = new HuiFuCreateOrder();
-        o.setTradeType("T_MINIAPP");
-        o.setOpenid(openId);
-        o.setReqSeqId("payment-"+storePayment.getPayCode());
-        o.setTransAmt(storePayment.getPayMoney().toString());
-        o.setGoodsDesc("商城订单支付");
-        o.setAppId(param.getAppId());
-        //公司分账
-        try {
-            HuiFuUtils.doDiv(o,company.getCompanyId());
-            //存储分账明细
-            HuiFuUtils.saveDivItem(o, storePayment.getPayCode(), storePayment.getPayCode());
-        } catch (Exception e) {
-            logger.error("-------------微信收款分账出错:{}", e.getMessage());
-        }
-        HuifuCreateOrderResult result = huiFuService.createOrder(o);
-        if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
-            FsStorePaymentScrm mt=new FsStorePaymentScrm();
-            mt.setPaymentId(storePayment.getPaymentId());
-            mt.setTradeNo(result.getHf_seq_id());
-            fsStorePaymentMapper.updateFsStorePayment(mt);
-            Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
-            String s = (String) resultMap.get("package");
-            resultMap.put("packageValue",s);
-            return R.ok().put("result",resultMap);
-        }
-        else{
-            return R.error(result.getResp_desc());
+        if (fsStorePaymentMapper.insertFsStorePayment(storePayment) > 0) {
+            if (merchantAppConfig.getMerchantType().equals("wx")) {
+                //创建微信订单
+                WxPayConfig payConfig = new WxPayConfig();
+                payConfig.setAppId(appId);
+                payConfig.setMchId(fsPayConfig.getWxMchId());
+                payConfig.setMchKey(fsPayConfig.getWxMchKey());
+                payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
+                payConfig.setKeyPath(null);
+                payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
+                wxPayService.setConfig(payConfig);
+                WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+                orderRequest.setOpenid(openId);//公众号支付提供用户openid
+                orderRequest.setBody("拍商品订单支付");
+                orderRequest.setOutTradeNo("product-" + storePayment.getPayCode());
+                orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
+                //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
+                orderRequest.setTradeType("JSAPI");
+                orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+                //调用统一下单接口,获取"预支付交易会话标识"
+                try {
+                    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
+                    return R.ok().put("data", orderResult).put("type", "wx").put("isPay", 0);
+                } catch (WxPayException e) {
+                    e.printStackTrace();
+                    throw new CustomException("支付失败" + e.getMessage());
+                }
+            } else if (merchantAppConfig.getMerchantType().equals("hf")) {
+
+                //汇付支付
+                HuiFuCreateOrder o = new HuiFuCreateOrder();
+                o.setTradeType("T_MINIAPP");
+                o.setOpenid(openId);
+                o.setReqSeqId("payment-"+storePayment.getPayCode());
+                o.setTransAmt(storePayment.getPayMoney().toString());
+                o.setGoodsDesc("商城订单支付");
+                o.setAppId(appId);
+                //公司分账
+                try {
+                    HuiFuUtils.doDiv(o,company.getCompanyId());
+                    //存储分账明细
+                    HuiFuUtils.saveDivItem(o, storePayment.getPayCode(), storePayment.getPayCode());
+                } catch (Exception e) {
+                    logger.error("-------------微信收款分账出错:{}", e.getMessage());
+                }
+                HuifuCreateOrderResult result = huiFuService.createOrder(o);
+
+                if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
+                    FsStorePaymentScrm mt=new FsStorePaymentScrm();
+                    mt.setPaymentId(storePayment.getPaymentId());
+                    mt.setTradeNo(result.getHf_seq_id());
+                    mt.setAppId(appId);
+                    fsStorePaymentMapper.updateFsStorePayment(mt);
+                    Map<String, Object> resultMap = com.alibaba.fastjson.JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
+                    String s = (String) resultMap.get("package");
+                    resultMap.put("packageValue",s);
+                    return R.ok().put("result",resultMap);
+                }
+                else{
+                    return R.error(result.getResp_desc());
+                }
+            }
+        }else {
+            return R.error("新增订单失败!");
         }
+        return R.error("支付失败!");
+
     }
 
     @Override

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

@@ -1096,7 +1096,7 @@ public class LiveOrderController extends AppBaseController
             storePayment.setCompanyId(order.getCompanyId());
             storePayment.setCompanyUserId(order.getCompanyUserId());
             storePayment.setStatus(0);
-            storePayment.setPayMode(fsPayConfig.getType());
+            storePayment.setPayMode(merchantAppConfig.getMerchantType());
             storePayment.setPayCode(payCode);
             storePayment.setPayMoney(order.getPayDelivery());
             storePayment.setCreateTime(new Date());
@@ -1108,7 +1108,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());
@@ -1131,7 +1131,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());