新客立减
This commit is contained in:
@@ -6,7 +6,6 @@ import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.entity.MkConsumeDiscountRandom;
|
||||
import com.czg.market.service.MkConsumeDiscountService;
|
||||
import com.czg.market.vo.MkConsumeDiscountVO;
|
||||
@@ -20,7 +19,6 @@ import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||
import com.czg.market.service.MkShopConsumeDiscountRecordService;
|
||||
import com.czg.service.market.mapper.MkShopConsumeDiscountRecordMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -43,7 +41,9 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||
@DubboReference
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
private MkConsumeDiscountVO checkOpen(Long shopId) {
|
||||
|
||||
@Override
|
||||
public MkConsumeDiscountVO checkDiscount(Long shopId, Long userId) {
|
||||
MkConsumeDiscountVO consumeDiscountVO = consumeDiscountService.detail(shopId);
|
||||
if (consumeDiscountVO.getIsEnable() != 1) {
|
||||
throw new ApiNotPrintException("新客立减未开启");
|
||||
@@ -60,12 +60,6 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||
if ("RANDOM".equals(consumeDiscountVO.getDiscountType()) && (randomList == null || randomList.isEmpty()) ){
|
||||
throw new ApiNotPrintException("随机立减配置错误");
|
||||
}
|
||||
return consumeDiscountVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void canUseDiscount(Long shopId, Long userId, BigDecimal amount) {
|
||||
checkOpen(shopId);
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
|
||||
long count = orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE));
|
||||
@@ -77,6 +71,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||
|
||||
AssertUtil.isTrue(recordCount > 0, "新客立减已使用");
|
||||
|
||||
return consumeDiscountVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +106,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||
if (count > 0) {
|
||||
throw new ApiNotPrintException("新客立减仅新用户可用");
|
||||
}
|
||||
MkConsumeDiscountVO consumeDiscountVO = checkOpen(shopId);
|
||||
MkConsumeDiscountVO consumeDiscountVO = checkDiscount(shopId, userId);
|
||||
|
||||
DateTime now = DateUtil.date();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user