package com.jianshui.web.controller.platform;

import cn.hutool.core.bean.BeanUtil;
import com.jianshui.common.core.controller.BaseController;
import com.jianshui.common.core.page.TableDataInfo;
import com.jianshui.invoice.domain.Invoice;
import com.jianshui.invoice.domain.dto.HXResponse;
import com.jianshui.invoice.mapper.InvoiceMapper;
import com.jianshui.platform.dto.InvoiceAdd.BillInfoPDTO;
import com.jianshui.platform.dto.InvoiceListQueryPDTO;
import com.jianshui.platform.dto.invoicered.InvoiceQueryPDTO;
import com.jianshui.platform.service.InvoiceAddPService;
import com.jianshui.platform.vo.InvoiceListPVO;
import com.jianshui.platform.vo.invoicered.InvoiceQueryPVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 发票录入
 * 
 */
@Api(tags={"发票管理"},value = "发票管理")
@RestController
@RequestMapping("/platForm/invoiceAdd/")
public class InvoiceAddPController extends BaseController {
    @Autowired
    private InvoiceAddPService addService;

    @Autowired
    private InvoiceMapper invoiceMapper;

    @ApiOperation(value = "发票开具(数电)",notes = "发票直接开具请求(支持数电普票、数电专票)")
    @PostMapping( "invoiceIssuance")
    public HXResponse invoiceIssuance(@RequestBody BillInfoPDTO billInfoPDTO) throws Exception {
        return addService.invoiceIssuance(billInfoPDTO);
    }

    @ApiOperation(value = "蓝字发票查询",notes = "查询所有未冲红蓝字发票")
    @GetMapping( "invoiceQuery")
    public TableDataInfo invoiceQuery(InvoiceQueryPDTO invoiceQueryPDTO) throws Exception {

        startPage();
        Invoice invoice = BeanUtil.copyProperties(invoiceQueryPDTO,Invoice.class);
        List<Invoice> invoiceLIst = invoiceMapper.selectInvoiceList(invoice);

        List<InvoiceQueryPVO> invoiceQueryPVOS = BeanUtil.copyToList(invoiceLIst,InvoiceQueryPVO.class);
        return getDataTable(invoiceQueryPVOS);
    }

    @ApiOperation(value = "发票管理列表",notes = "发票管理")
    @GetMapping( "invoiceList")
    public TableDataInfo invoiceList(InvoiceListQueryPDTO queryPDTO) throws Exception {

        startPage();
        Invoice invoice = BeanUtil.copyProperties(queryPDTO,Invoice.class);
        List<Invoice> invoiceLIst = invoiceMapper.selectInvoiceList(invoice);

        List<InvoiceListPVO> invoiceListPVOS = BeanUtil.copyToList(invoiceLIst,InvoiceListPVO.class);
        return getDataTable(invoiceListPVOS);
    }



























}
