package org.jeecg.modules.api.teambuyController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.apiBean.PageBean;
import org.jeecg.modules.apiService.CouponService;
import org.jeecg.modules.apiService.ShopcarService;
import org.jeecg.modules.teambuyBuycar.entity.TeambuyBuycar;
import org.jeecg.modules.teambuyCoupon.entity.TeambuyCoupon;
import org.jeecg.modules.teambuyCouponUser.entity.TeambuyCouponUser;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags="我的-优惠券相关接口")
@RestController
@RequestMapping("/teambuy/coupon")
@Slf4j
public class CouponController {
    /******************************************************************************************************************/
    //优惠券
    @Resource
    private CouponService couponService;
    /******************************************************************************************************************/
    //查看优惠券列表
    @ApiOperation(value="优惠券-查看我的优惠券列表/详情", notes="优惠券-查看我的优惠券列表/详情")
    @RequestMapping(value = "/queryCouponList", method = {RequestMethod.GET})
    public Result<?> queryCouponList(@RequestHeader("X-Access-Token") String token, TeambuyCouponUser teambuyCouponUser, PageBean pageBean){
        return couponService.queryCouponList(token, teambuyCouponUser, pageBean);
    }

    //查看可领取的优惠券
    @ApiOperation(value="优惠券-查看可领取的优惠券", notes="优惠券-查看可领取的优惠券")
    @RequestMapping(value = "/queryFetchCouponList", method = {RequestMethod.GET})
    public Result<?> queryFetchCouponList(@RequestHeader("X-Access-Token") String token){
        return couponService.queryFetchCouponList(token);
    }

    //获取优惠券
    @ApiOperation(value="优惠券-领取优惠券", notes="优惠券-领取优惠券")
    @RequestMapping(value = "/fetchCoupon", method = {RequestMethod.POST})
    public Result<?> fetchCoupon(@RequestHeader("X-Access-Token") String token, String couponId){
        return couponService.fetchCoupon(token, couponId);
    }

    //使用优惠券
    @ApiOperation(value="优惠券-使用优惠券", notes="优惠券-使用优惠券")
    @RequestMapping(value = "/useCoupon", method = {RequestMethod.POST})
    public Result<?> useCoupon(@RequestHeader("X-Access-Token") String token, String userCouponId){
        return couponService.useCoupon(token, userCouponId);
    }




}
