<?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.th.demo.mapping.finance.InvoiceNewMapper" >
    <resultMap id="BaseResultMap" type="com.th.demo.model.finance.InvoiceNew" >
        <id column="uuid" property="uuid" jdbcType="VARCHAR" />
        <result column="acc_date" property="accDate" jdbcType="VARCHAR" />
        <result column="fk_componey" property="fkComponey" jdbcType="VARCHAR" />
        <result column="acc_wgt" property="accWgt" jdbcType="VARCHAR" />
        <result column="invoice_amt" property="invoiceAmt" jdbcType="VARCHAR" />
        <result column="acc_reminder" property="accReminder" jdbcType="VARCHAR" />
        <result column="acc_amt" property="accAmt" jdbcType="VARCHAR" />
        <result column="crt_time" property="crtTime" jdbcType="VARCHAR" />
        <result column="crt_user_id" property="crtUserId" jdbcType="VARCHAR" />
        <result column="invoice_company" property="invoiceCompany" jdbcType="VARCHAR" />
        <result column="invoice_date" property="invoiceDate" jdbcType="VARCHAR" />
        <result column="write_invoice_amt" property="writeInvoiceAmt" jdbcType="VARCHAR" />

    </resultMap>
    <select id="selectInvoice" resultMap="BaseResultMap" >
        select * from t_invoice t
    </select>
    <insert id="insert" parameterType="com.th.demo.model.finance.InvoiceNew" >
        <selectKey keyProperty="uuid" order="BEFORE" resultType="java.lang.String">
            SELECT  REPLACE(UUID(),'-','') as uuid from dual
        </selectKey>
        insert into t_invoice(uuid,acc_date,fk_componey,acc_wgt,invoice_amt,acc_reminder,acc_amt,crt_time,crt_user_id,invoice_company,invoice_date,write_invoice_amt)
        values (#{uuid,jdbcType=VARCHAR},#{accDate,jdbcType=VARCHAR},#{fkComponey,jdbcType=VARCHAR},#{accWgt,jdbcType=VARCHAR},#{invoiceAmt,jdbcType=VARCHAR}
        ,#{accReminder,jdbcType=VARCHAR},#{accAmt,jdbcType=VARCHAR},#{crtTime,jdbcType=VARCHAR},#{crtUserId,jdbcType=VARCHAR},#{invoiceCompany,jdbcType=VARCHAR}
        ,#{invoiceDate,jdbcType=VARCHAR},#{writeInvoiceAmt,jdbcType=VARCHAR})
    </insert>
    <insert id="insertNew" parameterType="com.th.demo.model.finance.InvoiceNew" >
        <selectKey keyProperty="uuid" order="BEFORE" resultType="java.lang.String">
            SELECT  REPLACE(UUID(),'-','') as uuid from dual
        </selectKey>
        insert into t_invoice(uuid,acc_date,fk_componey,acc_wgt,invoice_amt,acc_reminder,acc_amt,crt_time,crt_user_id,invoice_company,invoice_date,write_invoice_amt)
        values (#{uuid,jdbcType=VARCHAR},#{accDate,jdbcType=VARCHAR},#{fkComponey,jdbcType=VARCHAR},#{accWgt,jdbcType=VARCHAR},#{invoiceAmt,jdbcType=VARCHAR}
        ,#{accReminder,jdbcType=VARCHAR},#{accAmt,jdbcType=VARCHAR},#{crtTime,jdbcType=VARCHAR},#{crtUserId,jdbcType=VARCHAR},#{invoiceCompany,jdbcType=VARCHAR}
        ,#{invoiceDate,jdbcType=VARCHAR},#{writeInvoiceAmt,jdbcType=VARCHAR})
    </insert>

    <update id="updateWriteInvocieInfo" parameterType="com.th.demo.model.finance.VerifyAccount" >
        update t_verify_account  t
				set t.write_invoice_amt = #{writeInvoiceAmt,jdbcType=DOUBLE}
						,t.invoice_date = #{invoiceDate,jdbcType=VARCHAR}
						,t.invoice_company = #{invoiceCompany,jdbcType=VARCHAR}
						,t.invoice_crt_time =  #{invoiceCrtTime,jdbcType=TIMESTAMP}
						,t.invoice_id = #{invoiceId,jdbcType=VARCHAR}
	    where t.uuid = #{uuid,jdbcType=VARCHAR}
    </update>
</mapper>