From ff1be70b35a043a42ef7471c3ed9f10a9a736db0 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 09 一月 2025 14:33:04 +0800
Subject: [PATCH] bug修改
---
applet/src/main/java/com/jilongda/applet/controller/TCouponController.java | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/applet/src/main/java/com/jilongda/applet/controller/TCouponController.java b/applet/src/main/java/com/jilongda/applet/controller/TCouponController.java
index 74de739..4132109 100644
--- a/applet/src/main/java/com/jilongda/applet/controller/TCouponController.java
+++ b/applet/src/main/java/com/jilongda/applet/controller/TCouponController.java
@@ -1,9 +1,21 @@
package com.jilongda.applet.controller;
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.jilongda.applet.model.TCoupon;
+import com.jilongda.applet.model.TCouponReceive;
+import com.jilongda.applet.model.TLineUp;
+import com.jilongda.applet.service.TCouponReceiveService;
+import com.jilongda.applet.service.TCouponService;
+import com.jilongda.applet.utils.LoginInfoUtil;
+import com.jilongda.common.basic.ApiResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
-import org.springframework.web.bind.annotation.RestController;
+import java.time.LocalDateTime;
/**
* <p>
@@ -14,8 +26,35 @@
* @since 2024-12-09
*/
@RestController
+@Api(tags = "扫码获取优惠券")
@RequestMapping("/t-coupon")
public class TCouponController {
-
+ @Autowired
+ private TCouponService couponService;
+ @Autowired
+ private TCouponReceiveService couponReceiveService;
+ @Autowired
+ private LoginInfoUtil loginInfoUtil;
+ @ApiOperation(value = "扫码获取优惠券")
+ @GetMapping(value = "/scanCode")
+ public ApiResult scanCode(Integer id) {
+ TCoupon coupon = couponService.getById(id);
+ if (coupon==null){
+ return ApiResult.failed("优惠券已失效");
+ }
+ TCouponReceive tCouponReceive = new TCouponReceive();
+ tCouponReceive.setCouponId(coupon.getId());
+ tCouponReceive.setUserId(loginInfoUtil.getUserId());
+ tCouponReceive.setType(4);
+ tCouponReceive.setAmount(coupon.getAmount());
+ tCouponReceive.setStoreId(coupon.getStoreId());
+ if (coupon.getTime()!=0){
+ tCouponReceive.setEndTime(LocalDateTime.now().plusDays(coupon.getTime()));
+ }
+ tCouponReceive.setAmountCondition(coupon.getAmountCondition());
+ tCouponReceive.setStatus(1);
+ couponReceiveService.save(tCouponReceive);
+ return ApiResult.success();
+ }
}
--
Gitblit v1.7.1