diff --git a/src/main/java/com/gxwebsoft/shop/controller/ShopUserCouponController.java b/src/main/java/com/gxwebsoft/shop/controller/ShopUserCouponController.java index 2fe95dd..2c795f7 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/ShopUserCouponController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/ShopUserCouponController.java @@ -117,7 +117,9 @@ public class ShopUserCouponController extends BaseController { @Operation(summary = "领取优惠券") @PostMapping("/take") public ApiResult take(@RequestBody ShopUserCoupon userCoupon) { - ShopCoupon coupon = couponService.getByIdRel(userCoupon.getCouponId()); + final User loginUser = getLoginUser(); + if (loginUser == null) return fail("请先登录"); + ShopCoupon coupon = couponService.getByIdRel(userCoupon.getCouponId()); if (coupon.getTotalCount() != -1 && coupon.getReceiveNum() >= coupon.getTotalCount()) return fail("已经被领完了"); List userCouponList = shopUserCouponService.list( new LambdaQueryWrapper()