From a38256f9ca869a61fcad1d116041a262e9285edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Fri, 22 Aug 2025 16:55:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(shop):=20=E4=BF=AE=E5=A4=8D=E6=9C=AA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7=E5=8F=AF=E9=A2=86=E5=8F=96?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E7=9A=84bug-=20=E5=9C=A8=E9=A2=86?= =?UTF-8?q?=E5=8F=96=E4=BC=98=E6=83=A0=E5=88=B8=E6=8E=A5=E5=8F=A3=E4=B8=AD?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=99=BB=E5=BD=95=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20-=20=E7=A1=AE=E4=BF=9D=E5=8F=AA=E6=9C=89?= =?UTF-8?q?=E5=B7=B2=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7=E6=89=8D=E8=83=BD?= =?UTF-8?q?=E9=A2=86=E5=8F=96=E4=BC=98=E6=83=A0=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gxwebsoft/shop/controller/ShopUserCouponController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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()