新客立减
This commit is contained in:
parent
dfb19c9ae6
commit
818751740d
|
|
@ -22,7 +22,7 @@ public interface MkShopConsumeDiscountRecordService extends IService<MkShopConsu
|
|||
*/
|
||||
MkShopConsumeDiscountRecord getDiscount(Long shopId, Long userId, Long orderId);
|
||||
|
||||
boolean canUseDiscount(Long shopId, Long userId, BigDecimal amount);
|
||||
void canUseDiscount(Long shopId, Long userId, BigDecimal amount);
|
||||
|
||||
/**
|
||||
* 修改记录状态
|
||||
|
|
|
|||
|
|
@ -64,20 +64,19 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseDiscount(Long shopId, Long userId, BigDecimal amount) {
|
||||
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));
|
||||
if (count > 0) {
|
||||
return false;
|
||||
}
|
||||
AssertUtil.isTrue(count > 0, "新客立减仅限新用户使用");
|
||||
|
||||
|
||||
long recordCount = count(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId).eq(MkShopConsumeDiscountRecord::getShopUserId, shopUser.getId())
|
||||
.eq(MkShopConsumeDiscountRecord::getIsUse, 1));
|
||||
|
||||
AssertUtil.isTrue(recordCount > 0, "新客立减已使用");
|
||||
|
||||
return recordCount <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue