package com.fs.oms.mapper;

import java.util.List;
import com.fs.oms.domain.OmsStore;
import com.fs.oms.vo.OmsStoreVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 网店Mapper接口
 *
 * @author fs
 * @date 2023-05-18
 */
public interface OmsStoreMapper
{
    /**
     * 查询网店
     *
     * @param storeId 网店ID
     * @return 网店
     */
    public OmsStore selectOmsStoreById(Long storeId);

    /**
     * 查询网店列表
     *
     * @param omsStore 网店
     * @return 网店集合
     */
    public List<OmsStore> selectOmsStoreList(OmsStore omsStore);

    /**
     * 查询网店列表
     *
     * @param omsStore 网店
     * @return 网店集合
     */
    @Select({"<script> " +
            "SELECT s.*,w.warehouse_name as channelWarehouseName from oms_store s LEFT JOIN oms_warehouse w on s.warehouse_id=w.warehouse_id " +
            " where 1=1 " +
            "<if test = 'maps.storeType != null     '> " +
            "and s.store_type =#{maps.storeType} " +
            "</if>" +

            "<if test = 'maps.storeName != null and maps.storeName != \"\"     '> " +
            "and s.store_name =#{maps.storeName} " +
            "</if>" +

            "<if test = 'maps.storeCode != null and maps.storeCode != \"\"     '> " +
            "and s.store_code =#{maps.storeCode} " +
            "</if>" +

            "<if test = 'maps.status != null   '> " +
            "and s.status =#{maps.status} " +
            "</if>" +

            "<if test = 'maps.channelType != null   '> " +
            "and s.channel_type =#{maps.channelType} " +
            "</if>" +

            "<if test = 'maps.linkUsername != null and maps.linkUsername != \"\"     '> " +
            "and s.link_username =#{maps.linkUsername} " +
            "</if>" +

            "<if test = 'maps.linkPhone != null and maps.linkPhone != \"\"     '> " +
            "and s.link_phone =#{maps.linkPhone} " +
            "</if>" +

            "<if test = 'maps.beginTime != null and maps.beginTime != \"\"   '> " +
            " AND date_format(s.limit_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
            "</if>" +
            "<if test = 'maps.endTime != null and maps.endTime != \"\"   '> " +
            " AND date_format(s.limit_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
            "</if>" +

            " order by s.store_id desc "+

            "</script>"})
    public List<OmsStoreVO> selectOmsStoreListVO(@Param("maps") OmsStore omsStore);

    /**
     * 新增网店
     *
     * @param omsStore 网店
     * @return 结果
     */
    public int insertOmsStore(OmsStore omsStore);

    /**
     * 修改网店
     *
     * @param omsStore 网店
     * @return 结果
     */
    public int updateOmsStore(OmsStore omsStore);

    /**
     * 删除网店
     *
     * @param storeId 网店ID
     * @return 结果
     */
    public int deleteOmsStoreById(Long storeId);

    /**
     * 批量删除网店
     *
     * @param storeIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteOmsStoreByIds(Long[] storeIds);
}
