Compare commits

...

2 Commits

Author SHA1 Message Date
wangw 08d87469ff Merge remote-tracking branch 'origin/test' into test 2025-09-17 11:22:24 +08:00
wangw 66369da7f1 新特性 2025-09-17 11:22:16 +08:00
1 changed files with 7 additions and 12 deletions

View File

@ -7,7 +7,6 @@ import cn.hutool.core.exceptions.ValidateException;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.account.vo.UserCouponVo; import com.czg.account.vo.UserCouponVo;
import com.czg.market.dto.ShopCouponDTO; import com.czg.market.dto.ShopCouponDTO;
@ -16,7 +15,6 @@ import com.czg.market.entity.ShopCoupon;
import com.czg.market.service.MkCouponGiftService; import com.czg.market.service.MkCouponGiftService;
import com.czg.market.service.MkShopCouponRecordService; import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.service.ShopCouponService; import com.czg.market.service.ShopCouponService;
import com.czg.product.service.ProductService;
import com.czg.service.market.mapper.ShopCouponMapper; import com.czg.service.market.mapper.ShopCouponMapper;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import com.czg.utils.PageUtil; import com.czg.utils.PageUtil;
@ -36,8 +34,6 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static java.lang.StringTemplate.STR;
/** /**
* 优惠券信息表 服务层实现 * 优惠券信息表 服务层实现
* *
@ -84,17 +80,17 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
if (param.getGiveNum() != -10086) { if (param.getGiveNum() != -10086) {
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) { if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
throw new ValidateException("修改失败 总发放数量必须大于已发放数量"); throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
}else { } else {
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum()); param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
} }
} }
}else { } else {
if(param.getGiveNum()== -10086){ if (param.getGiveNum() == -10086) {
param.setLeftNum(-10086); param.setLeftNum(-10086);
}else { } else {
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) { if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
throw new ValidateException("修改失败 总发放数量必须大于已发放数量"); throw new ValidateException("修改失败 总发放数量必须大于已发放数量");
}else { } else {
param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum()); param.setLeftNum(param.getGiveNum() - tbShopCoupon.getGiftNum());
} }
} }
@ -129,14 +125,13 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
List<UserCouponVo> tbUserCouponVos = recordService.queryByVipIdAndShopId(shopId, shopUserId, type); List<UserCouponVo> tbUserCouponVos = recordService.queryByVipIdAndShopId(shopId, shopUserId, type);
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) { if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese(""); String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("");
LocalTime now = LocalTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
//券id 券使用描述 //券id 券使用描述
Map<Long, JSONObject> coupons = new HashMap<>(); Map<Long, JSONObject> coupons = new HashMap<>();
for (UserCouponVo tbUserCouponVo : tbUserCouponVos) { for (UserCouponVo tbUserCouponVo : tbUserCouponVos) {
if (!coupons.containsKey(tbUserCouponVo.getCouponId())) { if (!coupons.containsKey(tbUserCouponVo.getCouponId())) {
setCouponInfo(coupons, tbUserCouponVo, null, week, now, formatter); setCouponInfo(coupons, tbUserCouponVo, null, week, formatter);
} }
JSONObject couponJson = coupons.get(tbUserCouponVo.getCouponId()); JSONObject couponJson = coupons.get(tbUserCouponVo.getCouponId());
tbUserCouponVo.setUseRestrictions(couponJson.getString("useRestrictions")); tbUserCouponVo.setUseRestrictions(couponJson.getString("useRestrictions"));
@ -188,7 +183,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
.update(); .update();
} }
private void setCouponInfo(Map<Long, JSONObject> coupons, UserCouponVo tbUserCouponVo, BigDecimal amount, String week, LocalTime now, DateTimeFormatter formatter) { private void setCouponInfo(Map<Long, JSONObject> coupons, UserCouponVo tbUserCouponVo, BigDecimal amount, String week, DateTimeFormatter formatter) {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
boolean isUse = true; boolean isUse = true;
ShopCoupon tbShopCoupon = getById(tbUserCouponVo.getCouponId()); ShopCoupon tbShopCoupon = getById(tbUserCouponVo.getCouponId());