|
@@ -121,6 +121,11 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
|
|
if (form.getContractId() != null) {
|
|
|
Contract contract = contractService.getById(form.getContractId());
|
|
|
Assert.isTrue(contract != null, "关联协议数据不存在");
|
|
|
+
|
|
|
+ // 校验协议用户是否还有优惠券
|
|
|
+ Long count = this.count(new LambdaQueryWrapper<Coupon>().eq(Coupon::getContractId, form.getContractId()));
|
|
|
+ Assert.isTrue(count != null && count < contract.getMaxCouponCount(), "优惠券已领完");
|
|
|
+
|
|
|
SysUser user = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getContractId, form.getContractId()));
|
|
|
Assert.isTrue(user != null, "关联协议用户数据不存在");
|
|
|
form.setFromUserId(user.getId());
|