package com.gree.mall.miniapp.commonmapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gree.mall.miniapp.bean.material.*;
import com.gree.mall.miniapp.bean.material.parts.*;
import com.gree.mall.miniapp.bean.material.stock.WorkerNormStockBean;
import com.gree.mall.miniapp.plus.entity.AdminWebsit;
import com.gree.mall.miniapp.plus.entity.WebsitPartsSalesItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface MaterialMapper {


    /**
     * 购买记录
     */
    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    IPage<SalesOrderBean> buyList(IPage page, @Param("companyWechatId") String companyWechatId, @Param("userId") String userId, @Param("flag") String flag);

    /**
     * 网点库存分类
     *
     * @param companyWechatId
     * @param websitId
     * @return
     */
    List<WebsitSalesCategoryVO> existStockCategory(@Param("companyWechatId") String companyWechatId, @Param("websitId") String websitId);

    /**
     * 网点库存商品
     *
     * @param companyWechatId
     * @param websitId
     * @return
     */
    List<WebsitSalesGoodsVO> existStockGoods(@Param("companyWechatId") String companyWechatId,
                                             @Param("websitId") String websitId,
                                             @Param("goodsType") String goodsType,
                                             @Param("categoryId") String categoryId,
                                             @Param("goodsName") String goodsName);

    /**
     * 非网点库存商品
     *
     * @param companyWechatId
     * @param websitId
     * @return
     */
    List<WebsitSalesGoodsVO> notStockGoods(@Param("companyWechatId") String companyWechatId,
                                             @Param("websitId") String websitId,
                                             @Param("goodsType") String goodsType,
                                             @Param("categoryId") String categoryId,
                                             @Param("goodsName") String goodsName);

    /**
     *
     * @param page
     * @param companyWechatId
     * @param userId
     * @param orderId
     * @param goodsType
     * @param startTime
     * @param endTime
     * @return
     */
    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    IPage<NormRecordVO> normRecordList(IPage page,
                                       @Param("companyWechatId") String companyWechatId,
                                       @Param("userId") String userId,
                                       @Param("orderId") String orderId,
                                       @Param("goodsType") String goodsType,
                                       @Param("startTime") String startTime,
                                       @Param("endTime") String endTime);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    IPage<PartsRefundVO> partsRefundList(Page<Object> objectPage,
                                         @Param("companyWechatId") String currentCompanyWechatId,
                                         @Param("userId") String userId,
                                         @Param("type") String type,
                                         @Param("status") String status);

    /**
     * 查询购物车的商品清单
     * @param workerId
     * @param websitId
     * @param goodsType
     * @return
     */
    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<WebsitShoppingCartList> queryShoppingCartList(@Param("workerId") String workerId,
                                                       @Param("websitId") String websitId,
                                                       @Param("goodsType") String goodsType);

    /**
     * 收费标准师傅库存
     * @param goodsId
     * @param workerId
     * @return
     */
    List<WorkerNormStockBean> queryWorkerStockQty(@Param("goodsId") String goodsId, @Param("workerId") String workerId);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    IPage<NewRefundManageBean> appList(IPage page,
                                       @Param("companyWechatId") String companyWechatId,
                                       @Param("applyNo") String applyNo,
                                       @Param("flag") String flag,
                                       @Param("identity") String identity,
                                       @Param("partsNumber") String partsNumber);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    IPage<PartsSalesOrderBean> appSalesList(Page page,
                                            @Param("companyWechatId") String companyWechatId,
                                            @Param("identity") String identity,
                                            @Param("salesId") String salesId,
                                            @Param("status") String status,
                                            @Param("pushFlag") String pushFlag,
                                            @Param("partsNumber") String partsNumber);

    /**
     * 带锁的查询
     * @param websitId
     * @param salesId
     * @param partsWebsitId
     * @param identity
     * @param pushFlag
     * @param records
     * @return
     */
    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<WebsitPartsSalesItem> querySalesPushFlagItem(String websitId, String salesId, String partsWebsitId,
                                                      String identity, String pushFlag, List<SalesItemRecordDTO> records);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<PartsSalesOrderItemBean> selectItemBySalesOrderId(@Param("id") String id);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<OldRefundManageRecordBean> queryOldRefundRecordById(@Param("id") String id);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<String> websitGroupList(@Param("companyWechatId") String companyWechatId, @Param("websitId") String websitId, @Param("partsWebsitId") String partsWebsitId);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<WebsitPartsStockBean> existWebsitStockList(@Param("companyWechatId") String companyWechatId,
                                                    @Param("websitId") String websitId,
                                                    @Param("partsWebsitId") String partsWebsitId,
                                                    @Param("partsNumber") String partsNumber,
                                                    @Param("partsName") String partsName,
                                                    @Param("materialGroupName") String materialGroupName);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<AdminWebsit> existWebsitList(@Param("companyWechatId") String companyWechatId, @Param("identity") String identity);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<String> existWebsitGroupList(@Param("companyWechatId") String companyWechatId,
                                     @Param("identity") String identity,
                                     @Param("websitId") String websitId,
                                     @Param("partsWebsitId") String partsWebsitId,
                                     @Param("partsAttr") String partsAttr);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<PartsWorkerStockBean> existWorkerStockList(@Param("companyWechatId") String companyWechatId,
                                                    @Param("identity") String identity,
                                                    @Param("websitId") String websitId,
                                                    @Param("partsWebsitId") String partsWebsitId,
                                                    @Param("partsAttr") String partsAttr,
                                                    @Param("partsNumber") String partsNumber,
                                                    @Param("partsName") String partsName,
                                                    @Param("materialGroupName") String materialGroupName,
                                                    @Param("productRelaId") String productRelaId);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    List<WebsitPartsSalesItem> querySalesEndTimeByIdentity(@Param("companyWechatId") String companyWechatId,
                                                           @Param("websitId") String websitId,
                                                           @Param("partsWebsitId") String partsWebsitId,
                                                           @Param("identity") String identity);

    /**
     * 统计查询师傅旧件和新件库存
     * @param companyWechatId
     * @param identity
     * @param websitId
     * @return
     */
    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    WorkerStockCensusBean workerStockStatistics(@Param("companyWechatId") String companyWechatId,
                                                @Param("identity") String identity,
                                                @Param("websitId") String websitId);

    /**
     * 统计查询师傅新件待返还数量和金额
     * @param companyWechatId
     * @param identity
     * @param websitId
     * @return
     */
    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    WorkerStockCensusBean workerNewStockStatistics(@Param("companyWechatId") String companyWechatId,
                                                   @Param("identity") String identity,
                                                   @Param("websitId") String websitId);

    /**
     * 统计查询师傅旧件待返还数量和金额
     * @param companyWechatId
     * @param identity
     * @param websitId
     * @return
     */
    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    WorkerStockCensusBean workerOldStockStatistics(@Param("companyWechatId") String companyWechatId,
                                                   @Param("identity") String identity,
                                                   @Param("websitId") String websitId);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    IPage<OldRefundManageBean> appOldRefundList(Page page,
                                                @Param("companyWechatId") String companyWechatId,
                                                @Param("applyNo") String applyNo,
                                                @Param("repairFlag") String repairFlag,
                                                @Param("flag") String flag,
                                                @Param("identity") String identity,
                                                @Param("partsNumber") String partsNumber);

    @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
    IPage<WebsitExtends> queryWebsitList(Page page,
                                         @Param("companyWechatId") String companyWechatId,
                                         @Param("websitId") String websitId,
                                         @Param("longitude") String longitude,
                                         @Param("latitude") String latitude);
}
