package com.hai.dao;

import com.hai.model.GasSelfBuiltStationModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

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

/**
 * mapper扩展类
 */
public interface HighMerchantStoreMapperExt {

    @Select({
            "<script>" +
                    " select" +
                    " a.id storeId," +
                    " a.merchant_id storeMerId," +
                    " c.merchant_name storeMerName," +
                    " d.id companyId," +
                    " d.`name` companyName," +
                    " a.region_id regionId,  " +
                    " a.region_name regionName," +
                    " a.store_key storeKey, " +
                    " a.store_name storeName," +
                    " a.address storeAddress," +
                    " a.prestore_type storePrestoreType," +
                    " b.amounts amounts," +
                    " b.amounts_early_warning amountsEarlyWarning," +
                    " b.amounts_early_warning_status amountsEarlyWarningStatus," +
                    " a.create_time storeCreateTime" +
                    " from high_merchant_store a" +
                    " LEFT JOIN high_merchant_store_account b on b.store_id = a.id" +
                    " LEFT JOIN high_merchant c on c.id = a.merchant_id" +
                    " LEFT JOIN bs_company d on d.id = c.company_id" +
                    " where a.type = 1 and a.source_type = 1 and a.`status` <![CDATA[ <> ]]> 0" +
                    " <if test='param.companyId != null'> and d.id = #{param.companyId}</if> " +
                    " <if test='param.merId != null'> and c.id = #{param.merId}</if> " +
                    " <if test='param.gasName != null'> and a.store_name like concat('%', #{param.gasName} ,'%') </if> " +
                    " <if test='param.prestoreType != null'> and a.prestore_type = #{param.prestoreType}</if> " +
                    " <if test='param.amountsEarlyWarningStatus != null'> and b.amounts_early_warning_status = #{param.amountsEarlyWarningStatus}</if> " +
                    " ORDER BY amountsEarlyWarningStatus desc, storeCreateTime desc" +
                    "</script>"
    })
    List<GasSelfBuiltStationModel> selectGasSelfBuiltStationList(@Param("param") Map<String, Object> param);
}
