<?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.hzya.frame.seeyon.cbs8.dao.impl.CbsLogDaoImpl">
    <resultMap id="get-CbsLogEntity-result" type="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
        <result property="id" column="id" />
        <result property="oa_id" column="oa_id" />
        <result property="bill_code" column="bill_code" />
        <result property="tab_name_en" column="tab_name_en" />
        <result property="tab_name_ch" column="tab_name_ch" />
        <result property="pay_state" column="pay_state" />
        <result property="message" column="message" />
        <result property="apply_state" column="apply_state" />
        <result property="successed" column="successed" />
        <result property="title" column="title" />
        <result property="pay_company" column="pay_company" />
        <result property="payee" column="payee" />
        <result property="amount" column="amount" />
        <result property="cbs_apply_code" column="cbs_apply_code" />
    </resultMap>

    <sql id="CbsLogEntity_Base_Column_List">
        id,
        field0002 as title,
        field0003 as pay_company,
        field0004 as payee,
        field0005 as cbs_apply_code,
        field0006 as bill_code,
        field0007 as oa_id,
        field0008 as tab_name_ch,
        field0009 as tab_name_en,
        field0010 as pay_state,
        field0011 as message,
        field0012 as apply_state,
        field0014 as successed
    </sql>

    <!-- 查询推送失败，用户手动发起请求 采用==查询 -->
    <select id="entity_list_base" resultMap="get-CbsLogEntity-result" parameterType="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
        select
        <include refid="CbsLogEntity_Base_Column_List"/>
        from
        formmain_0232
        <trim prefix="where" prefixOverrides="and">
            <if test="title != null and title !='' "> field0002 = #{title} </if>
            <if test="pay_company != null and pay_company !='' "> and field0003 = #{pay_company} </if>
            <if test="payee != null and payee !='' "> and field0004 = #{payee} </if>
            <if test="cbs_apply_code != null and cbs_apply_code !='' "> and field0005 = #{cbs_apply_code} </if>
            <if test="bill_code != null and bill_code !='' "> and field0006 = #{bill_code} </if>
            <if test="oa_id != null and oa_id !='' "> and field0007 = #{oa_id} </if>
            <if test="tab_name_ch != null and tab_name_ch !='' "> and field0008 = #{tab_name_ch} </if>
            <if test="tab_name_en != null and tab_name_en !='' "> and field0009 = #{tab_name_en} </if>
            <if test="pay_state != null and pay_state !='' "> and field0010 = #{pay_state} </if>
            <if test="message != null and message !='' "> and field0011 = #{message} </if>
            <if test="apply_state != null and apply_state !='' "> and field0012 = #{apply_state} </if>
            <if test="successed != null and successed !='' "> and field0014 = #{successed} </if>
        </trim>
    </select>

    <select id="entity_list_like" resultMap="get-CbsLogEntity-result" parameterType="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
        select
        <include refid="CbsLogEntity_Base_Column_List"/>
        from
        formmain_0232
        <trim prefix="where" prefixOverrides="and">
            <if test="title != null and title !='' "> field0002 = #{title} </if>
            <if test="id != null and id !='' "> and id = #{id} </if>
            <if test="pay_company != null and pay_company !='' "> and field0003 like '${pay_company}%' </if>
            <if test="payee != null and payee !='' "> and field0004 like '${payee}%' </if>
            <if test="cbs_apply_code != null and cbs_apply_code !='' "> and field0005 like '${cbs_apply_code}%' </if>
            <if test="bill_code != null and bill_code !='' "> and field0006 like '${bill_code}%' </if>
            <if test="oa_id != null and oa_id !='' "> and field0007 = #{oa_id} </if>
            <if test="tab_name_ch != null and tab_name_ch !='' "> and field0008 like '${tab_name_ch}%' </if>
            <if test="tab_name_en != null and tab_name_en !='' "> and field0009 like '${tab_name_en}%' </if>
            <if test="pay_state != null and pay_state !='' "> and field0010 like '${pay_state}%' </if>
            <if test="message != null and message !='' "> and field0011 like '${message}%' </if>
            <if test="apply_state != null and apply_state !='' "> and field0012 like '${apply_state}%' </if>
            <if test="successed != null and successed !='' "> and field0014 like '${successed}%' </if>
        </trim>
    </select>

    <select id="CbsLogEntity_list_base_in_payment" resultMap="get-CbsLogEntity-result" parameterType="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
        select
        <include refid="CbsLogEntity_Base_Column_List"/>
        from
        formmain_0232
        <trim prefix="where" prefixOverrides="and">
            <if test="oa_id != null and oa_id !='' "> field0007 = #{oa_id} </if>
            <if test="id != null and id !='' "> and id = #{id} </if>
            <if test="bill_code != null and bill_code !='' "> and field0006 = #{bill_code} </if>
            <if test="tab_name_en != null and tab_name_en !='' "> and field0008 = #{tab_name_en} </if>
            <if test="tab_name_ch != null and tab_name_ch !='' "> and field0009 = #{tab_name_ch} </if>
            <if test="pay_state != null and pay_state !='' "> and field0010 = #{pay_state} </if>
            <if test="message != null and message !='' "> and field0011 = #{message} </if>
            <if test="apply_state != null and apply_state !='' "> and field0012 = #{apply_state} </if>
            <if test="successed != null and successed !='' "> and field0014 = #{successed} </if>
            and (field0010='支付中'
            or field0010 not in ('审批撤销','审批拒绝','处理失败','退票','支付成功','取消支付','修改支付','支付失败','推送失败'))
        </trim>
    </select>


    <!--修改视图支付状态-->
    <update id="entity_update" parameterType="com.hzya.frame.seeyon.cbs8.entity.CbsLogEntity">
        update formmain_0232 set
        <trim suffix="" suffixOverrides=",">
            <if test="pay_state != null and pay_state !='' ">field0010 =#{pay_state},</if>
            field0011 =#{message},
            <if test="apply_state != null and apply_state !='' ">field0012 =#{apply_state},</if>
            <if test="successed != null and successed !='' ">field0014 =#{successed}</if>
        </trim>
        where id = #{id}
    </update>



</mapper>
