<?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.xingxi.mq.server.order.mapper.InvoiceOrderMqMapper">
    
    <resultMap type="InvoiceOrder" id="InvoiceOrderResult">
        <result property="id"    column="id"    />
        <result property="orderId"    column="orderId"    />
        <result property="orderNo"    column="orderNo"    />
        <result property="orderDetailId"    column="orderDetailId"    />
        <result property="buyerId"    column="buyerId"    />
        <result property="buyerRole"    column="buyerRole"    />
        <result property="tradeType"    column="tradeType"    />
        <result property="sellerId"    column="sellerId"    />
        <result property="sellerRole"    column="sellerRole"    />
        <result property="payeeId"    column="payeeId"    />
        <result property="payeeRole"    column="payeeRole"    />
        <result property="suiteId"    column="suiteId"    />
        <result property="prodId"    column="prodId"    />
        <result property="prodName"    column="prodName"    />
        <result property="pprId"    column="pprId"    />
        <result property="pprName"    column="pprName"    />
        <result property="mateId"    column="mateId"    />
        <result property="mateName"    column="mateName"    />
        <result property="prodType"    column="prodType"    />
        <result property="orgProdId"    column="orgProdId"    />
        <result property="surfaceQty"    column="surfaceQty"    />
        <result property="unitQty"    column="unitQty"    />
        <result property="orderQty"    column="orderQty"    />
        <result property="price"    column="price"    />
        <result property="returnQty"    column="returnQty"    />
        <result property="finishTime"    column="finishTime"    />
        <result property="orderStatus"    column="orderStatus"    />
        <result property="invoiceTime"    column="invoiceTime"    />
        <result property="invoiceStatus"    column="invoiceStatus"    />
        <result property="invoiceBatchNo"    column="invoiceBatchNo"    />
        <result property="invoiceBillNo"    column="invoiceBillNo"    />
        <result property="delFlag"    column="delFlag"    />
        <result property="createUser"    column="createUser"    />
        <result property="createTime"    column="createTime"    />
        <result property="updateUser"    column="updateUser"    />
        <result property="updateTime"    column="updateTime"    />
    </resultMap>


    <sql id="selectInvoiceOrderVo">
        select
            id,
            orderId,
            orderNo,
            orderDetailId,
            buyerId,
            buyerRole,
            tradeType,
            sellerId,
            sellerRole,
            payeeId,
            payeeRole,
            suiteId,
            prodId,
            prodName,
            pprId,
            pprName,
            mateId,
            mateName,
            prodType,
            orgProdId,
            surfaceQty,
            unitQty,
            orderQty,
            price,
            returnQty,
            finishTime,
            orderStatus,
            invoiceTime,
            invoiceStatus,
            invoiceBatchNo,
            invoiceBillNo,
            delFlag,
            createUser,
            createTime,
            updateUser,
            updateTime
        from t_invoice_order
    </sql>

    <update id="updateInvoiceOrderReturnQty" parameterType="InvoiceOrder">
        update t_invoice_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="returnQty != null">returnQty = returnQty - #{returnQty},</if>
            <if test="updateUser != null and updateUser != ''">updateUser = #{updateUser},</if>
            <if test="updateTime != null">updateTime = #{updateTime},</if>
        </trim>
        where delFlag = '0'
            <if test="id != null "> and id = #{id}</if>
            <if test="orderId != null "> and orderId = #{orderId}</if>
            <if test="orderNo != null  and orderNo != ''"> and orderNo = #{orderNo}</if>
            <if test="orderDetailId != null "> and orderDetailId = #{orderDetailId}</if>
            <if test="buyerId != null "> and buyerId = #{buyerId}</if>
            <if test="buyerRole != null  and buyerRole != ''"> and buyerRole = #{buyerRole}</if>
            <if test="tradeType != null  and tradeType != ''"> and tradeType = #{tradeType}</if>
            <if test="sellerId != null "> and sellerId = #{sellerId}</if>
            <if test="sellerRole != null  and sellerRole != ''"> and sellerRole = #{sellerRole}</if>
            <if test="payeeId != null "> and payeeId = #{payeeId}</if>
            <if test="payeeRole != null  and payeeRole != ''"> and payeeRole = #{payeeRole}</if>
            <if test="suiteId != null  and suiteId != ''"> and suiteId = #{suiteId}</if>
            <if test="prodId != null "> and prodId = #{prodId}</if>
            <if test="pprId != null "> and pprId = #{pprId}</if>
            <if test="mateId != null "> and mateId = #{mateId}</if>
            <if test="prodType != null  and prodType != ''"> and prodType = #{prodType}</if>
            <if test="orgProdId != null "> and orgProdId = #{orgProdId}</if>
            <if test="orderStatus != null  and orderStatus != ''"> and orderStatus = #{orderStatus}</if>
            <if test="invoiceStatus != null  and invoiceStatus != ''"> and invoiceStatus = #{invoiceStatus}</if>
            <if test="invoiceBatchNo != null  and invoiceBatchNo != ''"> and invoiceBatchNo = #{invoiceBatchNo}</if>
            <if test="invoiceBillNo != null  and invoiceBillNo != ''"> and invoiceBillNo = #{invoiceBillNo}</if>
    </update>

</mapper>