新客立减
This commit is contained in:
parent
818751740d
commit
930ca57ddf
|
|
@ -1,8 +1,8 @@
|
||||||
package com.czg.market.service;
|
package com.czg.market.service;
|
||||||
|
|
||||||
|
import com.czg.market.vo.MkConsumeDiscountVO;
|
||||||
import com.mybatisflex.core.service.IService;
|
import com.mybatisflex.core.service.IService;
|
||||||
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
|
@ -22,7 +22,13 @@ public interface MkShopConsumeDiscountRecordService extends IService<MkShopConsu
|
||||||
*/
|
*/
|
||||||
MkShopConsumeDiscountRecord getDiscount(Long shopId, Long userId, Long orderId);
|
MkShopConsumeDiscountRecord getDiscount(Long shopId, Long userId, Long orderId);
|
||||||
|
|
||||||
void canUseDiscount(Long shopId, Long userId, BigDecimal amount);
|
/**
|
||||||
|
* 是否可用新客立减
|
||||||
|
*
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @param userId 用户id
|
||||||
|
*/
|
||||||
|
MkConsumeDiscountVO checkDiscount(Long shopId, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改记录状态
|
* 修改记录状态
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import com.czg.account.entity.ShopUser;
|
||||||
import com.czg.account.service.ShopUserService;
|
import com.czg.account.service.ShopUserService;
|
||||||
import com.czg.constant.TableValueConstant;
|
import com.czg.constant.TableValueConstant;
|
||||||
import com.czg.exception.ApiNotPrintException;
|
import com.czg.exception.ApiNotPrintException;
|
||||||
import com.czg.exception.CzgException;
|
|
||||||
import com.czg.market.entity.MkConsumeDiscountRandom;
|
import com.czg.market.entity.MkConsumeDiscountRandom;
|
||||||
import com.czg.market.service.MkConsumeDiscountService;
|
import com.czg.market.service.MkConsumeDiscountService;
|
||||||
import com.czg.market.vo.MkConsumeDiscountVO;
|
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.market.service.MkShopConsumeDiscountRecordService;
|
||||||
import com.czg.service.market.mapper.MkShopConsumeDiscountRecordMapper;
|
import com.czg.service.market.mapper.MkShopConsumeDiscountRecordMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -43,7 +41,9 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private OrderInfoService orderInfoService;
|
private OrderInfoService orderInfoService;
|
||||||
|
|
||||||
private MkConsumeDiscountVO checkOpen(Long shopId) {
|
|
||||||
|
@Override
|
||||||
|
public MkConsumeDiscountVO checkDiscount(Long shopId, Long userId) {
|
||||||
MkConsumeDiscountVO consumeDiscountVO = consumeDiscountService.detail(shopId);
|
MkConsumeDiscountVO consumeDiscountVO = consumeDiscountService.detail(shopId);
|
||||||
if (consumeDiscountVO.getIsEnable() != 1) {
|
if (consumeDiscountVO.getIsEnable() != 1) {
|
||||||
throw new ApiNotPrintException("新客立减未开启");
|
throw new ApiNotPrintException("新客立减未开启");
|
||||||
|
|
@ -60,12 +60,6 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||||
if ("RANDOM".equals(consumeDiscountVO.getDiscountType()) && (randomList == null || randomList.isEmpty()) ){
|
if ("RANDOM".equals(consumeDiscountVO.getDiscountType()) && (randomList == null || randomList.isEmpty()) ){
|
||||||
throw new ApiNotPrintException("随机立减配置错误");
|
throw new ApiNotPrintException("随机立减配置错误");
|
||||||
}
|
}
|
||||||
return consumeDiscountVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void canUseDiscount(Long shopId, Long userId, BigDecimal amount) {
|
|
||||||
checkOpen(shopId);
|
|
||||||
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
|
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
|
||||||
long count = orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
|
long count = orderInfoService.count(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
|
||||||
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE));
|
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE));
|
||||||
|
|
@ -77,6 +71,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||||
|
|
||||||
AssertUtil.isTrue(recordCount > 0, "新客立减已使用");
|
AssertUtil.isTrue(recordCount > 0, "新客立减已使用");
|
||||||
|
|
||||||
|
return consumeDiscountVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -111,7 +106,7 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
throw new ApiNotPrintException("新客立减仅新用户可用");
|
throw new ApiNotPrintException("新客立减仅新用户可用");
|
||||||
}
|
}
|
||||||
MkConsumeDiscountVO consumeDiscountVO = checkOpen(shopId);
|
MkConsumeDiscountVO consumeDiscountVO = checkDiscount(shopId, userId);
|
||||||
|
|
||||||
DateTime now = DateUtil.date();
|
DateTime now = DateUtil.date();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue