<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iamberry.wechat.service.mapper.IntegralConfigMapper">
    <resultMap  id="BaseResultMap" type="IntegralConfig" >
        <result    column="inte_conf_id"    property="inteConfId" />
        <result    column="promotions_id"    property="promotionsId" />
        <result    column="inte_conf_name"    property="inteConfName" />
        <result    column="inte_conf_calculation"    property="inteConfCalculation" />
        <result    column="inte_conf_status"    property="inteConfStatus" />
        <result    column="inte_conf_desc"    property="inteConfDesc" />
        <result    column="inte_conf_create_time"    property="inteConfCreateTime" />
        <result    column="inte_conf_update_time"    property="inteConfUpdateTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.inte_conf_id,
        t.promotions_id,
        t.inte_conf_name,
        t.inte_conf_calculation,
        t.inte_conf_status,
        t.inte_conf_desc,
        t.inte_conf_create_time,
        t.inte_conf_update_time
    </sql>
    <select id="getIntegralConfigList" resultMap="BaseResultMap" parameterType="IntegralConfig" >
        select
        <include refid="Base_List" />
        from tb_iamberry_ism_integral_config t
        <where>
            <if test="inteConfId != null ">
                AND t.inte_conf_id = #{inteConfId}
            </if >
            <if test="promotionsId != null ">
                AND t.promotions_id = #{promotionsId}
            </if >
            <if test="inteConfName != null and inteConfName != ''">
                AND t.inte_conf_name  like  CONCAT ('%',#{inteConfName},'%')
            </if >
            <if test="inteConfCalculation != null and inteConfCalculation != ''">
                AND t.inte_conf_calculation  like  CONCAT ('%',#{inteConfCalculation},'%')
            </if >
            <if test="inteConfStatus != null ">
                AND t.inte_conf_status = #{inteConfStatus}
            </if >
        </where>
    </select>

    <select id="getSpikeListAllByPromo" resultMap="BaseResultMap" parameterType="IntegralConfig" >
        select
        <include refid="Base_List" />
        from tb_iamberry_ism_integral_config t
        <where>
            t.inte_conf_status  = 1
            AND t.promotions_id IN (
            <foreach collection="array" item="item" separator=",">
                #{item}
            </foreach>
            )
        </where>
        ORDER BY t.inte_conf_sort
    </select>

    <select id="getIntegralConfigById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_ism_integral_config t
        where t.inte_conf_id= #{inteConfId}
    </select>
</mapper>