无关风月
2025-01-10 3cad62fb2e427a721da31f8afbbe3248655ff479
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.jilongda.applet.controller;
 
 
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 java.time.LocalDateTime;
 
/**
 * <p>
 * 优惠券领取记录 前端控制器
 * </p>
 *
 * @author 无关风月
 * @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();
//    }
}