package com.fs.hospital.mapper;

import java.util.List;
import com.fs.hospital.domain.HospitalProductCheckOrder;
import com.fs.hospital.domain.HospitalProductPurchaseOrderItem;
import com.fs.hospital.vo.HospitalProductCheckOrderHVO;
import org.apache.ibatis.annotations.Select;

/**
 * 采购单Mapper接口
 *
 * @author fs
 * @date 2024-03-14
 */
public interface HospitalProductCheckOrderMapper
{
    /**
     * 查询采购单
     *
     * @param orderId 采购单主键
     * @return 采购单
     */
    public HospitalProductCheckOrder selectHospitalProductCheckOrderByOrderId(Long orderId);

    /**
     * 查询采购单列表
     *
     * @param hospitalProductCheckOrder 采购单
     * @return 采购单集合
     */
    public List<HospitalProductCheckOrder> selectHospitalProductCheckOrderList(HospitalProductCheckOrder hospitalProductCheckOrder);

    /**
     * 新增采购单
     *
     * @param hospitalProductCheckOrder 采购单
     * @return 结果
     */
    public int insertHospitalProductCheckOrder(HospitalProductCheckOrder hospitalProductCheckOrder);

    /**
     * 修改采购单
     *
     * @param hospitalProductCheckOrder 采购单
     * @return 结果
     */
    public int updateHospitalProductCheckOrder(HospitalProductCheckOrder hospitalProductCheckOrder);

    /**
     * 删除采购单
     *
     * @param orderId 采购单主键
     * @return 结果
     */
    public int deleteHospitalProductCheckOrderByOrderId(Long orderId);

    /**
     * 批量删除采购单
     *
     * @param orderIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalProductCheckOrderByOrderIds(Long[] orderIds);

    @Select("select o.*,s.store_name,u.nick_name,h.hospital_name from hospital_product_check_order o LEFT JOIN fs_store s ON s.store_id= o.store_id LEFT JOIN hospital_user u ON u.user_id=o.user_id LEFT JOIN hospital h ON h.hospital_id=o.hospital_id where o.order_id=#{orderId}")

    HospitalProductCheckOrderHVO selectHospitalProductCheckOrderByOrderIdHVO(Long orderId);
    @Select("select * from  hospital_product_purchase_order_item where  limit_count>0 AND product_id=#{hospitalId} and order_type=1 ORDER BY item_id desc")
    List<HospitalProductPurchaseOrderItem> selectHospitalPurchaseOrderItemByProductId(Long productId);
    @Select("select * from  hospital_product_purchase_order_item  where  product_id=#{productId} and order_type=1 ORDER BY item_id desc limit 1")
    HospitalProductPurchaseOrderItem selectHospitalPurchaseOrderItemByProductIdOne(Long productId);
}
