jyy
2021-03-19 382794b20c47d0f74317b2ac5bb7b6849986166f
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.matrix.system.shopXcx.api.action;
 
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.shopXcx.api.service.WxShopCouponService;
import com.matrix.system.shopXcx.dao.ShopCouponDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
/**
 * @author jyy
 * @description 优惠券
 * @date 2019-06-12 15:17
 */
@Controller
@RequestMapping(value = "wxapi/shopCoupon")
public class WxShopCouponAction {
 
    @Autowired
    private WxShopCouponService shopCouponService;
 
    @Autowired
    private ShopCouponDao shopCouponDao;
    @Autowired
    private RedisUserLoginUtils redisUserLoginUtils;
 
    /**
     * 获取可以领取的优惠券
     *
     * @return
     */
    @RequestMapping(value = "getUsableCoupon")
    @ResponseBody
    public AjaxResult getUsableCoupon(@RequestBody PaginationVO pageVo) {
 
        pageVo.setSort("update_time");
        pageVo.setOrder("desc");
        return shopCouponService.getUsableCoupon(pageVo);
    }
 
    /**
     * 领取优惠券
     *
     * @param couponId 优惠券ID
     * @return
     */
    @GetMapping(value = "receiveCoupon/{couponId}")
    @ResponseBody
    public AjaxResult receiveCoupon(@PathVariable("couponId") Integer couponId) {
        return shopCouponService.receiveCoupon(couponId);
    }
 
    /**
     * 根据优惠券状态查询我的优惠券信息(1=已使用;2=待使用;3=过期)
     *
     * @return
     */
    @RequestMapping(value = "getMyCouponInfoByStatus/{status}")
    @ResponseBody
    public AjaxResult getMyCouponInfo(@PathVariable("status") Integer status, @RequestBody PaginationVO pageVo) {
 
        return shopCouponService.getMyCouponInfoByStatus(HostInterceptor.getCompanyId(),status, pageVo);
    }
 
    /**
     * 根据产品id获取可用的优惠券列表
     *
     * @return
     */
    @GetMapping(value = "getCouponListByProductId/{productId}")
    @ResponseBody
    public AjaxResult getCouponListByProductId(@PathVariable("productId") int productId) {
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, shopCouponService.getCouponListByProductId(productId));
    }
 
    @GetMapping(value = "getCouponListByTag/{tag}")
    @ResponseBody
    public AjaxResult getCouponListByTag(@PathVariable("tag") String tag) {
        return shopCouponService.getCouponListByTag(tag, HostInterceptor.getCompanyId());
    }
 
}