优惠券结束时间

This commit is contained in:
张松
2025-09-28 15:24:28 +08:00
parent cbef1e5fd4
commit b3e84d142c
2 changed files with 15 additions and 1 deletions

View File

@@ -1,5 +1,8 @@
package com.czg.market.entity; package com.czg.market.entity;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.KeyType;
@@ -10,6 +13,7 @@ import java.sql.Time;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.io.Serial; import java.io.Serial;
import java.time.LocalTime;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@@ -241,4 +245,10 @@ public class ShopCoupon implements Serializable {
*/ */
private Integer isDel; private Integer isDel;
public void setInfo() {
if ("fixed".equals(getValidType())) {
setValidEndTime(LocalDateTime.now().plusDays(validDays));
}
}
} }

View File

@@ -102,7 +102,11 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
if (!couponIdList.isEmpty()) { if (!couponIdList.isEmpty()) {
Map<Long, ShopCoupon> couponMap = shopCouponService.list(new QueryWrapper().in(ShopCoupon::getId, couponIdList)).stream().collect(Collectors.toMap(ShopCoupon::getId, v -> v)); Map<Long, ShopCoupon> couponMap = shopCouponService.list(new QueryWrapper().in(ShopCoupon::getId, couponIdList)).stream().collect(Collectors.toMap(ShopCoupon::getId, v -> v));
couponInfoDTOS.forEach(item -> { couponInfoDTOS.forEach(item -> {
couponInfoVOS.add(new CouponInfoVO().setCoupon(couponMap.get(item.getId())).setNum(item.getNum())); ShopCoupon shopCoupon = couponMap.get(item.getId());
if (shopCoupon != null) {
shopCoupon.setInfo();
}
couponInfoVOS.add(new CouponInfoVO().setCoupon(shopCoupon).setNum(item.getNum()));
}); });
} }
detailVO.setCouponInfoList(couponInfoVOS); detailVO.setCouponInfoList(couponInfoVOS);