发放优惠券

This commit is contained in:
2025-12-03 09:54:00 +08:00
parent 990bd5b144
commit d5319c50ac
4 changed files with 64 additions and 26 deletions

View File

@@ -514,20 +514,8 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
/**
* 组装信息
*/
@Override
public MkShopCouponRecord assembleRecord(Long chatCouponId, ShopCoupon coupon) {
LocalDateTime start = LocalDateTime.now().with(LocalTime.MIN);
LocalDateTime end = null;
if ("fixed".equals(coupon.getValidType())) {
//固定时间
if (coupon.getDaysToTakeEffect() != null && coupon.getDaysToTakeEffect() > 0) {
start = LocalDateTimeUtil.offset(start, coupon.getDaysToTakeEffect(), ChronoUnit.DAYS).with(LocalTime.MIN);
}
end = LocalDateTimeUtil.offset(start, coupon.getValidDays(), ChronoUnit.DAYS).with(LocalTime.MAX).truncatedTo(ChronoUnit.SECONDS);
} else if ("custom".equals(coupon.getValidType())) {
//自定义时间
start = coupon.getValidStartTime();
end = coupon.getValidEndTime();
}
MkShopCouponRecord record = new MkShopCouponRecord();
record.setShopId(coupon.getShopId());
@@ -544,8 +532,13 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
record.setMaxDiscountAmount(coupon.getMaxDiscountAmount());
record.setCreateTime(LocalDateTime.now());
record.setIsDel(0);
record.setUseStartTime(start);
record.setUseEndTime(end);
if ("fixed".equals(coupon.getValidType())) {
record.setDaysToTakeEffect(coupon.getDaysToTakeEffect());
record.setValidDays(coupon.getValidDays());
} else if ("custom".equals(coupon.getValidType())) {
record.setUseStartTime(coupon.getValidStartTime());
record.setUseEndTime(coupon.getValidEndTime());
}
return record;
}
@@ -564,10 +557,20 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
return;
}
coupon.setGiftNum(coupon.getGiftNum() + number);
if ("fixed".equals(record.getValidType())) {
LocalDateTime start = LocalDateTime.now().with(LocalTime.MIN);
//固定时间
if (record.getDaysToTakeEffect() != null && record.getDaysToTakeEffect() > 0) {
start = LocalDateTimeUtil.offset(start, record.getDaysToTakeEffect(), ChronoUnit.DAYS).with(LocalTime.MIN);
}
LocalDateTime end = LocalDateTimeUtil.offset(start, record.getValidDays(), ChronoUnit.DAYS).with(LocalTime.MAX).truncatedTo(ChronoUnit.SECONDS);
record.setUseStartTime(start);
record.setUseEndTime(end);
}
for (int i = 0; i < number; i++) {
recordList.add(record);
}
mapper.insertBatchSelective(recordList, 50);
mapper.insertBatchSelective(recordList, 10);
QueryWrapper queryWrapper = new QueryWrapper();
ShopCoupon newCoupon = new ShopCoupon();