新客立减相关
This commit is contained in:
@@ -22,6 +22,7 @@ import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.auth.v1alpha1.Ca;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -35,7 +36,7 @@ import java.util.Random;
|
||||
* @since 2025-09-17
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@DubboService
|
||||
public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopConsumeDiscountRecordMapper, MkShopConsumeDiscountRecord> implements MkShopConsumeDiscountRecordService {
|
||||
@Resource
|
||||
private MkConsumeDiscountService consumeDiscountService;
|
||||
@@ -101,9 +102,25 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||
AssertUtil.isTrue(!flag, "修改失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewUser(ShopUser shopUser, Long shopId) {
|
||||
MkShopConsumeDiscountRecord discountRecord = getOne(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId)
|
||||
.eq(MkShopConsumeDiscountRecord::getIsUse, 1)
|
||||
.eq(MkShopConsumeDiscountRecord::getShopUserId, shopUser.getId()));
|
||||
boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
|
||||
return !exists && discountRecord == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MkShopConsumeDiscountRecord getDiscount(Long shopId, Long userId, Long orderId) {
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, userId).eq(ShopUser::getSourceShopId, shopId));
|
||||
boolean newUser = isNewUser(shopUser, shopId);
|
||||
if (!newUser) {
|
||||
// throw new ApiNotPrintException("新客立减仅新用户可用");
|
||||
log.info("新客立减仅限新用户使用");
|
||||
return null;
|
||||
}
|
||||
MkShopConsumeDiscountRecord discountRecord = getOne(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId)
|
||||
.eq(MkShopConsumeDiscountRecord::getOrderId, orderId)
|
||||
.eq(MkShopConsumeDiscountRecord::getIsUse, 0)
|
||||
@@ -115,13 +132,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||
}
|
||||
return discountRecord;
|
||||
}
|
||||
boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
|
||||
if (exists) {
|
||||
// throw new ApiNotPrintException("新客立减仅新用户可用");
|
||||
log.info("新客立减仅限新用户使用");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
MkConsumeDiscountVO consumeDiscountVO = canUse(shopId, userId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user