package com.bonus.canteen.core.drp.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.drp.model.DrpIntoDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface DrpIntoDetailMapper extends BaseMapper<DrpIntoDetail> {
//   List<DrpIntoDetailPageVO> selectListByIntoId(String intoId);
//
//   List<NoOutInventoryVO> selectNoOutInventory(@Param("configId") Long configId);
//
//   List<AndroidIntoDetailPageVO> selectAndroidListByIntoId(String intoId);
//
//   @Select({"select detail_id,inventory_num,material_id,unit_id,supplier_id,unit_price from drp_into_detail where detail_id = #{intoDetailId}"})
//   NoOutInventoryVO selectDetailByDetailId(Long intoDetailId);
//
//   Page<DrpInventoryIntoDetailPageVO> pageDrpIntoDetail(Page<?> resultPage, @Param("content") DrpIntoDetailPageDTO content, @Param("status") Integer status);

   List<DrpIntoDetail> listIntoDetailByInventoryId(@Param("inventoryId") Long inventoryId, @Param("intoStatus") Integer intoStatus, @Param("leastNum") Integer leastNum);

//   @Select({"select did.detail_id,did.inventory_id,did.material_id,mm.material_name,did.product_date,did.expire_time,did.into_id,did.inventory_num,did.unit_id,du.unit_name,did.unit_price,did.size,dii.into_date from drp_into_detail did LEFT JOIN menu_material mm on mm.material_id = did.material_id LEFT JOIN drp_unit du on du.unit_id = did.unit_id left join drp_into_inventory dii on dii.into_id = did.into_id ${ew.customSqlSegment} ORDER BY dii.into_date ASC"})
//   List<DrpInventoryMaterialVO> listInventoryMaterial(@Param("ew") QueryWrapper<DrpIntoDetail> queryWrapper);
//
//   @Select({"select distinct did.unit_id,du.unit_name,du.rate from drp_into_detail did LEFT JOIN drp_into_inventory dii on dii.into_id = did.into_id LEFT JOIN drp_unit du on du.unit_id = did.unit_id ${ew.customSqlSegment}"})
//   List<DrpUnitModel> getOutUnit(@Param("ew") QueryWrapper<DrpIntoDetail> queryWrapper);
//
//   List<DrpExcelIntoDetailVO> listExcelDetail(String intoId);

   @Update({"update drp_into_detail set inventory_num = inventory_num + #{inventoryNum} where detail_id = #{detailId}"})
   void plusInventoryNumByDetailId(@Param("detailId") Long detailId, @Param("inventoryNum") BigDecimal inventoryNum);

   @Update({"update drp_into_detail set inventory_num = inventory_num - #{inventoryNum} where detail_id = #{detailId}"})
   void minusInventoryNumByDetailId(@Param("detailId") Long detailId, @Param("inventoryNum") BigDecimal inventoryNum);
//
//   MaterialIntoDetailModel selectLastIntoDetail(@Param("materialId") Long materialId, @Param("warehouseId") Long warehouseId, @Param("status") Integer status);
//
//   List<DrpIntoByMaterialListVO> listIntoByMaterial(@Param("content") DrpIntoByMaterialListDTO content, @Param("status") Integer status);
//
//   List<AndroidIntoDetailPageVO> selectAndroidListByIntoIdList(@Param("intoIdList") List<String> intoIdList);
//
//   BigDecimal getDeliveryQualifiedRate(@Param("supplierId") Long supplierId, @Param("startTime") LocalDate startTime, @Param("endTime") LocalDate endTime, @Param("intoStatus") Integer intoStatus);
//
//   List<DrpEachBatchInventoryPageVO> pageEachBatchInventory(@Param("content") DrpEachBatchInventoryPageDTO content, @Param("pinyinInitials") String pinyinInitials, @Param("pinyinFull") String pinyinFull, @Param("intoStatus") Integer intoStatus);
//
//   List<IntoOutOverviewVO> selectCountAndAmount(@Param("warehouseIdList") List<Long> warehouseIdList);
//
//   List<IntoCategoryDistributeVO> getCategoryDistribute(@Param("warehouseId") String warehouseId);
//
//   List<IntoCategoryDistributeVO> outActivity(@Param("content") DrpStatisticsQueryDTO content);
//
//   List<IntoIdAndOutIdByMaterialIdListModel> listIntoIdAndOutIdByMaterialId(@Param("content") IntoIdAndOutIdByMaterialIdListDTO content, @Param("status") Integer status);
//
//   List<IntoModel> listIntoIdByMaterialId(@Param("content") IntoIdAndOutIdByMaterialIdListDTO content, @Param("status") Integer status);
//
//   List<DrpIntoDetailListVO> listIntoDetailByIntoId(@Param("intoId") String intoId);
//
//   List<LeastPriceAndDateModel> listLeastPriceAndDate(@Param("materialIdList") List<Long> materialIdList, @Param("status") Integer status);
//
//   List<LeastPriceAndDateModel> listMonthPrice(@Param("materialIdList") List<Long> materialIdList, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("status") Integer status);
//
//   Integer checkIfOut(@Param("intoId") String intoId);
//
//   List<CancelInventoryDetailModel> listCancelInventoryDetail(@Param("intoId") String intoId);
//
//   List<DrpOrderGoodsIntoDetailPageVO> pageOrderGoodsIntoDetail(@Param("content") DrpOrderGoodsIntoDetailPageDTO content);
//
//   List<MaterialIntoDetailInfoListVO> listMaterialIntoDetailInfo(@Param("content") MaterialIntoDetailInfoListDTO content, @Param("status") Integer status);
//
//   List<DrpMqCancelIntoAndOutModel> listCancelIntoDetailMq(@Param("recordId") String recordId);
//
//   List<DrpBackFieldIntoDetailVO> listBackFieldIntoDetail(@Param("content") DrpBackFieldIntoDetailDTO content, @Param("status") Integer status);
//
//   List<DrpIntoDetailListVO> pageIntoDetailByIntoId(@Param("content") DrpOrderDetailPageDTO content);
//
//   String selectFirstDetailSupplierName(@Param("intoId") String intoId);
}
