<?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.ClearOrderDetailVoMapper">
    
    <resultMap type="ClearOrderDetail" id="ClearOrderDetailResult">
        <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="sellerId"    column="sellerId"    />
        <result property="sellerRole"    column="sellerRole"    />
        <result property="tradeType"    column="tradeType"    />
        <result property="suiteId"    column="suiteId"    />
        <result property="prodId"    column="prodId"    />
        <result property="prodName"    column="prodName"    />
        <result property="prodPropId"    column="prodPropId"    />
        <result property="prodPropName"    column="prodPropName"    />
        <result property="orgProdId"    column="orgProdId"    />
        <result property="mateId"    column="mateId"    />
        <result property="mateName"    column="mateName"    />
        <result property="prodType"    column="prodType"    />
        <result property="buyPrice"    column="buyPrice"    />
        <result property="salePrice"    column="salePrice"    />
        <result property="orderQty"    column="orderQty"    />
        <result property="returnQty"    column="returnQty"    />
        <result property="serviceRate"    column="serviceRate"    />
        <result property="finishTime"    column="finishTime"    />
        <result property="orderStatus"    column="orderStatus"    />
        <result property="settleTime"    column="settleTime"    />
        <result property="settleStatus"    column="settleStatus"    />
        <result property="invoiceTime"    column="invoiceTime"    />
        <result property="invoiceStatus"    column="invoiceStatus"    />
        <result property="settleBatchNo"    column="settleBatchNo"    />
        <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="selectClearOrderDetail">
        select
            c.id,
            c.orderId,
            c.orderNo,
            c.orderDetailId,
            c.buyerId,
            c.buyerRole,
            c.sellerId,
            c.sellerRole,
            c.tradeType,
            c.suiteId,
            c.prodId,
            c.prodName,
            c.prodPropId,
            c.prodPropName,
            c.orgProdId,
            c.mateId,
            c.mateName,
            c.prodType,
            c.buyPrice,
            c.salePrice,
            c.orderQty,
            c.returnQty,
            c.serviceRate,
            c.finishTime,
            c.orderStatus,
            c.settleTime,
            c.settleStatus,
            c.invoiceTime,
            c.invoiceStatus,
            c.settleBatchNo,
            c.invoiceBatchNo,
            c.invoiceBillNo,
            c.delFlag,
            c.createUser,
            c.createTime,
            c.updateUser,
            c.updateTime
        from t_clear_order_detail c
    </sql>

    <update id="updateReturnQty" parameterType="ClearOrderDetail">
        update t_clear_order_detail set returnQty = returnQty + #{returnQty}, updateUser = #{updateUser}, updateTime = #{updateTime}
        where 1 = 1
            <if test="orderId != null "> and orderId = #{orderId}</if>
            <if test="orderDetailId != null "> and orderDetailId = #{orderDetailId}</if>
            <if test="suiteId != null and suiteId != ''"> and suiteId = #{suiteId}</if>
    </update>

</mapper>