无关风月
2025-01-23 c3019597126f19e8508bd22e7da3a39058033510
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()