
package com.tmerclub.cloud.product.mapper;

import com.tmerclub.cloud.common.order.vo.WarehouseVO;
import com.tmerclub.cloud.api.product.dto.WarehouseDTO;
import com.tmerclub.cloud.product.model.Warehouse;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 *
 *
 * @author tmerclub
 * @date 2023-11-08 11:11:44
 */
public interface WarehouseMapper {

    /**
     * 获取列表
     * @param warehouse 仓库参数
     * @return 列表
     */
    List<WarehouseVO> list(@Param("warehouse") WarehouseDTO warehouse);

    /**
     * 获取可配送仓库列表
     * @param warehouseDTO 仓库dto
     * @return 仓库列表
     */
    List<WarehouseVO> listCanDeliveryWarehouse(@Param("warehouseDTO")WarehouseDTO warehouseDTO);

    /**
     * 根据id获取
     *
     * @param warehouseId id
     * @return
     */
    WarehouseVO getByWarehouseId(@Param("warehouseId") Long warehouseId);

    /**
     * 保存
     * @param warehouse
     */
    void save(@Param("warehouse") Warehouse warehouse);

    /**
     * 更新
     * @param warehouse
     */
    void update(@Param("warehouse") Warehouse warehouse);

    /**
     * 根据id删除
     * @param warehouseId
     */
    void deleteById(@Param("warehouseId") Long warehouseId);

    /**
     * 根据仓库id获取对应供货城市
     *
     * @param warehouseId 仓库id
     * @return
     */
    List<Long> getWarehouseAreaByWarehouseId(@Param("warehouseId") Long warehouseId);

    /**
     * 统计该仓库名称使用的数量
     *
     * @param shopId      店铺id
     * @param warehouseName   仓库名称
     * @param sysType     系统类型
     * @param warehouseId 运费模板id
     * @return 使用的数量
     */
    int countByWarehouseName(@Param("shopId") Long shopId, @Param("warehouseName") String warehouseName, @Param("sysType") Integer sysType, @Param("warehouseId") Long warehouseId);


    /**
     * 统计之前保存的供应城市id
     * @param shopId
     * @param sysType
     * @param warehouseId
     * @return
     */
    List<Long> listareaByShopIdAndSysType(@Param("shopId") Long shopId, @Param("sysType") Integer sysType, @Param("warehouseId") Long warehouseId);

    /**
     * 获取商家的默认仓库
     *
     * @param shopId
     * @param sysType
     * @return
     */
    WarehouseVO getDefaultWarehouseIdByShopId(@Param("shopId") Long shopId, @Param("sysType") Integer sysType);

    /**
     * 获取店铺的所有仓库列表
     * @param shopId
     * @param sysType
     * @return
     */
    List<WarehouseVO> listWarehouseByShopId(@Param("shopId") Long shopId, @Param("sysType") Integer sysType);

    /**
     * 批量保存
     * @param warehouseList
     */
    void batchSave(@Param("warehouseList") List<Warehouse> warehouseList);

    /**
     * 获取默认仓库集合
     * @return
     */
    List<WarehouseVO> listDefaultWarehouses();
}
