<?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.ruoyi.jarvis.mapper.OrderRowsMapper">

    <resultMap type="OrderRows" id="OrderRowsResult">
        <result property="id" column="id"/>
        <result property="orderId" column="order_id"/>
        <result property="parentId" column="parent_id"/>
        <result property="orderTime" column="order_time"/>
        <result property="finishTime" column="finish_time"/>
        <result property="modifyTime" column="modify_time"/>
        <result property="orderEmt" column="order_emt"/>
        <result property="plus" column="plus"/>
        <result property="unionId" column="union_id"/>
        <result property="skuId" column="sku_id"/>
        <result property="skuName" column="sku_name"/>
        <result property="skuNum" column="sku_num"/>
        <result property="skuReturnNum" column="sku_return_num"/>
        <result property="skuFrozenNum" column="sku_frozen_num"/>
        <result property="price" column="price"/>
        <result property="commissionRate" column="commission_rate"/>
        <result property="subSideRate" column="sub_side_rate"/>
        <result property="subsidyRate" column="subsidy_rate"/>
        <result property="finalRate" column="final_rate"/>
        <result property="estimateCosPrice" column="estimate_cos_price"/>
        <result property="estimateFee" column="estimate_fee"/>
        <result property="actualCosPrice" column="actual_cos_price"/>
        <result property="actualFee" column="actual_fee"/>
        <result property="validCode" column="valid_code"/>
        <result property="traceType" column="trace_type"/>
        <result property="positionId" column="position_id"/>
        <result property="siteId" column="site_id"/>
        <result property="unionAlias" column="union_alias"/>
        <result property="pid" column="pid"/>
        <result property="cid1" column="cid1"/>
        <result property="cid2" column="cid2"/>
        <result property="cid3" column="cid3"/>
        <result property="subUnionId" column="sub_union_id"/>
        <result property="unionTag" column="union_tag"/>
        <result property="popId" column="pop_id"/>
        <result property="ext1" column="ext1"/>
        <result property="payMonth" column="pay_month"/>
        <result property="cpActId" column="cp_act_id"/>
        <result property="unionRole" column="union_role"/>
        <result property="giftCouponOcsAmount" column="gift_coupon_ocs_amount"/>
        <result property="giftCouponKey" column="gift_coupon_key"/>
        <result property="balanceExt" column="balance_ext"/>
        <result property="sign" column="sign"/>
        <result property="proPriceAmount" column="pro_price_amount"/>
        <result property="rid" column="rid"/>
        <result property="goodsInfoId" column="goods_info_id"/>
        <result property="expressStatus" column="express_status"/>
        <result property="channelId" column="channel_id"/>
        <result property="skuTag" column="sku_tag"/>
        <result property="itemId" column="item_id"/>
        <result property="callerItemId" column="caller_item_id"/>
        <result property="orderTag" column="order_tag"/>
    </resultMap>

    <sql id="selectOrderRowsVo">
        select id, order_id, parent_id, order_time, finish_time, modify_time, order_emt, plus, union_id, sku_id, sku_name, sku_num, sku_return_num, sku_frozen_num, price, commission_rate, sub_side_rate, subsidy_rate, final_rate, estimate_cos_price, estimate_fee, actual_cos_price, actual_fee, valid_code, trace_type, position_id, site_id, union_alias, pid, cid1, cid2, cid3, sub_union_id, union_tag, pop_id, ext1, pay_month, cp_act_id, union_role, gift_coupon_ocs_amount, gift_coupon_key, balance_ext, sign, pro_price_amount, rid, goods_info_id, express_status, channel_id, sku_tag, item_id, caller_item_id, order_tag from order_rows
    </sql>

    <select id="selectOrderRowsList" parameterType="OrderRows" resultMap="OrderRowsResult">
        <include refid="selectOrderRowsVo"/>
        <where>
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="parentId != null "> and parent_id = #{parentId}</if>
            <if test="orderTime != null "> and order_time = #{orderTime}</if>
            <if test="finishTime != null "> and finish_time = #{finishTime}</if>
            <if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
            <if test="orderEmt != null "> and order_emt = #{orderEmt}</if>
            <if test="plus != null "> and plus = #{plus}</if>
            <if test="unionId != null "> and union_id = #{unionId}</if>
            <if test="skuId != null "> and sku_id = #{skuId}</if>
            <if test="skuName != null  and skuName != ''"> and sku_name like concat('%', #{skuName}, '%')</if>
            <if test="skuNum != null "> and sku_num = #{skuNum}</if>
            <if test="skuReturnNum != null "> and sku_return_num = #{skuReturnNum}</if>
            <if test="skuFrozenNum != null "> and sku_frozen_num = #{skuFrozenNum}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="commissionRate != null "> and commission_rate = #{commissionRate}</if>
            <if test="subSideRate != null "> and sub_side_rate = #{subSideRate}</if>
            <if test="subsidyRate != null "> and subsidy_rate = #{subsidyRate}</if>
            <if test="finalRate != null "> and final_rate = #{finalRate}</if>
            <if test="estimateCosPrice != null "> and estimate_cos_price = #{estimateCosPrice}</if>
            <if test="estimateFee != null "> and estimate_fee = #{estimateFee}</if>
            <if test="actualCosPrice != null "> and actual_cos_price = #{actualCosPrice}</if>
            <if test="actualFee != null "> and actual_fee = #{actualFee}</if>
            <if test="validCode != null "> and valid_code = #{validCode}</if>
            <if test="validCodes != null and validCodes.length &gt; 0">
                and valid_code in
                <foreach item="item" index="index" collection="validCodes" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="traceType != null "> and trace_type = #{traceType}</if>
            <if test="positionId != null "> and position_id = #{positionId}</if>
            <if test="siteId != null "> and site_id = #{siteId}</if>
            <if test="unionAlias != null  and unionAlias != ''"> and union_alias like concat('%', #{unionAlias}, '%')</if>
            <if test="pid != null  and pid != ''"> and pid = #{pid}</if>
            <if test="cid1 != null "> and cid1 = #{cid1}</if>
            <if test="cid2 != null "> and cid2 = #{cid2}</if>
            <if test="cid3 != null "> and cid3 = #{cid3}</if>
            <if test="subUnionId != null  and subUnionId != ''"> and sub_union_id = #{subUnionId}</if>
            <if test="unionTag != null  and unionTag != ''"> and union_tag = #{unionTag}</if>
            <if test="popId != null "> and pop_id = #{popId}</if>
            <if test="ext1 != null  and ext1 != ''"> and ext1 = #{ext1}</if>
            <if test="payMonth != null  and payMonth != ''"> and pay_month = #{payMonth}</if>
            <if test="cpActId != null "> and cp_act_id = #{cpActId}</if>
            <if test="unionRole != null "> and union_role = #{unionRole}</if>
            <if test="giftCouponOcsAmount != null "> and gift_coupon_ocs_amount = #{giftCouponOcsAmount}</if>
            <if test="giftCouponKey != null  and giftCouponKey != ''"> and gift_coupon_key = #{giftCouponKey}</if>
            <if test="balanceExt != null  and balanceExt != ''"> and balance_ext = #{balanceExt}</if>
            <if test="sign != null  and sign != ''"> and sign = #{sign}</if>
            <if test="proPriceAmount != null "> and pro_price_amount = #{proPriceAmount}</if>
            <if test="rid != null "> and rid = #{rid}</if>
            <if test="goodsInfoId != null "> and goods_info_id = #{goodsInfoId}</if>
            <if test="expressStatus != null "> and express_status = #{expressStatus}</if>
            <if test="channelId != null "> and channel_id = #{channelId}</if>
            <if test="skuTag != null  and skuTag != ''"> and sku_tag = #{skuTag}</if>
            <if test="itemId != null  and itemId != ''"> and item_id = #{itemId}</if>
            <if test="callerItemId != null  and callerItemId != ''"> and caller_item_id = #{callerItemId}</if>
            <if test="orderTag != null  and orderTag != ''"> and order_tag = #{orderTag}</if>
            <if test="params.beginTime != null"> and order_time &gt;= #{params.beginTime}</if>
            <if test="params.endTime != null"> and order_time &lt;= #{params.endTime}</if>
        </where>
        <choose>
            <when test="params.orderBy != null and params.orderBy != ''">
                order by ${params.orderBy} ${params.isAsc}
            </when>
            <otherwise>
                order by order_time desc
            </otherwise>
        </choose>
    </select>

    <select id="selectOrderRowsById" parameterType="String" resultMap="OrderRowsResult">
        <include refid="selectOrderRowsVo"/>
        where id = #{id}
    </select>

    <select id="selectOrderRowsListWithFilter" resultMap="OrderRowsResult">
        <include refid="selectOrderRowsVo"/>
        <where>
            <if test="orderRows.orderId != null "> and order_id = #{orderRows.orderId}</if>
            <if test="orderRows.parentId != null "> and parent_id = #{orderRows.parentId}</if>
            <if test="orderRows.orderTime != null "> and order_time = #{orderRows.orderTime}</if>
            <if test="orderRows.finishTime != null "> and finish_time = #{orderRows.finishTime}</if>
            <if test="orderRows.modifyTime != null "> and modify_time = #{orderRows.modifyTime}</if>
            <if test="orderRows.orderEmt != null "> and order_emt = #{orderRows.orderEmt}</if>
            <if test="orderRows.plus != null "> and plus = #{orderRows.plus}</if>
            <if test="orderRows.unionId != null "> and union_id = #{orderRows.unionId}</if>
            <if test="orderRows.skuId != null "> and sku_id = #{orderRows.skuId}</if>
            <if test="orderRows.skuName != null  and orderRows.skuName != ''"> and sku_name like concat('%', #{orderRows.skuName}, '%')</if>
            <if test="orderRows.skuNum != null "> and sku_num = #{orderRows.skuNum}</if>
            <if test="orderRows.skuReturnNum != null "> and sku_return_num = #{orderRows.skuReturnNum}</if>
            <if test="orderRows.skuFrozenNum != null "> and sku_frozen_num = #{orderRows.skuFrozenNum}</if>
            <if test="orderRows.price != null "> and price = #{orderRows.price}</if>
            <if test="orderRows.commissionRate != null "> and commission_rate = #{orderRows.commissionRate}</if>
            <if test="orderRows.subSideRate != null "> and sub_side_rate = #{orderRows.subSideRate}</if>
            <if test="orderRows.subsidyRate != null "> and subsidy_rate = #{orderRows.subsidyRate}</if>
            <if test="orderRows.finalRate != null "> and final_rate = #{orderRows.finalRate}</if>
            <if test="orderRows.estimateCosPrice != null "> and estimate_cos_price = #{orderRows.estimateCosPrice}</if>
            <if test="orderRows.estimateFee != null "> and estimate_fee = #{orderRows.estimateFee}</if>
            <if test="orderRows.actualCosPrice != null "> and actual_cos_price = #{orderRows.actualCosPrice}</if>
            <if test="orderRows.actualFee != null "> and actual_fee = #{orderRows.actualFee}</if>
            <if test="orderRows.validCode != null "> and valid_code = #{orderRows.validCode}</if>
            <if test="orderRows.traceType != null "> and trace_type = #{orderRows.traceType}</if>
            <if test="orderRows.positionId != null "> and position_id = #{orderRows.positionId}</if>
            <if test="orderRows.siteId != null "> and site_id = #{orderRows.siteId}</if>
            <if test="orderRows.unionAlias != null  and orderRows.unionAlias != ''"> and union_alias like concat('%', #{orderRows.unionAlias}, '%')</if>
            <if test="orderRows.pid != null  and orderRows.pid != ''"> and pid = #{orderRows.pid}</if>
            <if test="orderRows.cid1 != null "> and cid1 = #{orderRows.cid1}</if>
            <if test="orderRows.cid2 != null "> and cid2 = #{orderRows.cid2}</if>
            <if test="orderRows.cid3 != null "> and cid3 = #{orderRows.cid3}</if>
            <if test="orderRows.subUnionId != null  and orderRows.subUnionId != ''"> and sub_union_id = #{orderRows.subUnionId}</if>
            <if test="orderRows.unionTag != null  and orderRows.unionTag != ''"> and union_tag = #{orderRows.unionTag}</if>
            <if test="orderRows.popId != null "> and pop_id = #{orderRows.popId}</if>
            <if test="orderRows.ext1 != null  and orderRows.ext1 != ''"> and ext1 = #{orderRows.ext1}</if>
            <if test="orderRows.payMonth != null  and orderRows.payMonth != ''"> and pay_month = #{orderRows.payMonth}</if>
            <if test="orderRows.cpActId != null "> and cp_act_id = #{orderRows.cpActId}</if>
            <if test="orderRows.unionRole != null "> and union_role = #{orderRows.unionRole}</if>
            <if test="orderRows.giftCouponOcsAmount != null "> and gift_coupon_ocs_amount = #{orderRows.giftCouponOcsAmount}</if>
            <if test="orderRows.giftCouponKey != null  and orderRows.giftCouponKey != ''"> and gift_coupon_key = #{orderRows.giftCouponKey}</if>
            <if test="orderRows.balanceExt != null  and orderRows.balanceExt != ''"> and balance_ext = #{orderRows.balanceExt}</if>
            <if test="orderRows.sign != null  and orderRows.sign != ''"> and sign = #{orderRows.sign}</if>
            <if test="orderRows.proPriceAmount != null "> and pro_price_amount = #{orderRows.proPriceAmount}</if>
            <if test="orderRows.rid != null "> and rid = #{orderRows.rid}</if>
            <if test="orderRows.goodsInfoId != null "> and goods_info_id = #{orderRows.goodsInfoId}</if>
            <if test="orderRows.expressStatus != null "> and express_status = #{orderRows.expressStatus}</if>
            <if test="orderRows.channelId != null "> and channel_id = #{orderRows.channelId}</if>
            <if test="orderRows.skuTag != null  and orderRows.skuTag != ''"> and sku_tag = #{orderRows.skuTag}</if>
            <if test="orderRows.itemId != null  and orderRows.itemId != ''"> and item_id = #{orderRows.itemId}</if>
            <if test="orderRows.callerItemId != null  and orderRows.callerItemId != ''"> and caller_item_id = #{orderRows.callerItemId}</if>
            <if test="orderRows.orderTag != null  and orderRows.orderTag != ''"> and order_tag = #{orderRows.orderTag}</if>
            <if test="beginTime != null"> and order_time &gt;= #{beginTime}</if>
            <if test="endTime != null"> and order_time &lt;= #{endTime}</if>
            <if test="excludeUnionIds != null and excludeUnionIds.size() &gt; 0">
                and union_id not in
                <foreach item="unionId" collection="excludeUnionIds" open="(" separator="," close=")">
                    #{unionId}
                </foreach>
            </if>
        </where>
        <choose>
            <when test="orderRows.params != null and orderRows.params.orderBy != null and orderRows.params.orderBy != ''">
                order by ${orderRows.params.orderBy} ${orderRows.params.isAsc}
            </when>
            <otherwise>
                order by order_time desc
            </otherwise>
        </choose>
    </select>

    <insert id="insertOrderRows" parameterType="OrderRows">
        insert into order_rows
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">id,</if>
            <if test="orderId != null">order_id,</if>
            <if test="parentId != null">parent_id,</if>
            <if test="orderTime != null">order_time,</if>
            <if test="finishTime != null">finish_time,</if>
            <if test="modifyTime != null">modify_time,</if>
            <if test="orderEmt != null">order_emt,</if>
            <if test="plus != null">plus,</if>
            <if test="unionId != null">union_id,</if>
            <if test="skuId != null">sku_id,</if>
            <if test="skuName != null and skuName != ''">sku_name,</if>
            <if test="skuNum != null">sku_num,</if>
            <if test="skuReturnNum != null">sku_return_num,</if>
            <if test="skuFrozenNum != null">sku_frozen_num,</if>
            <if test="price != null">price,</if>
            <if test="commissionRate != null">commission_rate,</if>
            <if test="subSideRate != null">sub_side_rate,</if>
            <if test="subsidyRate != null">subsidy_rate,</if>
            <if test="finalRate != null">final_rate,</if>
            <if test="estimateCosPrice != null">estimate_cos_price,</if>
            <if test="estimateFee != null">estimate_fee,</if>
            <if test="actualCosPrice != null">actual_cos_price,</if>
            <if test="actualFee != null">actual_fee,</if>
            <if test="validCode != null">valid_code,</if>
            <if test="traceType != null">trace_type,</if>
            <if test="positionId != null">position_id,</if>
            <if test="siteId != null">site_id,</if>
            <if test="unionAlias != null and unionAlias != ''">union_alias,</if>
            <if test="pid != null and pid != ''">pid,</if>
            <if test="cid1 != null">cid1,</if>
            <if test="cid2 != null">cid2,</if>
            <if test="cid3 != null">cid3,</if>
            <if test="subUnionId != null and subUnionId != ''">sub_union_id,</if>
            <if test="unionTag != null and unionTag != ''">union_tag,</if>
            <if test="popId != null">pop_id,</if>
            <if test="ext1 != null and ext1 != ''">ext1,</if>
            <if test="payMonth != null and payMonth != ''">pay_month,</if>
            <if test="cpActId != null">cp_act_id,</if>
            <if test="unionRole != null">union_role,</if>
            <if test="giftCouponOcsAmount != null">gift_coupon_ocs_amount,</if>
            <if test="giftCouponKey != null and giftCouponKey != ''">gift_coupon_key,</if>
            <if test="balanceExt != null and balanceExt != ''">balance_ext,</if>
            <if test="sign != null and sign != ''">sign,</if>
            <if test="proPriceAmount != null">pro_price_amount,</if>
            <if test="rid != null">rid,</if>
            <if test="goodsInfoId != null">goods_info_id,</if>
            <if test="expressStatus != null">express_status,</if>
            <if test="channelId != null">channel_id,</if>
            <if test="skuTag != null and skuTag != ''">sku_tag,</if>
            <if test="itemId != null and itemId != ''">item_id,</if>
            <if test="callerItemId != null and callerItemId != ''">caller_item_id,</if>
            <if test="orderTag != null and orderTag != ''">order_tag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{id},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="parentId != null">#{parentId},</if>
            <if test="orderTime != null">#{orderTime},</if>
            <if test="finishTime != null">#{finishTime},</if>
            <if test="modifyTime != null">#{modifyTime},</if>
            <if test="orderEmt != null">#{orderEmt},</if>
            <if test="plus != null">#{plus},</if>
            <if test="unionId != null">#{unionId},</if>
            <if test="skuId != null">#{skuId},</if>
            <if test="skuName != null and skuName != ''">#{skuName},</if>
            <if test="skuNum != null">#{skuNum},</if>
            <if test="skuReturnNum != null">#{skuReturnNum},</if>
            <if test="skuFrozenNum != null">#{skuFrozenNum},</if>
            <if test="price != null">#{price},</if>
            <if test="commissionRate != null">#{commissionRate},</if>
            <if test="subSideRate != null">#{subSideRate},</if>
            <if test="subsidyRate != null">#{subsidyRate},</if>
            <if test="finalRate != null">#{finalRate},</if>
            <if test="estimateCosPrice != null">#{estimateCosPrice},</if>
            <if test="estimateFee != null">#{estimateFee},</if>
            <if test="actualCosPrice != null">#{actualCosPrice},</if>
            <if test="actualFee != null">#{actualFee},</if>
            <if test="validCode != null">#{validCode},</if>
            <if test="traceType != null">#{traceType},</if>
            <if test="positionId != null">#{positionId},</if>
            <if test="siteId != null">#{siteId},</if>
            <if test="unionAlias != null and unionAlias != ''">#{unionAlias},</if>
            <if test="pid != null and pid != ''">#{pid},</if>
            <if test="cid1 != null">#{cid1},</if>
            <if test="cid2 != null">#{cid2},</if>
            <if test="cid3 != null">#{cid3},</if>
            <if test="subUnionId != null and subUnionId != ''">#{subUnionId},</if>
            <if test="unionTag != null and unionTag != ''">#{unionTag},</if>
            <if test="popId != null">#{popId},</if>
            <if test="ext1 != null and ext1 != ''">#{ext1},</if>
            <if test="payMonth != null and payMonth != ''">#{payMonth},</if>
            <if test="cpActId != null">#{cpActId},</if>
            <if test="unionRole != null">#{unionRole},</if>
            <if test="giftCouponOcsAmount != null">#{giftCouponOcsAmount},</if>
            <if test="giftCouponKey != null and giftCouponKey != ''">#{giftCouponKey},</if>
            <if test="balanceExt != null and balanceExt != ''">#{balanceExt},</if>
            <if test="sign != null and sign != ''">#{sign},</if>
            <if test="proPriceAmount != null">#{proPriceAmount},</if>
            <if test="rid != null">#{rid},</if>
            <if test="goodsInfoId != null">#{goodsInfoId},</if>
            <if test="expressStatus != null">#{expressStatus},</if>
            <if test="channelId != null">#{channelId},</if>
            <if test="skuTag != null and skuTag != ''">#{skuTag},</if>
            <if test="itemId != null and itemId != ''">#{itemId},</if>
            <if test="callerItemId != null and callerItemId != ''">#{callerItemId},</if>
            <if test="orderTag != null and orderTag != ''">#{orderTag},</if>
        </trim>
    </insert>

    <update id="updateOrderRows" parameterType="OrderRows">
        update order_rows
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="parentId != null">parent_id = #{parentId},</if>
            <if test="orderTime != null">order_time = #{orderTime},</if>
            <if test="finishTime != null">finish_time = #{finishTime},</if>
            <if test="modifyTime != null">modify_time = #{modifyTime},</if>
            <if test="orderEmt != null">order_emt = #{orderEmt},</if>
            <if test="plus != null">plus = #{plus},</if>
            <if test="unionId != null">union_id = #{unionId},</if>
            <if test="skuId != null">sku_id = #{skuId},</if>
            <if test="skuName != null and skuName != ''">sku_name = #{skuName},</if>
            <if test="skuNum != null">sku_num = #{skuNum},</if>
            <if test="skuReturnNum != null">sku_return_num = #{skuReturnNum},</if>
            <if test="skuFrozenNum != null">sku_frozen_num = #{skuFrozenNum},</if>
            <if test="price != null">price = #{price},</if>
            <if test="commissionRate != null">commission_rate = #{commissionRate},</if>
            <if test="subSideRate != null">sub_side_rate = #{subSideRate},</if>
            <if test="subsidyRate != null">subsidy_rate = #{subsidyRate},</if>
            <if test="finalRate != null">final_rate = #{finalRate},</if>
            <if test="estimateCosPrice != null">estimate_cos_price = #{estimateCosPrice},</if>
            <if test="estimateFee != null">estimate_fee = #{estimateFee},</if>
            <if test="actualCosPrice != null">actual_cos_price = #{actualCosPrice},</if>
            <if test="actualFee != null">actual_fee = #{actualFee},</if>
            <if test="validCode != null">valid_code = #{validCode},</if>
            <if test="traceType != null">trace_type = #{traceType},</if>
            <if test="positionId != null">position_id = #{positionId},</if>
            <if test="siteId != null">site_id = #{siteId},</if>
            <if test="unionAlias != null and unionAlias != ''">union_alias = #{unionAlias},</if>
            <if test="pid != null and pid != ''">pid = #{pid},</if>
            <if test="cid1 != null">cid1 = #{cid1},</if>
            <if test="cid2 != null">cid2 = #{cid2},</if>
            <if test="cid3 != null">cid3 = #{cid3},</if>
            <if test="subUnionId != null and subUnionId != ''">sub_union_id = #{subUnionId},</if>
            <if test="unionTag != null and unionTag != ''">union_tag = #{unionTag},</if>
            <if test="popId != null">pop_id = #{popId},</if>
            <if test="ext1 != null and ext1 != ''">ext1 = #{ext1},</if>
            <if test="payMonth != null and payMonth != ''">pay_month = #{payMonth},</if>
            <if test="cpActId != null">cp_act_id = #{cpActId},</if>
            <if test="unionRole != null">union_role = #{unionRole},</if>
            <if test="giftCouponOcsAmount != null">gift_coupon_ocs_amount = #{giftCouponOcsAmount},</if>
            <if test="giftCouponKey != null and giftCouponKey != ''">gift_coupon_key = #{giftCouponKey},</if>
            <if test="balanceExt != null and balanceExt != ''">balance_ext = #{balanceExt},</if>
            <if test="sign != null and sign != ''">sign = #{sign},</if>
            <if test="proPriceAmount != null">pro_price_amount = #{proPriceAmount},</if>
            <if test="rid != null">rid = #{rid},</if>
            <if test="goodsInfoId != null">goods_info_id = #{goodsInfoId},</if>
            <if test="expressStatus != null">express_status = #{expressStatus},</if>
            <if test="channelId != null">channel_id = #{channelId},</if>
            <if test="skuTag != null and skuTag != ''">sku_tag = #{skuTag},</if>
            <if test="itemId != null and itemId != ''">item_id = #{itemId},</if>
            <if test="callerItemId != null and callerItemId != ''">caller_item_id = #{callerItemId},</if>
            <if test="orderTag != null and orderTag != ''">order_tag = #{orderTag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderRowsById" parameterType="String">
        delete from order_rows where id = #{id}
    </delete>

    <delete id="deleteOrderRowsByIds" parameterType="String">
        delete from order_rows where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="selectOrderRowsByOrderId" parameterType="String" resultMap="OrderRowsResult">
        <include refid="selectOrderRowsVo"/>
        where order_id = #{orderId}
    </select>

    <select id="selectOrderRowsByGiftCouponKey" parameterType="String" resultMap="OrderRowsResult">
        <include refid="selectOrderRowsVo"/>
        where gift_coupon_key = #{giftCouponKey}
        order by order_time desc
    </select>
</mapper>
