消费赠券修改

This commit is contained in:
张松
2025-11-21 16:23:44 +08:00
parent 6d7715db27
commit 231326e66b
2 changed files with 30 additions and 20 deletions

View File

@@ -707,6 +707,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
AssertUtil.isTrue(config.getIsEnable() != 1, "分销未开启"); AssertUtil.isTrue(config.getIsEnable() != 1, "分销未开启");
// 当前用户上级分销员 // 当前用户上级分销员
ShopUser sourceShopUserInfo = shopUserService.getShopUserInfo(shopId, sourceUserId); ShopUser sourceShopUserInfo = shopUserService.getShopUserInfo(shopId, sourceUserId);
if (sourceShopUserInfo == null) {
return;
}
ShopUserInvite sourceInviteUser = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, sourceShopUserInfo.getId()); ShopUserInvite sourceInviteUser = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, sourceShopUserInfo.getId());
if (sourceInviteUser.getDistributionUserId() == null) { if (sourceInviteUser.getDistributionUserId() == null) {
return; return;

View File

@@ -19,6 +19,7 @@ import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -31,6 +32,7 @@ import java.util.List;
* @author ww * @author ww
* @since 2025-09-12 * @since 2025-09-12
*/ */
@Slf4j
@Service @Service
public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerCouponMapper, MkShopConsumerCoupon> implements MkShopConsumerCouponService { public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerCouponMapper, MkShopConsumerCoupon> implements MkShopConsumerCouponService {
@@ -75,11 +77,17 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
} }
MkCouponGiftDTO giftCoupon = giftCoupons.getFirst(); MkCouponGiftDTO giftCoupon = giftCoupons.getFirst();
if (consumerCoupon.getLeftNum() == -10086 || consumerCoupon.getLeftNum() >= consumerCoupon.getGiftNum()) { if (consumerCoupon.getLeftNum() == -10086 || consumerCoupon.getLeftNum() >= consumerCoupon.getGiftNum()) {
if (consumerCoupon.getGetLimit() == -10086 || consumerCoupon.getGetLimit() <= consumerCoupon.getGiveNum()) { boolean canReceive = consumerCoupon.getGetLimit() == -10086;
// 限量发放,校验用户已经发放数量
if (consumerCoupon.getGetLimit() != -10086) {
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()));
if (consumerCoupon.getGetLimit() >= count + giftCoupon.getNum()) { log.info("用户: {}, 已经发放: {}, 限量: {}", shopUserId, count, consumerCoupon.getGetLimit());
canReceive = consumerCoupon.getGetLimit() >= count + giftCoupon.getNum();
}
if (canReceive) {
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO(); MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO();
giftDTO.setShopId(shopId); giftDTO.setShopId(shopId);
giftDTO.setShopUserId(shopUserId); giftDTO.setShopUserId(shopUserId);
@@ -101,7 +109,6 @@ public class MkShopConsumerCouponServiceImpl extends ServiceImpl<MkShopConsumerC
} }
} }
} }
}
@Override @Override
public MkShopConsumerCouponDTO getConsumerCouponById(Long id) { public MkShopConsumerCouponDTO getConsumerCouponById(Long id) {