<?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.yiqi.app.mapper.AppUserBillMstrMapper">

    <resultMap type="AppUserBillMstr" id="AppUserBillMstrResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="content" column="content"/>
        <result property="orderNo" column="order_no"/>
        <result property="orderType" column="order_type"/>
        <result property="payType" column="pay_type"/>
        <result property="appUserId" column="app_user_id"/>
        <result property="orgId" column="org_id"/>
        <result property="sourceType" column="source_type"/>
        <result property="billType" column="bill_type"/>
        <result property="payTotalAmount" column="pay_total_amount"/>
        <result property="cashPayAmount" column="cash_pay_amount"/>
        <result property="rechargePayAmount" column="recharge_pay_amount"/>
        <result property="givePayAmount" column="give_pay_amount"/>
        <result property="receivePoint" column="receive_point"/>
        <result property="usePoint" column="use_point"/>
        <result property="isRefund" column="is_refund"/>
        <result property="createById" column="create_by_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateById" column="update_by_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectAppUserBillMstrVo">
        select id, title, content, order_no, order_type, pay_type, app_user_id, org_id, source_type, bill_type, pay_total_amount, cash_pay_amount, recharge_pay_amount, give_pay_amount, receive_point, use_point, is_refund, create_by_id, create_by, create_time, update_by_id, update_by, update_time, remark
        from app_user_bill_mstr
    </sql>

    <select id="selectAppUserBillMstrList" parameterType="AppUserBillMstr" resultMap="AppUserBillMstrResult">
        <include refid="selectAppUserBillMstrVo"/>
        <where>
            <if test="title != null  and title != ''">
                and title = #{title}
            </if>
            <if test="content != null  and content != ''">
                and content = #{content}
            </if>
            <if test="orderNo != null  and orderNo != ''">
                and order_no = #{orderNo}
            </if>
            <if test="orderType != null  and orderType != ''">
                and order_type = #{orderType}
            </if>
            <if test="payType != null  and payType != ''">
                and pay_type = #{payType}
            </if>
            <if test="appUserId != null ">
                and app_user_id = #{appUserId}
            </if>
            <if test="orgId != null ">
                and org_id = #{orgId}
            </if>
            <if test="sourceType != null  and sourceType != ''">
                and source_type = #{sourceType}
            </if>
            <if test="billType != null ">
                and bill_type = #{billType}
            </if>
            <if test="payTotalAmount != null ">
                and pay_total_amount = #{payTotalAmount}
            </if>
            <if test="cashPayAmount != null ">
                and cash_pay_amount = #{cashPayAmount}
            </if>
            <if test="rechargePayAmount != null ">
                and recharge_pay_amount = #{rechargePayAmount}
            </if>
            <if test="givePayAmount != null ">
                and give_pay_amount = #{givePayAmount}
            </if>
            <if test="receivePoint != null ">
                and receive_point = #{receivePoint}
            </if>
            <if test="usePoint != null ">
                and use_point = #{usePoint}
            </if>
            <if test="isRefund != null  and isRefund != ''">
                and is_refund = #{isRefund}
            </if>
        </where>
    </select>

    <select id="selectAppUserBillMstrById" parameterType="Long"
            resultMap="AppUserBillMstrResult">
        <include refid="selectAppUserBillMstrVo"/>
        where id = #{id}
    </select>

    <insert id="insertAppUserBillMstr" parameterType="AppUserBillMstr" useGeneratedKeys="true"
            keyProperty="id">
        insert into app_user_bill_mstr
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,
            </if>
            <if test="content != null">content,
            </if>
            <if test="orderNo != null">order_no,
            </if>
            <if test="orderType != null">order_type,
            </if>
            <if test="payType != null">pay_type,
            </if>
            <if test="appUserId != null">app_user_id,
            </if>
            <if test="orgId != null">org_id,
            </if>
            <if test="sourceType != null">source_type,
            </if>
            <if test="billType != null">bill_type,
            </if>
            <if test="payTotalAmount != null">pay_total_amount,
            </if>
            <if test="cashPayAmount != null">cash_pay_amount,
            </if>
            <if test="rechargePayAmount != null">recharge_pay_amount,
            </if>
            <if test="givePayAmount != null">give_pay_amount,
            </if>
            <if test="receivePoint != null">receive_point,
            </if>
            <if test="usePoint != null">use_point,
            </if>
            <if test="isRefund != null">is_refund,
            </if>
            <if test="createById != null">create_by_id,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateById != null">update_by_id,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
            <if test="remark != null">remark,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},
            </if>
            <if test="content != null">#{content},
            </if>
            <if test="orderNo != null">#{orderNo},
            </if>
            <if test="orderType != null">#{orderType},
            </if>
            <if test="payType != null">#{payType},
            </if>
            <if test="appUserId != null">#{appUserId},
            </if>
            <if test="orgId != null">#{orgId},
            </if>
            <if test="sourceType != null">#{sourceType},
            </if>
            <if test="billType != null">#{billType},
            </if>
            <if test="payTotalAmount != null">#{payTotalAmount},
            </if>
            <if test="cashPayAmount != null">#{cashPayAmount},
            </if>
            <if test="rechargePayAmount != null">#{rechargePayAmount},
            </if>
            <if test="givePayAmount != null">#{givePayAmount},
            </if>
            <if test="receivePoint != null">#{receivePoint},
            </if>
            <if test="usePoint != null">#{usePoint},
            </if>
            <if test="isRefund != null">#{isRefund},
            </if>
            <if test="createById != null">#{createById},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateById != null">#{updateById},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
            <if test="remark != null">#{remark},
            </if>
        </trim>
    </insert>

    <update id="updateAppUserBillMstr" parameterType="AppUserBillMstr">
        update app_user_bill_mstr
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title =
                #{title},
            </if>
            <if test="content != null">content =
                #{content},
            </if>
            <if test="orderNo != null">order_no =
                #{orderNo},
            </if>
            <if test="orderType != null">order_type =
                #{orderType},
            </if>
            <if test="payType != null">pay_type =
                #{payType},
            </if>
            <if test="appUserId != null">app_user_id =
                #{appUserId},
            </if>
            <if test="orgId != null">org_id =
                #{orgId},
            </if>
            <if test="sourceType != null">source_type =
                #{sourceType},
            </if>
            <if test="billType != null">bill_type =
                #{billType},
            </if>
            <if test="payTotalAmount != null">pay_total_amount =
                #{payTotalAmount},
            </if>
            <if test="cashPayAmount != null">cash_pay_amount =
                #{cashPayAmount},
            </if>
            <if test="rechargePayAmount != null">recharge_pay_amount =
                #{rechargePayAmount},
            </if>
            <if test="givePayAmount != null">give_pay_amount =
                #{givePayAmount},
            </if>
            <if test="receivePoint != null">receive_point =
                #{receivePoint},
            </if>
            <if test="usePoint != null">use_point =
                #{usePoint},
            </if>
            <if test="isRefund != null">is_refund =
                #{isRefund},
            </if>
            <if test="createById != null">create_by_id =
                #{createById},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateById != null">update_by_id =
                #{updateById},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
            <if test="remark != null">remark =
                #{remark},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppUserBillMstrById" parameterType="Long">
        delete from app_user_bill_mstr where id = #{id}
    </delete>

    <delete id="deleteAppUserBillMstrByIds" parameterType="String">
        delete from app_user_bill_mstr where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>



</mapper>