Browse Source

refactor(order): 重构订单相关代码

- 移除 AppOrderUser 相关的 mapper、service 和 controller
- 更新 AppOrderDTO 和 AppOrder 实体类
- 重构 OrderServiceImpl 中的订单创建逻辑
- 更新 AppSitePriceRules 实体类
SheepHy 1 week ago
parent
commit
47e96ef669
13 changed files with 82 additions and 178 deletions
  1. 52 16
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/OrderServiceImpl.java
  2. 19 4
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/OrderVO.java
  3. 0 18
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppOrderUserController.java
  4. 0 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/dto/AppOrderDTO.java
  5. 4 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppIsin.java
  6. 0 101
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppOrderUser.java
  7. 6 6
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppSitePriceRules.java
  8. 0 17
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/AppOrderUserMapper.java
  9. 0 5
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppOrderUserMapper.xml
  10. 1 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppSiteMapper.xml
  11. 0 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppOrderUserService.java
  12. 0 6
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppOrderServiceImpl.java
  13. 0 2
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppOrderUserServiceImpl.java

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

@@ -19,6 +19,7 @@ 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;
@@ -40,7 +41,9 @@ public class OrderServiceImpl implements IOrderService {
     @Resource
     private AppOrderProductMapper appOrderProductMapper;
     @Resource
-    private AppOrderUserMapper appOrderUserMapper;
+    private AppSiteMapper appSiteMapper;
+    @Resource
+    private AppIsinMapper appIsinMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -49,11 +52,34 @@ public class OrderServiceImpl implements IOrderService {
         List<String> list = Arrays.asList(rulesId.split(","));
         AppOrder order = createOrder(list, 0, user.getId(), userIds);
         if(null == order) throw new JeecgBootException("创建订单失败!");
-        AppSitePlace appSitePlace = appSitePlaceMapper.selectById(list.get(0));
+        AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectById(list.get(0));
+        AppSitePlace appSitePlace = appSitePlaceMapper.selectById(appSitePriceRules.getSitePlaceId());
+        AppSite appSite = appSiteMapper.selectById(appSitePlace.getSiteId());
         OrderVO.createOrderPlaceSchool result = new OrderVO.createOrderPlaceSchool();
-//        result.setId(order.getId())
-//                .setOrderStatus(order.getOrderStatus())
-//                .setPlaceName()
+        List<OrderVO.couponNumberInformation> couponNumberInformation = new ArrayList<>();
+        List<AppIsin> appIsins = appIsinMapper.selectList(Wrappers.<AppIsin>lambdaQuery().eq(AppIsin::getOrderId, order.getId()));
+        appIsins.forEach(appIsin -> {
+            OrderVO.couponNumberInformation information = new OrderVO.couponNumberInformation();
+            information.setId(appIsin.getId())
+                    .setCouponCode(appIsin.getIsinCode())
+                    .setCouponStatus(appIsin.getIsinStatus())
+                    .setExpireTime(appIsin.getExpireTime());
+            couponNumberInformation.add(information);
+        });
+        result.setId(order.getId())
+                .setOrderStatus(order.getOrderStatus())
+                .setPlaceName(appSitePlace.getName())
+                .setDate(appSitePriceRules.getDateOfSale())
+                .setUserName(user.getRealname())
+                .setAddress(appSite.getAddress())
+                .setLongitude(appSite.getLongitude())
+                .setLatitude(appSite.getLatitude())
+                .setReminder(appSitePlace.getReminder())
+                .setOrderCode(order.getOrderCode())
+                .setMobile(user.getPhone())
+                .setCreateTime(order.getCreateTime())
+                .setPayTime(order.getPayTime())
+                .setCouponNumberInformation(couponNumberInformation);
         return null;
     }
 
@@ -195,6 +221,8 @@ public class OrderServiceImpl implements IOrderService {
                             .setCreateBy(userId)
                             .setUpdateBy(userId);
                     createOrderCoupon(s, userIds);
+                    appOrderMapper.insert(appOrder);
+                    createOrderProduct(appOrder, id);
                 }
                 break;
             case 1:
@@ -202,7 +230,6 @@ public class OrderServiceImpl implements IOrderService {
             case 2:
                 break;
         }
-        appOrderMapper.insert(appOrder);
         return appOrder;
     }
 
@@ -244,14 +271,23 @@ public class OrderServiceImpl implements IOrderService {
         });
     }
 
-//    /**
-//     * @Author SheepHy
-//     * @Description 生成订单明细
-//     * @Date 11:57 2025/7/16
-//     * @Param
-//     * @return
-//     **/
-//    private void createOrderProduct(String orderId, List<String> id,) {
-//
-//    }
+    /**
+     * @Author SheepHy
+     * @Description 生成订单明细
+     * @Date 11:57 2025/7/16
+     * @Param appOrder id
+     **/
+    private void createOrderProduct(AppOrder appOrder, List<String> id){
+        id.forEach(productId -> {
+            AppOrderProduct appOrderProduct = new AppOrderProduct();
+            appOrderProduct.setOrderId(appOrder.getId())
+                    .setProductId(appOrder.getProductIds())
+                    .setRuleId(productId)
+                    .setCreateBy(appOrder.getCreateBy())
+                    .setUpdateBy(appOrder.getUpdateBy())
+                    .setCreateTime(new Date())
+                    .setUpdateTime(new Date());
+            appOrderProductMapper.insert(appOrderProduct);
+        });
+    }
 }

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

@@ -132,10 +132,6 @@ public class OrderVO {
         private BigDecimal longitude;
         @Schema(description ="纬度")
         private BigDecimal latitude;
-        @Schema(description = "到期时间")
-        private Date expireTime;
-        @Schema(description = "券号")
-        private String couponCode;
         @Schema(description = "使用须知")
         private String reminder;
         /** 订单信息**/
@@ -149,6 +145,25 @@ public class OrderVO {
         private Date createTime;
         @Schema(description = "支付时间")
         private Date payTime;
+        @Schema(description = "学校场地预约-券号信息")
+        private List<couponNumberInformation> couponNumberInformation;
+    }
+
+    @Data
+    @Accessors(chain = true)
+    @EqualsAndHashCode(callSuper = false)
+    @Schema(description="学校场地预约-券号信息")
+    public static class couponNumberInformation{
+        @Schema(description = "券ID")
+        private String id;
+        @Schema(description = "用户名称")
+        private String userName;
+        @Schema(description = "券号")
+        private String couponCode;
+        @Schema(description = "券状态")
+        private int couponStatus;
+        @Schema(description = "到期时间")
+        private Date expireTime;
     }
 
 }

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

@@ -1,20 +1,10 @@
 package org.jeecg.modules.system.app.controller;
 
 import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.common.system.query.QueryRuleEnum;
-import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.system.app.entity.AppOrderUser;
 import org.jeecg.modules.system.app.service.IAppOrderUserService;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -22,18 +12,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 
-import org.jeecgframework.poi.excel.ExcelImportUtil;
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
-import org.jeecgframework.poi.excel.entity.ImportParams;
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
-import com.alibaba.fastjson.JSON;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.Operation;
 import org.jeecg.common.aspect.annotation.AutoLog;

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

@@ -9,7 +9,6 @@ import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
 import org.jeecg.modules.system.app.entity.AppOrder;
 import org.jeecg.modules.system.app.entity.AppOrderProduct;
-import org.jeecg.modules.system.app.entity.AppOrderUser;
 
 import java.util.List;
 

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

@@ -72,6 +72,10 @@ public class AppIsin implements Serializable {
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     @Schema(description = "更新时间;更新时间")
     private Date updateTime;
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @Schema(description = "到期时间;到期时间")
+    private Date expireTime;
 	/**系统状态;状态(0-正常,1-冻结)*/
 	@Excel(name = "系统状态;状态(0-正常,1-冻结)", width = 15)
     @Schema(description = "系统状态;状态(0-正常,1-冻结)")

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

@@ -1,101 +0,0 @@
-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.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.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-/**
- * @Description: 订单人员详细表
- * @Author: jeecg-boot
- * @Date:   2025-07-03
- * @Version: V1.0
- */
-@Data
-@TableName("nm_order_user")
-@Accessors(chain = true)
-@EqualsAndHashCode(callSuper = false)
-@Schema(description="订单人员详细表")
-public class AppOrderUser implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-	/**id*/
-	@TableId(type = IdType.ASSIGN_ID)
-    @Schema(description = "id")
-    private String id;
-	/**部门id*/
-	@Excel(name = "部门id", width = 15)
-    @Schema(description = "部门id")
-    private String orgCode;
-	/**租户id*/
-	@Excel(name = "租户id", width = 15)
-    @Schema(description = "租户id")
-    private String tenantId;
-	/**订单*/
-	@Excel(name = "订单", width = 15)
-    @Schema(description = "订单")
-    private String orderId;
-	/**人员名称*/
-	@Excel(name = "人员名称", width = 15)
-    @Schema(description = "人员名称")
-    private String name;
-	/**身份证*/
-	@Excel(name = "身份证", width = 15)
-    @Schema(description = "身份证")
-    private String idNumber;
-	/**电话*/
-	@Excel(name = "电话", width = 15)
-    @Schema(description = "电话")
-    private String phone;
-	/**保留1*/
-	@Excel(name = "保留1", width = 15)
-    @Schema(description = "保留1")
-    private String reserve1;
-	/**保留2*/
-	@Excel(name = "保留2", width = 15)
-    @Schema(description = "保留2")
-    private String reserve2;
-	/**乐观锁*/
-	@Excel(name = "乐观锁", width = 15)
-    @Schema(description = "乐观锁")
-    private Integer revision;
-	/**创建人;创建人*/
-    @Schema(description = "创建人;创建人")
-    private String createBy;
-	/**创建时间;创建时间*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
-    @Schema(description = "创建时间;创建时间")
-    private Date createTime;
-	/**更新人;更新人*/
-    @Schema(description = "更新人;更新人")
-    private String updateBy;
-	/**更新时间;更新时间*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
-    @Schema(description = "更新时间;更新时间")
-    private Date updateTime;
-	/**系统状态;状态(0-正常,1-冻结)*/
-	@Excel(name = "系统状态;状态(0-正常,1-冻结)", width = 15)
-    @Schema(description = "系统状态;状态(0-正常,1-冻结)")
-    private Integer status;
-	/**删除标志;删除状态(0-正常,1-已删除)*/
-	@Excel(name = "删除标志;删除状态(0-正常,1-已删除)", width = 15)
-    @Schema(description = "删除标志;删除状态(0-正常,1-已删除)")
-    @TableLogic
-    private Integer delFlag;
-}

+ 6 - 6
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/entity/AppSitePriceRules.java

@@ -94,15 +94,15 @@ public class AppSitePriceRules implements Serializable {
     /**创建人;创建人*/
     @Schema(description = "创建人;创建人")
     private String createBy;
-    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
-    @Schema(description = "销售日期")
-    private Date createTime;
-    /**创建时间;创建时间*/
     @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
     @DateTimeFormat(pattern="yyyy-MM-dd")
-    @Schema(description = "创建时间;创建时间")
+    @Schema(description = "销售日期")
     private Date dateOfSale;
+    /**创建时间;创建时间*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @Schema(description = "创建时间;创建时间")
+    private Date createTime;
     /**更新人;更新人*/
     @Schema(description = "更新人;更新人")
     private String updateBy;

+ 0 - 17
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/AppOrderUserMapper.java

@@ -1,17 +0,0 @@
-package org.jeecg.modules.system.app.mapper;
-
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-import org.jeecg.modules.system.app.entity.AppOrderUser;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
- * @Description: 订单人员详细表
- * @Author: jeecg-boot
- * @Date:   2025-07-03
- * @Version: V1.0
- */
-public interface AppOrderUserMapper extends BaseMapper<AppOrderUser> {
-
-}

+ 0 - 5
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppOrderUserMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="org.jeecg.modules.system.app.mapper.AppOrderUserMapper">
-
-</mapper>

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

@@ -4,7 +4,7 @@
     <select id="getPlaceList" resultType="org.jeecg.modules.app.vo.PlaceVO">
         SELECT
         b.id,
-        b.NAME,
+        c.depart_name AS name,
         b.good_rate AS goodRate,
         b.address,
         b.category_id,

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

@@ -1,6 +1,5 @@
 package org.jeecg.modules.system.app.service;
 
-import org.jeecg.modules.system.app.entity.AppOrderUser;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 /**

+ 0 - 6
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppOrderServiceImpl.java

@@ -4,19 +4,13 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.system.app.dto.AppOrderDTO;
 import org.jeecg.modules.system.app.entity.AppOrder;
-import org.jeecg.modules.system.app.entity.AppOrderProduct;
-import org.jeecg.modules.system.app.entity.AppOrderUser;
-import org.jeecg.modules.system.app.enums.OrderTypeEnum;
 import org.jeecg.modules.system.app.mapper.*;
 import org.jeecg.modules.system.app.service.IAppOrderService;
-import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.annotation.Resource;
-
 /**
  * @Description: 订单表
  * @Author: jeecg-boot

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

@@ -1,7 +1,5 @@
 package org.jeecg.modules.system.app.service.impl;
 
-import org.jeecg.modules.system.app.entity.AppOrderUser;
-import org.jeecg.modules.system.app.mapper.AppOrderUserMapper;
 import org.jeecg.modules.system.app.service.IAppOrderUserService;
 import org.springframework.stereotype.Service;