<?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.CommissionOrderDetailVoMapper">
    
    <resultMap type="CommissionOrderDetail" id="CommissionOrderDetailVoResult">
        <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="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="prodType"    column="prodType"    />
        <result property="orderQty"    column="orderQty"    />
        <result property="price"    column="price"    />
        <result property="returnQty"    column="returnQty"    />
        <result property="commissionRate"    column="commissionRate"    />
        <result property="commissionAmount"    column="commissionAmount"    />
        <result property="orderDetailStatus"    column="orderDetailStatus"    />
        <result property="finishTime"    column="finishTime"    />
        <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="selectCommissionOrderDetailVo">
        select
            c.id,
            c.orderId,
            c.orderNo,
            c.orderDetailId,
            c.buyerId,
            c.buyerRole,
            c.sellerId,
            c.sellerRole,
            c.suiteId,
            c.prodId,
            c.prodName,
            c.prodPropId,
            c.prodPropName,
            c.prodType,
            c.orderQty,
            c.price,
            c.returnQty,
            c.commissionRate,
            c.commissionAmount,
            c.orderDetailStatus,
            c.finishTime,
            c.delFlag,
            c.createUser,
            c.createTime,
            c.updateUser,
            c.updateTime
        from t_commission_order_detail c
    </sql>

    <update id="updateCommissionOrderDetailVo" parameterType="CommissionOrderDetail">
        update t_commission_order_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="returnQty != null">returnQty = returnQty + #{returnQty},</if>
            <if test="commissionAmount != null">commissionAmount = commissionAmount - #{commissionAmount},</if>
            <if test="orderDetailStatus != null and orderDetailStatus != ''">orderDetailStatus = #{orderDetailStatus},</if>
            <if test="finishTime != null">finishTime = #{finishTime},</if>
            <if test="delFlag != null and delFlag != ''">delFlag = #{delFlag},</if>
            <if test="updateUser != null and updateUser != ''">updateUser = #{updateUser},</if>
            <if test="updateTime != null">updateTime = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

</mapper>