优惠券初始值问题

This commit is contained in:
wangw 2025-03-10 14:58:10 +08:00
parent ef1722b728
commit ef1e14f94c
3 changed files with 12 additions and 7 deletions

View File

@ -81,12 +81,10 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
@Override
public void giveActivate(ShopUser shopUser, BigDecimal memAmount, Long relationId) {
log.info("充钱4 会员充值奖励5");
ShopActivate activate = queryChain().select().eq(ShopActivate::getShopId, shopUser.getShopId())
.le(ShopActivate::getAmount, memAmount)
.orderBy(ShopActivate::getGiftAmount, false)
.one();
log.info("赠送活动:{}", activate);
if (ObjectUtil.isNull(activate)) {
return;
}

View File

@ -3,6 +3,7 @@ package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.exceptions.ValidateException;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
@ -20,6 +21,7 @@ import com.czg.account.vo.UserCouponVo;
import com.czg.product.entity.Product;
import com.czg.product.service.ProductService;
import com.czg.service.account.mapper.ShopCouponMapper;
import com.czg.utils.AssertUtil;
import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@ -74,6 +76,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
public Boolean add(ShopCouponDTO couponDTO) {
ShopCoupon shopCoupon = new ShopCoupon();
BeanUtil.copyProperties(couponDTO, shopCoupon);
shopCoupon.setLeftNumber(shopCoupon.getNumber());
return save(shopCoupon);
}
@ -81,6 +84,14 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
public Boolean edit(ShopCouponDTO couponDTO) {
ShopCoupon shopCoupon = new ShopCoupon();
BeanUtil.copyProperties(couponDTO, shopCoupon);
if (couponDTO.getNumber() != null) {
ShopCoupon tbShopCoupon = getById(couponDTO.getId());
if (shopCoupon.getNumber() < tbShopCoupon.getNumber()) {
throw new ValidateException("修改失败 发放数量不可减少");
} else {
shopCoupon.setLeftNumber(shopCoupon.getLeftNumber() + shopCoupon.getNumber() - tbShopCoupon.getNumber());
}
}
return updateById(shopCoupon);
}
@ -108,7 +119,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
@Override
public List<UserCouponVo> findCoupon(Long shopId, Long shopUserId, Integer type) {
List<UserCouponVo> tbUserCouponVos = couponRecordService.queryByVipIdAndShopId(shopId, shopUserId,type);
List<UserCouponVo> tbUserCouponVos = couponRecordService.queryByVipIdAndShopId(shopId, shopUserId, type);
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("");
LocalTime now = LocalTime.now();

View File

@ -531,7 +531,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
} else {
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.CASH_IN);
}
log.info("充钱1 是否是霸王餐:{}", isFree);
if (isFree) {
if (StrUtil.isBlank(czgCallBackDto.getExtParam())) {
throw new ValidateException("霸王餐支付,订单号处理失败");
@ -543,12 +542,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
.set(OrderInfo::getPayAmount, 0)
.update();
}
log.info("充钱2");
//更新会员余额 并生成流水
Long flowId = shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
log.info("充钱3 更新钱:{}", flowId);
if (!isFree) {
log.info("充钱4 会员充值奖励");
//会员活动
activateService.giveActivate(shopUser,
new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN), flowId);