浏览代码

feat(app): 优化订单相关功能和数据结构

- 修改 AppOrder 实体类,优化订单状态描述
- 更新 AppSitePlaceMapper.xml,增加提醒和退款类型字段- 修改 DetailServiceImpl,添加提醒和退款类型信息
- 更新 IOrderService 接口,增加课程限购校验方法
- 新增 OrderController 中的课程限购校验接口
- 实现 OrderServiceImpl 中的课程限购校验和课程折扣检查逻辑
- 更新 OrderVO 和 PlaceInfoVO,调整相关字段和描述
SheepHy 1 周之前
父节点
当前提交
9a37ffc64c

+ 14 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/OrderController.java

@@ -34,4 +34,18 @@ public class OrderController {
                                                                            @RequestParam("startTime") @Schema(description = "当前选择日期(年月日)")Date startTime){
         return Result.ok(appOrderService.previewOrderPlaceSchool(placeId,startTime));
     }
+
+    /**
+     * @Author SheepHy
+     * @Description 课程限购校验
+     * @Date 16:22 2025/7/14
+     * @Param courseId 课程ID
+     * @return boolean
+     **/
+    @Operation(summary="课程限购校验")
+    @GetMapping("/checkCourseLimitNum")
+    public Result<Boolean> checkCourseLimitNum(@RequestParam("courseId") @Schema(description = "课程ID")String courseId,
+                                               @RequestParam("limitNum") @Schema(description = "购买数")int limitNum){
+        return Result.OK(appOrderService.checkCourseLimitNum(courseId, limitNum));
+    }
 }

+ 2 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/IOrderService.java

@@ -17,12 +17,12 @@ public interface IOrderService {
 
     /**
      * @Author SheepHy
-     * @Description 课程库存校验
+     * @Description 课程限购校验
      * @Date 16:22 2025/7/14
      * @Param courseId 课程ID
      * @return boolean
      **/
-    boolean checkCourseInventory(String courseId);
+    boolean checkCourseLimitNum(String courseId, int limitNum);
 
     /**
      * @Author SheepHy

+ 3 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/DetailServiceImpl.java

@@ -105,7 +105,9 @@ public class DetailServiceImpl implements IDetailService {
                                 .eq(AppSitePriceRules::getSitePlaceId, appSitePlace.getId())
                                 .last("limit 1").orderByDesc(AppSitePriceRules::getSellingPrice)).getSellingPrice())
                         .setCategory(getCategoryName(appSitePlace.getCategoryId()))
-                        .setCover(appSitePlace.getCover());
+                        .setCover(appSitePlace.getCover())
+                        .setReminder(appSitePlace.getReminder())
+                        .setRefundType(appSitePlace.getRefundType());
                 placeInfoMsgVOS.add(placeInfoMsgVO);
             });
             placeInfo.setPlaceInfoMsgVO(placeInfoMsgVOS);

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

@@ -1,9 +1,14 @@
 package org.jeecg.modules.app.service.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.extern.log4j.Log4j2;
 import org.jeecg.modules.app.service.IOrderService;
 import org.jeecg.modules.app.vo.OrderVO;
+import org.jeecg.modules.system.app.entity.AppCourses;
+import org.jeecg.modules.system.app.entity.AppOrder;
 import org.jeecg.modules.system.app.entity.AppSitePlace;
+import org.jeecg.modules.system.app.mapper.AppCoursesMapper;
+import org.jeecg.modules.system.app.mapper.AppOrderMapper;
 import org.jeecg.modules.system.app.mapper.AppSitePlaceMapper;
 import org.jeecg.modules.system.app.mapper.AppSitePriceRulesMapper;
 import org.springframework.stereotype.Service;
@@ -22,11 +27,13 @@ public class OrderServiceImpl implements IOrderService {
     @Resource
     private AppSitePriceRulesMapper appSitePriceRulesMapper;
     @Resource
-    private AppC appCourseMapper;
+    private AppCoursesMapper appCoursesMapper;
+    @Resource
+    private AppOrderMapper appOrderMapper;
 
     @Override
-    public boolean checkCourseInventory(String courseId) {
-        return false;
+    public boolean checkCourseLimitNum(String courseId, int limitNum) {
+        return appCoursesMapper.selectById(courseId).getLimitNum() <= limitNum;
     }
 
     @Override
@@ -44,6 +51,14 @@ public class OrderServiceImpl implements IOrderService {
 
     @Override
     public OrderVO.PreviewOrderCourse previewOrderCourse(String courseId) {
+        OrderVO.PreviewOrderCourse previousOrderCourse = new OrderVO.PreviewOrderCourse();
+        AppCourses appCourses = appCoursesMapper.selectById(courseId);
+        previousOrderCourse.setId(appCourses.getId())
+                .setCover(appCourses.getCover())
+                .setName(appCourses.getName())
+                .setSellingPrice(appCourses.getSellingPrice())
+                .setReminder(appCourses.getReminder());
+//                .setHasDiscount();
         return null;
     }
 
@@ -51,4 +66,28 @@ public class OrderServiceImpl implements IOrderService {
     public OrderVO.PreviewOrderPlaceGymnasiumChartered previewOrderPlaceGymnasiumChartered(String placeId) {
         return null;
     }
+
+    /**
+     * @Author SheepHy
+     * @Description 查询用户对该类型课程是否有试听资格
+     * @Date 16:45 2025/7/14
+     * @Param courseId userId
+     * @return boolean
+     **/
+    private boolean checkCourseDiscount(String categoryId, String userId) {
+        boolean success = Boolean.TRUE;
+        List<AppOrder> appOrders = appOrderMapper.selectList(Wrappers.<AppOrder>lambdaQuery()
+                .eq(AppOrder::getUserId, userId)
+                .ne(AppOrder::getOrderStatus, 6)
+                .ne(AppOrder::getOrderStatus, 5)
+                .eq(AppOrder::getStatus, 0)
+                .eq(AppOrder::getDelFlag, 0)
+                .eq(AppOrder::getType,2));
+        if (appOrders.isEmpty()) return true;
+        appOrders.forEach(appOrder -> {
+            AppCourses appCourses = appCoursesMapper.selectById(appOrder.getProductIds());
+//            if(appCourses.getCategoryId().equals(categoryId)) success = Boolean.FALSE;
+        });
+        return success;
+    }
 }

+ 4 - 8
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/OrderVO.java

@@ -55,18 +55,14 @@ public class OrderVO {
         private String name;
         @Schema(description = "课程图片")
         private String cover;
-        @Schema(description = "商品价")
-        private BigDecimal totalPrice;
+        @Schema(description = "商品价")
+        private BigDecimal sellingPrice;
         @Schema(description = "优惠")
         private BigDecimal discountPrice;
-        @Schema(description = "小计")
-        private BigDecimal subtotal;
-        @Schema(description = "合计")
-        private BigDecimal total;
         @Schema(description = "总优惠")
         private BigDecimal totalDiscount;
-        @Schema(description = "提交金额")
-        private BigDecimal amount;
+        @Schema(description = "是否有优惠")
+        private Boolean hasDiscount;
         @Schema(description = "提示")
         private String reminder;
     }

+ 9 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/PlaceInfoVO.java

@@ -58,10 +58,14 @@ public class PlaceInfoVO {
         private String id;
         @Schema(description = "场地名称")
         private String name;
+        @Schema(description = "提示/须知")
+        private String reminder;
         @Schema(description = "图片")
         private String cover;
         @Schema(description = "销售数量")
         private int sales;
+        @Schema(description = "退款类型;0可退/到期自动退 1限时退 2不可退")
+        private int refundType;
         @Schema(description = "类目")
         private List<String> category;
         @Schema(description = "原价")
@@ -78,6 +82,10 @@ public class PlaceInfoVO {
         private String id;
         @Schema(description = "场地名称")
         private String name;
+        @Schema(description = "提示/须知")
+        private String reminder;
+        @Schema(description = "退款类型;0可退/到期自动退 1限时退 2不可退")
+        private int refundType;
         @Schema(description = "图片")
         private String cover;
         @Schema(description = "销售数量")
@@ -115,7 +123,7 @@ public class PlaceInfoVO {
         @Schema(description = "封面")
         private String cover;
         @Schema(description = "课时")
-        private Integer period;
+        private int period;
         @Schema(description = "距离")
         private BigDecimal km;
         @JsonFormat(timezone = "GMT+8",pattern = "MM-dd")

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

@@ -1,23 +1,19 @@
 package org.jeecg.modules.system.app.entity;
 
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.util.Date;
-import java.math.BigDecimal;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableLogic;
-import org.jeecg.common.constant.ProvinceCityArea;
-import org.jeecg.common.util.SpringContextUtils;
-import lombok.Data;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
-import org.jeecgframework.poi.excel.annotation.Excel;
-import org.jeecg.common.aspect.annotation.Dict;
 import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
 
 /**
  * @Description: 订单表
@@ -87,7 +83,7 @@ public class AppOrder implements Serializable {
     private String payType;
 	/**订单状态*/
 	@Excel(name = "订单状态", width = 15)
-    @Schema(description = "订单状态")
+    @Schema(description = "订单状态0初始 1、支付中 2、待使用 3、已使用 4、待评价 5、退款中 6、已退款")
     private String orderStatus;
 	/**二维码券号*/
 	@Excel(name = "二维码券号", width = 15)

+ 3 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppSitePlaceMapper.xml

@@ -20,7 +20,9 @@
             a.advance_time,
             MIN(b.original_price) AS original_price,
             MAX(b.selling_price) AS selling_price,
-            a.cover
+            a.cover,
+            a.reminder,
+            a.refund_type
         FROM
             nm_site_place a
                 LEFT JOIN nm_site_price_rules b ON a.id = b.site_place_id