package com.hfkj.dao;

import com.hfkj.entity.BsGasOilPrice;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

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

/**
 * mapper扩展类
 */
public interface BsGasOilPriceMapperExt {
    @Select({" <script>" +
            "  select b.* from bs_merchant a, bs_gas_oil_price b " +
            "  where a.id = b.mer_id " +
            "  and a.source_type = 1 " +
            "  and a.`status` = 1 " +
            "  and a.province_code = #{regionId} " +
            "  and b.oil_no = #{oilNo} " +
            "  <if test='oilPriceZoneId != null'> and a.oil_price_zone_id = #{oilPriceZoneId} </if>" +
            " </script>"})
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT),
            @Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="oil_type", property="oilType", jdbcType=JdbcType.INTEGER),
            @Result(column="oil_type_name", property="oilTypeName", jdbcType=JdbcType.VARCHAR),
            @Result(column="oil_no", property="oilNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="oil_no_name", property="oilNoName", jdbcType=JdbcType.VARCHAR),
            @Result(column="preferential_margin", property="preferentialMargin", jdbcType=JdbcType.DECIMAL),
            @Result(column="gas_station_drop", property="gasStationDrop", jdbcType=JdbcType.DECIMAL),
            @Result(column="price_official", property="priceOfficial", jdbcType=JdbcType.DECIMAL),
            @Result(column="price_gun", property="priceGun", jdbcType=JdbcType.DECIMAL),
            @Result(column="price_vip", property="priceVip", jdbcType=JdbcType.DECIMAL),
            @Result(column="price_cost", property="priceCost", jdbcType=JdbcType.DECIMAL),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
            @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
    })
    List<BsGasOilPrice> selectPriceListByRegionAndOilNo(@Param("regionId") Long regionId, @Param("oilPriceZoneId") Integer oilPriceZoneId, @Param("oilNo") String oilNo);

}
