package com.cf.imes.module.manage.dal.mysql.pack;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.manage.controller.admin.pack.vo.PackRespVO;
import com.cf.imes.module.manage.controller.admin.pack.vo.PackageDetailsReqVO;
import com.cf.imes.module.manage.controller.admin.pack.vo.PlateDetailsRespVO;
import com.cf.imes.module.manage.dal.dataobject.query.OrderPackageDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface OrderPackageMapper extends BaseMapperX<OrderPackageDO> {



//    default List<OrderPackageDO> selectByOrderNo(PackageDetailsReqVO reqVO) {
//        return selectList(new LambdaQueryWrapperX<OrderPackageDO>()
//                .eqIfPresent(OrderPackageDO::getOrderNo, orderNo)
//                .orderByDesc(OrderPackageDO::getId));
//    }


    IPage<OrderPackageDO> selectByOrderNo(@Param("page") IPage page,@Param("reqVO") PackageDetailsReqVO reqVO,@Param("organId") Long organId);


    default OrderPackageDO selectByPackNo(String packNo,Long organId) {
        return selectOne(new LambdaQueryWrapperX<OrderPackageDO>()
                .eq(OrderPackageDO::getOrganId, organId)
                .eqIfPresent(OrderPackageDO::getPackageNo, packNo));
    }



    List<PackRespVO> selectPackPage(/*@Param("page") IPage page,*/@Param("collect") List<Long> collect);


    IPage<PlateDetailsRespVO> selectMissingBoard( @Param("page") IPage page, @Param("orderNo") Long orderNo, @Param("organId") Long organId);




    default OrderPackageDO selectByPackId(Long packId,Long organId) {
        return selectOne(new LambdaQueryWrapperX<OrderPackageDO>()
                .eq(OrderPackageDO::getOrganId, organId)
                .eqIfPresent(OrderPackageDO::getId, packId));
    }



    void updateParts(@Param("packageId") Long packageId, @Param("packageNo") Long packageNo);



    default List<OrderPackageDO> selectPackStatus(Long orderId,Long organId) {
        return selectList(new LambdaQueryWrapperX<OrderPackageDO>()
                .eq(OrderPackageDO::getOrganId,organId)
                .eqIfPresent(OrderPackageDO::getOrderId, orderId));
    }
}
