package shop.alien.store.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiSort;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.entity.store.vo.StoreSalesDetailsVo;
import shop.alien.store.service.StoreSalesDetailsService;

@Api(tags = {"二期-售卖明细"})
@Slf4j
@ApiSort(11)
@CrossOrigin
@RestController
@RequestMapping("/salesDetails")
@RequiredArgsConstructor
public class StoreSalesDetailsController {

    private final StoreSalesDetailsService storeSalesDetailsService;

    @ApiOperation("获取门店售卖明细")
    @ApiOperationSupport(order = 1)
    @PostMapping("/getSalesDetails")
    public R<IPage<StoreSalesDetailsVo>> getSalesDetails(@RequestBody StoreSalesDetailsVo storeSalesDetailsVo) {
        log.info("StoreSalesDetailsController.getSalesDetails?storeSalesDetailsVo=" + storeSalesDetailsVo.toString());
        return R.data(storeSalesDetailsService.getSalesDetails(storeSalesDetailsVo));
    }

    @ApiOperation("查询套餐/代金券")
    @ApiOperationSupport(order = 2)
    @PostMapping("/getCouponDetails")
    public R<IPage<StoreSalesDetailsVo>> getCouponDetails(@RequestBody StoreSalesDetailsVo storeSalesDetailsVo) {
        System.out.println(storeSalesDetailsVo.toString());
        log.info("StoreSalesDetailsController.getCouponDetails?storeSalesDetailsVo=" + storeSalesDetailsVo.toString());
        return R.data(storeSalesDetailsService.getCouponDetails(storeSalesDetailsVo));
    }

}
