新客立减

This commit is contained in:
张松 2025-09-25 18:05:00 +08:00
parent 930ca57ddf
commit e08b8faf16
2 changed files with 11 additions and 4 deletions

View File

@ -28,7 +28,7 @@ public interface MkShopConsumeDiscountRecordService extends IService<MkShopConsu
* @param shopId 店铺id
* @param userId 用户id
*/
MkConsumeDiscountVO checkDiscount(Long shopId, Long userId);
void checkDiscount(Long shopId, Long userId, Long orderId, BigDecimal amount);
/**
* 修改记录状态

View File

@ -19,6 +19,7 @@ import com.czg.market.entity.MkShopConsumeDiscountRecord;
import com.czg.market.service.MkShopConsumeDiscountRecordService;
import com.czg.service.market.mapper.MkShopConsumeDiscountRecordMapper;
import jakarta.annotation.Resource;
import org.apache.dubbo.auth.v1alpha1.Ca;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
@ -41,9 +42,15 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
@DubboReference
private OrderInfoService orderInfoService;
@Override
public MkConsumeDiscountVO checkDiscount(Long shopId, Long userId) {
public void checkDiscount(Long shopId, Long userId, Long orderId, BigDecimal amount) {
MkConsumeDiscountVO consumeDiscountVO = canUse(shopId, userId);
MkShopConsumeDiscountRecord discountRecord = getOne(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId).eq(MkShopConsumeDiscountRecord::getOrderId, orderId));
AssertUtil.isNull(discountRecord, "新客立减记录不存在");
AssertUtil.isTrue(amount.compareTo(consumeDiscountVO.getDiscountAmount()) != 0, "减免金额错误");
}
private MkConsumeDiscountVO canUse(Long shopId, Long userId) {
MkConsumeDiscountVO consumeDiscountVO = consumeDiscountService.detail(shopId);
if (consumeDiscountVO.getIsEnable() != 1) {
throw new ApiNotPrintException("新客立减未开启");
@ -106,7 +113,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
if (count > 0) {
throw new ApiNotPrintException("新客立减仅新用户可用");
}
MkConsumeDiscountVO consumeDiscountVO = checkDiscount(shopId, userId);
MkConsumeDiscountVO consumeDiscountVO = canUse(shopId, userId);
DateTime now = DateUtil.date();