<?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.yijia.station.mapper.StationPayMapper">
    
    <resultMap type="StationPay" id="StationPayResult">
        <result property="payId"    column="pay_id"    />
        <result property="payMode"    column="pay_mode"    />
        <result property="stationId"    column="station_id"    />
        <result property="stationName"    column="station_name"    />
        <result property="imagePhotosFlag"    column="image_photos_flag"    />
        <result property="cardEnabledFlag"    column="card_enabled_flag"    />
        <result property="activityPic"    column="activity_pic"    />
        <result property="preferentialWayShareFlag"    column="preferential_way_share_flag"    />
        <result property="otherPreferentialWay"    column="other_preferential_way"    />
        <result property="payPrintNum"    column="pay_print_num"    />
        <result property="payCallbackPage"    column="pay_callback_page"    />
        <result property="wsPrintFlag"    column="ws_print_flag"    />
        <result property="printSetting"    column="print_setting"    />
        <result property="discountSetting"    column="discount_setting"    />
        <result property="isNoOil"    column="is_no_oil"    />
        <result property="notice"    column="notice"    />
        <result property="integralPrintFlag"    column="integral_print_flag"    />
        <result property="integralFlag"    column="integral_flag"    />
    </resultMap>

    <sql id="selectStationPayVo">
        select integral_flag,pay_id, pay_mode, station_id, station_name, image_photos_flag, card_enabled_flag, activity_pic, preferential_way_share_flag, other_preferential_way, pay_print_num, pay_callback_page, ws_print_flag, print_setting, discount_setting, is_no_oil,notice,integral_print_flag from station_pay
    </sql>

    <select id="selectStationPayList" parameterType="StationPay" resultMap="StationPayResult">
        <include refid="selectStationPayVo"/>
        <where>  
            <if test="payMode != null  and payMode != ''"> and pay_mode = #{payMode}</if>
            <if test="stationId != null "> and station_id = #{stationId}</if>
            <if test="stationName != null  and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
            <if test="imagePhotosFlag != null  and imagePhotosFlag != ''"> and image_photos_flag = #{imagePhotosFlag}</if>
            <if test="cardEnabledFlag != null  and cardEnabledFlag != ''"> and card_enabled_flag = #{cardEnabledFlag}</if>
            <if test="activityPic != null  and activityPic != ''"> and activity_pic = #{activityPic}</if>
            <if test="preferentialWayShareFlag != null  and preferentialWayShareFlag != ''"> and preferential_way_share_flag = #{preferentialWayShareFlag}</if>
            <if test="otherPreferentialWay != null  and otherPreferentialWay != ''"> and other_preferential_way = #{otherPreferentialWay}</if>
            <if test="payPrintNum != null "> and pay_print_num = #{payPrintNum}</if>
            <if test="payCallbackPage != null  and payCallbackPage != ''"> and pay_callback_page = #{payCallbackPage}</if>
            <if test="wsPrintFlag != null  and wsPrintFlag != ''"> and ws_print_flag = #{wsPrintFlag}</if>
            <if test="printSetting != null  and printSetting != ''"> and print_setting = #{printSetting}</if>
            <if test="discountSetting != null  and discountSetting != ''"> and discount_setting = #{discountSetting}</if>
            <if test="isNoOil != null  and isNoOil != ''"> and is_no_oil = #{isNoOil}</if>
            <if test="notice != null  and notice != ''"> and notice = #{notice}</if>
            <if test="integralPrintFlag != null  and integralPrintFlag != ''"> and integral_print_flag = #{integralPrintFlag}</if>
            <if test="integralFlag != null  and integralFlag != ''"> and integral_flag = #{integralFlag}</if>
            <if test="stationIdList != null ">
                and station_id in
                <foreach item="item" index="index" collection="stationIdList"
                         open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
        order by  pay_id desc
    </select>
    
    <select id="selectStationPayById" parameterType="Long" resultMap="StationPayResult">
        <include refid="selectStationPayVo"/>
        where pay_id = #{payId}
    </select>
        
    <insert id="insertStationPay" parameterType="StationPay" useGeneratedKeys="true" keyProperty="payId">
        insert into station_pay
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="payMode != null">pay_mode,</if>
            <if test="stationId != null">station_id,</if>
            <if test="stationName != null">station_name,</if>
            <if test="imagePhotosFlag != null">image_photos_flag,</if>
            <if test="cardEnabledFlag != null">card_enabled_flag,</if>
            <if test="activityPic != null">activity_pic,</if>
            <if test="preferentialWayShareFlag != null">preferential_way_share_flag,</if>
            <if test="otherPreferentialWay != null">other_preferential_way,</if>
            <if test="payPrintNum != null">pay_print_num,</if>
            <if test="payCallbackPage != null">pay_callback_page,</if>
            <if test="wsPrintFlag != null">ws_print_flag,</if>
            <if test="printSetting != null">print_setting,</if>
            <if test="discountSetting != null">discount_setting,</if>
            <if test="isNoOil != null">is_no_oil,</if>
            <if test="notice != null">notice,</if>
            <if test="integralPrintFlag != null">integral_print_flag,</if>
            <if test="integralFlag != null">integral_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="payMode != null">#{payMode},</if>
            <if test="stationId != null">#{stationId},</if>
            <if test="stationName != null">#{stationName},</if>
            <if test="imagePhotosFlag != null">#{imagePhotosFlag},</if>
            <if test="cardEnabledFlag != null">#{cardEnabledFlag},</if>
            <if test="activityPic != null">#{activityPic},</if>
            <if test="preferentialWayShareFlag != null">#{preferentialWayShareFlag},</if>
            <if test="otherPreferentialWay != null">#{otherPreferentialWay},</if>
            <if test="payPrintNum != null">#{payPrintNum},</if>
            <if test="payCallbackPage != null">#{payCallbackPage},</if>
            <if test="wsPrintFlag != null">#{wsPrintFlag},</if>
            <if test="printSetting != null">#{printSetting},</if>
            <if test="discountSetting != null">#{discountSetting},</if>
            <if test="isNoOil != null">#{isNoOil},</if>
            <if test="notice != null">#{notice},</if>
            <if test="integralPrintFlag != null">#{integralPrintFlag},</if>
            <if test="integralFlag != null">#{integralFlag},</if>
         </trim>
    </insert>

    <update id="updateStationPay" parameterType="StationPay">
        update station_pay
        <trim prefix="SET" suffixOverrides=",">
            <if test="payMode != null">pay_mode = #{payMode},</if>
            <if test="stationId != null">station_id = #{stationId},</if>
            <if test="stationName != null">station_name = #{stationName},</if>
            <if test="imagePhotosFlag != null">image_photos_flag = #{imagePhotosFlag},</if>
            <if test="cardEnabledFlag != null">card_enabled_flag = #{cardEnabledFlag},</if>
            <if test="activityPic != null">activity_pic = #{activityPic},</if>
            <if test="preferentialWayShareFlag != null">preferential_way_share_flag = #{preferentialWayShareFlag},</if>
            <if test="otherPreferentialWay != null">other_preferential_way = #{otherPreferentialWay},</if>
            <if test="payPrintNum != null">pay_print_num = #{payPrintNum},</if>
            <if test="payCallbackPage != null">pay_callback_page = #{payCallbackPage},</if>
            <if test="wsPrintFlag != null">ws_print_flag = #{wsPrintFlag},</if>
            <if test="printSetting != null">print_setting = #{printSetting},</if>
            <if test="discountSetting != null">discount_setting = #{discountSetting},</if>
            <if test="isNoOil != null">is_no_oil = #{isNoOil},</if>
            <if test="notice != null">notice = #{notice},</if>
            <if test="integralPrintFlag != null">  integral_print_flag = #{integralPrintFlag},</if>
            <if test="integralFlag != null">  integral_flag = #{integralFlag},</if>
        </trim>
        where pay_id = #{payId}
    </update>

    <delete id="deleteStationPayById" parameterType="Long">
        delete from station_pay where pay_id = #{payId}
    </delete>

    <delete id="deleteStationPayByIds" parameterType="String">
        delete from station_pay where pay_id in 
        <foreach item="payId" collection="array" open="(" separator="," close=")">
            #{payId}
        </foreach>
    </delete>
    
</mapper>