修改 10086 为常量
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
package com.czg.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* market 常量
|
||||||
|
* @author yjjie
|
||||||
|
* @date 2025/12/11 18:22
|
||||||
|
*/
|
||||||
|
public interface MarketConstants {
|
||||||
|
|
||||||
|
class Num {
|
||||||
|
/**
|
||||||
|
* 不限数量
|
||||||
|
*/
|
||||||
|
public static final int NOT_LIMIT = -10086;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.czg.service.market.service.impl;
|
|||||||
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.ShopUserService;
|
import com.czg.account.service.ShopUserService;
|
||||||
|
import com.czg.constant.MarketConstants;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.dto.ChatCouponDTO;
|
import com.czg.market.dto.ChatCouponDTO;
|
||||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||||
@@ -59,8 +60,8 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
|
|||||||
.shopId(shopId)
|
.shopId(shopId)
|
||||||
.title(chatCoupon.getTitle())
|
.title(chatCoupon.getTitle())
|
||||||
.getLimit(chatCoupon.getGetLimit() == null ? 1 : chatCoupon.getGetLimit())
|
.getLimit(chatCoupon.getGetLimit() == null ? 1 : chatCoupon.getGetLimit())
|
||||||
.giveNum(chatCoupon.getGiveNum() == null ? -10086 : chatCoupon.getGiveNum())
|
.giveNum(chatCoupon.getGiveNum() == null ? MarketConstants.Num.NOT_LIMIT : chatCoupon.getGiveNum())
|
||||||
.leftNum(chatCoupon.getGiveNum() == null ? -10086 : chatCoupon.getGiveNum())
|
.leftNum(chatCoupon.getGiveNum() == null ? MarketConstants.Num.NOT_LIMIT : chatCoupon.getGiveNum())
|
||||||
.useNum(0)
|
.useNum(0)
|
||||||
.couponId(chatCoupon.getCouponId())
|
.couponId(chatCoupon.getCouponId())
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.czg.service.market.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.exceptions.ValidateException;
|
import com.czg.constant.MarketConstants;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.dto.MkCouponGiftDTO;
|
import com.czg.market.dto.MkCouponGiftDTO;
|
||||||
import com.czg.market.dto.MkShopConsumerCouponDTO;
|
import com.czg.market.dto.MkShopConsumerCouponDTO;
|
||||||
@@ -68,7 +68,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//判断是否已被领取
|
//判断是否已被领取
|
||||||
if (consumerCoupon.getGiveNum() != -10086 && consumerCoupon.getGiveNum() <= consumerCoupon.getGiftNum()) {
|
if (consumerCoupon.getGiveNum() != MarketConstants.Num.NOT_LIMIT && consumerCoupon.getGiveNum() <= consumerCoupon.getGiftNum()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<MkCouponGiftDTO> giftCoupons = couponGiftService.getCouponGiftBySourceId(consumerCoupon.getId(), 3);
|
List<MkCouponGiftDTO> giftCoupons = couponGiftService.getCouponGiftBySourceId(consumerCoupon.getId(), 3);
|
||||||
@@ -76,10 +76,10 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MkCouponGiftDTO giftCoupon = giftCoupons.getFirst();
|
MkCouponGiftDTO giftCoupon = giftCoupons.getFirst();
|
||||||
if (consumerCoupon.getLeftNum() == -10086 || consumerCoupon.getLeftNum() >= giftCoupon.getNum()) {
|
if (consumerCoupon.getLeftNum() == MarketConstants.Num.NOT_LIMIT || consumerCoupon.getLeftNum() >= giftCoupon.getNum()) {
|
||||||
boolean canReceive = consumerCoupon.getGetLimit() == -10086;
|
boolean canReceive = consumerCoupon.getGetLimit() == MarketConstants.Num.NOT_LIMIT;
|
||||||
// 限量发放,校验用户已经发放数量
|
// 限量发放,校验用户已经发放数量
|
||||||
if (consumerCoupon.getGetLimit() != -10086) {
|
if (consumerCoupon.getGetLimit() != MarketConstants.Num.NOT_LIMIT) {
|
||||||
long count = recordService.count(new QueryWrapper().eq(MkShopCouponRecord::getShopId, shopId)
|
long count = recordService.count(new QueryWrapper().eq(MkShopCouponRecord::getShopId, shopId)
|
||||||
.eq(MkShopCouponRecord::getShopUserId, shopUserId)
|
.eq(MkShopCouponRecord::getShopUserId, shopUserId)
|
||||||
.eq(MkShopCouponRecord::getSourceId, consumerCoupon.getId()));
|
.eq(MkShopCouponRecord::getSourceId, consumerCoupon.getId()));
|
||||||
@@ -99,7 +99,7 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
|||||||
recordService.receiveCoupon(giftDTO, giftCoupon.getNum(), false);
|
recordService.receiveCoupon(giftDTO, giftCoupon.getNum(), false);
|
||||||
//更新优惠券信息
|
//更新优惠券信息
|
||||||
consumerCoupon.setGiftNum(consumerCoupon.getGiftNum() + giftCoupon.getNum());
|
consumerCoupon.setGiftNum(consumerCoupon.getGiftNum() + giftCoupon.getNum());
|
||||||
if (consumerCoupon.getLeftNum() != -10086) {
|
if (consumerCoupon.getLeftNum() != MarketConstants.Num.NOT_LIMIT) {
|
||||||
consumerCoupon.setLeftNum(consumerCoupon.getLeftNum() - giftCoupon.getNum());
|
consumerCoupon.setLeftNum(consumerCoupon.getLeftNum() - giftCoupon.getNum());
|
||||||
}
|
}
|
||||||
updateById(new MkShopConsumerCoupon()
|
updateById(new MkShopConsumerCoupon()
|
||||||
@@ -135,9 +135,8 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void updateConsumerCouponById(MkShopConsumerCouponDTO param) {
|
public void updateConsumerCouponById(MkShopConsumerCouponDTO param) {
|
||||||
MkShopConsumerCoupon consumerCoupon = getById(param.getId());
|
MkShopConsumerCoupon consumerCoupon = getById(param.getId());
|
||||||
if (consumerCoupon.getGiveNum() == -10086) {
|
if (param.getGiveNum() == MarketConstants.Num.NOT_LIMIT) {
|
||||||
if (param.getGiveNum() == -10086) {
|
param.setLeftNum(MarketConstants.Num.NOT_LIMIT);
|
||||||
param.setLeftNum(-10086);
|
|
||||||
} else {
|
} else {
|
||||||
if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
|
if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
|
||||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||||
@@ -145,17 +144,6 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
|
|||||||
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
|
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (param.getGiveNum() == -10086) {
|
|
||||||
param.setLeftNum(-10086);
|
|
||||||
} else {
|
|
||||||
if (param.getGiveNum() < consumerCoupon.getGiftNum()) {
|
|
||||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
|
||||||
} else {
|
|
||||||
param.setLeftNum(param.getGiveNum() - consumerCoupon.getGiftNum());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateById(BeanUtil.toBean(param, MkShopConsumerCoupon.class), true);
|
updateById(BeanUtil.toBean(param, MkShopConsumerCoupon.class), true);
|
||||||
//更新优惠券信息/数量
|
//更新优惠券信息/数量
|
||||||
couponGiftService.addCouponGift(param.getId(), "消费赠券", 3, param.getCouponGiftList());
|
couponGiftService.addCouponGift(param.getId(), "消费赠券", 3, param.getCouponGiftList());
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.czg.account.service.ShopUserService;
|
|||||||
import com.czg.account.service.UserInfoService;
|
import com.czg.account.service.UserInfoService;
|
||||||
import com.czg.account.vo.CouponReceiveVo;
|
import com.czg.account.vo.CouponReceiveVo;
|
||||||
import com.czg.account.vo.UserCouponVo;
|
import com.czg.account.vo.UserCouponVo;
|
||||||
|
import com.czg.constant.MarketConstants;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.dto.*;
|
import com.czg.market.dto.*;
|
||||||
import com.czg.market.entity.MkShopCouponRecord;
|
import com.czg.market.entity.MkShopCouponRecord;
|
||||||
@@ -340,7 +341,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
coupon.setGiftNum(coupon.getGiftNum() + number);
|
coupon.setGiftNum(coupon.getGiftNum() + number);
|
||||||
if (coupon.getGiveNum() != -10086 && isLimit) {
|
if (coupon.getGiveNum() != MarketConstants.Num.NOT_LIMIT && isLimit) {
|
||||||
coupon.setLeftNum(coupon.getLeftNum() - number);
|
coupon.setLeftNum(coupon.getLeftNum() - number);
|
||||||
}
|
}
|
||||||
String couponJson = JSONObject.toJSONString(coupon);
|
String couponJson = JSONObject.toJSONString(coupon);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.czg.account.service.ShopInfoService;
|
|||||||
import com.czg.account.service.ShopUserService;
|
import com.czg.account.service.ShopUserService;
|
||||||
import com.czg.account.vo.ShopInfoCouponVO;
|
import com.czg.account.vo.ShopInfoCouponVO;
|
||||||
import com.czg.account.vo.UserCouponVo;
|
import com.czg.account.vo.UserCouponVo;
|
||||||
|
import com.czg.constant.MarketConstants;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.dto.MkShopCouponGiftDTO;
|
import com.czg.market.dto.MkShopCouponGiftDTO;
|
||||||
import com.czg.market.dto.ShopCouponDTO;
|
import com.czg.market.dto.ShopCouponDTO;
|
||||||
@@ -124,7 +125,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
|||||||
if ("custom".equals(coupon.getValidType()) && coupon.getValidEndTime() != null && coupon.getValidEndTime().isBefore(LocalDateTime.now())) {
|
if ("custom".equals(coupon.getValidType()) && coupon.getValidEndTime() != null && coupon.getValidEndTime().isBefore(LocalDateTime.now())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (coupon.getGiveNum() != -10086 && coupon.getLeftNum() <= 0) {
|
if (coupon.getGiveNum() != MarketConstants.Num.NOT_LIMIT && coupon.getLeftNum() <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean isNotNewUser = true;
|
boolean isNotNewUser = true;
|
||||||
@@ -144,7 +145,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isNotNewUser && coupon.getGetLimit() != -10086) {
|
if (isNotNewUser && coupon.getGetLimit() != MarketConstants.Num.NOT_LIMIT) {
|
||||||
if (coupon.getSyncId() != null) {
|
if (coupon.getSyncId() != null) {
|
||||||
long count = recordService.count(new QueryWrapper()
|
long count = recordService.count(new QueryWrapper()
|
||||||
.eq(MkShopCouponRecord::getUserId, userId)
|
.eq(MkShopCouponRecord::getUserId, userId)
|
||||||
@@ -211,8 +212,8 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
|||||||
@Override
|
@Override
|
||||||
public void updateCouponById(ShopCouponDTO param) {
|
public void updateCouponById(ShopCouponDTO param) {
|
||||||
ShopCoupon tbShopCoupon = getById(param.getId());
|
ShopCoupon tbShopCoupon = getById(param.getId());
|
||||||
if (tbShopCoupon.getGiveNum() == -10086) {
|
if (tbShopCoupon.getGiveNum() == MarketConstants.Num.NOT_LIMIT) {
|
||||||
if (param.getGiveNum() != -10086) {
|
if (param.getGiveNum() != MarketConstants.Num.NOT_LIMIT) {
|
||||||
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
||||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||||
} else {
|
} else {
|
||||||
@@ -220,8 +221,8 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (param.getGiveNum() == -10086) {
|
if (param.getGiveNum() == MarketConstants.Num.NOT_LIMIT) {
|
||||||
param.setLeftNum(-10086);
|
param.setLeftNum(MarketConstants.Num.NOT_LIMIT);
|
||||||
} else {
|
} else {
|
||||||
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
if (param.getGiveNum() < tbShopCoupon.getGiftNum()) {
|
||||||
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
throw new CzgException("修改失败 总发放数量必须大于已发放数量");
|
||||||
@@ -564,7 +565,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
|||||||
useRestrictions.append("全时段");
|
useRestrictions.append("全时段");
|
||||||
}
|
}
|
||||||
useRestrictions.append(" 可用");
|
useRestrictions.append(" 可用");
|
||||||
if (tbUserCouponVo.getUseLimit() != -10086) {
|
if (tbUserCouponVo.getUseLimit() != MarketConstants.Num.NOT_LIMIT) {
|
||||||
long useCount = recordService.count(new QueryWrapper()
|
long useCount = recordService.count(new QueryWrapper()
|
||||||
.eq(MkShopCouponRecord::getCouponId, tbUserCouponVo.getCouponId())
|
.eq(MkShopCouponRecord::getCouponId, tbUserCouponVo.getCouponId())
|
||||||
.eq(MkShopCouponRecord::getShopUserId, shopUserId)
|
.eq(MkShopCouponRecord::getShopUserId, shopUserId)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.czg.account.entity.*;
|
|||||||
import com.czg.account.service.*;
|
import com.czg.account.service.*;
|
||||||
import com.czg.config.RabbitPublisher;
|
import com.czg.config.RabbitPublisher;
|
||||||
import com.czg.config.RedisCst;
|
import com.czg.config.RedisCst;
|
||||||
|
import com.czg.constant.MarketConstants;
|
||||||
import com.czg.constant.TableValueConstant;
|
import com.czg.constant.TableValueConstant;
|
||||||
import com.czg.entity.notify.CzgPayNotifyDTO;
|
import com.czg.entity.notify.CzgPayNotifyDTO;
|
||||||
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
||||||
@@ -710,7 +711,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
* 判断每日使用限量
|
* 判断每日使用限量
|
||||||
*/
|
*/
|
||||||
private void isUseLimit(ShopCoupon coupon, MkShopCouponRecord record) {
|
private void isUseLimit(ShopCoupon coupon, MkShopCouponRecord record) {
|
||||||
if (coupon.getUseLimit() != -10086) {
|
if (coupon.getUseLimit() != MarketConstants.Num.NOT_LIMIT) {
|
||||||
long useNum = couponRecordService.count(new QueryWrapper()
|
long useNum = couponRecordService.count(new QueryWrapper()
|
||||||
.eq(MkShopCouponRecord::getCouponId, coupon.getId())
|
.eq(MkShopCouponRecord::getCouponId, coupon.getId())
|
||||||
.eq(MkShopCouponRecord::getShopId, record.getShopId())
|
.eq(MkShopCouponRecord::getShopId, record.getShopId())
|
||||||
|
|||||||
Reference in New Issue
Block a user