Преглед изворни кода

feat(app):
1.订单实体增加数量amount字段
2.部分订单逻辑

wzq пре 3 дана
родитељ
комит
a5cdef422d
11 измењених фајлова са 311 додато и 48 уклоњено
  1. 29 21
      national-motion-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java
  2. 9 4
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/OrderController.java
  3. 32 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/form/CreateOrderForm.java
  4. 36 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/form/InsureOrderInfoForm.java
  5. 19 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/form/UserPayForm.java
  6. 4 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/IOrderService.java
  7. 160 20
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/OrderServiceImpl.java
  8. 3 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/dto/AppSitePlaceUnfixedDTO.java
  9. 11 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppOrder.java
  10. 3 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppSitePlace.java
  11. 5 2
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppSitePlaceServiceImpl.java

+ 29 - 21
national-motion-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java

@@ -30,7 +30,7 @@ public interface CommonConstant {
 	 * 系统日志类型: 登录
 	 */
 	int LOG_TYPE_1 = 1;
-	
+
 	/**
 	 * 系统日志类型: 操作
 	 */
@@ -50,27 +50,27 @@ public interface CommonConstant {
 	 * 操作日志类型: 查询
 	 */
 	int OPERATE_TYPE_1 = 1;
-	
+
 	/**
 	 * 操作日志类型: 添加
 	 */
 	int OPERATE_TYPE_2 = 2;
-	
+
 	/**
 	 * 操作日志类型: 更新
 	 */
 	int OPERATE_TYPE_3 = 3;
-	
+
 	/**
 	 * 操作日志类型: 删除
 	 */
 	int OPERATE_TYPE_4 = 4;
-	
+
 	/**
 	 * 操作日志类型: 倒入
 	 */
 	int OPERATE_TYPE_5 = 5;
-	
+
 	/**
 	 * 操作日志类型: 导出
 	 */
@@ -85,7 +85,7 @@ public interface CommonConstant {
     Integer SC_INTERNAL_NOT_FOUND_404 = 404;
     /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
     Integer SC_OK_200 = 200;
-    
+
     /**访问权限认证未通过 510*/
     Integer SC_JEECG_NO_AUTHZ=510;
 
@@ -109,7 +109,7 @@ public interface CommonConstant {
      */
     Integer MENU_TYPE_0  = 0;
    /**
-    *  1:子菜单 
+    *  1:子菜单
     */
     Integer MENU_TYPE_1  = 1;
     /**
@@ -120,28 +120,28 @@ public interface CommonConstant {
     /**通告对象类型(USER:指定用户,ALL:全体用户)*/
     String MSG_TYPE_UESR  = "USER";
     String MSG_TYPE_ALL  = "ALL";
-    
+
     /**发布状态(0未发布,1已发布,2已撤销)*/
     String NO_SEND  = "0";
     String HAS_SEND  = "1";
     String HAS_CANCLE  = "2";
-    
+
     /**阅读状态(0未读,1已读)*/
     Integer HAS_READ_FLAG  = 1;
     Integer NO_READ_FLAG  = 0;
-    
+
     /**优先级(L低,M中,H高)*/
     String PRIORITY_L  = "L";
     String PRIORITY_M  = "M";
     String PRIORITY_H  = "H";
-    
+
     /**
      * 短信模板方式  0 .登录模板、1.注册模板、2.忘记密码模板
      */
     String SMS_TPL_TYPE_0  = "0";
     String SMS_TPL_TYPE_1  = "1";
     String SMS_TPL_TYPE_2  = "2";
-    
+
     /**
      * 状态(0无效1有效)
      */
@@ -161,7 +161,7 @@ public interface CommonConstant {
      */
     String MSG_CATEGORY_1 = "1";
     String MSG_CATEGORY_2 = "2";
-    
+
     /**
      * 是否配置菜单的数据权限 1是0否
      */
@@ -174,7 +174,7 @@ public interface CommonConstant {
     Integer USER_UNFREEZE = 1;
     Integer USER_FREEZE = 2;
     Integer USER_QUIT = 3;
-    
+
     /**字典翻译文本后缀*/
     String DICT_TEXT_SUFFIX = "_dictText";
     /**字典翻译颜色后缀*/
@@ -409,7 +409,7 @@ public interface CommonConstant {
      * https:// https协议
      */
     String HTTPS_PROTOCOL = "https://";
-    
+
     /** 部门表唯一key,id */
     String DEPART_KEY_ID = "id";
     /** 部门表唯一key,orgCode */
@@ -514,7 +514,7 @@ public interface CommonConstant {
     * 用户租户状态(审核中)
     */
    String USER_TENANT_UNDER_REVIEW = "3";
-   
+
    /**
     * 用户租户状态(拒绝)
     */
@@ -524,7 +524,7 @@ public interface CommonConstant {
     * 用户租户状态(邀请)
     */
    String USER_TENANT_INVITE = "5";
-   
+
    /**
     * 不是叶子节点
     */
@@ -600,7 +600,7 @@ public interface CommonConstant {
     */
    public static final String SAAS_MODE_TENANT = "tenant";
    //update-end---author:scott ---date::2023-09-10  for:积木报表常量----
- 
+
    //update-begin---author:wangshuai---date:2024-04-07---for:修改手机号常量---
    /**
     * 修改手机号短信验证码redis-key的前缀
@@ -616,7 +616,7 @@ public interface CommonConstant {
      * 缓存用户最后一次收到消息通知的时间 KEY
      */
    String CACHE_KEY_USER_LAST_ANNOUNT_TIME_1HOUR = "sys:cache:userinfo:user_last_annount_time::%s";
-   
+
    /**
     * 验证原手机号
     */
@@ -627,7 +627,7 @@ public interface CommonConstant {
     */
    String UPDATE_PHONE = "updatePhone";
    //update-end---author:wangshuai---date:2024-04-07---for:修改手机号常量---
-    
+
    /**
     * 修改手机号验证码请求次数超出
     */
@@ -637,4 +637,12 @@ public interface CommonConstant {
     * 教练
     * */
    String INSTRUCTOR = "instructor";
+
+    /**
+     * 订单类型(0-场地 1-赛事 2-课程)
+     */
+   Integer ORDER_TYPE_0 = 0;
+   Integer ORDER_TYPE_1 = 1;
+   Integer ORDER_TYPE_2 = 2;
+
 }

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

@@ -6,13 +6,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.app.form.CreateOrderForm;
+import org.jeecg.modules.app.form.UserPayForm;
 import org.jeecg.modules.app.service.IOrderService;
 import org.jeecg.modules.app.vo.OrderVO;
 import org.springframework.format.annotation.DateTimeFormat;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Date;
@@ -107,4 +106,10 @@ public class OrderController {
     public Result<List<OrderVO.PreviewOrderPlaceSchoolTime>> previewOrderPlaceSchoolTime(@RequestParam("placeId") @Schema(description = "当前选择场次ID")String placeId){
         return Result.ok(appOrderService.previewOrderPlaceSchoolTime(placeId));
     }
+
+    @Operation(summary = "学校场地预约-创建")
+    @PostMapping("/createOrder")
+    public Result<UserPayForm> schoolPlaceOrder(@RequestBody CreateOrderForm createOrderForm) {
+        return Result.ok(appOrderService.schoolPlaceOrder(createOrderForm));
+    }
 }

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

@@ -0,0 +1,32 @@
+package org.jeecg.modules.app.form;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description = "订单表单对象")
+public class CreateOrderForm implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    //订单类型;0场地1赛事2课程
+    @NotNull(message = "订单类型不能为空")
+    public Integer type;
+
+    //商品IDs
+    private String productIds;
+
+    //使用人IDs
+    private String familyIds;
+
+    //保险表单
+    private InsureOrderInfoForm insureOrderInfoForm;
+
+}

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

@@ -0,0 +1,36 @@
+package org.jeecg.modules.app.form;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description = "保险订单表单对象")
+public class InsureOrderInfoForm implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    //保险ID
+    private Integer insureId;
+
+    //生效时间
+    private Date assertStartTime;
+
+    private Date assertEndTime;
+
+    //保单费用(单价)
+    private BigDecimal money;
+
+    //保险用户编号
+    private String familyMembersIds;
+
+    //保单总金额
+    private BigDecimal amount;
+}

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

@@ -0,0 +1,19 @@
+package org.jeecg.modules.app.form;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description = "支付表单对象")
+public class UserPayForm implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String orderCode;
+}

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

@@ -1,5 +1,7 @@
 package org.jeecg.modules.app.service;
 
+import org.jeecg.modules.app.form.CreateOrderForm;
+import org.jeecg.modules.app.form.UserPayForm;
 import org.jeecg.modules.app.vo.OrderVO;
 
 import java.util.Date;
@@ -60,4 +62,6 @@ public interface IOrderService {
      * @return OrderVO.PreviewOrderPlaceSchoolTime {@link OrderVO.PreviewOrderPlaceSchoolTime}
      **/
     List<OrderVO.PreviewOrderPlaceSchoolTime> previewOrderPlaceSchoolTime(String placeId);
+
+    UserPayForm schoolPlaceOrder(CreateOrderForm createOrderForm);
 }

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

@@ -3,10 +3,15 @@ package org.jeecg.modules.app.service.impl;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.app.form.CreateOrderForm;
+import org.jeecg.modules.app.form.InsureOrderInfoForm;
+import org.jeecg.modules.app.form.UserPayForm;
 import org.jeecg.modules.app.service.IOrderService;
 import org.jeecg.modules.app.vo.OrderVO;
 import org.jeecg.modules.system.app.entity.*;
@@ -20,11 +25,9 @@ import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.concurrent.ThreadLocalRandom;
+import java.util.stream.Collectors;
 
 @Service
 @Log4j2
@@ -49,6 +52,10 @@ public class OrderServiceImpl implements IOrderService {
     private FamilyMembersMapper familyMembersMapper;
     @Resource
     private AppTeachingTimeMapper appTeachingTimeMapper;
+    @Resource
+    private InsureOrderInfoMapper insureOrderInfoMapper;
+    @Resource
+    private AppInsureMapper appInsureMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -56,7 +63,7 @@ public class OrderServiceImpl implements IOrderService {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         List<String> list = Arrays.asList(rulesId.split(","));
         AppOrder order = createOrder(list, 0, user.getId(), userIds);
-        if(null == order) throw new JeecgBootException("创建订单失败!");
+        if (null == order) throw new JeecgBootException("创建订单失败!");
         AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectById(list.get(0));
         AppSitePlace appSitePlace = appSitePlaceMapper.selectById(appSitePriceRules.getSitePlaceId());
         AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
@@ -112,7 +119,7 @@ public class OrderServiceImpl implements IOrderService {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         OrderVO.PreviewOrderCourse previousOrderCourse = new OrderVO.PreviewOrderCourse();
         AppCourses appCourses = appCoursesMapper.selectById(courseId);
-        if (appCourses==null|| StringUtils.isEmpty(appCourses.getCover())){
+        if (appCourses == null || StringUtils.isEmpty(appCourses.getCover())) {
             throw new JeecgBootException("未查询到课程数据");
         }
         List<String> list = Arrays.asList(appCourses.getCover().split(","));
@@ -123,12 +130,12 @@ public class OrderServiceImpl implements IOrderService {
                 .setSellingPrice(appCourses.getSellingPrice())
                 .setReminder(appCourses.getReminder())
                 .setHasDiscount(checkCourseDiscount);
-        if(checkCourseDiscount){
+        if (checkCourseDiscount) {
             previousOrderCourse.setDiscountPrice(appCourses.getSellingPrice());
             previousOrderCourse.setTotalDiscount(appCourses.getSellingPrice());
             previousOrderCourse.setSubtotal(appCourses.getSellingPrice().subtract(appCourses.getSellingPrice()));
             previousOrderCourse.setTotalPrice(appCourses.getSellingPrice().subtract(appCourses.getSellingPrice()));
-        }else {
+        } else {
             previousOrderCourse.setDiscountPrice(BigDecimal.ZERO);
             previousOrderCourse.setTotalDiscount(BigDecimal.ZERO);
             previousOrderCourse.setSubtotal(appCourses.getSellingPrice());
@@ -184,11 +191,122 @@ public class OrderServiceImpl implements IOrderService {
     }
 
     /**
+     * 创建订单
+     *
+     * @param createOrderForm
+     * @return 支付订单对象
+     */
+    @Override
+    public UserPayForm schoolPlaceOrder(CreateOrderForm createOrderForm) {
+        //获取登录用户
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        String orderCode = generateOrderNumber(0);
+
+        //创建订单
+        AppOrder appOrder = new AppOrder();
+        appOrder
+                .setOrderCode(orderCode)
+                .setUserId(user.getId())
+                .setOrgCode(user.getOrgCode())
+                .setUserPhone(user.getPhone())
+                .setPayTime(new Date())
+                .setOrderStatus(0)
+        ;
+
+        //订单内容
+        switch (createOrderForm.getType()) {
+            //场地
+            case 0:
+                List<AppSitePriceRules> priceRules = appSitePriceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery()
+                        .in(AppSitePriceRules::getId, List.of(createOrderForm.getProductIds().split(","))));
+                //订单金额
+                BigDecimal totalPrice = priceRules.stream()
+                        .map(AppSitePriceRules::getSellingPrice)
+                        .reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+
+                if (priceRules.get(0).getType() == 0) {
+                    if (totalPrice.compareTo(BigDecimal.ZERO) == 0) {
+                        appOrder.setPayType(3)
+                                .setOrderStatus(2)
+                                .setPayTime(new Date());
+                    } else {
+                        appOrder.setPayType(2)
+                                .setOrderStatus(0);
+                    }
+                }
+                    appOrder
+                            .setOrderCode(priceRules.get(0).getOrgCode())
+                            .setProductIds(priceRules.get(0).getSitePlaceId())
+                            .setType(0)
+                            .setOriginalPrice(totalPrice)
+                            .setPrice(totalPrice)
+                            .setCreateTime(new Date())
+                            .setUpdateTime(new Date())
+                            .setCreateBy(user.getId())
+                            .setUpdateBy(user.getId());
+                break;
+            //赛事
+            case 1:
+
+                break;
+            //课程
+            case 2:
+                //如果当前课程商品类目是第一次购买,触发免费政策
+                HashMap<String, Boolean> stringBooleanHashMap = new HashMap<>();
+                List<String> productId = Arrays.stream(appOrder.getProductIds().split(",")).collect(Collectors.toList());
+                List<AppCourses> appCourses = appCoursesMapper.selectList(Wrappers.<AppCourses>lambdaQuery().in(AppCourses::getId, productId));
+                for (AppCourses appCours : appCourses) {
+                    Boolean b = checkOrderOrFree(user.getId(), appCours.getCategoryId());
+                    stringBooleanHashMap.put(appCours.getCategoryId(), b);
+                }
+
+
+                break;
+
+        }
+        appOrderMapper.insert(appOrder);
+
+        //构建保单内容
+        InsureOrderInfoForm insureOrderInfoForm = createOrderForm.getInsureOrderInfoForm();
+        if (ObjectUtils.isNotEmpty(insureOrderInfoForm)) {
+            List<String> ids = Arrays.stream(insureOrderInfoForm.getFamilyMembersIds().split(",")).collect(Collectors.toList());
+            AppInsure appInsure = appInsureMapper.selectById(insureOrderInfoForm.getInsureId());
+            for (String id : ids) {
+                //创建保单
+                InsureOrderInfo insureOrderInfo = new InsureOrderInfo();
+                insureOrderInfo
+                        .setOrderId(appOrder.getId())
+                        .setBdOrderNo("0000000000")
+                        .setInsureName(appInsure.getInsuranceType_dictText())
+                        .setInsureCompany(appInsure.getInsuranceName_dictText())
+                        .setInsureId(appInsure.getId())
+                        .setMoney(insureOrderInfoForm.getMoney())
+                        .setUserId(id)
+                        .setAssertStartTime(insureOrderInfoForm.getAssertStartTime())
+                        .setAssertEndTime(insureOrderInfoForm.getAssertEndTime())
+                        .setIsEnterSystem(CommonConstant.STATUS_0_INT)
+                ;
+                insureOrderInfoMapper.insert(insureOrderInfo);
+            }
+        }
+
+        //构建支付表单返回给前端支撑支付调用
+        UserPayForm payForm = new UserPayForm();
+        payForm
+                .setOrderCode(orderCode)
+        ;
+        return payForm;
+
+    }
+
+
+    /**
+     * @return boolean
      * @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;
@@ -198,7 +316,7 @@ public class OrderServiceImpl implements IOrderService {
                 .ne(AppOrder::getOrderStatus, 5)
                 .eq(AppOrder::getStatus, 0)
                 .eq(AppOrder::getDelFlag, 0)
-                .eq(AppOrder::getType,2));
+                .eq(AppOrder::getType, 2));
         if (appOrders.isEmpty()) return true;
         for (AppOrder appOrder : appOrders) {
             if (!appOrder.getProductIds().contains(categoryId)) {
@@ -210,30 +328,30 @@ public class OrderServiceImpl implements IOrderService {
     }
 
     /**
+     * @return
      * @Author SheepHy
      * @Description 根据不同的类型生成订单及订单明细
      * @Date 15:09 2025/7/15
      * @Param id type userId
-     * @return
      **/
     @Transactional
     public AppOrder createOrder(List<String> id, int type, String userId, String userIds) {
         //todo 保险 闸机待接入
         //订单类型;0场地1赛事2课程
         AppOrder appOrder = new AppOrder();
-        switch(type){
+        switch (type) {
             case 0:
                 List<AppSitePriceRules> priceRules = appSitePriceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery()
                         .in(AppSitePriceRules::getId, id));
                 BigDecimal totalPrice = priceRules.stream()
                         .map(AppSitePriceRules::getSellingPrice)
                         .reduce(BigDecimal.ZERO, BigDecimal::add);
-                if(priceRules.get(0).getType() == 0){
-                    if(totalPrice.compareTo(BigDecimal.ZERO) == 0){
+                if (priceRules.get(0).getType() == 0) {
+                    if (totalPrice.compareTo(BigDecimal.ZERO) == 0) {
                         appOrder.setPayType(3)
                                 .setOrderStatus(2)
                                 .setPayTime(new Date());
-                    }else {
+                    } else {
                         appOrder.setPayType(2)
                                 .setOrderStatus(1);
                     }
@@ -255,6 +373,7 @@ public class OrderServiceImpl implements IOrderService {
                 }
                 break;
             case 1:
+
                 break;
             case 2:
 
@@ -264,27 +383,27 @@ public class OrderServiceImpl implements IOrderService {
     }
 
     /**
+     * @return String 订单号
      * @Author SheepHy
      * @Description 订单编号生成逻辑
      * @Date 17:18 2025/7/15
-     * @return String 订单号
      **/
     private String generateOrderNumber(int type) {
         String format = DateUtil.format(new Date(), "yyyyMMddHHmmss");
         int nextInt = ThreadLocalRandom.current().nextInt(1000, 10000);
-        if(type == 0){
+        if (type == 0) {
             return "D" + format + nextInt;
-        }else {
+        } else {
             return "T" + format + nextInt;
         }
     }
 
     /**
+     * @return
      * @Author SheepHy
      * @Description 根据订单及购买人数生成对应券码
      * @Date 10:20 2025/7/16
      * @Param
-     * @return
      **/
     private void createOrderCoupon(String orderId, String userIds) {
         String lastFourDigits = orderId.substring(orderId.length() - 4);
@@ -307,7 +426,7 @@ public class OrderServiceImpl implements IOrderService {
      * @Date 11:57 2025/7/16
      * @Param appOrder id
      **/
-    private void createOrderProduct(AppOrder appOrder, List<String> id){
+    private void createOrderProduct(AppOrder appOrder, List<String> id) {
         id.forEach(productId -> {
             AppOrderProduct appOrderProduct = new AppOrderProduct();
             appOrderProduct.setOrderId(appOrder.getId())
@@ -320,4 +439,25 @@ public class OrderServiceImpl implements IOrderService {
             appOrderProductMapper.insert(appOrderProduct);
         });
     }
+
+    /**
+     * 校验是否为第一次购买当前类目的课程
+     * @param userId
+     * @param categoryId
+     * @return
+     */
+    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) {
+            List<String> productId = Arrays.stream(appOrder.getProductIds().split(",")).collect(Collectors.toList());
+            List<AppCourses> appCourses = appCoursesMapper.selectList(Wrappers.<AppCourses>lambdaQuery().in(AppCourses::getId, productId));
+            for (AppCourses appCours : appCourses) {
+                if (appCours.getCategoryId().equals(categoryId)) {
+                    return Boolean.TRUE;
+                }
+            }
+        }
+        return Boolean.FALSE;
+    }
 }

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

@@ -56,6 +56,9 @@ public class AppSitePlaceUnfixedDTO {
     @Excel(name = "不可用日期;多个逗号分割", width = 15)
     @Schema(description = "不可用日期;多个逗号分割")
     private String downTime;
+    @Excel(name = "预约:0否 1是", width = 15)
+    @Schema(description = "预约:0否 1是")
+    private Integer orSubscribe;
     /**提前预约时间:0免预约 单位:时*/
     @Excel(name = "提前预约时间:0免预约 单位:时", width = 15)
     @Schema(description = "提前预约时间:0免预约 单位:时")

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

@@ -50,10 +50,20 @@ public class AppOrder implements Serializable {
 	@Excel(name = "产品id列表;场地/赛事/课程", width = 15)
     @Schema(description = "产品id列表;场地/赛事/课程")
     private String productIds;
+    /**商品数量*/
+    @Excel(name = "商品数量", width = 15)
+    @Schema(description = "商品数量")
+    private Integer amount;
 	/**用户id*/
 	@Excel(name = "用户id", width = 15)
     @Schema(description = "用户id")
     private String userId;
+    /**
+     * 用户手机号
+     */
+    @Excel(name = "用户手机号", width = 15)
+    @Schema(description = "用户手机号")
+    private String userPhone;
 	/**原订单总价*/
 	@Excel(name = "原订单总价", width = 15)
     @Schema(description = "原订单总价")
@@ -72,7 +82,7 @@ public class AppOrder implements Serializable {
     private String payId;
 	/**支付类型;0 wx 1zfb 2yl*/
 	@Excel(name = "支付类型;0 wx 1zfb 2yl", width = 15)
-    @Schema(description = "支付类型;0 wx 1zfb 2yl")
+    @Schema(description = "支付类型;0 wx 1zfb 2yl 3free")
     private int payType;
 	/**订单状态*/
 	@Excel(name = "订单状态", width = 15)

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

@@ -114,6 +114,9 @@ public class AppSitePlace implements Serializable {
 	@Excel(name = "不可用日期;多个逗号分割", width = 15)
     @Schema(description = "不可用日期;多个逗号分割")
     private String downTime;
+    @Excel(name = "预约:0否 1是", width = 15)
+    @Schema(description = "预约:0否 1是")
+    private Integer orSubscribe;
 	/**提前预约时间:0免预约 单位:时*/
 	@Excel(name = "提前预约时间:0免预约 单位:时", width = 15)
     @Schema(description = "提前预约时间:0免预约 单位:时")

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

@@ -257,7 +257,9 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
                     .setType(SitePlaceTypeEnum.UNFIXED.getCode())
                     .setOriginalPrice(unsetDTO.getOriginalPrice())
                     .setSellingPrice(unsetDTO.getSellingPrice())
-                    .setDayOfWeek(week);
+                    .setDayOfWeek(week)
+                    .setStatus(CommonConstant.STATUS_NORMAL)
+                    .setDelFlag(CommonConstant.STATUS_NORMAL)
             ;
             if (downTimes.contains(week)) {
                 appSitePriceRules.setStatus(1);
@@ -330,7 +332,8 @@ public class AppSitePlaceServiceImpl extends ServiceImpl<AppSitePlaceMapper, App
         LambdaQueryWrapper<AppSitePlace> wrapper = Wrappers.<AppSitePlace>lambdaQuery().eq(AppSitePlace::getType, SitePlaceTypeEnum.UNFIXED.getCode())
 //                .eq(AppSitePlace::getSiteId, dto.getSiteId())
                 .eq(AppSitePlace::getOrgCode, loginUser.getOrgCode())
-                .like(StringUtils.isNotBlank(dto.getName()), AppSitePlace::getName, dto.getName());
+                .eq(AppSitePlace::getType, SitePlaceTypeEnum.UNFIXED.getCode())
+                .like(StringUtils.isNotBlank(dto.getName()), AppSitePlace::getName, dto.getName()).orderByDesc(AppSitePlace::getCreateTime);
 
         IPage<AppSitePlace> resultPage = baseMapper.selectPage(page, wrapper);
         return resultPage.convert(record -> {