package com.hzs.scm.po.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hzs.common.domain.scm.po.PoOrder;
import com.hzs.common.domain.scm.po.ext.PoOrderExt;
import com.hzs.common.domain.scm.purchase.ext.IcPurchaseInBExt;
import com.hzs.scm.po.param.PoOrderItemsParam;
import com.hzs.scm.po.param.PoOrderParam;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 采购订单表头 Mapper 接口
 * </p>
 *
 * @author hzs
 * @since 2023-11-17
 */
public interface PoOrderMapper extends BaseMapper<PoOrder> {

    /*
     * @description: 根据主键查询采购订单、采购订单明细
     * @author: sui q
     * @date: 2023/11/21 10:49
     * @param: null null
     **/
    PoOrderExt queryPoOrderById(@Param("pkOrder") Long pkOrder,@Param("orderStatus") Integer orderStatus);

    /*
     * @description: 根据查询条件查询采购订单
     * @author: sui q
     * @date: 2023/11/21 15:01
     * @param: null null
     **/
    List<PoOrderExt> queryPoOrderByCondition(PoOrderParam poOrderParam);

    /*
     * @description: 参照生成采购入库单，可能存在多个采购订单生成一个入库单，支持1对多 多对1
     * @author: sui q
     * @date: 2023/11/21 17:47
     * @param: null null
     **/
    List<PoOrderExt> queryPoOrderByOrderItems(@Param("orderItemsParamList") List<PoOrderItemsParam> orderItemsParamList);

    /*
     * @description: 查询待入库的采购订单
     * @author: sui q
     * @date: 2023/11/23 13:53
     * @param: null null
     **/
    List<PoOrderExt> queryPoOrderToStoreByCondition(PoOrderParam poOrderParam);

    /*
     * @description: 采购入库时回写采购订单主表状态
     * @author: sui q
     * @date: 2023/11/27 13:39
     * @param: null null
     **/
    void updatePoOrderStatusByPurchase(@Param("purchaseInbExtList") List<IcPurchaseInBExt> purchaseInbExtList, @Param("pkMember") Long pkMember,
                                       @Param("orderStatus") Integer orderStatus);

}
