From c3019597126f19e8508bd22e7da3a39058033510 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 23 一月 2025 11:41:24 +0800
Subject: [PATCH] bug修改

---
 manage/src/main/java/com/jilongda/manage/controller/TCouponController.java |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/manage/src/main/java/com/jilongda/manage/controller/TCouponController.java b/manage/src/main/java/com/jilongda/manage/controller/TCouponController.java
index df84469..35c71de 100644
--- a/manage/src/main/java/com/jilongda/manage/controller/TCouponController.java
+++ b/manage/src/main/java/com/jilongda/manage/controller/TCouponController.java
@@ -45,6 +45,7 @@
 import java.awt.image.BufferedImage;
 import java.io.IOException;
 import java.io.InputStream;
+import java.math.BigDecimal;
 import java.nio.charset.StandardCharsets;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -77,6 +78,9 @@
     @ApiOperation(value = "添加优惠券")
     @PostMapping(value = "/add")
     public ApiResult<String> add( @RequestBody TCoupon dto) throws Exception {
+        if (dto.getTime()!=null && dto.getTime()>365){
+            return ApiResult.failed("优惠券有效期不能大于365天");
+        }
         if (dto.getType()==1||dto.getType()==4)dto.setGrantStatus(1);
         couponService.save(dto);
         switch (dto.getType()){
@@ -157,10 +161,11 @@
         int size = couponReceiveService.list(new LambdaQueryWrapper<TCouponReceive>()
                 .eq(TCouponReceive::getCouponId, id)).size();
         tCouponInfoVO.setGrantCout(size);
-        int size1 = couponReceiveService.list(new LambdaQueryWrapper<TCouponReceive>()
+        List<TCouponReceive> list = couponReceiveService.list(new LambdaQueryWrapper<TCouponReceive>()
                 .eq(TCouponReceive::getCouponId, id)
-                .eq(TCouponReceive::getStatus, 2)).size();
-        tCouponInfoVO.setUseCount(size1);
+                .eq(TCouponReceive::getStatus, 2));
+        list.stream().map(TCouponReceive::getAmount).reduce(BigDecimal::add).ifPresent(tCouponInfoVO::setUseMoney);
+        tCouponInfoVO.setUseCount(list.size());
         if (byId.getType()==3){
             // 查询领取人
             List<Integer> collect = couponReceiveService.lambdaQuery()

--
Gitblit v1.7.1