| | |
| | | return couponMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Coupon> findValidList() { |
| | | return couponMapper.selectList(new QueryWrapper<Coupon>().lambda() |
| | | .eq(Coupon::getIsdeleted, Constants.ZERO) |
| | | .eq(Coupon::getStatus, Constants.ZERO) |
| | | .orderByDesc(Coupon::getId)); |
| | | } |
| | | |
| | | private void validateCoupon(Coupon coupon) { |
| | | if (Objects.isNull(coupon) || StringUtils.isBlank(coupon.getName())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "优惠券名称不能为空"); |
| | |
| | | if (coupon.getPrice() >= coupon.getLimitPrice()) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "优惠金额必须小于满额"); |
| | | } |
| | | if (coupon.getLimitPrice() < 1000) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "满减金额最低10元"); |
| | | } |
| | | if (coupon.getLimitPrice() - coupon.getPrice() < 1000) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "满减金额必须大于扣减金额10元以上"); |
| | | } |
| | | if (Objects.isNull(coupon.getPushDays()) || coupon.getPushDays() < 1) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "推送后领取有效天数必须大于等于1天"); |
| | | } |