<?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.yiqi.order.mapper.OrderClothMapper">

    <resultMap type="OrderCloth" id="OrderClothResult">
        <result property="id" column="id"/>
        <result property="orderNo" column="order_no"/>
        <result property="orderType" column="order_type"/>
        <result property="orgId" column="org_id"/>
        <result property="sourceType" column="source_type"/>
        <result property="factoryId" column="factory_id"/>
        <result property="appUserId" column="app_user_id"/>
        <result property="province" column="province"/>
        <result property="city" column="city"/>
        <result property="area" column="area"/>
        <result property="address" column="address"/>
        <result property="addressDetail" column="address_detail"/>
        <result property="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
        <result property="contactName" column="contact_name"/>
        <result property="contactPhone" column="contact_phone"/>
        <result property="orderAmount" column="order_amount"/>
        <result property="orderClothCount" column="order_cloth_count"/>
        <result property="payAmount" column="pay_amount"/>
        <result property="payType" column="pay_type"/>
        <result property="payTime" column="pay_time"/>
        <result property="outTradeOrderNo" column="out_trade_order_no"/>
        <result property="orderSource" column="order_source"/>
        <result property="refundAmount" column="refund_amount"/>
        <result property="refundContent" column="refund_content"/>
        <result property="appointmentTime" column="appointment_time"/>
        <result property="appointmentCount" column="appointment_count"/>
        <result property="orderStatus" column="order_status"/>
        <result property="takeClothTime" column="take_cloth_time"/>
        <result property="takeClothAppUserId" column="take_cloth_app_user_id"/>
        <result property="setPriceTime" column="set_price_time"/>
        <result property="pickUpTime" column="pick_up_time"/>
        <result property="washClothStartTime" column="wash_cloth_start_time"/>
        <result property="washClothEndTime" column="wash_cloth_end_time"/>
        <result property="sendToStoreTime" column="send_to_store_time"/>
        <result property="sendToUserTime" column="send_to_user_time"/>
        <result property="refundApplyTime" column="refund_apply_time"/>
        <result property="refundTime" column="refund_time"/>
        <result property="refundStatus" column="refund_status"/>
        <result property="refundReason" column="refund_reason"/>
        <result property="sendClothAppUserId" column="send_cloth_app_user_id"/>
        <result property="takeClothWay" column="take_cloth_way"/>
        <result property="sendClothWay" column="send_cloth_way"/>
        <result property="activityDiscountAmount" column="activity_discount_amount"/>
        <result property="finishTime" column="finish_time"/>
        <result property="employeeId" column="employee_id"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createById" column="create_by_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateById" column="update_by_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="isDisassemblyAndAssembly" column="is_disassembly_and_assembly"/>
        <result property="isLargeItem" column="is_large_item"/>
        <result property="clothSpeedId" column="cloth_speed_id"/>
        <result property="clothSpeedName" column="cloth_speed_name"/>
        <result property="isSpecial" column="is_special"/>
        <result property="couponDeductAmount" column="coupon_deduct_amount"/>
        <result property="cashDeductAmount" column="cash_deduct_amount"/>
    </resultMap>

    <resultMap type="com.yiqi.order.domain.vo.OrderClothVO" id="OrderClothVOResult">
        <result property="id" column="id"/>
        <result property="orderNo" column="order_no"/>
        <result property="orgId" column="org_id"/>
        <result property="sourceType" column="source_type"/>
        <result property="factoryId" column="factory_id"/>
        <result property="appUserId" column="app_user_id"/>
        <result property="province" column="province"/>
        <result property="city" column="city"/>
        <result property="area" column="area"/>
        <result property="address" column="address"/>
        <result property="addressDetail" column="address_detail"/>
        <result property="longitude" column="longitude"/>
        <result property="latitude" column="latitude"/>
        <result property="contactName" column="contact_name"/>
        <result property="contactPhone" column="contact_phone"/>
        <result property="orderAmount" column="order_amount"/>
        <result property="orderClothCount" column="order_cloth_count"/>
        <result property="payAmount" column="pay_amount"/>
        <result property="payType" column="pay_type"/>
        <result property="payTime" column="pay_time"/>
        <result property="outTradeOrderNo" column="out_trade_order_no"/>
        <result property="orderSource" column="order_source"/>
        <result property="refundAmount" column="refund_amount"/>
        <result property="refundContent" column="refund_content"/>
        <result property="appointmentTime" column="appointment_time"/>
        <result property="appointmentCount" column="appointment_count"/>
        <result property="orderStatus" column="order_status"/>
        <result property="takeClothTime" column="take_cloth_time"/>
        <result property="takeClothAppUserId" column="take_cloth_app_user_id"/>
        <result property="setPriceTime" column="set_price_time"/>
        <result property="pickUpTime" column="pick_up_time"/>
        <result property="washClothStartTime" column="wash_cloth_start_time"/>
        <result property="washClothEndTime" column="wash_cloth_end_time"/>
        <result property="sendToStoreTime" column="send_to_store_time"/>
        <result property="sendToUserTime" column="send_to_user_time"/>
        <result property="refundApplyTime" column="refund_apply_time"/>
        <result property="refundTime" column="refund_time"/>
        <result property="refundStatus" column="refund_status"/>
        <result property="refundReason" column="refund_reason"/>
        <result property="sendClothAppUserId" column="send_cloth_app_user_id"/>
        <result property="takeClothWay" column="take_cloth_way"/>
        <result property="sendClothWay" column="send_cloth_way"/>
        <result property="activityDiscountAmount" column="activity_discount_amount"/>
        <result property="finishTime" column="finish_time"/>
        <result property="employeeId" column="employee_id"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createById" column="create_by_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateById" column="update_by_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="isDisassemblyAndAssembly" column="is_disassembly_and_assembly"/>
        <result property="isLargeItem" column="is_large_item"/>
        <result property="clothSpeedId" column="cloth_speed_id"/>
        <result property="clothSpeedName" column="cloth_speed_name"/>
        <result property="isSpecial" column="is_special"/>
        <result property="couponDeductAmount" column="coupon_deduct_amount"/>
        <result property="cashDeductAmount" column="cash_deduct_amount"/>
        <association property="sysOrg" columnPrefix="sys_org_" javaType="com.yiqi.system.domain.SysOrg">
            <result property="name" column="name"/>
            <result property="bindAreaId" column="bind_area_id"/>
            <result property="address" column="address"/>
            <result property="addressDetail" column="address_detail"/>
            <result property="contactPhone" column="contact_phone"/>
            <result property="pic" column="pic"/>
        </association>
    </resultMap>

    <sql id="selectOrderClothVo">
        select *
        from order_cloth
    </sql>
    <sql id="orderClothFinancialVo">
        select a.order_no as orderNo, a.order_cloth_count as orderClothCount, a.order_amount as orderAmount, a.pay_amount as payAmount,
            a.pay_info as payInfo, a.refund_status as refundStatus, a.coupon_deduct_amount as couponDeductAmount, a.cash_deduct_amount as cashDeductAmount,
               a.activity_discount_amount as activityDiscountAmount, a.has_pay as hasPay, a.pay_status as payStatus, a.create_time as createTime, au.real_name as userName, au.phone_number as phoneNumber,
            a.create_by as employeeName, a.create_by_id as employeeId, a.order_status as orderStatus, a.pay_type as payType
        from order_cloth a
            left join app_user au on a.app_user_id = au.id
    </sql>

    <select id="findPage" resultMap="OrderClothVOResult">
        select c.id, c.order_no, c.org_id, c.source_type, c.factory_id, c.app_user_id,  c.pay_status as payStatus,
               c.contact_name, c.contact_phone, c.order_amount, c.pay_info, c.order_cloth_count, c.pay_amount, c.pay_type, c.pay_time, c.out_trade_order_no,
               c.order_source, c.refund_amount, c.refund_content, c.appointment_time, c.appointment_count, c.order_status, c.take_cloth_time,
               c.take_cloth_app_user_id, c.set_price_time, c.pick_up_time, c.wash_cloth_start_time, c.wash_cloth_end_time, c.send_to_store_time,
               c.send_to_user_time, c.refund_time, c.refund_status, c.send_cloth_app_user_id, c.take_cloth_way,
               c.send_cloth_way, c.coupon_amount, c.finish_time, c.employee_id, c.del_flag, c.create_by_id, c.create_by, c.create_time, c.update_by_id,
               c.update_by, c.update_time, c.remark, c.is_disassembly_and_assembly, c.is_large_item, c.cloth_speed_id, c.cloth_speed_name, c.is_special,
               c.coupon_deduct_amount, c.cash_deduct_amount, org.name as sys_org_name, org.bind_area_id as sys_org_bind_area_id, org.address as sys_org_address,
               org.address_detail as sys_org_address_detail,org.contact_phone as sys_org_contact_phone,org.pic as sys_org_pic
        from order_cloth as c left join sys_org as org on c.source_type=org.source_type and c.org_id=org.id
        where c.del_flag = '0' and c.app_user_id = #{appUserId} and c.refund_status != '2'
        <if test="orderClothAppQueryDTO.startDate != null">
            and c.create_time &gt;= #{orderClothAppQueryDTO.startDate}
        </if>
        <if test="orderClothAppQueryDTO.endDate != null">
            and c.create_time &lt;= #{orderClothAppQueryDTO.endDate}
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '0'.toString() ">
            and c.order_status='0'
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '1'.toString() ">
            and c.order_status='0'
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '2'.toString() ">
            and (c.order_status='2' or c.order_status='3')
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '3'.toString() ">
            and (c.order_status='4' or c.order_status='5' or c.order_status='6')
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '4'.toString() ">
            and c.order_status='7' and c.send_cloth_way='1'
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '5'.toString() ">
            and c.order_status='8'
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '6'.toString() ">
            and c.order_status='7'
<!--            and c.send_cloth_way='0'-->
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '7'.toString() ">
            and c.order_status='9'
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '8'.toString() ">
            and c.order_status='10'
        </if>
        <if test="orderClothAppQueryDTO.orderStatus != null and orderClothAppQueryDTO.orderStatus == '100'.toString() ">
            and c.order_status='100'
        </if>
        order by c.create_time desc
        limit #{orderClothAppQueryDTO.startRow},#{orderClothAppQueryDTO.pageSize}
    </select>

    <select id="selectOrderClothList" parameterType="OrderCloth" resultMap="OrderClothResult">
        <include refid="selectOrderClothVo"/>
        <where>
            and del_flag='0'
            <if test="orderNo != null  and orderNo != ''">
                and order_no = #{orderNo}
            </if>
            <if test="createTime != null ">
                and create_time = #{createTime}
            </if>
        </where>
    </select>

    <select id="selectOrderClothById" parameterType="Long"
            resultMap="OrderClothResult">
        <include refid="selectOrderClothVo"/>
        where id = #{id}
        and del_flag='0'
    </select>
    <select id="getDeliveryOrderRecordList" resultType="com.yiqi.order.domain.vo.OrderClothRecordVO">
        select a.order_no as orderNo,c.id as storeId, c.name as storeName, b.real_name as realName, a.finish_time as finishTime,
               a.pick_up_time as pickUpTime, a.send_cloth_way as sendClothWay, a.send_to_store_time as sendToStoreTime,
               a.send_to_user_time as sendToUserTime
        from order_cloth a
        left join app_user b ON a.send_cloth_app_user_id = b.id
        left join sys_store c ON a.org_id = c.id
        where a.order_status IN ('9','10') and a.refund_status = '0' and a.del_flag='0'
            and a.send_cloth_app_user_id = #{appUserId}
    </select>

    <select id="getAppointmentClothOrderList" resultType="com.yiqi.order.domain.vo.OrderClothAppointmentVO">
        select o.order_no as orderNo, o.appointment_time as appointmentTime, o.appointment_count as appointmentCount, o.pay_status as payStatus,
        o.take_cloth_app_user_id as takeClothAppUserId, o.order_status AS orderStatus,
        a.user_address as address, o.take_cloth_way as takeClothWay, o.send_cloth_way AS sendClothWay,
        o.is_disassembly_and_assembly as isDisassemblyAndAssembly, o.is_large_item as isLargeItem, b.real_name as takeClothAppUserName,
        a.user_name as contactName, a.user_phone as contactPhone, b.phone_number as takeClothAppUserPhone
        ,o.org_id as orgId,o.source_type as sourceType,org.name as orgName,a.delivery_way as deliveryWay
        from order_cloth o
        left join app_user b on o.take_cloth_app_user_id = b.id
        left join order_delivery a on a.order_sn=o.order_no
        <if test="takeClothWay != null  and takeClothWay == '1'.toString()">
            and a.cloth_order_type=0
        </if>
        <if test="sendClothWay != null  and sendClothWay == '1'.toString()">
            and a.cloth_order_type=1
        </if>
        left join sys_org as org on org.id=o.org_id and org.source_type=o.source_type and org.id is not null
        where o.del_flag='0' and o.is_appointment = 'Y' and o.order_status != '100'
        <if test="orderType != null  and orderType != ''">
            and o.order_type=#{orderType}
        </if>
        <if test="queryOrderStatus != null  and queryOrderStatus.size > 0 ">
            and o.order_status in
            <foreach item="id" collection="queryOrderStatus" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <if test="orgId != null">
            and o.org_id = #{orgId}
        </if>
        <if test="sourceType != null  and sourceType != ''">
            and o.source_type = #{sourceType}
        </if>
        <if test="takeClothWay != null  and takeClothWay != ''">
            and o.take_cloth_way = #{takeClothWay}
        </if>
        <if test="sendClothWay != null  and sendClothWay != ''">
            and o.send_cloth_way = #{sendClothWay}
        </if>
        <if test="orderNo != null  and orderNo != ''">
            and o.order_no = #{orderNo}
        </if>
        <if test="contactName != null  and contactName != ''">
            and a.user_name = #{contactName}
        </if>
        <if test="contactPhone != null  and contactPhone != ''">
            and a.user_phone = #{contactPhone}
        </if>
        <if test="appointmentTime != null  and appointmentTime != ''">
            and o.appointment_time >= DATE_FORMAT(#{appointmentTime},'%Y-%m-%d 00:00:00')
            and o.appointment_time <![CDATA[ <= ]]> DATE_FORMAT(#{appointmentTime},'%Y-%m-%d 23:59:59')
        </if>
        order by o.create_time desc
        <if test="pageSizeExport != 0">
            limit #{pageSizeExport}
        </if>
    </select>
    <select id="listFinancialStatisticsByClothOrderDay"
            resultType="com.yiqi.order.domain.vo.OrderClothFinancialVO">
        <include refid="orderClothFinancialVo"/>
        <where>
             a.order_status IN ('6','7','8','9','10','11') and a.refund_status = '0' and a.del_flag='0'
                and a.org_id = #{orgId} and a.source_type = '02'
        <if test="orderFinancialDayQueryDTO.beginCreateTime != null and orderFinancialDayQueryDTO.beginCreateTime != ''"><!-- 开始时间检索 -->
            and date_format(a.create_time,'%y%m%d') &gt;= date_format(#{orderFinancialDayQueryDTO.beginCreateTime},'%y%m%d')
        </if>
        <if test="orderFinancialDayQueryDTO.endCreateTime != null and orderFinancialDayQueryDTO.endCreateTime != ''"><!-- 结束时间检索 -->
            and date_format(a.create_time,'%y%m%d') &lt;= date_format(#{orderFinancialDayQueryDTO.endCreateTime},'%y%m%d')
        </if>
        </where>
        order by a.create_time desc
        limit #{orderFinancialDayQueryDTO.startRow},#{orderFinancialDayQueryDTO.pageSize}
    </select>
    <select id="listFinancialStatisticsByClothOrderToday"
            resultType="com.yiqi.order.domain.vo.OrderClothFinancialVO">
        <include refid="orderClothFinancialVo"/>
        <where>
            a.order_status IN ('6','7','8','9','10','11') and a.refund_status = '0' and a.del_flag='0'
            and a.org_id = #{orgId} and a.source_type = '02'
            <if test="orderFinancialDayQueryDTO.beginCreateTime != null and orderFinancialDayQueryDTO.beginCreateTime != ''"><!-- 开始时间检索 -->
                and date_format(a.create_time,'%y%m%d') &gt;= date_format(#{orderFinancialDayQueryDTO.beginCreateTime},'%y%m%d')
            </if>
            <if test="orderFinancialDayQueryDTO.endCreateTime != null and orderFinancialDayQueryDTO.endCreateTime != ''"><!-- 结束时间检索 -->
                and date_format(a.create_time,'%y%m%d') &lt;= date_format(#{orderFinancialDayQueryDTO.endCreateTime},'%y%m%d')
            </if>
        </where>
        order by a.create_time desc
    </select>
    <select id="countFinancialStatisticsByClothOrderDay" resultType="java.lang.Integer">
        select count(*)
        from order_cloth a
        <where>
            a.order_status IN ('6','7','8','9','10','11') and a.refund_status = '0' and a.del_flag='0'
            and a.org_id = #{orgId} and a.source_type = '02'
            <if test="orderFinancialDayQueryDTO.beginCreateTime != null and orderFinancialDayQueryDTO.beginCreateTime != ''"><!-- 开始时间检索 -->
                and date_format(a.create_time,'%y%m%d') &gt;= date_format(#{orderFinancialDayQueryDTO.beginCreateTime},'%y%m%d')
            </if>
            <if test="orderFinancialDayQueryDTO.endCreateTime != null and orderFinancialDayQueryDTO.endCreateTime != ''"><!-- 结束时间检索 -->
                and date_format(a.create_time,'%y%m%d') &lt;= date_format(#{orderFinancialDayQueryDTO.endCreateTime},'%y%m%d')
            </if>
        </where>
    </select>
    <select id="listFinancialStatisticsByClothOrderMTD"
            resultType="com.yiqi.order.domain.vo.OrderClothFinancialVO">
        <include refid="orderClothFinancialVo"/>
        <where>
            a.order_status IN ('6','7','8','9','10','11') and a.refund_status = '0' and a.del_flag='0'
            and a.org_id = #{orgId} and a.source_type = '02'
            and a.create_time BETWEEN DATE_FORMAT(NOW(), '%Y-%m-01') AND LAST_DAY(NOW())
    </where>
        order by a.create_time desc
    </select>
    <select id="listFinancialStatisticsByClothOrderMonth"
            resultType="com.yiqi.order.domain.vo.OrderClothFinancialVO">
        <include refid="orderClothFinancialVo"/>
        <where>
        a.order_status IN ('6','7','8','9','10','11') and a.refund_status = '0' and a.del_flag='0'
        and a.org_id = #{orgId} and a.source_type = '02'
        <if test="orderFinancialMonthQueryDTO.monthTime != null and orderFinancialMonthQueryDTO.monthTime != ''"><!-- 开始时间检索 -->
            and DATE_FORMAT(a.create_time,'%Y-%m') = #{orderFinancialMonthQueryDTO.monthTime}
        </if>
        </where>
        order by a.create_time desc
        limit #{orderFinancialMonthQueryDTO.startRow},#{orderFinancialMonthQueryDTO.pageSize}
    </select>
    <select id="countFinancialStatisticsByClothOrderMonth" resultType="java.lang.Integer">
        select count(*)
        from order_cloth a
        <where>
            a.order_status IN ('6','7','8','9','10','11') and a.refund_status = '0' and a.del_flag='0'
            and a.org_id = #{orgId} and a.source_type = '02'
            <if test="orderFinancialMonthQueryDTO.monthTime != null and orderFinancialMonthQueryDTO.monthTime != ''"><!-- 开始时间检索 -->
                and DATE_FORMAT(a.create_time,'%Y-%m') = #{orderFinancialMonthQueryDTO.monthTime}
            </if>
        </where>
        order by a.create_time desc
    </select>

    <insert id="insertOrderCloth" parameterType="OrderCloth" useGeneratedKeys="true"
            keyProperty="id">
        insert into order_cloth
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">order_no,
            </if>
            <if test="orgId != null">org_id,
            </if>
            <if test="sourceType != null">source_type,
            </if>
            <if test="factoryId != null">factory_id,
            </if>
            <if test="appUserId != null">app_user_id,
            </if>
            <if test="province != null">province,
            </if>
            <if test="city != null">city,
            </if>
            <if test="area != null">area,
            </if>
            <if test="address != null">address,
            </if>
            <if test="addressDetail != null">address_detail,
            </if>
            <if test="longitude != null">longitude,
            </if>
            <if test="latitude != null">latitude,
            </if>
            <if test="contactName != null">contact_name,
            </if>
            <if test="contactPhone != null">contact_phone,
            </if>
            <if test="orderAmount != null">order_amount,
            </if>
            <if test="orderClothCount != null">order_cloth_count,
            </if>
            <if test="payAmount != null">pay_amount,
            </if>
            <if test="payType != null">pay_type,
            </if>
            <if test="payTime != null">pay_time,
            </if>
            <if test="outTradeOrderNo != null">out_trade_order_no,
            </if>
            <if test="orderSource != null">order_source,
            </if>
            <if test="refundAmount != null">refund_amount,
            </if>
            <if test="refundContent != null">refund_content,
            </if>
            <if test="appointmentTime != null">appointment_time,
            </if>
            <if test="appointmentCount != null">appointment_count,
            </if>
            <if test="orderStatus != null">order_status,
            </if>
            <if test="takeClothTime != null">take_cloth_time,
            </if>
            <if test="takeClothAppUserId != null">take_cloth_app_user_id,
            </if>
            <if test="setPriceTime != null">set_price_time,
            </if>
            <if test="pickUpTime != null">pick_up_time,
            </if>
            <if test="washClothStartTime != null">wash_cloth_start_time,
            </if>
            <if test="washClothEndTime != null">wash_cloth_end_time,
            </if>
            <if test="sendToStoreTime != null">send_to_store_time,
            </if>
            <if test="sendToUserTime != null">send_to_user_time,
            </if>
            <if test="refundApplyTime != null">refund_apply_time,
            </if>
            <if test="refundTime != null">refund_time,
            </if>
            <if test="refundStatus != null">refund_status,
            </if>
            <if test="refundReason != null">refund_reason,
            </if>
            <if test="sendClothAppUserId != null">send_cloth_app_user_id,
            </if>
            <if test="takeClothWay != null">take_cloth_way,
            </if>
            <if test="sendClothWay != null">send_cloth_way,
            </if>
            <if test="couponAmount != null">coupon_amount,
            </if>
            <if test="finishTime != null">finish_time,
            </if>
            <if test="employeeId != null">employee_id,
            </if>
            <if test="delFlag != null">del_flag,
            </if>
            <if test="createById != null">create_by_id,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateById != null">update_by_id,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
            <if test="remark != null">remark,
            </if>
            <if test="isDisassemblyAndAssembly != null">is_disassembly_and_assembly,
            </if>
            <if test="isLargeItem != null">is_large_item,
            </if>
            <if test="clothSpeedId != null">cloth_speed_id,
            </if>
            <if test="clothSpeedName != null">cloth_speed_name,
            </if>
            <if test="isSpecial != null">is_special,
            </if>
            <if test="cashDeductAmount != null">cash_deduct_amount,
            </if>
            <if test="couponDeductAmount != null">coupon_deduct_amount,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">#{orderNo},
            </if>
            <if test="orgId != null">#{orgId},
            </if>
            <if test="sourceType != null">#{sourceType},
            </if>
            <if test="factoryId != null">#{factoryId},
            </if>
            <if test="appUserId != null">#{appUserId},
            </if>
            <if test="province != null">#{province},
            </if>
            <if test="city != null">#{city},
            </if>
            <if test="area != null">#{area},
            </if>
            <if test="address != null">#{address},
            </if>
            <if test="addressDetail != null">#{addressDetail},
            </if>
            <if test="longitude != null">#{longitude},
            </if>
            <if test="latitude != null">#{latitude},
            </if>
            <if test="contactName != null">#{contactName},
            </if>
            <if test="contactPhone != null">#{contactPhone},
            </if>
            <if test="orderAmount != null">#{orderAmount},
            </if>
            <if test="orderClothCount != null">#{orderClothCount},
            </if>
            <if test="payAmount != null">#{payAmount},
            </if>
            <if test="payType != null">#{payType},
            </if>
            <if test="payTime != null">#{payTime},
            </if>
            <if test="outTradeOrderNo != null">#{outTradeOrderNo},
            </if>
            <if test="orderSource != null">#{orderSource},
            </if>
            <if test="refundAmount != null">#{refundAmount},
            </if>
            <if test="refundContent != null">#{refundContent},
            </if>
            <if test="appointmentTime != null">#{appointmentTime},
            </if>
            <if test="appointmentCount != null">#{appointmentCount},
            </if>
            <if test="orderStatus != null">#{orderStatus},
            </if>
            <if test="takeClothTime != null">#{takeClothTime},
            </if>
            <if test="takeClothAppUserId != null">#{takeClothAppUserId},
            </if>
            <if test="setPriceTime != null">#{setPriceTime},
            </if>
            <if test="pickUpTime != null">#{pickUpTime},
            </if>
            <if test="washClothStartTime != null">#{washClothStartTime},
            </if>
            <if test="washClothEndTime != null">#{washClothEndTime},
            </if>
            <if test="sendToStoreTime != null">#{sendToStoreTime},
            </if>
            <if test="sendToUserTime != null">#{sendToUserTime},
            </if>
            <if test="refundApplyTime != null">#{refundApplyTime},
            </if>
            <if test="refundTime != null">#{refundTime},
            </if>
            <if test="refundStatus != null">#{refundStatus},
            </if>
            <if test="refundReason != null">#{refundReason},
            </if>
            <if test="sendClothAppUserId != null">#{sendClothAppUserId},
            </if>
            <if test="takeClothWay != null">#{takeClothWay},
            </if>
            <if test="sendClothWay != null">#{sendClothWay},
            </if>
            <if test="couponAmount != null">#{couponAmount},
            </if>
            <if test="finishTime != null">#{finishTime},
            </if>
            <if test="employeeId != null">#{employeeId},
            </if>
            <if test="delFlag != null">#{delFlag},
            </if>
            <if test="createById != null">#{createById},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateById != null">#{updateById},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
            <if test="remark != null">#{remark},
            </if>
            <if test="isDisassemblyAndAssembly != null">#{isDisassemblyAndAssembly},
            </if>
            <if test="isLargeItem != null">#{isLargeItem},
            </if>
            <if test="clothSpeedId != null">#{clothSpeedId},
            </if>
            <if test="clothSpeedName != null">#{clothSpeedName},
            </if>
            <if test="isSpecial != null">#{isSpecial},
            </if>
            <if test="cashDeductAmount != null">#{cashDeductAmount},
            </if>
            <if test="couponDeductAmount != null">#{couponDeductAmount},
            </if>
        </trim>
    </insert>

    <update id="updateOrderCloth" parameterType="OrderCloth">
        update order_cloth
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderNo != null">order_no =
                #{orderNo},
            </if>
            <if test="orgId != null">org_id =
                #{orgId},
            </if>
            <if test="sourceType != null">source_type =
                #{sourceType},
            </if>
            <if test="factoryId != null">factory_id =
                #{factoryId},
            </if>
            <if test="appUserId != null">app_user_id =
                #{appUserId},
            </if>
            <if test="province != null">province =
                #{province},
            </if>
            <if test="city != null">city =
                #{city},
            </if>
            <if test="area != null">area =
                #{area},
            </if>
            <if test="address != null">address =
                #{address},
            </if>
            <if test="addressDetail != null">address_detail =
                #{addressDetail},
            </if>
            <if test="longitude != null">longitude =
                #{longitude},
            </if>
            <if test="latitude != null">latitude =
                #{latitude},
            </if>
            <if test="contactName != null">contact_name =
                #{contactName},
            </if>
            <if test="contactPhone != null">contact_phone =
                #{contactPhone},
            </if>
            <if test="orderAmount != null">order_amount =
                #{orderAmount},
            </if>
            <if test="orderClothCount != null"> order_cloth_amount =
                #{orderClothCount},
            </if>
            <if test="payAmount != null">pay_amount =
                #{payAmount},
            </if>
            <if test="payType != null">pay_type =
                #{payType},
            </if>
            <if test="payTime != null">pay_time =
                #{payTime},
            </if>
            <if test="outTradeOrderNo != null">out_trade_order_no =
                #{outTradeOrderNo},
            </if>
            <if test="orderSource != null">order_source =
                #{orderSource},
            </if>
            <if test="refundAmount != null">refund_amount =
                #{refundAmount},
            </if>
            <if test="refundContent != null">refund_content =
                #{refundContent},
            </if>
            <if test="appointmentTime != null">appointment_time =
                #{appointmentTime},
            </if>
            <if test="appointmentCount != null">appointment_count =
                #{appointmentCount},
            </if>
            <if test="orderStatus != null">order_status =
                #{orderStatus},
            </if>
            <if test="takeClothTime != null">take_cloth_time =
                #{takeClothTime},
            </if>
            <if test="takeClothAppUserId != null">take_cloth_app_user_id =
                #{takeClothAppUserId},
            </if>
            <if test="setPriceTime != null">set_price_time =
                #{setPriceTime},
            </if>
            <if test="pickUpTime != null">pick_up_time =
                #{pickUpTime},
            </if>
            <if test="washClothStartTime != null">wash_cloth_start_time =
                #{washClothStartTime},
            </if>
            <if test="washClothEndTime != null">wash_cloth_end_time =
                #{washClothEndTime},
            </if>
            <if test="sendToStoreTime != null">send_to_store_time =
                #{sendToStoreTime},
            </if>
            <if test="sendToUserTime != null">send_to_user_time =
                #{sendToUserTime},
            </if>
            <if test="refundApplyTime != null">refund_apply_time =
                #{refundApplyTime},
            </if>
            <if test="refundTime != null">refund_time =
                #{refundTime},
            </if>
            <if test="refundStatus != null">refund_status =
                #{refundStatus},
            </if>
            <if test="refundReason != null">refund_reason =
                #{refundReason},
            </if>
            <if test="sendClothAppUserId != null">send_cloth_app_user_id =
                #{sendClothAppUserId},
            </if>
            <if test="takeClothWay != null">take_cloth_way =
                #{takeClothWay},
            </if>
            <if test="sendClothWay != null">send_cloth_way =
                #{sendClothWay},
            </if>
            <if test="couponAmount != null">coupon_amount =
                #{couponAmount},
            </if>
            <if test="finishTime != null">finish_time =
                #{finishTime},
            </if>
            <if test="employeeId != null">employee_id =
                #{employeeId},
            </if>
            <if test="delFlag != null">del_flag =
                #{delFlag},
            </if>
            <if test="createById != null">create_by_id =
                #{createById},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateById != null">update_by_id =
                #{updateById},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
            <if test="remark != null">remark =
                #{remark},
            </if>
            <if test="isDisassemblyAndAssembly != null">is_disassembly_and_assembly =
                #{isDisassemblyAndAssembly},
            </if>
            <if test="isLargeItem != null">is_large_item =
                #{isLargeItem},
            </if>
            <if test="clothSpeedId != null">cloth_speed_id =
                #{clothSpeedId},
            </if>
            <if test="clothSpeedName != null">cloth_speed_name =
                #{clothSpeedName},
            </if>
            <if test="isSpecial != null">is_special =
                #{isSpecial},
            </if>
            <if test="cashDeductAmount != null">cash_deduct_amount =
            #{cashDeductAmount},
            </if>
            <if test="couponDeductAmount != null">coupon_deduct_amount =
            #{couponDeductAmount},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderClothById" parameterType="Long">
        update order_cloth set del_flag='2' where id = #{id}
    </delete>

    <delete id="deleteOrderClothByIds" parameterType="String">
        update order_cloth set del_flag='2' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>



</mapper>