package com.cool.store.controller.webb;

import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo;
import com.cool.store.dto.InvoicingDTO;
import com.cool.store.request.LineListRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.InvoicingService;
import com.cool.store.vo.LineInfoVO;
import com.cool.store.vo.LineListVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author suzhuhong
 * @Date 2024/12/31 14:02
 * @Version 1.0
 */
@RestController
@RequestMapping("/pc/invoicing")
@Api("发票")
public class InvoicingController {

    @Resource
    InvoicingService invoicingService;


    @ApiOperation("提交发票")
    @PostMapping("/submitInvoicing")
    public ResponseResult<Boolean> submitInvoicing(@RequestBody InvoicingDTO invoicingDTO) {
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(invoicingService.addInvoicing(invoicingDTO,user));
    }

    @ApiOperation("编辑发票")
    @PostMapping("/editInvoicing")
    public ResponseResult<Boolean> editInvoicing(@RequestBody InvoicingDTO invoicingDTO) {
        LoginUserInfo user = CurrentUserHolder.getUser();
        return ResponseResult.success(invoicingService.editInvoicing(invoicingDTO,user));
    }

    @ApiOperation("查询发票")
    @GetMapping("/getInvoicingByShopId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "shopId", value = "门店shopId", required = true)
    })
    public ResponseResult<InvoicingDTO> getInvoicingByShopId(@RequestParam("shopId")Long shopId) {
        return ResponseResult.success(invoicingService.getInvoicingByShopId(shopId));
    }


}
