ソースを参照

多小程序支付开发

yfh 2 週間 前
コミット
336f51f6b2

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/service/channel/WxPaymentHandler.java

@@ -67,7 +67,7 @@ public class WxPaymentHandler extends PaymentHandler{
         try {
             WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
             String resultJson = JSON.toJSONString(orderResult);
-            return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType",context.getPayType());
+            return R.ok().put("result", resultJson).put("type", "wx").put("isPay", 0).put("payType",context.getPayType());
         } catch (WxPayException e) {
             e.printStackTrace();
             throw new CustomException("支付失败" + e.getMessage());

+ 20 - 3
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -94,6 +94,12 @@ import com.fs.wx.miniapp.config.WxMaConfiguration;
 import com.fs.wx.miniapp.config.WxMaProperties;
 import com.fs.wx.service.OrderQueryService;
 import com.fs.wx.service.ShippingService;
+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 lombok.Synchronized;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.commons.collections4.CollectionUtils;
@@ -3378,7 +3384,10 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             //易宝支付
             String json = configService.selectConfigByKey("store.pay");
             FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
-
+            WxMiniProgramConfig wxMiniProgramConfig = new WxMiniProgramConfig();
+            wxMiniProgramConfig.setAppid(param.getAppId());
+            List<WxMiniProgramConfig>  wxMiniProgramConfigs = wxMiniProgramConfigMapper.selectWxMiniProgramConfigList(wxMiniProgramConfig);
+            WxMiniProgramConfig wConfig = wxMiniProgramConfigs.get(0);
             String openId = null;
             String appId = param.getAppId();
             if (StringUtils.isNotBlank(appId)) {
@@ -3389,7 +3398,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                     openId = fsUserWx.getOpenId();
                 }
             } else {
-                appId = fsPayConfig.getAppId();
+                appId = fsCoursePlaySourceConfigMapper.selectFsCoursePlaySourceConfigByAppId(param.getAppId()).getAppid();
                 openId = Objects.isNull(user) ? "" : user.getMaOpenId();
                 if (StringUtils.isBlank(openId)){
                     FsUserWx fsUserWx = fsUserWxMapper.selectListByUserIdAndAppId(user.getUserId(),appId);
@@ -3439,6 +3448,8 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 }else{
                     return R.error(result.getResp_desc());
                 }
+            }else if (fsPayConfig.getType().equals("wx")){
+                return orderService.otherPayment(param);
             }else if (fsPayConfig.getType().equals("yb")){
                 WxJspayDTO p = new WxJspayDTO();
                 // 使用setter方法为对象赋值
@@ -3806,6 +3817,10 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         FsUser user=userService.selectFsUserById(order.getUserId());
         String json = configService.selectConfigByKey("store.pay");
         FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
+        WxMiniProgramConfig wxMiniProgramConfig = new WxMiniProgramConfig();
+        wxMiniProgramConfig.setAppid(param.getAppId());
+        List<WxMiniProgramConfig>  wxMiniProgramConfigs = wxMiniProgramConfigMapper.selectWxMiniProgramConfigList(wxMiniProgramConfig);
+        WxMiniProgramConfig wConfig = wxMiniProgramConfigs.get(0);
         String openId = null;
         String appId = param.getAppId();
         if (StringUtils.isNotBlank(appId)) {
@@ -3816,7 +3831,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 openId = fsUserWx.getOpenId();
             }
         } else {
-            appId = fsPayConfig.getAppId();
+            appId = fsCoursePlaySourceConfigMapper.selectFsCoursePlaySourceConfigByAppId(param.getAppId()).getAppid();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 FsUserWx fsUserWx = fsUserWxMapper.selectListByUserIdAndAppId(user.getUserId(),appId);
@@ -3870,6 +3885,8 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 else{
                     return R.error(result.getResp_desc());
                 }
+            }else if (fsPayConfig.getType().equals("wx")){
+                return orderService.pay(param);
             }else if(fsPayConfig.getType().equals("yb")){
                 WxJspayDTO p = new WxJspayDTO();
                 // 使用setter方法为对象赋值