| | |
| | | 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.*; |
| | |
| | | @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()){ |
| | |
| | | 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() |