Browse Source

refactor(app): 重构 AppIsinService 并优化订单相关功能

- 重构 AppIsinService 接口和实现类,移动到 app 包下
-优化 OrderServiceImpl 中的价格计算逻辑,增加格式化处理
- 更新 AppSitePriceRulesMapper.xml 中的 SQL 查询
- 新增 UseIsinInfoVO 类用于券使用记录返回参数
SheepHy 1 week ago
parent
commit
34e4e98863

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

@@ -0,0 +1,11 @@
+package org.jeecg.modules.app.service;
+
+public interface IAppIsinService {
+    /**
+     * @Author SheepHy
+     * @Description 券使用记录
+     * @Date 16:10 2025/7/16
+     * @Param
+     * @return
+     **/
+}

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

@@ -0,0 +1,10 @@
+package org.jeecg.modules.app.service.impl;
+
+import lombok.extern.log4j.Log4j2;
+import org.jeecg.modules.app.service.IAppIsinService;
+import org.springframework.stereotype.Service;
+
+@Service
+@Log4j2
+public class AppIsinServiceImpl implements IAppIsinService {
+}

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

@@ -131,11 +131,20 @@ public class OrderServiceImpl implements IOrderService {
         List<String> list = Arrays.asList(rulesId.split(","));
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         OrderVO.PreviewOrderPlaceGymnasiumChartered result = new OrderVO.PreviewOrderPlaceGymnasiumChartered();
-        List<AppSitePriceRules> priceRules = appSitePriceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery()
-                .in(AppSitePriceRules::getId, rulesId));
+        List<AppSitePriceRules> priceRules = new ArrayList<>();
+        list.forEach(priceRule -> {
+            AppSitePriceRules appSitePriceRule = appSitePriceRulesMapper.selectById(priceRule);
+            priceRules.add(appSitePriceRule);
+        });
         BigDecimal totalPrice = priceRules.stream()
                 .map(AppSitePriceRules::getSellingPrice)
                 .reduce(BigDecimal.ZERO, BigDecimal::add);
+        // 格式化 totalPrice 和 subtotal 为两位小数
+        totalPrice = totalPrice.setScale(2, BigDecimal.ROUND_HALF_UP);
+        String formattedTotalPrice = totalPrice.toString(); // 直接使用 toString() 保留两位小数
+        String formattedSubtotal = totalPrice.toString();   // 小计与总价相同
+        result.setTotalPrice(new BigDecimal(formattedTotalPrice)); // 设置格式化后的 totalPrice
+        result.setSubtotal(new BigDecimal(formattedSubtotal));
         if (priceRules.isEmpty()) {
             throw new IllegalArgumentException("未找到对应的价格规则");
         }

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

@@ -1,9 +1,11 @@
 package org.jeecg.modules.app.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -103,8 +105,12 @@ public class OrderVO {
         private String id;
         @Schema(description = "时间段名称")
         private String name;
+        @JsonFormat(timezone = "GMT+8",pattern = "HH:mm:ss")
+        @DateTimeFormat(pattern="HH:mm:ss")
         @Schema(description = "开始时间")
         private Date startTime;
+        @JsonFormat(timezone = "GMT+8",pattern = "HH:mm:ss")
+        @DateTimeFormat(pattern="HH:mm:ss")
         @Schema(description = "结束时间")
         private Date endTime;
     }

+ 16 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/UseIsinInfoVO.java

@@ -0,0 +1,16 @@
+package org.jeecg.modules.app.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description="券使用记录返回参数VO")
+public class UseIsinInfoVO {
+    @Schema(description = "券id")
+    private String id;
+
+}

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

@@ -76,10 +76,10 @@
         WHEN DATE(a.date_of_sale) = CURDATE() THEN '(今天)'
         WHEN DATE(a.date_of_sale) = DATE_ADD(CURDATE(), INTERVAL 1 DAY) THEN '(明天)'
         WHEN DATE(a.date_of_sale) = DATE_ADD(CURDATE(), INTERVAL 2 DAY) THEN '(后天)'
-        ELSE ''
+        ELSE '-'
         END,
-        TIME_FORMAT(a.start_time, '%H:%i'), '-', TIME_FORMAT(a.end_time, '%H:%i'), ' | ', b.[name](file://F:\IdeaProject\national-motion\national-motion-backend\national-motion-module-system\national-motion-system-biz\src\main\java\org\jeecg\modules\app\vo\PlaceVO.java#L18-L19)
-        ) AS `name`
+        TIME_FORMAT(a.start_time, '%H:%i'), '-', TIME_FORMAT(a.end_time, '%H:%i'), ' | ', b.`name`
+        ) AS `name`,
         a.id,
         a.start_time,
         a.end_time

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

@@ -1,14 +0,0 @@
-package org.jeecg.modules.system.app.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import org.jeecg.modules.system.app.entity.AppIsin;
-
-/**
- * @Description: nm_isin
- * @Author: jeecg-boot
- * @Date:   2025-07-16
- * @Version: V1.0
- */
-public interface IAppIsinService extends IService<AppIsin> {
-
-}

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

@@ -1,18 +0,0 @@
-package org.jeecg.modules.system.app.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.jeecg.modules.system.app.entity.AppIsin;
-import org.jeecg.modules.system.app.mapper.AppIsinMapper;
-import org.jeecg.modules.system.app.service.IAppIsinService;
-import org.springframework.stereotype.Service;
-
-/**
- * @Description: nm_isin
- * @Author: jeecg-boot
- * @Date:   2025-07-16
- * @Version: V1.0
- */
-@Service
-public class AppIsinServiceImpl extends ServiceImpl<AppIsinMapper, AppIsin> implements IAppIsinService {
-
-}