package com.fs.app.controller;


import com.fs.app.annotation.Login;
import com.fs.common.core.domain.R;
import com.fs.common.param.BaseQueryParam;
import com.fs.store.domain.FsStoreCouponIssue;
import com.fs.store.domain.FsStoreCouponUser;
import com.fs.store.param.FsCouponIssueParam;
import com.fs.store.param.FsCouponUserEnableParam;
import com.fs.store.param.FsCouponUserParam;
import com.fs.store.param.FsStoreCouponReceiveParam;
import com.fs.store.service.IFsStoreCouponIssueService;
import com.fs.store.service.IFsStoreCouponService;
import com.fs.store.service.IFsStoreCouponUserService;
import com.fs.store.vo.FsStoreCouponIssueVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.stream.Collectors;


@Api("优惠券接口")
@RestController
@RequestMapping(value="/app/coupon")
public class CouponController extends  AppBaseController {

    @Autowired
    private IFsStoreCouponIssueService fsStoreCouponIssueService;
    @Autowired
    private IFsStoreCouponService couponService;
    @Autowired
    private IFsStoreCouponUserService fsStoreCouponUserService;





    @Login
    @ApiOperation("获取销售可用套餐卷列表")
    @GetMapping("/getCompanyCouponIssueList")
    public R getCompanyCouponIssueList(FsCouponIssueParam param, HttpServletRequest request){
        PageHelper.startPage(param.getPage(), param.getPageSize());
        try {
            List<FsStoreCouponIssueVO> list=fsStoreCouponIssueService.getCompanyCouponIssueList(param);
            PageInfo<FsStoreCouponIssueVO> listPageInfo=new PageInfo<>(list);
            return R.ok().put("data",listPageInfo);
        } catch (Exception e){
            return R.error("操作异常");
        }
    }
    @Login
    @ApiOperation("获取销售可用套餐卷")
    @GetMapping("/getCouponIssueById")
    public R getCouponIssueById(@RequestParam(value="id") Long id, HttpServletRequest request){


        FsStoreCouponIssueVO couponIssue=fsStoreCouponIssueService.selectFsStoreCouponIssueVOById(id);
        return R.ok().put("data",couponIssue);
    }




}
