package com.zfire.mall.manager.commonmapper;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zfire.mall.manager.bean.invoice.*;
import com.zfire.mall.manager.bean.pick.PickManagerPushBean;
import com.zfire.mall.manager.bean.pick.PickSummary;
import com.zfire.mall.manager.bean.sale.SaleOrderBean;
import com.zfire.mall.manager.plus.entity.InvoiceApplication;
import com.zfire.mall.manager.zfire.bean.ZfireParamBean;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * @author chang
 */
@Mapper
public interface InvoiceMapper {

    IPage<InvoiceBean> listInvoice(IPage page,
                                   @Param("automaticStatus") Integer automaticStatus,
                                   @Param("createBy") String createBy,
                                   @Param("approvalName") String approvalName,
                                   @Param("categoryId") String categoryId,
                                   @Param("k3ServiceId") String k3ServiceId,
                                   @Param("mainOrderId") String mainOrderId,
                                   @Param("id") String id,
                                   @Param("categoryName") String categoryName,
                                   @Param("type") Integer type,
                                   @Param("customerName") String customerName,
                                   @Param("correspondId") String correspondId,
                                   @Param("correspondName") String correspondName,
                                   @Param("materialName") String materialName,
                                   @Param("specification") String specification,
                                   @Param("startTime") String startTime,
                                   @Param("endTime") String endTime,
                                   @Param("customerNumber") String customerNumber,
                                   @Param("examineStatus") String examineStatus,
                                   @Param("orderType") String orderType,
                                   @Param("customerId") String customerId,
                                   @Param("serviceIds") List<String> serviceIds,
                                   @Param("status") String status,
                                   @Param("serviceId") String serviceId,
                                   @Param("k3CategoryIds") List<String> k3CategoryIds
                                   );

    InvoiceBody detail(String id);

    Integer selectInteger(@Param("materialId") String materialId, @Param("correspondId") String correspondId);


    IPage<InvoiceProjectBean> listProject(IPage page,
                                          @Param("automaticStatus") Integer automaticStatus,
                                          @Param("createBy") String createBy,
                                          @Param("refRegionWork") String refRegionWork,
                                          @Param("approvalName") String approvalName,
                                          @Param("categoryId") String categoryId,
                                          @Param("k3ServiceId") String k3ServiceId,
                                          @Param("refUseUnit") String refUseUnit,
                                          @Param("mainOrderId") String mainOrderId,
                                          @Param("id") String id,
                                          @Param("customerName") String customerName,
                                          @Param("type") Integer type,
                                          @Param("correspondId") String correspondId,
                                          @Param("correspondName") String correspondName,
                                          @Param("materialName") String materialName,
                                          @Param("specification") String specification,
                                          @Param("startTime") String startTime,
                                          @Param("endTime") String endTime,
                                          @Param("customerNumber") String customerNumber,
                                          @Param("examineStatus") String examineStatus,
                                          @Param("orderType") String orderType,
                                          @Param("customerId") String customerId,
                                          @Param("serviceIds") List<String> serviceIds,
                                          @Param("refEnginRecordNo") String refEnginRecordNo,
                                          @Param("status") String status,
                                          @Param("serviceId") String serviceId,
                                          @Param("k3CategoryIds") List<String> k3CategoryIds);


    InvoiceProjectBody detailProject(String id);

    @SqlParser(filter = true)
    List<InvoicePickBean> listInvoicePick(@Param("correspondId") String correspondId,
                                          @Param("customerId") String customerId,
                                          @Param("serviceIds") List<String> serviceIds,
                                          @Param("k3CategoryIds") List<String> k3CategoryIds);

    @SqlParser(filter = true)
    IPage<InvoiceOrder> listOrder(IPage page,
                                  @Param("specification") String specification,
                                  @Param("id") String id,
                                  @Param("categoryName") String categoryName,
                                  @Param("customerId") String customerId,
                                  @Param("serviceIds") List<String> serviceIds,
                                  @Param("adminCompanyIds") List<String> adminCompanyIds,
                                  @Param("k3CategoryIds") List<String> k3CategoryIds);


    @SqlParser(filter = true)
    IPage<InvoiceProjectOrder> listProjectOrder(IPage page,
                                                @Param("enginOrderNo") String enginOrderNo,
                                                @Param("refEnginRecordNo") String refEnginRecordNo,
                                                @Param("categoryName") String categoryName,
                                                @Param("refProjectName") String refProjectName,
                                                @Param("specification") String specification,
                                                @Param("startTime") String startTime,
                                                @Param("endTime") String endTime,
                                                @Param("customerId") String customerId,
                                                @Param("serviceIds") List<String> serviceIds,
                                                @Param("k3CategoryIds") List<String> k3CategoryIds);


    @SqlParser(filter = true)
    PickSummary summary(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @SqlParser(filter = true)
    PickSummary summaryHome(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @SqlParser(filter = true)
    PickSummary summaryTrade(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @SqlParser(filter = true)
    PickSummary summaryLif(@Param("startTime") String startTime, @Param("endTime") String endTime);

    Integer selectInvoice(String retailId);

    Integer selectInvoiceOk(String retailId);

    @SqlParser(filter = true)
    List<InvoiceRetreatOrder> listInvoiceRetreat(String mainOrderId);

    @SqlParser(filter = true)
    IPage<InvoiceBean> listInvoiceHuiZong(IPage page,
                                          @Param("invoicePrintStatus") Integer invoicePrintStatus,
                                          @Param("createBy") String createBy,
                                          @Param("refEnginRecordNo") String refEnginRecordNo,
                                          @Param("discriminate") String discriminate,
                                          @Param("materialOldNumber") String materialOldNumber,
                                          @Param("printStatus") Integer printStatus,
                                          @Param("type") Integer type,
                                          @Param("approvalStartTime") String approvalStartTime,
                                          @Param("approvalEndTime") String approvalEndTime,
                                          @Param("categoryId") String categoryId,
                                          @Param("k3ServiceId") String k3ServiceId,
                                          @Param("mainOrderId") String mainOrderId,
                                          @Param("id") String id,
                                          @Param("categoryName") String categoryName,
                                          @Param("customerName") String customerName,
                                          @Param("correspondId") List<String> correspondId,
                                          @Param("correspondName") String correspondName,
                                          @Param("materialName") String materialName,
                                          @Param("specification") String specification,
                                          @Param("startTime") String startTime,
                                          @Param("endTime") String endTime,
                                          @Param("customerNumber") String customerNumber,
                                          @Param("examineStatus") String examineStatus,
                                          @Param("materialNumber") String materialNumber,
                                          @Param("customerId") String customerId,
                                          @Param("serviceIds") List<String> serviceIds,
                                          @Param("createStartTime") String createStartTime,
                                          @Param("createEndTime") String createEndTime,
                                          @Param("serviceId") String serviceId,
                                          @Param("k3CategoryIds") List<String> k3CategoryIds);

    @SqlParser(filter = true)
    IPage<SaleOrderBean> listSaleOrder(IPage page,
                                       @Param("categoryName") String categoryName,
                                       @Param("mainOrderId") String mainOrderId,
                                       @Param("enginOrderNo") String enginOrderNo,
                                       @Param("refEnginRecordNo") String refEnginRecordNo,
                                       @Param("refProjectName") String refProjectName,
                                       @Param("saleType") Integer saleType,
                                       @Param("id") String id,
                                       @Param("correspondName") String correspondName,
                                       @Param("materialNumber") String materialNumber,
                                       @Param("orderNo") String orderNo,
                                       @Param("customerName") String customerName,
                                       @Param("correspondId") String correspondId,
                                       @Param("specification") String specification,
                                       @Param("materialName") String materialName,
                                       @Param("customerNumber") String customerNumber,
                                       @Param("startTime") String startTime,
                                       @Param("endTime") String endTime,
                                       @Param("customerId") String customerId,
                                       @Param("serviceIds") List<String> serviceIds,
                                       @Param("k3CategoryIds") List<String> k3CategoryIds);

    Integer selectReserved(String retailId);

    void printAdd(List<String> ids);

    InvoiceNumber listInvoiceNumber(IPage page,
                              @Param("invoicePrintStatus") Integer invoicePrintStatus,
                              @Param("createBy") String createBy,
                              @Param("refEnginRecordNo") String refEnginRecordNo,
                              @Param("discriminate") String discriminate,
                              @Param("materialOldNumber") String materialOldNumber,
                              @Param("printStatus") Integer printStatus,
                              @Param("type") Integer type,
                              @Param("approvalStartTime") String approvalStartTime,
                              @Param("approvalEndTime") String approvalEndTime,
                              @Param("categoryId") String categoryId,
                              @Param("k3ServiceId") String k3ServiceId,
                              @Param("mainOrderId") String mainOrderId,
                              @Param("id") String id,
                              @Param("categoryName") String categoryName,
                              @Param("customerName") String customerName,
                              @Param("correspondId") List<String> correspondId,
                              @Param("correspondName") String correspondName,
                              @Param("materialName") String materialName,
                              @Param("specification") String specification,
                              @Param("startTime") String startTime,
                              @Param("endTime") String endTime,
                              @Param("customerNumber") String customerNumber,
                              @Param("examineStatus") String examineStatus,
                              @Param("materialNumber") String materialNumber,
                              @Param("customerId") String customerId,
                              @Param("serviceIds") List<String> serviceIds,
                              @Param("createStartTime") String createStartTime,
                              @Param("createEndTime") String createEndTime,
                              @Param("serviceId") String serviceId,
                              @Param("k3CategoryIds") List<String> k3CategoryIds);

    Integer selectSalesNum(String retailId);

    @SqlParser(filter = true)
    void updateStatus(String id);

    @SqlParser(filter = true)
    void updateInvoice(@Param("id") String id);

    @SqlParser(filter = true)
    void updateSalseOrderId(@Param("id")String id);

    @SqlParser(filter = true)
    Integer listInvoiceHuiZongCount(
                                          @Param("invoicePrintStatus") Integer invoicePrintStatus,
                                          @Param("createBy") String createBy,
                                          @Param("refEnginRecordNo") String refEnginRecordNo,
                                          @Param("discriminate") String discriminate,
                                          @Param("materialOldNumber") String materialOldNumber,
                                          @Param("printStatus") Integer printStatus,
                                          @Param("type") Integer type,
                                          @Param("approvalStartTime") String approvalStartTime,
                                          @Param("approvalEndTime") String approvalEndTime,
                                          @Param("categoryId") String categoryId,
                                          @Param("k3ServiceId") String k3ServiceId,
                                          @Param("mainOrderId") String mainOrderId,
                                          @Param("id") String id,
                                          @Param("categoryName") String categoryName,
                                          @Param("customerName") String customerName,
                                          @Param("correspondId") List<String> correspondId,
                                          @Param("correspondName") String correspondName,
                                          @Param("materialName") String materialName,
                                          @Param("specification") String specification,
                                          @Param("startTime") String startTime,
                                          @Param("endTime") String endTime,
                                          @Param("customerNumber") String customerNumber,
                                          @Param("examineStatus") String examineStatus,
                                          @Param("materialNumber") String materialNumber,
                                          @Param("customerId") String customerId,
                                          @Param("serviceIds") List<String> serviceIds,
                                          @Param("createStartTime") String createStartTime,
                                          @Param("createEndTime") String createEndTime,
                                          @Param("serviceId") String serviceId,
                                          @Param("k3CategoryIds") List<String> k3CategoryIds);


    List<PickManagerPushBean> listPush(String syncTime);


    @SqlParser(filter = true)
    void updateWithold(@Param("id") String id, @Param("retailUpdate") String retailUpdate);

    @SqlParser(filter = true)
    void updateWitholdOrder(@Param("orderId")String orderId,@Param("retailUpdate") String retailUpdate);

    Page<InvoiceApplicationPick> listInvoiceOrder(IPage page, @Param("date")Date date,
                                              @Param("customerId")String customerId,
                                              @Param("serviceIds")List<String> serviceIds,
                                              @Param("k3CategoryIds")List<String> k3CategoryIds,
                                                  @Param("invoiceId")String invoiceId,
                                                  @Param("startTime")String startTime,
                                                  @Param("endTime")String endTime,
                                                  @Param("userName")String userName,
                                                  @Param("address")String address,
                                                  @Param("remark")String remark);


    @SqlParser(filter = true)
    IPage<InvoiceVO> listV2(Page page, @Param("ex")ZfireParamBean zfireParamBean,
                            @Param("customerId") String customerId,
                            @Param("serviceIds")  List<String> serviceIds,
                            @Param("k3CategoryIds") List<String> k3CategoryIds);

    @SqlParser(filter = true)
    Integer listCountV2(@Param("ex")ZfireParamBean zfireParamBean,
                        @Param("customerId") String customerId,
                        @Param("serviceIds")  List<String> serviceIds,
                        @Param("k3CategoryIds") List<String> k3CategoryIds);

    @SqlParser(filter = true)
    IPage<InvoiceRetailVO> listRetailV2(Page page,@Param("ex")ZfireParamBean zfireParamBean,
                                        @Param("customerId") String customerId,
                                        @Param("serviceIds")  List<String> serviceIds,
                                        @Param("k3CategoryIds") List<String> k3CategoryIds,
                                        @Param("integer") Integer integer);

    @SqlParser(filter = true)
    IPage<InvoiceProjectVO> listProjectV2(Page page,@Param("ex")ZfireParamBean zfireParamBean,
                                          @Param("customerId") String customerId,
                                          @Param("serviceIds")  List<String> serviceIds,
                                          @Param("k3CategoryIds") List<String> k3CategoryIds,
                                          @Param("orderType") String orderType);

    @SqlParser(filter = true)
    InvoiceNumber listInvoiceNumberV2(@Param("ex")ZfireParamBean zfireParamBean,
                                      @Param("customerId")String customerId,
                                      @Param("serviceIds")List<String> serviceIds,
                                      @Param("k3CategoryIds")List<String> k3CategoryIds);
    @SqlParser(filter = true)
    void updatePick(String id);


    @SqlParser(filter = true)
    void updateTaiZhang(@Param("id") String id);

    @SqlParser(filter = true)
    void updateSaleTaiZhang(@Param("id")String id);


    @SqlParser(filter = true)
    void updateSaleOrderTaiZhang(@Param("enginOrderNo")String enginOrderNo);

    @SqlParser(filter = true)
    List<InvoiceRetailVO> retailList(List<String> collect);

    @SqlParser(filter = true)
    List<InvoiceProjectVO> projectList(List<String> collect);

    @SqlParser(filter = true)
    List<InvoiceVO> huiZongList(List<String> collect);

    Long listOrderNum(                   @Param("specification") String specification,
                                         @Param("id") String id,
                                         @Param("categoryName") String categoryName,
                                         @Param("customerId") String customerId,
                                         @Param("serviceIds") List<String> serviceIds,
                                         @Param("adminCompanyIds") List<String> adminCompanyIds,
                                         @Param("k3CategoryIds") List<String> k3CategoryIds);

    List<String> detection();
}
