Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -39,7 +39,7 @@ public interface MkShopCouponRecordService extends IService<MkShopCouponRecord>
|
||||
*
|
||||
* @param giftDTO 除 sourceFlowId 外 全必填 如果有 也填
|
||||
* @param number 发放数量
|
||||
* @param isLimit 是否校验限领,活动与管理员添加 不计限领
|
||||
* @param isLimit 是否校验限领/扣除剩余数量,活动与管理员添加 不计限领
|
||||
*/
|
||||
void receiveCoupon(MkShopCouponGiftDTO giftDTO, Integer number, boolean isLimit);
|
||||
|
||||
|
||||
@@ -140,18 +140,22 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
||||
AssertUtil.isNull(coupon.getShopId(), "优惠券店铺不存在");
|
||||
AssertUtil.isNotEqual(coupon.getShopId(), giftDTO.getShopId(), "优惠券店铺与发放店铺不一致");
|
||||
AssertUtil.isNotEqual(coupon.getStatus(), 1, "优惠券已失效");
|
||||
if (coupon.getGiveNum() >= 0 && coupon.getLeftNum() < number) {
|
||||
throw new CzgException("优惠券库存不足");
|
||||
}
|
||||
if (isLimit) {
|
||||
if (coupon.getGiveNum() >= 0 && coupon.getLeftNum() < number) {
|
||||
throw new CzgException("优惠券库存不足");
|
||||
}
|
||||
//查询已领取张数
|
||||
long count = this.queryChain()
|
||||
.eq(MkShopCouponRecord::getShopUserId, shopUser.getId())
|
||||
.eq(MkShopCouponRecord::getCouponId, giftDTO.getCouponId()).count();
|
||||
if (coupon.getGetLimit() >= 0 && count >= coupon.getGetLimit()) {
|
||||
throw new CzgException("已达到领取限制,不可领取7");
|
||||
throw new CzgException("已达到领取限制,不可领取");
|
||||
}
|
||||
}
|
||||
coupon.setGiftNum(coupon.getGiftNum() + number);
|
||||
if (coupon.getGiveNum() != -10086 && isLimit) {
|
||||
coupon.setLeftNum(coupon.getLeftNum() - number);
|
||||
}
|
||||
String couponJson = JSONObject.toJSONString(coupon);
|
||||
LocalDateTime start = LocalDateTime.now().with(LocalTime.MIN);
|
||||
LocalDateTime end = null;
|
||||
@@ -188,11 +192,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
||||
record.setUseEndTime(end);
|
||||
save(record);
|
||||
}
|
||||
coupon.setGiftNum(coupon.getGiftNum() + number);
|
||||
if (coupon.getGiveNum() != -10086) {
|
||||
coupon.setLeftNum(coupon.getLeftNum() - number);
|
||||
}
|
||||
couponService.update(coupon,true);
|
||||
couponService.update(coupon, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user