package com.yunzhi.marketing.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunzhi.marketing.entity.TaBuilding;
import com.yunzhi.marketing.entity.TaPersonBuilding;
import com.yunzhi.marketing.entity.TaSalesBatch;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 销售批次表  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2020-02-10
 */
@Mapper
public interface TaSalesBatchMapper extends BaseMapper<TaSalesBatch> {
    IPage<TaSalesBatch> selectByCondition(IPage<TaSalesBatch> page, @Param("salesBatchName") String salesBatchName, @Param("buildingId") String buildingId, @Param("status") Integer status, @Param("orgId") Integer orgId, @Param("personBuildingList") List<TaPersonBuilding> personBuildingList);

    /**
     * 根据批次号统计预选数据
     *
     * @param orgId
     * @param taSalesBatchList
     * @return
     */
    Integer countPreSelectRecord(@Param("orgId") Integer orgId, @Param("taSalesBatchList") List<TaSalesBatch> taSalesBatchList);

    void updateSalesBatchStatus(@Param("orgId") Integer orgId, @Param("taSalesBatchList") List<TaSalesBatch> taSalesBatchList);

    /**
     * 获取房源总数和总热度
     *
     * @param salesBatchId
     * @return
     */
    Map<String, Object> getTotalHousesAndHeat(@Param("salesBatchId") Integer salesBatchId);

    /**
     * 根据销售批次获取项目信息
     *
     * @param salesBatchId
     * @param orgId
     * @return
     */
    List<TaBuilding> getBuildingById(@Param("salesBatchId") String salesBatchId,
                                     @Param("orgId") Integer orgId);

    /**
     * 出售房源自增
     *
     * @param salesBatchId
     * @param orgId
     * @return
     */
    Boolean addSalesNumberById(@Param("salesBatchId") Integer salesBatchId,
                               @Param("orgId") Integer orgId);
}
