Bladeren bron

fix(app):
1.修改订单接口

wzq 4 weken geleden
bovenliggende
commit
ec1295728a

+ 3 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/form/UserPayForm.java

@@ -22,6 +22,9 @@ public class UserPayForm implements Serializable {
     @Schema(description = "订单号")
     private String orderCode;
 
+    @Schema(description = "是否拉起支付订单(0-否 1-是)")
+    private Integer orPayOrder = 1;
+
     @Schema(description = "JsApi参数")
     private Map<String,String> params;
 }

+ 52 - 42
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/OrderServiceImpl.java

@@ -595,9 +595,6 @@ public class OrderServiceImpl implements IOrderService {
                                 .setDelFlag(CommonConstant.DEL_FLAG_0);
 
                         proInfoList.add(appOrderProInfo);
-//                        appDeviceMapper.selectList(Wrappers.<AppDevice>lambdaQuery().eq(AppDevice::getId,appSite.getId())).forEach(appDevice -> {
-//                            addUser(priceRule.getDateOfSale(),appDevice.getDeviceSerial(),familyMembers.getFullName(),id);
-//                        });
                     }
                 }
 
@@ -744,6 +741,7 @@ public class OrderServiceImpl implements IOrderService {
                     appOrderProInfo.setExpireTime(DateUtil.format(appGameSchedule.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
                     appOrderProInfo.setOriginalPrice(appGamePriceRules.getSellingPrice());
                     appOrderProInfo.setPrice(appGamePriceRules.getSellingPrice());
+                    appOrderProInfo.setProductImage(appGame.getCover());
                     appOrderProInfo.setOrderStatus(0);
                     appOrderProInfo.setQuantity(1);
                     appOrderProInfo.setFamilyUserId(familyUserId);
@@ -843,13 +841,14 @@ public class OrderServiceImpl implements IOrderService {
 
                     if (createOrderForm.getOrFreeOrder() == 1) {
                         Boolean flag = checkOrderOrFree(user.getId(), appCourse.getCategoryId());
-                        if (!flag && i == 1) {
+                        if (flag && i == 1) {
                             //订单中的多个商品中的第一个商品触发免费,将金额设置为优惠金额
                             sDiscounts = sDiscounts.add(appCourse.getSellingPrice());
                             appOrderProInfo.setOrFreePro(CommonConstant.STATUS_1_INT);
                             appOrder.setContractNo(null);
                             //试听优惠
                             appOrder.setSDiscounts(sDiscounts);
+                            appOrder.setOrderOrFree(CommonConstant.STATUS_1_INT);
                         }
                     }
 
@@ -1002,47 +1001,56 @@ public class OrderServiceImpl implements IOrderService {
                 .setOrderId(appOrder.getId())
                 .setOrderCode(orderCode)
         ;
-        Calendar calendar = Calendar.getInstance();
-        calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
 
-        //构建微信支付参数
-        JSONObject params = new JSONObject();
-        params.put("appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
+        //判断是否试听课(试听课不走订单)
+        if (ObjectUtil.isNotEmpty(appOrder.getOrderOrFree()) && appOrder.getOrderOrFree() == 1) {
+            payForm.setOrPayOrder(0);
+        }
+        else if (appOrder.getOrderType() == 0){
+            payForm.setOrPayOrder(0);
+        }else {
+            Calendar calendar = Calendar.getInstance();
+            calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
+
+            //构建微信支付参数
+            JSONObject params = new JSONObject();
+            params.put("appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
 //        params.put("sub_appid", WechatConstants.WECHAT_MP_APPID); //小程序appid
-        params.put("mchid", WechatConstants.WECHAT_MCH_ID); //商户号
-        params.put("description", "全龄运动"); //商品描述
-        params.put("out_trade_no", appOrder.getOrderCode()); //商户订单号
-        params.put("time_expire", sdf.format(calendar.getTime())); //交易结束时间 选填 时间到了之后将不能再支付 遵循rfc3339标准格式
-        params.put("attach", appOrder.getOrderCode()); //附加数据 选填
-        // 在查询API和支付通知中原样返回 可作为自定义参数使用
-        params.put("notify_url", WechatUrlConstants.PAY_V3_NOTIFY); //支付结果异步通知接口
-        params.put("trade_type", WechatConstants.WECHAT_MP_TRADE_TYPE);//JSAPI
-        //分账必传参数
-        JSONObject settleInfo = new JSONObject();
-        settleInfo.put("profit_sharing", Boolean.TRUE);
-        params.put("settle_info", settleInfo);
-
-        //订单金额信息
-        JSONObject amount_json = new JSONObject();
-        //支付金额 单位:分
-        amount_json.put("total", Integer.parseInt(amount_fee(new BigDecimal("0.01"))));//测试0.01元
+            params.put("mchid", WechatConstants.WECHAT_MCH_ID); //商户号
+            params.put("description", "全龄运动"); //商品描述
+            params.put("out_trade_no", appOrder.getOrderCode()); //商户订单号
+            params.put("time_expire", sdf.format(calendar.getTime())); //交易结束时间 选填 时间到了之后将不能再支付 遵循rfc3339标准格式
+            params.put("attach", appOrder.getOrderCode()); //附加数据 选填
+            // 在查询API和支付通知中原样返回 可作为自定义参数使用
+            params.put("notify_url", WechatUrlConstants.PAY_V3_NOTIFY); //支付结果异步通知接口
+            params.put("trade_type", WechatConstants.WECHAT_MP_TRADE_TYPE);//JSAPI
+            //分账必传参数
+            JSONObject settleInfo = new JSONObject();
+            settleInfo.put("profit_sharing", Boolean.TRUE);
+            params.put("settle_info", settleInfo);
+
+            //订单金额信息
+            JSONObject amount_json = new JSONObject();
+            //支付金额 单位:分
+            amount_json.put("total", Integer.parseInt(amount_fee(new BigDecimal("0.01"))));//测试0.01元
 //        amount_json.put("total", Integer.parseInt(amount_fee(appOrder.getPrice())));
-        params.put("amount", amount_json);
+            params.put("amount", amount_json);
 
-        //支付者信息
-        JSONObject payer = new JSONObject();
-        //用户在小程序侧的openid
-        payer.put("openid", sysUser.getOpenid());
-        params.put("payer", payer);
+            //支付者信息
+            JSONObject payer = new JSONObject();
+            //用户在小程序侧的openid
+            payer.put("openid", sysUser.getOpenid());
+            params.put("payer", payer);
 
-        //拉起支付-返回JSAPI参数
+            //拉起支付-返回JSAPI参数
 //        Map<String, String> result = weChatPayService.wechatPay(params);
 //        payForm.setParams(result);
 
-        //发布任务到redission延迟队列
-        String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
-        redissonDelayQueue.offerTask(task, 60 * 15);
+            //发布任务到redission延迟队列
+            String task = CommonConstant.ORDER_TIME_OUT_TASK_PREFIX + appOrder.getId();
+            redissonDelayQueue.offerTask(task, 60 * 15);
+        }
 
         return payForm;
 
@@ -1663,12 +1671,14 @@ public class OrderServiceImpl implements IOrderService {
     private Boolean checkOrderOrFree(String userId, String categoryId) {
         //查询当前用户的所有课程订单
         List<AppOrder> appOrders = appOrderMapper.selectList(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getUserId, userId).eq(AppOrder::getType, CommonConstant.ORDER_TYPE_2));
-        for (AppOrder appOrder : appOrders) {
-            AppCourses appCours = appCoursesMapper.selectById(appOrder.getProductIds());
-            if (appCours.getCategoryId().equals(categoryId)) {
-                return Boolean.TRUE;
+        if (CollUtil.isNotEmpty(appOrders)){
+            for (AppOrder appOrder : appOrders) {
+                AppCourses appCours = appCoursesMapper.selectById(appOrder.getProductIds());
+                if (appCours.getCategoryId().equals(categoryId)) {
+                    return Boolean.FALSE;
+                }
             }
         }
-        return Boolean.FALSE;
+        return Boolean.TRUE;
     }
 }

+ 4 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppOrder.java

@@ -179,4 +179,8 @@ public class AppOrder implements Serializable {
     @Excel(name = "地点ID", width = 15)
     @Schema(description = "地点ID")
     private String addressSiteId;
+
+    @Excel(name = "是否免费课订单(0-否 1-是)", width = 15)
+    @Schema(description = "是否免费课订单(0-否 1-是)")
+    private Integer orderOrFree;
 }