Browse Source

no message

FengChaoYu 9 months ago
parent
commit
2f8b841017

+ 6 - 3
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/material/MaterialSalesController.java

@@ -5,6 +5,7 @@ import com.gree.mall.miniapp.annotation.ApiNotAuth;
 import com.gree.mall.miniapp.bean.PayDetail;
 import com.gree.mall.miniapp.bean.material.*;
 import com.gree.mall.miniapp.constant.Constant;
+import com.gree.mall.miniapp.constant.SybConstants;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.helper.ResponseHelper;
 import com.gree.mall.miniapp.logic.material.WebsitSalesLogic;
@@ -187,17 +188,19 @@ public class MaterialSalesController {
 
     @ApiNotAuth
     @GetMapping("/pay")
-    @ApiOperation(value = "生成小程序支付")
+    @ApiOperation(value = "生成支付")
     public ResponseHelper<PayDetail> websitDefault(
             @ApiParam(value = "appOrderId",required = true) @RequestParam String key,
-            @ApiParam(value = "openid",required = true) @RequestParam String openid
+            @ApiParam(value = "openid",required = true) @RequestParam String openid,
+            @ApiParam(value = "通联支付类型") @RequestParam(required = false, defaultValue = SybConstants.PAY_TYPE_W06) String payType,
+            @ApiParam(value = "支付完成跳转(必须为https协议地址,且不允许带参数)") @RequestParam(required = false) String frontUrl
     ) throws RemoteServiceException, InterruptedException {
         Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.LOCK_ORDER + ":" + key);
         if(!obtain.tryLock(10, TimeUnit.SECONDS)){
             throw new RemoteServiceException("系统繁忙,请稍后再尝试");
         }
         try {
-            PayDetail pay = websitSalesLogic.generatePayRecord(key, openid);
+            PayDetail pay = websitSalesLogic.generatePayRecord(key, openid, payType, frontUrl);
             return ResponseHelper.success(pay);
         }finally {
             obtain.unlock();

+ 3 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/common/AllInPayLogic.java

@@ -33,13 +33,13 @@ public class AllInPayLogic {
     /**
      * 通联支付
      */
-    public Map<String, String> serviceUnifiedOrder(WebsitSalesPayOrder order, String payType)
+    public Map<String, String> serviceUnifiedOrder(WebsitSalesPayOrder order, String payType, String frontUrl)
             throws RemoteServiceException {
         Map<String, String> reqMap = new HashMap<>();
         reqMap.put("orgid", order.getOrgId());
         reqMap.put("cusid", order.getMchNo());
         reqMap.put("appid", order.getAppid());
-        if (SybConstants.PAY_TYPE_W06.equals(payType)) {
+        if (!SybConstants.PAY_TYPE_W01.equals(payType)) {
             reqMap.put("acct", order.getOpenid());
             reqMap.put("sub_appid", mallAppid);
         }
@@ -49,6 +49,7 @@ public class AllInPayLogic {
         reqMap.put("body", order.getWebsitName());
         reqMap.put("paytype", payType);
         reqMap.put("remark", order.getOrderId());
+        reqMap.put("front_url", frontUrl);
 
         HashMap<String, String> heads = new HashMap();
         String token = commonLogic.getInfToken();

+ 6 - 3
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/WebsitSalesLogic.java

@@ -499,9 +499,11 @@ public class WebsitSalesLogic {
      * 生成支付记录
      * @param key
      * @param openid
+     * @param payType
+     * @param frontUrl
      * @return
      */
-    public PayDetail generatePayRecord(String key, String openid) {
+    public PayDetail generatePayRecord(String key, String openid, String payType, String frontUrl) {
         PayDetail payDetail = null;
         final WebsitSalesPayMap payMap = websitSalesPayMapService.getById(key);
 
@@ -529,11 +531,12 @@ public class WebsitSalesLogic {
                     .setOrderType(PayOrderTypeEnum.S.getKey())
                     .setRunTime(DateUtil.offsetSecond(DateUtil.date(), 10))
                     .setOrderSource(sales.getGoodsType().equals(WebsitGoodsTypeEnum.M.toString()) ? "M_SALES" : "P_SALES")
-                    .setIsDeliver(false);
+                    .setIsDeliver(false)
+                    .setSource(payType.equals(SybConstants.PAY_TYPE_W06) ? "小程序" : "公众号");
 
 
             // 请求通联得到结果
-            Map<String, String> resMap = allInPayLogic.serviceUnifiedOrder(payOrder, SybConstants.PAY_TYPE_W06);
+            Map<String, String> resMap = allInPayLogic.serviceUnifiedOrder(payOrder, payType, frontUrl);
 
             if (!resMap.get("trxstatus").equals("0000")) {
                 throw new RemoteServiceException("通联统一支付接口执行失败:" + resMap.get("errmsg"));