package com.fs.app.controller.live;

import com.fs.app.annotation.Login;
import com.fs.app.controller.AppBaseController;
import com.fs.app.facade.LiveFacadeService;
import com.fs.common.core.domain.R;
import com.fs.live.param.CouponPO;
import com.fs.live.service.ILiveCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/app/live/coupon")
public class LiveCouponController extends AppBaseController {

    @Autowired
    private ILiveCouponService liveCouponService;
    @Autowired
    private LiveFacadeService liveFacadeService;

    /**
     * 领取优惠券
     */
    @Login
    @PostMapping("/claim")
    public R claim(@RequestBody CouponPO coupon) {
        coupon.setUserId(Long.parseLong(getUserId()));
        return liveFacadeService.couponClaim(coupon);
    }

    /**
     * 用户优惠券列表
     */
    @Login
    @PostMapping("/list")
    public R list(@RequestBody CouponPO coupon) {
        coupon.setUserId(Long.parseLong(getUserId()));
        return liveCouponService.userCouponList(coupon);
    }

    /**
     * 当前商品优惠券
     */
    @Login
    @PostMapping("/curCoupon")
    public R curCoupon(@RequestBody CouponPO coupon) {
        coupon.setUserId(Long.parseLong(getUserId()));
        return liveCouponService.curCoupon(coupon);
    }

}
