<?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.tmerclub.cloud.order.mapper.OrderMapper">
    <resultMap id="orderMap" type="com.tmerclub.cloud.order.model.Order">
        <id column="order_id" property="orderId"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="shop_id" property="shopId"/>
        <result column="user_id" property="userId"/>
        <result column="order_addr_id" property="orderAddrId"/>
        <result column="shop_name" property="shopName"/>
        <result column="total" property="total"/>
        <result column="actual_total" property="actualTotal"/>
        <result column="order_score" property="orderScore"/>
        <result column="remarks" property="remarks"/>
        <result column="shop_remarks" property="shopRemarks"/>
        <result column="status" property="status"/>
        <result column="pay_type" property="payType"/>
        <result column="delivery_type" property="deliveryType"/>
        <result column="order_type" property="orderType"/>
        <result column="close_type" property="closeType"/>
        <result column="all_count" property="allCount"/>
        <result column="pay_time" property="payTime"/>
        <result column="delivery_time" property="deliveryTime"/>
        <result column="finally_time" property="finallyTime"/>
        <result column="cancel_time" property="cancelTime"/>
        <result column="book_time" property="bookTime"/>
        <result column="is_payed" property="isPayed"/>
        <result column="delete_status" property="deleteStatus"/>
        <result column="refund_status" property="refundStatus"/>
        <result column="freight_amount" property="freightAmount"/>
        <result column="score_amount" property="scoreAmount"/>
        <result column="member_amount" property="memberAmount"/>
        <result column="platform_coupon_amount" property="platformCouponAmount"/>
        <result column="shop_coupon_amount" property="shopCouponAmount"/>
        <result column="discount_amount" property="discountAmount"/>
        <result column="platform_amount" property="platformAmount"/>
        <result column="reduce_amount" property="reduceAmount"/>
        <result column="shop_change_free_amount" property="shopChangeFreeAmount"/>
        <result column="platform_free_freight_amount" property="platformFreeFreightAmount"/>
        <result column="free_freight_amount" property="freeFreightAmount"/>
        <result column="order_invoice_id" property="orderInvoiceId"/>
        <result column="supplier_id" property="supplierId"/>
        <result column="wait_purchase" property="waitPurchase"/>
        <result column="supplier_delivery_type" property="supplierDeliveryType"/>
        <result column="purchase_spread_amount" property="purchaseSpreadAmount"/>
        <result column="pre_sale_type" property="preSaleType"/>
        <result column="order_mold" property="orderMold"/>
        <result column="shop_combo_amount" property="shopComboAmount"/>
        <result column="is_settled" property="isSettled"/>
        <result column="platform_commission" property="platformCommission"/>
        <result column="pay_sys_type" property="paySysType"/>
        <result column="write_off_num" property="writeOffNum"/>
        <result column="write_off_multiple_count" property="writeOffMultipleCount"/>
        <result column="write_off_start" property="writeOffStart"/>
        <result column="write_off_end" property="writeOffEnd"/>
        <result column="write_off_status" property="writeOffStatus"/>
        <result column="write_off_count" property="writeOffCount"/>
    </resultMap>

    <resultMap id="orderAndItemMap" type="com.tmerclub.cloud.order.model.Order">
        <id column="order_id" property="orderId"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="shop_id" property="shopId"/>
        <result column="user_id" property="userId"/>
        <result column="order_addr_id" property="orderAddrId"/>
        <result column="shop_name" property="shopName"/>
        <result column="total" property="total"/>
        <result column="actual_total" property="actualTotal"/>
        <result column="order_score" property="orderScore"/>
        <result column="order_invoice_id" property="orderInvoiceId"/>
        <result column="remarks" property="remarks"/>
        <result column="shop_remarks" property="shopRemarks"/>
        <result column="status" property="status"/>
        <result column="pay_type" property="payType"/>
        <result column="delivery_type" property="deliveryType"/>
        <result column="order_type" property="orderType"/>
        <result column="close_type" property="closeType"/>
        <result column="all_count" property="allCount"/>
        <result column="pay_time" property="payTime"/>
        <result column="delivery_time" property="deliveryTime"/>
        <result column="finally_time" property="finallyTime"/>
        <result column="cancel_time" property="cancelTime"/>
        <result column="book_time" property="bookTime"/>
        <result column="is_payed" property="isPayed"/>
        <result column="delete_status" property="deleteStatus"/>
        <result column="refund_status" property="refundStatus"/>
        <result column="freight_amount" property="freightAmount"/>
        <result column="score_amount" property="scoreAmount"/>
        <result column="member_amount" property="memberAmount"/>
        <result column="platform_coupon_amount" property="platformCouponAmount"/>
        <result column="shop_coupon_amount" property="shopCouponAmount"/>
        <result column="discount_amount" property="discountAmount"/>
        <result column="platform_amount" property="platformAmount"/>
        <result column="reduce_amount" property="reduceAmount"/>
        <result column="shop_change_free_amount" property="shopChangeFreeAmount"/>
        <result column="platform_free_freight_amount" property="platformFreeFreightAmount"/>
        <result column="free_freight_amount" property="freeFreightAmount"/>
        <result column="consignee" property="consignee"/>
        <result column="mobile" property="mobile"/>
        <result column="supplier_id" property="supplierId"/>
        <result column="wait_purchase" property="waitPurchase"/>
        <result column="supplier_delivery_type" property="supplierDeliveryType"/>
        <result column="purchase_spread_amount" property="purchaseSpreadAmount"/>
        <result column="order_mold" property="orderMold"/>
        <result column="pre_sale_type" property="preSaleType"/>
        <result column="shop_combo_amount" property="shopComboAmount"/>
        <association property="orderPreSaleInfo" javaType="com.tmerclub.cloud.order.model.OrderPreSaleInfo">
            <result column="deposit_amount" property="depositAmount"/>
            <result column="balance_amount" property="balanceAmount"/>
            <result column="balance_start_time" property="balanceStartTime"/>
            <result column="balance_end_time" property="balanceEndTime"/>
            <result column="pre_sale_delivery_type" property="preSaleDeliveryType"/>
            <result column="pre_sale_delivery_time" property="preSaleDeliveryTime"/>
        </association>
        <collection property="orderItems" columnPrefix="oi_" ofType="com.tmerclub.cloud.order.model.OrderItem">
            <id column="order_item_id" property="orderItemId"/>
            <result column="shop_id" property="shopId"/>
            <result column="order_id" property="orderId"/>
            <result column="category_id" property="categoryId"/>
            <result column="spu_id" property="spuId"/>
            <result column="sku_id" property="skuId"/>
            <result column="party_code" property="partyCode"/>
            <result column="spu_code" property="spuCode"/>
            <result column="user_id" property="userId"/>
            <result column="final_refund_id" property="finalRefundId"/>
            <result column="distribution_user_id" property="distributionUserId"/>
            <result column="count" property="count"/>
            <result column="pic" property="pic"/>
            <result column="is_comm" property="isComm"/>
            <result column="comm_time" property="commTime"/>
            <result column="refund_status" property="refundStatus"/>
            <result column="be_delivered_num" property="beDeliveredNum"/>
            <result column="delivery_type" property="deliveryType"/>
            <result column="shop_cart_time" property="shopCartTime"/>
            <result column="price" property="price"/>
            <result column="spu_total_amount" property="spuTotalAmount"/>
            <result column="actual_total" property="actualTotal"/>
            <result column="share_reduce" property="shareReduce"/>
            <result column="platform_share_reduce" property="platformShareReduce"/>
            <result column="distribution_amount" property="distributionAmount"/>
            <result column="distribution_parent_amount" property="distributionParentAmount"/>
            <result column="score_fee" property="scoreFee"/>
            <result column="use_score" property="useScore"/>
            <result column="gain_score" property="gainScore"/>
            <result column="rate" property="rate"/>
            <result column="platform_commission" property="platformCommission"/>
            <result column="score_amount" property="scoreAmount"/>
            <result column="member_amount" property="memberAmount"/>
            <result column="platform_coupon_amount" property="platformCouponAmount"/>
            <result column="shop_coupon_amount" property="shopCouponAmount"/>
            <result column="discount_amount" property="discountAmount"/>
            <result column="free_freight_amount" property="freeFreightAmount"/>
            <result column="platform_free_freight_amount" property="platformFreeFreightAmount"/>
            <result column="shop_change_free_amount" property="shopChangeFreeAmount"/>
            <result column="create_time" property="createTime"/>
            <result column="update_time" property="updateTime"/>
            <result column="giveaway_amount" property="giveawayAmount"/>
            <result column="activity_id" property="activityId"/>
            <result column="activity_type" property="activityType"/>
            <collection property="orderItemLangList" ofType="com.tmerclub.cloud.order.model.OrderItemLang">
                <id column="lang" property="lang"/>
                <result column="spu_name" property="spuName"/>
                <result column="sku_name" property="skuName"/>
            </collection>
        </collection>
    </resultMap>

    <resultMap type="com.tmerclub.cloud.order.model.Order" id="orderAndOrderItem" extends="orderMap">
        <collection property="orderItems" columnPrefix="oi_" ofType="com.tmerclub.cloud.order.model.OrderItem">
            <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
            <result column="shop_id" property="shopId"/>
            <result column="order_id" property="orderId"/>
            <result column="spu_id" property="spuId"/>
            <result column="sku_id" property="skuId"/>
            <result column="party_code" property="partyCode"/>
            <result column="category_id" property="categoryId"/>
            <result column="user_id" property="userId"/>
            <result column="final_refund_id" property="finalRefundId"/>
            <result column="distribution_user_id" property="distributionUserId"/>
            <result column="count" property="count"/>
            <result column="pic" property="pic"/>
            <result column="is_comm" property="isComm"/>
            <result column="refund_status" property="refundStatus"/>
            <result column="be_delivered_num" property="beDeliveredNum"/>
            <result column="delivery_type" property="deliveryType"/>
            <result column="shop_cart_time" property="shopCartTime"/>
            <result column="price" property="price"/>
            <result column="spu_total_amount" property="spuTotalAmount"/>
            <result column="actual_total" property="actualTotal"/>
            <result column="share_reduce" property="shareReduce"/>
            <result column="platform_share_reduce" property="platformShareReduce"/>
            <result column="distribution_amount" property="distributionAmount"/>
            <result column="distribution_parent_amount" property="distributionParentAmount"/>
            <result column="use_score" property="useScore"/>
            <result column="gain_score" property="gainScore"/>
            <result column="shop_change_free_amount" property="shopChangeFreeAmount"/>
            <result column="item_purchase_amount" property="itemPurchaseAmount"/>
            <result column="purchase_platform_commission" property="purchasePlatformCommission"/>
            <result column="supplier_id" property="supplierId"/>
            <result column="supplier_rate" property="supplierRate"/>
            <result column="giveaway_amount" property="giveawayAmount"/>
            <result column="activity_id" property="activityId"/>
            <result column="activity_type" property="activityType"/>
            <result column="spu_mold" property="spuMold"/>
            <result column="virtual_remark" property="virtualRemark"/>
            <result column="combo_amount" property="comboAmount"/>
            <result column="supplier_pic" property="supplierPic"/>
            <result column="main_giveaway" property="mainGiveaway"/>
            <collection property="orderItemLangList" ofType="com.tmerclub.cloud.order.model.OrderItemLang">
                <id column="lang" property="lang" jdbcType="BIGINT"/>
                <result column="spu_name" property="spuName" jdbcType="VARCHAR"/>
                <result column="sku_name" property="skuName" jdbcType="VARCHAR"/>
                <result column="supplier_spu_name" property="supplierSpuName" jdbcType="VARCHAR"/>
                <result column="supplier_sku_name" property="supplierSkuName" jdbcType="VARCHAR"/>
            </collection>
        </collection>
    </resultMap>

    <resultMap type="com.tmerclub.cloud.common.order.bo.EsOrderBO" id="esOrderAndOrderItemAndUserAddrMap" extends="orderMap">
        <result column="mobile" jdbcType="VARCHAR" property="mobile"/>
        <result column="consignee" jdbcType="VARCHAR" property="consignee"/>
        <collection property="orderItems" columnPrefix="oi_" ofType="com.tmerclub.cloud.common.order.bo.EsOrderItemBO">
            <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
            <result column="shop_id" property="shopId"/>
            <result column="order_id" property="orderId"/>
            <result column="spu_id" property="spuId"/>
            <result column="sku_id" property="skuId"/>
            <result column="user_id" property="userId"/>
            <result column="final_refund_id" property="finalRefundId"/>
            <result column="distribution_user_id" property="distributionUserId"/>
            <result column="count" property="count"/>
            <result column="spu_name" property="spuName"/>
            <result column="sku_name" property="skuName"/>
            <result column="pic" property="pic"/>
            <result column="is_comm" property="isComm"/>
            <result column="refund_status" property="refundStatus"/>
            <result column="be_delivered_num" property="beDeliveredNum"/>
            <result column="delivery_type" property="deliveryType"/>
            <result column="shop_cart_time" property="shopCartTime"/>
            <result column="price" property="price"/>
            <result column="spu_total_amount" property="spuTotalAmount"/>
            <result column="actual_total" property="actualTotal"/>
            <result column="share_reduce" property="shareReduce"/>
            <result column="platform_share_reduce" property="platformShareReduce"/>
            <result column="distribution_amount" property="distributionAmount"/>
            <result column="distribution_parent_amount" property="distributionParentAmount"/>
            <result column="use_score" property="useScore"/>
            <result column="gain_score" property="gainScore"/>
        </collection>
    </resultMap>

    <resultMap type="com.tmerclub.cloud.order.vo.OrderAndPreSaleVO" id="preSalesOrderAndOrderItemMap">
        <result column="shop_id" property="shopId"/>
        <result column="order_id" property="orderId"/>
        <result column="status" property="status"/>
        <result column="supplier_id" property="supplierId"/>
        <result column="supplier_delivery_type" property="supplierDeliveryType"/>
        <result column="pre_sale_type" property="preSaleType"/>
        <result column="deposit_amount" property="depositAmount"/>
        <result column="pay_sys_type" property="paySysType"/>
        <collection property="orderItems" columnPrefix="oi_" ofType="com.tmerclub.cloud.common.order.vo.OrderItemVO">
            <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
            <result column="shop_id" property="shopId"/>
            <result column="order_id" property="orderId"/>
            <result column="spu_id" property="spuId"/>
            <result column="sku_id" property="skuId"/>
            <result column="user_id" property="userId"/>
            <result column="final_refund_id" property="finalRefundId"/>
            <result column="distribution_user_id" property="distributionUserId"/>
            <result column="count" property="count"/>
            <result column="spu_name" property="spuName"/>
            <result column="sku_name" property="skuName"/>
            <result column="pic" property="pic"/>
            <result column="activity_id" property="activityId"/>
            <result column="party_code" property="partyCode"/>
            <result column="is_comm" property="isComm"/>
            <result column="refund_status" property="refundStatus"/>
            <result column="be_delivered_num" property="beDeliveredNum"/>
            <result column="delivery_type" property="deliveryType"/>
            <result column="shop_cart_time" property="shopCartTime"/>
            <result column="price" property="price"/>
            <result column="spu_total_amount" property="spuTotalAmount"/>
            <result column="actual_total" property="actualTotal"/>
            <result column="share_reduce" property="shareReduce"/>
            <result column="platform_share_reduce" property="platformShareReduce"/>
            <result column="distribution_amount" property="distributionAmount"/>
            <result column="deposit_amount" property="depositAmount"/>
            <result column="distribution_parent_amount" property="distributionParentAmount"/>
            <result column="use_score" property="useScore"/>
            <result column="gain_score" property="gainScore"/>
            <result column="rate" property="rate"/>
            <result column="main_giveaway" property="mainGiveaway"/>
        </collection>
    </resultMap>
    <resultMap id="esOrderVo" type="com.tmerclub.cloud.common.order.bo.EsOrderBO" extends="orderMap">
        <result column="mobile" property="mobile"/>
        <result column="consignee" property="consignee"/>
        <result column="province_id" property="provinceId"/>
        <result column="province" property="province"/>
        <result column="city_id" property="cityId"/>
        <result column="city" property="city"/>
        <result column="area_id" property="areaId"/>
        <result column="area" property="area"/>
        <result column="addr" property="addr"/>
        <result column="post_code" property="postCode"/>
        <result column="deposit_amount" property="depositAmount"/>
        <result column="balance_amount" property="balanceAmount"/>
        <result column="pre_sale_delivery_type" property="preSaleDeliveryType"/>
        <result column="pre_sale_delivery_time" property="preSaleDeliveryTime"/>
        <result column="balance_start_time" property="balanceStartTime"/>
        <result column="balance_end_time" property="balanceEndTime"/>
        <result column="pay_id" property="payId"/>
        <result column="station_id" property="stationId"/>
        <result column="station_code" property="stationCode"/>
        <result column="order_mold" property="orderMold"/>
        <result column="main_order_id" property="mainOrderId"/>
        <collection property="orderItems" ofType="com.tmerclub.cloud.common.order.bo.EsOrderItemBO">
            <id column="oi_order_item_id" jdbcType="BIGINT" property="orderItemId"/>
            <result column="oi_shop_id" property="shopId"/>
            <result column="oi_order_id" property="orderId"/>
            <result column="oi_spu_id" property="spuId"/>
            <result column="oi_sku_id" property="skuId"/>
            <result column="oi_user_id" property="userId"/>
            <result column="oi_final_refund_id" property="finalRefundId"/>
            <result column="oi_distribution_user_id" property="distributionUserId"/>
            <result column="oi_count" property="count"/>
            <result column="oi_pic" property="pic"/>
            <result column="oi_is_comm" property="isComm"/>
            <result column="oi_refund_status" property="refundStatus"/>
            <result column="oi_be_delivered_num" property="beDeliveredNum"/>
            <result column="oi_delivery_type" property="deliveryType"/>
            <result column="oi_shop_cart_time" property="shopCartTime"/>
            <result column="oi_price" property="price"/>
            <result column="oi_spu_total_amount" property="spuTotalAmount"/>
            <result column="oi_actual_total" property="actualTotal"/>
            <result column="oi_share_reduce" property="shareReduce"/>
            <result column="oi_platform_share_reduce" property="platformShareReduce"/>
            <result column="oi_distribution_amount" property="distributionAmount"/>
            <result column="oi_distribution_parent_amount" property="distributionParentAmount"/>
            <result column="oi_use_score" property="useScore"/>
            <result column="oi_gain_score" property="gainScore"/>
            <result column="oi_party_code" property="partyCode"/>
            <result column="oi_spu_code" property="spuCode"/>
            <result column="oi_score_fee" property="scoreFee"/>
            <result column="oi_comm_time" property="commTime"/>
            <result column="oi_shop_change_free_amount" property="shopChangeFreeAmount"/>
            <result column="oi_free_freight_amount" property="freeFreightAmount"/>
            <result column="oi_giveaway_amount" property="giveawayAmount"/>
            <result column="oi_activity_id" property="activityId"/>
            <result column="oi_supplier_pic" property="supplierPic"/>
            <result column="oi_spu_mold" property="spuMold"/>
            <result column="oi_activity_type" property="activityType"/>
            <result column="oi_write_off_num" property="writeOffNum"/>
            <result column="oi_write_off_multiple_count" property="writeOffMultipleCount"/>
            <result column="oi_write_off_start" property="writeOffStart"/>
            <result column="oi_write_off_end" property="writeOffEnd"/>
            <result column="oi_purchase_platform_commission" property="purchasePlatformCommission"/>
            <collection property="orderItemLangList" ofType="com.tmerclub.cloud.common.order.vo.OrderItemLangVO">
                <id column="oi_lang" property="lang"/>
                <result column="oi_spu_name" property="spuName"/>
                <result column="oi_sku_name" property="skuName"/>
                <result column="oi_supplier_spu_name" property="supplierSpuName"/>
                <result column="oi_supplier_sku_name" property="supplierSkuName"/>
            </collection>
        </collection>
        <collection property="orderVirtualInfoList" ofType="com.tmerclub.cloud.common.order.bo.EsOrderVirtualInfoBO">
            <id column="ovi_order_virtual_info_id" jdbcType="BIGINT" property="orderVirtualInfoId"/>
            <result column="ovi_shop_id" property="shopId"/>
            <result column="ovi_order_id" property="orderId"/>
            <result column="ovi_station_id" property="stationId"/>
            <result column="ovi_write_off_code" property="writeOffCode"/>
            <result column="ovi_is_write_off" property="isWriteOff"/>
            <result column="ovi_write_off_time" property="writeOffTime"/>
            <result column="ovi_write_off_multiple_count" property="writeOffMultipleCount"/>
        </collection>
    </resultMap>
    <resultMap id="orderVO" type="com.tmerclub.cloud.common.order.vo.OrderVO" extends="orderMap">
        <result column="mobile" property="mobile"/>
        <collection property="orderItems" ofType="com.tmerclub.cloud.common.order.vo.OrderItemVO">
            <id column="oi_order_item_id" jdbcType="BIGINT" property="orderItemId"/>
            <result column="oi_shop_id" property="shopId"/>
            <result column="oi_order_id" property="orderId"/>
            <result column="oi_category_id" property="categoryId"/>
            <result column="oi_spu_id" property="spuId"/>
            <result column="oi_sku_id" property="skuId"/>
            <result column="oi_supplier_sku_id" property="supplierSkuId"/>
            <result column="oi_user_id" property="userId"/>
            <result column="oi_final_refund_id" property="finalRefundId"/>
            <result column="oi_distribution_user_id" property="distributionUserId"/>
            <result column="oi_stock_point_id" property="stockPointId"/>
            <result column="oi_count" property="count"/>
            <result column="oi_spu_code" property="spuCode"/>
            <result column="oi_party_code" property="partyCode"/>
            <result column="oi_pic" property="pic"/>
            <result column="oi_is_comm" property="isComm"/>
            <result column="oi_refund_status" property="refundStatus"/>
            <result column="oi_be_delivered_num" property="beDeliveredNum"/>
            <result column="oi_delivery_type" property="deliveryType"/>
            <result column="oi_shop_cart_time" property="shopCartTime"/>
            <result column="oi_price" property="price"/>
            <result column="oi_spu_mold" property="spuMold"/>
            <result column="oi_spu_total_amount" property="spuTotalAmount"/>
            <result column="oi_actual_total" property="actualTotal"/>
            <result column="oi_share_reduce" property="shareReduce"/>
            <result column="oi_platform_share_reduce" property="platformShareReduce"/>
            <result column="oi_distribution_amount" property="distributionAmount"/>
            <result column="oi_distribution_parent_amount" property="distributionParentAmount"/>
            <result column="oi_use_score" property="useScore"/>
            <result column="oi_gain_score" property="gainScore"/>
            <result column="oi_rate" property="rate"/>
            <result column="oi_score_fee" property="scoreFee"/>
            <result column="oi_comm_time" property="commTime"/>
            <result column="oi_score_amount" property="scoreAmount"/>
            <result column="oi_member_amount" property="memberAmount"/>
            <result column="oi_platform_coupon_amount" property="platformCouponAmount"/>
            <result column="oi_platform_free_freight_amount" property="platformFreeFreightAmount"/>
            <result column="oi_shop_coupon_amount" property="shopCouponAmount"/>
            <result column="oi_discount_amount" property="discountAmount"/>
            <result column="oi_shop_change_free_amount" property="shopChangeFreeAmount"/>
            <result column="oi_free_freight_amount" property="freeFreightAmount"/>
            <result column="oi_giveaway_amount" property="giveawayAmount"/>
            <result column="oi_activity_id" property="activityId"/>
            <result column="oi_supplier_pic" property="supplierPic"/>
            <result column="oi_activity_type" property="activityType"/>
            <result column="oi_purchase_platform_commission" property="purchasePlatformCommission"/>
            <result column="oi_platform_commission" property="platformCommission"/>
            <result column="oi_item_purchase_amount" property="itemPurchaseAmount"/>
            <result column="oi_supplier_rate" property="supplierRate"/>
            <result column="oi_supplier_spu_id" property="supplierSpuId"/>
            <result column="oi_is_refund" property="isRefund"/>
            <result column="oi_virtual_remark" property="virtualRemark"/>
            <result column="oi_write_off_num" property="writeOffNum"/>
            <result column="oi_write_off_start" property="writeOffStart"/>
            <result column="oi_write_off_end" property="writeOffEnd"/>
            <collection property="orderItemLangList" ofType="com.tmerclub.cloud.common.order.vo.OrderItemLangVO">
                <id column="oi_lang" property="lang"/>
                <result column="oi_spu_name" property="spuName"/>
                <result column="oi_sku_name" property="skuName"/>
                <result column="oi_supplier_spu_name" property="supplierSpuName"/>
                <result column="oi_supplier_sku_name" property="supplierSkuName"/>
            </collection>
        </collection>
    </resultMap>

    <resultMap id="esOrderVO" type="com.tmerclub.cloud.common.order.vo.EsOrderVO">
        <id column="order_id" property="orderId"/>
        <result column="actual_total" property="actualTotal"/>
        <result column="order_score" property="orderScore"/>
        <result column="status" property="status"/>
        <result column="order_type" property="orderType"/>
        <result column="refund_status" property="refundStatus"/>
        <result column="delivery_type" property="deliveryType"/>
        <result column="shop_name" property="shopName"/>
        <result column="shop_id" property="shopId"/>
        <result column="freight_amount" property="freightAmount"/>
        <result column="create_time" property="createTime"/>
        <result column="all_count" property="allCount"/>
        <result column="user_id" property="userId"/>
        <result column="order_invoice_id" property="orderInvoiceId"/>
        <result column="remarks" property="remarks"/>
        <result column="pre_sale_type" property="preSaleType"/>
        <result column="order_mold" property="orderMold"/>
        <result column="pre_sale_delivery_time" property="preSaleDeliveryTime"/>
        <result column="free_freight_amount" property="freeFreightAmount"/>
        <result column="platform_free_freight_amount" property="platformFreeFreightAmount"/>
        <result column="distribution_amount" property="distributionAmount"/>
        <result column="platform_commission" property="platformCommission"/>
        <result column="order_addr_id" property="orderAddrId"/>
        <result column="total" property="total"/>
        <result column="shop_remarks" property="shopRemarks"/>
        <result column="pay_type" property="payType"/>
        <result column="close_type" property="closeType"/>
        <result column="pay_time" property="payTime"/>
        <result column="delivery_time" property="deliveryTime"/>
        <result column="finally_time" property="finallyTime"/>
        <result column="cancel_time" property="cancelTime"/>
        <result column="book_time" property="bookTime"/>
        <result column="is_payed" property="isPayed"/>
        <result column="delete_status" property="deleteStatus"/>
        <result column="score_amount" property="scoreAmount"/>
        <result column="member_amount" property="memberAmount"/>
        <result column="platform_coupon_amount" property="platformCouponAmount"/>
        <result column="shop_coupon_amount" property="shopCouponAmount"/>
        <result column="discount_amount" property="discountAmount"/>
        <result column="platform_amount" property="platformAmount"/>
        <result column="reduce_amount" property="reduceAmount"/>
        <result column="supplier_delivery_type" property="updateOrViewDeliveryInfo"/>
        <result column="delivery_count" property="deliveryCount"/>
        <result column="wait_purchase" property="waitPurchase"/>
        <result column="purchase_spread_amount" property="purchaseSpreadAmount"/>
        <result column="supplier_id" property="supplierMobile"/>
        <result column="oi_spu_code" property="spuCodes"/>
        <result column="oi_party_code" property="partyCodes"/>
        <result column="balance_start_time" property="balanceStartTime"/>
        <result column="balance_end_time" property="balanceEndTime"/>
        <result column="deposit_amount" property="depositAmount"/>
        <result column="balance_amount" property="balanceAmount"/>
        <result column="pre_sale_delivery_type" property="preSaleDeliveryType"/>
        <collection property="orderItems" ofType="com.tmerclub.cloud.common.order.vo.EsOrderItemVO">
            <id column="oi_order_item_id" jdbcType="BIGINT" property="orderItemId"/>
            <result column="oi_shop_id" property="shopId"/>
            <result column="oi_spu_id" property="spuId"/>
            <result column="oi_sku_id" property="skuId"/>
            <result column="oi_user_id" property="userId"/>
            <result column="oi_final_refund_id" property="finalRefundId"/>
            <result column="oi_distribution_user_id" property="distributionUserId"/>
            <result column="oi_count" property="count"/>
            <result column="oi_pic" property="pic"/>
            <result column="oi_is_comm" property="isComm"/>
            <result column="oi_refund_status" property="refundStatus"/>
            <result column="oi_be_delivered_num" property="beDeliveredNum"/>
            <result column="oi_delivery_type" property="deliveryType"/>
            <result column="oi_shop_cart_time" property="shopCartTime"/>
            <result column="oi_price" property="price"/>
            <result column="oi_spu_total_amount" property="spuTotalAmount"/>
            <result column="oi_actual_total" property="actualTotal"/>
            <result column="oi_share_reduce" property="shareReduce"/>
            <result column="oi_platform_share_reduce" property="platformShareReduce"/>
            <result column="oi_distribution_amount" property="distributionAmount"/>
            <result column="oi_distribution_parent_amount" property="distributionParentAmount"/>
            <result column="oi_use_score" property="useScore"/>
            <result column="oi_gain_score" property="gainScore"/>
            <result column="oi_score_fee" property="scoreFee"/>
            <result column="oi_comm_time" property="commTime"/>
            <result column="oi_activity_id" property="activityId"/>
            <result column="oi_supplier_pic" property="supplierPic"/>
            <result column="oi_activity_type" property="activityType"/>
            <result column="oi_purchase_platform_commission" property="purchasePlatformCommission"/>
            <collection property="orderItemLangList" ofType="com.tmerclub.cloud.common.order.vo.OrderItemLangVO">
                <id column="oi_lang" property="lang"/>
                <result column="oi_spu_name" property="spuName"/>
                <result column="oi_sku_name" property="skuName"/>
                <result column="oi_supplier_spu_name" property="supplierSpuName"/>
                <result column="oi_supplier_sku_name" property="supplierSkuName"/>
            </collection>
        </collection>
    </resultMap>
    <resultMap id="orderExcelVO" type="com.tmerclub.cloud.common.order.vo.OrderExcelVO">
        <result column="order_id" property="orderId"/>
        <result column="create_time" property="createTime"/>
        <result column="delivery_type" property="deliveryType"/>
        <result column="consignee" property="consignee"/>
        <result column="mobile" property="mobile"/>
        <result column="receiving_addr" property="receivingAddr"/>
        <result column="total" property="total"/>
        <result column="freight_amount" property="freightAmount"/>
        <result column="reduce_amount" property="reduceAmount"/>
        <result column="order_score" property="orderScore"/>
        <result column="actual_total" property="actualTotal"/>
        <result column="pay_type" property="payType"/>
        <result column="status" property="status"/>
        <result column="refund_status" property="refundStatus"/>
        <result column="spu_name" property="spuName"/>
        <result column="sku_name" property="skuName"/>
        <result column="price" property="price"/>
        <result column="count" property="count"/>
        <result column="order_mold" property="orderMold"/>
        <result column="spu_total_amount" property="spuTotalAmount"/>
        <result column="share_reduce" property="shareReduce"/>
        <result column="actual_total_item" property="actualTotalItem"/>
        <result column="use_score" property="useScore"/>
        <result column="refund_status_item" property="refundStatusItem"/>
        <collection property="orderItemLangList" ofType="com.tmerclub.cloud.common.order.vo.OrderItemLangVO">
            <id column="lang" property="lang"/>
            <result column="spu_name" property="spuName"/>
            <result column="sku_name" property="skuName"/>
        </collection>
    </resultMap>
    <resultMap id="unDeliveryOrderExcelVO" type="com.tmerclub.cloud.order.vo.UnDeliveryOrderExcelVO">
        <result column="order_id" property="orderId"/>
        <result column="delivery_type" property="deliveryType"/>
        <result column="consignee" property="consignee"/>
        <result column="mobile" property="mobile"/>
        <result column="receiving_addr" property="receivingAddr"/>
        <collection property="orderItemList" javaType="list" ofType="com.tmerclub.cloud.common.order.vo.OrderItemVO">
            <result column="order_item_id" property="orderItemId"/>
            <result column="spu_name" jdbcType="VARCHAR" property="spuName"/>
            <result column="sku_name" jdbcType="VARCHAR" property="skuName"/>
            <result column="be_delivered_num" property="changeNum"/>
            <result column="activity_type" property="activityType"/>
            <result column="activity_id" property="activityId"/>
        </collection>
    </resultMap>
    <resultMap id="orderActivityMap" type="com.tmerclub.cloud.common.order.vo.OrderActivityVO">
        <result column="order_id" property="orderId"/>
        <result column="user_id" property="userId"/>
        <result column="is_payed" property="isPayed"/>
        <collection property="orderItems" ofType="com.tmerclub.cloud.common.order.vo.OrderItemVO">
            <id column="order_item_id" property="orderItemId"/>
            <result column="spu_id" property="spuId"/>
            <result column="sku_id" property="skuId"/>
            <result column="count" property="count"/>
            <result column="activity_id" property="activityId"/>
            <result column="activity_type" property="activityType"/>
        </collection>
    </resultMap>

    <sql id="Vo_Column_List">
        `order_id`,
        `create_time`,
        `update_time`,
        `shop_id`,
        `user_id`,
        `order_addr_id`,
        `delivery_type`,
        `shop_name`,
        `total`,
        `actual_total`,
        `freight_amount`,
        `order_score`,
        `status`,
        `pay_type`,
        `order_type`,
        `all_count`,
        `reduce_amount`,
        `score_amount`,
        `member_amount`,
        `platform_coupon_amount`,
        `shop_coupon_amount`,
        `discount_amount`,
        `platform_free_freight_amount`,
        `free_freight_amount`,
        `shop_change_free_amount`,
        `distribution_amount`,
        `platform_amount`,
        `platform_commission`,
        `pay_time`,
        `delivery_time`,
        `finally_time`,
        `settled_time`,
        `cancel_time`,
        `book_time`,
        `is_payed`,
        `close_type`,
        `refund_status`,
        `shop_remarks`,
        `remarks`,
        `delete_status`,
        `version`,
        `is_settled`,
        `supplier_id`,
        `wait_purchase`,
        `supplier_delivery_type`,
        `purchase_spread_amount`,
        `pre_sale_type`,
        `order_mold`,
        `order_mold`,
        `write_off_status`,
        `write_off_num`,
        `write_off_multiple_count`,
        `write_off_start`,
        `write_off_end`,
        `pay_sys_type`,
        `write_off_count`
    </sql>
    <sql id="Join_Column_List">
        o.`order_id`,
        o.`create_time`,
        o.`update_time`,
        o.`shop_id`,
        o.`user_id`,
        o.`order_addr_id`,
        o.`delivery_type`,
        o.`shop_name`,
        o.`total`,
        o.`actual_total`,
        o.`freight_amount`,
        o.`order_score`,
        o.`status`,
        o.`pay_type`,
        o.`order_type`,
        o.`all_count`,
        o.`reduce_amount`,
        o.`score_amount`,
        o.`member_amount`,
        o.`platform_coupon_amount`,
        o.`shop_coupon_amount`,
        o.`discount_amount`,
        o.`platform_free_freight_amount`,
        o.`free_freight_amount`,
        o.`shop_change_free_amount`,
        o.`distribution_amount`,
        o.`platform_amount`,
        o.`platform_commission`,
        o.`pay_time`,
        o.`delivery_time`,
        o.`finally_time`,
        o.`settled_time`,
        o.`cancel_time`,
        o.`book_time`,
        o.`is_payed`,
        o.`close_type`,
        o.`refund_status`,
        o.`shop_remarks`,
        o.`remarks`,
        o.`delete_status`,
        o.`version`,
        o.`is_settled`,
        o.`supplier_id`,
        o.`wait_purchase`,
        o.`supplier_delivery_type`,
        o.`purchase_spread_amount`,
        o.`pre_sale_type`,
        o.`order_mold`,
        o.`pay_sys_type`,
        o.`write_off_status`,
        o.`write_off_num`,
        o.`write_off_multiple_count`,
        o.`write_off_start`,
        o.`write_off_end`,
        o.`shop_combo_amount`,
        o.`write_off_count`,
        o.`main_order_id`
    </sql>

    <sql id="Join_Order_item_Column_List">
        oi.order_item_id oi_order_item_id,
        oi.create_time oi_create_time,
        oi.update_time oi_update_time,
        oi.shop_id oi_shop_id,
        oi.order_id oi_order_id,
        oi.category_id oi_category_id,
        oi.spu_id oi_spu_id,
        oi.sku_id oi_sku_id,
        oi.supplier_spu_id oi_supplier_spu_id,
        oi.supplier_sku_id oi_supplier_sku_id,
        oi.final_refund_id oi_final_refund_id,
        oi.distribution_user_id oi_distribution_user_id,
        oi.user_id oi_user_id,
        oi.stock_point_id oi_stock_point_id,
        oi.score_fee oi_score_fee,
        oi.shop_change_free_amount oi_shop_change_free_amount,
        oi.final_refund_id oi_final_refund_id,
        oi.distribution_user_id oi_distribution_user_id,
        oi.count oi_count,
        oi.pic oi_pic,
        oi.is_comm oi_is_comm,
        oi.comm_time oi_comm_time,
        oi.free_freight_amount oi_free_freight_amount,
        oi.comm_time oi_comm_time,
        oi.refund_status oi_refund_status,
        oi.be_delivered_num oi_be_delivered_num,
        oi.delivery_type oi_delivery_type,
        oi.shop_cart_time oi_shop_cart_time,
        oi.price oi_price,
        oi.spu_mold oi_spu_mold,
        oi.rate oi_rate,
        oi.spu_total_amount oi_spu_total_amount,
        oi.actual_total oi_actual_total,
        oi.share_reduce oi_share_reduce,
        oi.platform_share_reduce oi_platform_share_reduce,
        oi.distribution_amount oi_distribution_amount,
        oi.distribution_parent_amount oi_distribution_parent_amount,
        oi.score_fee oi_score_fee,
        oi.use_score oi_use_score,
        oi.gain_score oi_gain_score,
        oi.spu_code oi_spu_code,
        oi.party_code oi_party_code,
        oi.supplier_pic oi_supplier_pic,
        oi.platform_commission oi_platform_commission,
        oi.score_amount oi_score_amount,
        oi.member_amount oi_member_amount,
        oi.platform_coupon_amount oi_platform_coupon_amount,
        oi.shop_coupon_amount oi_shop_coupon_amount,
        oi.discount_amount oi_discount_amount,
        oi.platform_free_freight_amount oi_platform_free_freight_amount,
        oi.free_freight_amount oi_free_freight_amount,
        oi.shop_change_free_amount oi_shop_change_free_amount,
        oi.spu_code oi_spu_code,
        oi.party_code oi_party_code,
        oi.activity_id oi_activity_id,
        oi.activity_type oi_activity_type,
<!--        oi.giveaway_amount oi_giveaway_amount,-->
<!--        oi.main_giveaway oi_main_giveaway,-->
        oi.activity_type oi_activity_type,
        oi.activity_id oi_activity_id,
        oi.item_purchase_amount oi_item_purchase_amount,
        oi.purchase_platform_commission as oi_purchase_platform_commission,
        oi.supplier_rate as oi_supplier_rate,
        oi.stock_point_id as oi_stock_point_id,
        oi.is_refund oi_is_refund,
        oi.virtual_remark oi_virtual_remark,
        oi.write_off_num as oi_write_off_num,
        oi.write_off_multiple_count as oi_write_off_multiple_count,
        oi.write_off_start as oi_write_off_start,
        oi.write_off_end as oi_write_off_end
    </sql>

    <select id="getByOrderId" resultType="com.tmerclub.cloud.order.model.Order">
        select
        <include refid="Vo_Column_List"/>
        from `order`
        where order_id = #{orderId}
    </select>
    <update id="update">
        update `order`
        <set>
            <if test="order.shopName != null">
                `shop_name` = #{order.shopName},
            </if>
            <if test="order.orderAddrId != null">
                `order_addr_id` = #{order.orderAddrId},
            </if>
            <if test="order.total != null">
                `total` = #{order.total},
            </if>
            <if test="order.actualTotal != null">
                `actual_total` = #{order.actualTotal},
            </if>
            <if test="order.remarks != null">
                `remarks` = #{order.remarks},
            </if>
            <if test="order.shopRemarks != null">
                `shop_remarks` = #{order.shopRemarks},
            </if>
            <if test="order.status != null">
                `status` = #{order.status},
            </if>
            <if test="order.payType != null">
                `pay_type` = #{order.payType},
            </if>
            <if test="order.deliveryType != null">
                `delivery_type` = #{order.deliveryType},
            </if>
            <if test="order.orderType != null">
                `order_type` = #{order.orderType},
            </if>
            <if test="order.closeType != null">
                `close_type` = #{order.closeType},
            </if>
            <if test="order.allCount != null">
                `all_count` = #{order.allCount},
            </if>
            <if test="order.payTime != null">
                `pay_time` = #{order.payTime},
            </if>
            <if test="order.deliveryTime != null">
                `delivery_time` = #{order.deliveryTime},
            </if>
            <if test="order.finallyTime != null">
                `finally_time` = #{order.finallyTime},
            </if>
            <if test="order.cancelTime != null">
                `cancel_time` = #{order.cancelTime},
            </if>
            <if test="order.bookTime != null">
                `book_time` = #{order.bookTime},
            </if>
            <if test="order.isPayed != null">
                `is_payed` = #{order.isPayed},
            </if>
            <if test="order.deleteStatus != null">
                `delete_status` = #{order.deleteStatus},
            </if>
            <if test="order.refundStatus != null">
                `refund_status` = #{order.refundStatus},
            </if>
            <if test="order.freightAmount != null">
                `freight_amount` = #{order.freightAmount},
            </if>
            <if test="order.scoreAmount != null">
                `score_amount` = #{order.scoreAmount},
            </if>
            <if test="order.memberAmount != null">
                `member_amount` = #{order.memberAmount},
            </if>
            <if test="order.platformCouponAmount != null">
                `platform_coupon_amount` = #{order.platformCouponAmount},
            </if>
            <if test="order.shopCouponAmount != null">
                `shop_coupon_amount` = #{order.shopCouponAmount},
            </if>
            <if test="order.discountAmount != null">
                `discount_amount` = #{order.discountAmount},
            </if>
            <if test="order.platformAmount != null">
                `platform_amount` = #{order.platformAmount},
            </if>
            <if test="order.reduceAmount != null">
                `reduce_amount` = #{order.reduceAmount},
            </if>
            <if test="order.shopChangeFreeAmount != null">
                `shop_change_free_amount` = #{order.shopChangeFreeAmount},
            </if>
            <if test="order.freeFreightAmount != null">
                `free_freight_amount` = #{order.freeFreightAmount},
            </if>
            <if test="order.platformCommission != null">
                `platform_commission` = #{order.platformCommission},
            </if>
            <if test="order.updateTime != null">
                `update_time` = #{order.updateTime},
            </if>
            <if test="order.waitPurchase != null">
                `wait_purchase` = #{order.waitPurchase},
            </if>
            <if test="order.writeOffNum != null">
                `write_off_num` = #{order.writeOffNum},
            </if>
            <if test="order.writeOffStatus != null">
                `write_off_status` = #{order.writeOffStatus},
            </if>
            <if test="order.writeOffMultipleCount != null">
                `write_off_multiple_count` = #{order.writeOffMultipleCount},
            </if>
            <if test="order.writeOffStart != null">
                `write_off_start` = #{order.writeOffStart},
            </if>
            <if test="order.writeOffEnd != null">
                `write_off_end` = #{order.writeOffEnd},
            </if>
            <if test="order.purchaseSpreadAmount != null">
                `purchase_spread_amount` = #{order.purchaseSpreadAmount},
            </if>
            <if test="order.writeOffCount != null">
                `write_off_count` = #{order.writeOffCount},
            </if>
            <if test="order.mainOrderId != null">
                `main_order_id` = #{order.mainOrderId},
            </if>
            update_time = now()
        </set>
        where order_id = #{order.orderId}
    </update>
    <delete id="deleteById">
        delete
        from `order`
        where order_id = #{orderId}
    </delete>
    <insert id="saveBatch">
        insert into `order` (`order_id`, `shop_id`,`shop_name`, `user_id`, `order_addr_id`, `total`, `actual_total`,
        `remarks`,
        `shop_remarks`, `status`, `pay_type`, `delivery_type`, `order_type`, `close_type`,
        `all_count`, `pay_time`, `delivery_time`, `finally_time`, `cancel_time`, `book_time`,
        `is_payed`, `delete_status`, `refund_status`, `freight_amount`, `order_score`,
        `score_amount`,`distribution_amount`,
        `member_amount`, `platform_coupon_amount`, `shop_coupon_amount`, `discount_amount`,
        `platform_amount`, `reduce_amount`,`free_freight_amount`,
        `platform_free_freight_amount`,`shop_change_free_amount`, `platform_commission`, `is_settled`,
        `supplier_delivery_type`, `supplier_id`,`order_mold`, `pre_sale_type`,`shop_combo_amount`,
        `write_off_num`,`write_off_status`,`write_off_multiple_count`,`write_off_start`,`write_off_end`,`write_off_count`,`main_order_id`,`create_time`)
        values
        <foreach collection="orders" item="order" separator=",">
            (#{order.orderId}, #{order.shopId},#{order.shopName}, #{order.userId}, #{order.orderAddrId}, #{order.total},
            #{order.actualTotal}, #{order.remarks}, #{order.shopRemarks}, #{order.status},
            #{order.payType}, #{order.deliveryType}, #{order.orderType}, #{order.closeType},
            #{order.allCount}, #{order.payTime}, #{order.deliveryTime}, #{order.finallyTime},
            #{order.cancelTime}, #{order.bookTime}, #{order.isPayed}, #{order.deleteStatus},
            #{order.refundStatus}, #{order.freightAmount}, #{order.orderScore}, #{order.scoreAmount},
            #{order.distributionAmount}, #{order.memberAmount},
            #{order.platformCouponAmount}, #{order.shopCouponAmount}, #{order.discountAmount},
            #{order.platformAmount}, #{order.reduceAmount}, #{order.freeFreightAmount},
            #{order.platformFreeFreightAmount}, #{order.shopChangeFreeAmount}, #{order.platformCommission},
            #{order.isSettled}, #{order.supplierDeliveryType},#{order.supplierId},#{order.orderMold},#{order.preSaleType},#{order.shopComboAmount},
            #{order.writeOffNum}, #{order.writeOffStatus},#{order.writeOffMultipleCount},#{order.writeOffStart},#{order.writeOffEnd},#{order.writeOffCount},#{order.mainOrderId},
            #{order.createTime})
        </foreach>
    </insert>
    <insert id="saveCueOrder">
        insert into `order` (
            `order_id`,
            `create_time`,
            `shop_id`,
            `user_id`,
            `delivery_type`,
            `total`,
            `actual_total`,
            `status`,
            `all_count`,
            `order_type`
        ) values (
            #{orderId},
            #{createTime},
            #{shopId},
            #{userId},
            #{deliveryType},
            #{total},
            #{actualTotal},
            #{status},
            #{allCount},
            #{orderType}
        )
    </insert>
    <select id="getOrdersStatus" resultType="com.tmerclub.cloud.common.order.bo.OrderStatusBO">
        SELECT o.`status`, o.`order_id`, o.`order_type`,o.`shop_id`,o.actual_total,o.order_mold,o.user_id,o.supplier_id,o.freight_amount,o.platform_free_freight_amount,
        o.pre_sale_type,o.delivery_type,op.`balance_amount`,op.`deposit_amount`,op.`balance_end_time`
        FROM `order` o
        LEFT JOIN `order_pre_sale_info` op ON o.`order_id` = op.`order_id`
        WHERE o.order_id IN
        <foreach collection="orderIds" open="(" item="orderId" close=")" separator=",">
            #{orderId}
        </foreach>
    </select>

    <select id="listOrderActualAmount" resultType="com.tmerclub.cloud.order.vo.OrderAndPreSaleVO">
        SELECT o.actual_total,o.freight_amount,o.platform_free_freight_amount,IFNULL(ps.deposit_amount,0) as deposit_amount,IFNULL(ps.deposit_amount,0) as deposit_amount,
        IFNULL(ps.balance_amount,0) as balance_amount,o.order_type,o.pre_sale_type,o.status,o.shop_id,
        o.order_score AS orderScore
        FROM `order` o
        LEFT JOIN order_pre_sale_info ps ON ps.order_id = o.order_id
        WHERE
        <foreach collection="orderIds" open="(" item="orderId" close=")" separator="OR">
            o.order_id = #{orderId}
        </foreach>
    </select>

    <update id="updateByToPaySuccess">
        update `order` set
        <if test="orderStatus.deliveryType == 3">
            `status` = 3,delivery_time=NOW(),
        </if>
        <if test="orderStatus.deliveryType != 3">
            `status` = 2,
        </if>
        <if test="paySysType != null">
            pay_sys_type=#{paySysType},
        </if>
        <if test="payType != null">
            pay_type =#{payType},
        </if>
        is_payed =1,update_time=NOW(),pay_time=NOW()
        where order_id = #{orderStatus.orderId}
    </update>

    <update id="updateByToGroupPaySuccess">
        update `order` set `status` = 7,is_payed =1,update_time=NOW(),pay_time=NOW(),pay_sys_type=#{paySysType},pay_type =#{payType} where
        <foreach collection="orderIds" item="orderId" separator="OR" open="(" close=")">
            order_id = #{orderId}
        </foreach>
    </update>

    <update id="updateByToPreSaleSuccess">
        update `order` set
        <if test="status == 1">
            `status` = 9
        </if>
        <if test="status == 9">
            `status` = 2
        </if>
        where order_id  in
        <foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
             #{orderId}
        </foreach>
    </update>

    <update id="updateByToStatinoSuccess">
        update `order` set `status` = 3,delivery_time =NOW(),update_time=NOW() where order_id in
        <foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
            #{orderId}
        </foreach>
    </update>


    <select id="getOrdersSimpleAmountInfo" resultType="com.tmerclub.cloud.common.order.vo.OrderSimpleAmountInfoBO">
        select o.`shop_id`, o.`order_id`,o.wait_purchase,o.reduce_amount,o.actual_total, o.platform_amount,o.`status`,o.close_type,
        o.supplier_id,o.supplier_delivery_type,o.purchase_spread_amount,o.freight_amount,o.free_freight_amount,
        ifnull(SUM(oi.purchase_platform_commission),0) as purchase_platform_commission,ifnull(SUM(oi.item_purchase_amount),0) as purchase_amount,
        ifnull(SUM(oi.platform_commission),0) as platform_commission, o.pay_sys_type
        from `order` o
        LEFT JOIN `order_item` oi ON oi.`order_id` = o.`order_id`
        where
        <foreach collection="orderIds" open="(" item="orderId" close=")" separator="OR">
            o.order_id = #{orderId}
        </foreach>
        GROUP BY o.order_id
    </select>

    <update id="cancelOrders">
        update `order` set `status`=6,cancel_time = NOW(),update_time=NOW() where is_payed = 0 and
        <foreach collection="orderIds" item="orderId" open="(" close=")" separator="OR">
            order_id = #{orderId}
        </foreach>
    </update>

    <select id="getOrderByOrderIdAndUserId" resultMap="orderMap">
        select <include refid="Join_Column_List" />, oi.order_invoice_id
        from `order` o
        left join `order_invoice` oi on o.order_id = oi.order_id
        where o.order_id = #{orderId} and o.user_id = #{userId}
    </select>

    <select id="getOrderByOrderIdAndStationId" resultMap="orderMap">
        select distinct(oi.order_invoice_id),<include refid="Join_Column_List" />
        from `order` o
        left join `order_invoice` oi on o.order_id = oi.order_id
        left join `order_self_station` oss on o.order_id = oss.order_id
        left join `order_virtual_info` ovi ON ovi.order_id = o.order_id
        where o.order_id = #{orderId} and (oss.station_id = #{stationId} or ovi.station_id = #{stationId})
    </select>

    <update id="receiptOrder">
        update `order`
        set `status`=5,
            finally_time = NOW(),
            update_time=NOW()
        where order_id = #{orderId}
          and `status` = 3
          and (refund_status <![CDATA[<>]]> 1 OR refund_status IS NULL)
    </update>

    <update id="deleteOrder">
        UPDATE `order`
        SET `delete_status`=2
        where order_id = #{orderId}
    </update>

    <select id="getOrderByOrderIdAndShopId" resultMap="orderMap">
        select <include refid="Join_Column_List" />
        from `order` o
        where o.order_id = #{orderId}
          and (o.shop_id = #{shopId} or o.supplier_id = #{shopId})
    </select>

    <select id="getOrderAndOrderItemData" resultMap="orderAndOrderItem">
        SELECT <include refid="Join_Column_List" />,
        oi.`order_item_id` oi_order_item_id ,
        oi.`shop_id` oi_shop_id,
        oi.`order_id` oi_order_id,
        oi.`spu_id` oi_spu_id,
        oi.`sku_id` oi_sku_id,
        oi.`category_id` oi_category_id,
        oi.`user_id` oi_user_id,
        oi.`final_refund_id` oi_final_refund_id,
        oi.`distribution_user_id` oi_distribution_user_id,
        oi.`count` oi_count,
        oi.`pic` oi_pic,
        oi.`is_comm` oi_is_comm,
        oi.`refund_status` oi_refund_status,
        oi.`be_delivered_num` oi_be_delivered_num,
        oi.`delivery_type` oi_delivery_type,
        oi.`shop_cart_time` oi_shop_cart_time,
        oi.`price` oi_price,
        oi.`spu_total_amount` oi_spu_total_amount,
        oi.`actual_total` oi_actual_total,
        oi.`share_reduce` oi_share_reduce,
        oi.`platform_share_reduce` oi_platform_share_reduce,
        oi.`distribution_amount` oi_distribution_amount,
        oi.`distribution_parent_amount` oi_distribution_parent_amount,
        oi.`use_score` oi_use_score,
        oi.`gain_score` oi_gain_score,
        oi.`shop_change_free_amount` oi_shop_change_free_amount,
        oi.`item_purchase_amount` oi_item_purchase_amount,
        oi.`purchase_platform_commission` oi_purchase_platform_commission,
        oi.`supplier_rate` oi_supplier_rate,
        oi.`party_code` oi_party_code,
        oi.`virtual_remark` oi_virtual_remark,
        oi.`spu_mold` oi_spu_mold,
        oi.giveaway_amount oi_giveaway_amount,
        oi.activity_id oi_activity_id,
        oi.activity_type oi_activity_type,
        oi.`combo_amount` oi_combo_amount,
        oi.`supplier_pic` oi_supplier_pic,
        oi.`main_giveaway` oi_main_giveaway,
        oil.`lang` oi_lang,
        oil.`spu_name` oi_spu_name,
        oil.`sku_name` oi_sku_name,
        oil.`supplier_spu_name` oi_supplier_spu_name,
        oil.`supplier_sku_name` oi_supplier_sku_name
        from `order` o
        join order_item oi on o.order_id = oi.order_id
        left join order_item_lang oil on oi.order_item_id = oil.order_item_id
        where o.order_id = #{orderId}
        <if test="shopId != null">
            and o.shop_id = #{shopId}
        </if>
    </select>

    <select id="getSubmitOrderPayAmountInfo" resultType="com.tmerclub.cloud.order.bo.SubmitOrderPayAmountInfoBO">
        SELECT order_addr_id, SUM(o.actual_total) AS totalFee,SUM(o.score_amount) AS totalScore,SUM(o.order_score) AS orderScore,SUM(o.freight_amount) AS freight_amount, sum(o.platform_free_freight_amount) as platform_free_freight_amount,
        MAX(`o`.create_time) AS createTime,MAX(o.order_type) AS order_type,MAX(o.pre_sale_type) AS pre_sale_type,MAX(o.order_type) AS order_type,
        IFNULL(os.deposit_amount,0) AS deposit_amount,IFNULL(os.balance_amount,0) AS balance_amount,os.pay_status AS pre_sale_pay_status,
        os.balance_start_time,os.balance_end_time,o.user_id
        FROM `order` o
        LEFT JOIN order_pre_sale_info os ON os.order_id = o.order_id
        WHERE
        <foreach collection="orderIdList" item="orderId" separator="OR" close=")" open="(">
            o.order_id = #{orderId}
        </foreach>
    </select>

    <select id="getEsOrder" resultMap="esOrderAndOrderItemAndUserAddrMap">
        SELECT o.user_id,
               o.*,
               oi.`order_item_id`              oi_order_item_id,
               oi.`shop_id`                    oi_shop_id,
               oi.`order_id`                   oi_order_id,
               oi.`spu_id`                     oi_spu_id,
               oi.`sku_id`                     oi_sku_id,
               oi.`user_id`                    oi_user_id,
               oi.`final_refund_id`            oi_final_refund_id,
               oi.`distribution_user_id`       oi_distribution_user_id,
               oi.`count`                      oi_count,
               oi.`spu_name`                   oi_spu_name,
               oi.`sku_name`                   oi_sku_name,
               oi.`pic`                        oi_pic,
               oi.`is_comm`                    oi_is_comm,
               oi.`refund_status`              oi_refund_status,
               oi.`be_delivered_num`           oi_be_delivered_num,
               oi.`delivery_type`              oi_delivery_type,
               oi.`shop_cart_time`             oi_shop_cart_time,
               oi.`price`                      oi_price,
               oi.`spu_total_amount`           oi_spu_total_amount,
               oi.`actual_total`               oi_actual_total,
               oi.`share_reduce`               oi_share_reduce,
               oi.`platform_share_reduce`      oi_platform_share_reduce,
               oi.`distribution_amount`        oi_distribution_amount,
               oi.`distribution_parent_amount` oi_distribution_parent_amount,
               oi.`use_score`                  oi_use_score,
               oi.`gain_score`                 oi_gain_score,
               oa.consignee,
               oa.mobile
        FROM `order` AS o
                 JOIN order_item oi ON o.order_id = oi.order_id
                 left JOIN order_addr oa on o.order_addr_id = oa.order_addr_id
        where o.order_id = #{orderId}
    </select>

    <select id="countNumberOfStatus" resultType="com.tmerclub.cloud.common.order.vo.OrderCountVO">
        SELECT COUNT(o.order_id)                                                  as all_count,
               COUNT(CASE WHEN o.status = 1 or o.status = 9 THEN o.order_id ELSE NULL END)        AS unPay,
               COUNT(CASE WHEN o.status = 2 THEN o.order_id ELSE NULL END)        AS payed,
               COUNT(CASE WHEN o.status = 3 THEN o.order_id ELSE NULL END)        AS consignment,
               COUNT(CASE WHEN o.status = 5 THEN o.order_id ELSE NULL END)        AS success,
               COUNT(CASE WHEN o.status = 7 THEN o.order_id ELSE NULL END)        AS `grouping`,
               COUNT(CASE WHEN o.status = 9 THEN o.order_id ELSE NULL END)        AS pre_sale,
               COUNT(CASE WHEN o.refund_status = 1 THEN o.order_id ELSE NULL END) AS refund
        FROM `order` o
        WHERE o.user_id = #{userId}
          AND o.delete_status = 0
    </select>

    <select id="countByOrderId" resultType="int">
        select count(*)
        from `order`
        where order_id = #{orderId}
    </select>

    <update id="updateGroupOrderSuccessStatus">
        update `order` set
        <if test="orderMold == 1">
            status = 3
        </if>
        <if test="orderMold != 1">
            status = 2
        </if>
        where order_id in
        <foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
            #{orderId}
        </foreach>
        and status = 7
    </update>

    <update id="settledOrder">
        update `order` set is_settled = 1,settled_time = NOW() where
        <foreach collection="orderIds" item="orderId" open="(" close=")" separator="OR">
            order_id = #{orderId}
        </foreach>
    </update>

    <select id="countNormalOrderByOrderIds" resultType="java.lang.Integer">
        SELECT ifnull(sum(all_count),0) FROM `order`
        WHERE `status` <![CDATA[<>]]> 6 AND order_id IN
        <foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
            #{orderId}
        </foreach>
    </select>
    <update id="updateOrderTime">
        update `order`
        set update_time = NOW()
        where order_id = #{orderId}
    </update>

    <select id="getEsOrderInfo"  resultMap="esOrderVo">
        SELECT <include refid="Join_Column_List" />,
        oa.consignee,oa.mobile,oa.province_id,oa.province,oa.city_id,oa.city,
        oa.area_id,oa.area,oa.addr,oa.post_code,oiv.order_invoice_id,
        oi.order_item_id oi_order_item_id,oi.create_time oi_create_time,oi.update_time oi_update_time,
        oi.shop_id oi_shop_id,oi.order_id oi_order_id,oi.category_id oi_category_id,oi.spu_id oi_spu_id,oi.sku_id
        oi_sku_id,oi.user_id oi_user_id,oi.score_fee oi_score_fee,oi.shop_change_free_amount oi_shop_change_free_amount,
        oi.final_refund_id oi_final_refund_id,oi.distribution_user_id oi_distribution_user_id,oi.count oi_count,oi.pic
        oi_pic,oi.is_comm oi_is_comm,oi.comm_time oi_comm_time,oi.free_freight_amount oi_free_freight_amount,
        oi.comm_time oi_comm_time,oi.refund_status oi_refund_status,oi.be_delivered_num
        oi_be_delivered_num,oi.delivery_type oi_delivery_type,oi.shop_cart_time oi_shop_cart_time,oi.price oi_price,
        oi.spu_total_amount oi_spu_total_amount,oi.actual_total oi_actual_total,oi.spu_mold oi_spu_mold,
        oi.share_reduce oi_share_reduce,oi.platform_share_reduce oi_platform_share_reduce,oi.distribution_amount
        oi_distribution_amount,
        oi.distribution_parent_amount oi_distribution_parent_amount,
        oi.score_fee oi_score_fee,oi.use_score oi_use_score,oi.gain_score
        oi_gain_score,oi.rate oi_rate,oi.spu_code oi_spu_code,oi.party_code oi_party_code,
        oi.platform_commission oi_platform_commission,oi.score_amount oi_score_amount,oi.member_amount
        oi_member_amount,oi.platform_coupon_amount oi_platform_coupon_amount,
        oi.shop_coupon_amount oi_shop_coupon_amount,oi.discount_amount
        oi_discount_amount,oi.platform_free_freight_amount oi_platform_free_freight_amount,
        oi.free_freight_amount oi_free_freight_amount,oi.shop_change_free_amount oi_shop_change_free_amount,
        oi.spu_code oi_spu_code,oi.party_code oi_party_code,oi.activity_id oi_activity_id,oi.activity_type oi_activity_type,
        oi.write_off_num oi_write_off_num,oi.write_off_multiple_count oi_write_off_multiple_count,oi.write_off_start oi_write_off_start,
        oi.write_off_end oi_write_off_end,
        oil.lang oi_lang,oil.spu_name oi_spu_name,oil.sku_name oi_sku_name,oil.supplier_spu_name oi_supplier_spu_name,
        oil.supplier_sku_name oi_supplier_sku_name,
        oi.giveaway_amount oi_giveaway_amount, oi.supplier_pic oi_supplier_pic,
        oi.purchase_platform_commission as oi_purchase_platform_commission,
        ops.deposit_amount,ops.balance_amount,ops.pre_sale_delivery_type,ops.pre_sale_delivery_time,
        ops.balance_start_time,ops.balance_end_time, ifnull(os.pay_id, os.pay_ids) as pay_id,
        oss.station_id station_id ,oss.station_code,
        ovi.order_virtual_info_id ovi_order_virtual_info_id,ovi.station_id ovi_station_id,ovi.write_off_code ovi_write_off_code,
        ovi.is_write_off ovi_is_write_off, ovi.write_off_time ovi_write_off_time, ovi.write_off_multiple_count ovi_write_off_multiple_count,
        ovi.order_id ovi_order_id, ovi.shop_id ovi_shop_id
        FROM `order` o
        LEFT JOIN order_addr oa ON oa.order_addr_id = o.order_addr_id
        LEFT JOIN order_invoice oiv ON oiv.order_id = o.order_id
        LEFT JOIN order_item oi ON o.order_id = oi.order_id
        LEFT JOIN order_item_lang oil ON oil.order_item_id = oi.order_item_id
        LEFT JOIN order_pre_sale_info ops ON ops.order_id = o.order_id
        LEFT JOIN order_settlement os ON os.order_id = o.order_id
        LEFT JOIN order_self_station oss ON oss.order_id = o.order_id
        LEFT JOIN order_virtual_info ovi ON ovi.order_id = o.order_id
        WHERE o.order_id = #{orderId}
    </select>

    <update id="updateWaitPurchase">
        update `order`
        set
        `wait_purchase` = #{order.waitPurchase},
        `purchase_spread_amount` = #{order.purchaseSpreadAmount}
        where
        order_id = #{order.orderId} and `wait_purchase` = 0
    </update>

    <select id="getDeliveryInfoByOrderId" resultType="com.tmerclub.cloud.order.model.Order">
        select o.order_id, o.user_id, o.shop_id, o.refund_status, o.status, oa.consignee, oa.mobile
        from `order` o
        left join order_addr oa on o.order_addr_id = oa.order_addr_id
        where o.order_id = #{orderId}
    </select>

    <update id="updateDistributionAmount">
        update `order` set `distribution_amount` = #{order.distributionAmount}
        where order_id = #{order.orderId}
    </update>
    <update id="updateCueOrder">
        update
            `order`
        <set>
            <if test="status != null">
                `status` = #{status},
            </if>
            <if test="shopId != null">
                `shop_id` = #{shopId},
            </if>
            <if test="isSettled != null">
                `is_settled` = #{isSettled},
            </if>
            <if test="finallyTime != null">
                `finally_time` = #{finallyTime},
            </if>
        </set>
        where
            order_id = #{orderId}
    </update>

    <select id="getUserFirstUserOrder" resultType="com.tmerclub.cloud.common.mongodb.bo.order.MongoOrderBO">
        SELECT IF(MIN(order_id) = #{orderId}, 1, 0) firstOrder
        <if test="supplierId != null">
            ,IF(MIN(IF(supplier_id = #{supplierId} AND supplier_delivery_type = 1, order_id, NULL)) = #{orderId}, 1, 0) as firstSupplierOrder
        </if>
        <if test="supplierId == null">
            , 0 as firstSupplierOrder
        </if>
        FROM `order`
        WHERE user_id = #{userId} AND is_payed = 1
    </select>

    <select id="getBalanceTimeExpireByOrderId" resultMap="preSalesOrderAndOrderItemMap">
        SELECT <include refid="Join_Column_List" />,oi.`main_giveaway` oi_main_giveaway,oi.activity_id oi_activity_id,
            oi.spu_id oi_spu_id,oi.sku_id oi_sku_id,oi.count oi_count,oi.rate oi_rate,oi.party_code oi_party_code,
            oi.pic oi_pic,oi.price oi_price,oil.spu_name oi_spu_name,oil.sku_name oi_sku_name,
            op.deposit_amount,o.`pay_sys_type`
        FROM `order` o
        LEFT JOIN `order_item` oi ON oi.`order_id` = o.`order_id`
        LEFT JOIN `order_item_lang` oil ON oil.`order_item_id` = oil.`order_item_id` and oil.lang = 1
        LEFT JOIN `order_pre_sale_info` op ON op.`order_id` = o.`order_id`
        WHERE  o.order_id = #{orderId}
    </select>

    <select id="getActivityOrderInfo" resultMap="orderActivityMap">
        SELECT o.order_id,o.user_id,o.is_payed,
        oi.spu_id,oi.sku_id,oi.count,oi.order_item_id,
        oi.activity_id,oi.activity_type
        FROM `order` o
        LEFT JOIN `order_item` oi ON oi.`order_id` = o.`order_id`
        WHERE  o.order_id = #{orderId}
    </select>

    <select id="getUserBuyNumByActivityId" resultType="java.lang.Integer">
        SELECT sum(oi.count) FROM `order` o
        LEFT JOIN order_item oi ON o.order_id = oi.order_id
        WHERE o.status IN (1,2,3,5,7,9) AND o.user_id = #{userId} AND oi.spu_id = #{spuId}
        AND oi.activity_id = #{activityId} AND oi.activity_type = #{activityType}
    </select>
    <select id="getUserByOrderIdList" resultType="com.tmerclub.cloud.common.order.vo.EsOrderVO">
        select user_id,order_id from `order` where order_id in
        <foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
            #{orderId}
        </foreach>
    </select>


    <select id="countPageOrderIds" resultType="java.lang.Long">
        SELECT ifnull(count(order_id),0) FROM`order`
        WHERE user_id = #{orderSearchDTO.userId} AND delete_status = 0
        <if test="orderSearchDTO.orderId != null ">
            AND order_id LIKE CONCAT('%', #{orderSearchDTO.orderId}, '%')
        </if>
        <if test="orderSearchDTO.shopId != null ">
            AND shop_id = #{orderSearchDTO.shopId}
        </if>
        <if test="orderSearchDTO.status != null and orderSearchDTO.status == 1">
            AND status IN (1,9)
        </if>
        <if test="orderSearchDTO.status != null and orderSearchDTO.status != 1">
            AND status = #{orderSearchDTO.status}
        </if>
        <if test="orderSearchDTO.orderType != null">
             and order_type = #{orderSearchDTO.orderType}
        </if>
        <if test="orderSearchDTO.startTime != null">
            AND create_time &gt;= #{orderSearchDTO.startTime}
        </if>
        <if test="orderSearchDTO.endTime != null">
            AND create_time <![CDATA[ <= ]]> #{orderSearchDTO.endTime}
        </if>
        ORDER BY create_time DESC, order_id DESC
    </select>

    <select id="pageOrderIds" resultType="java.lang.Long">
        SELECT order_id FROM`order`
        WHERE user_id = #{orderSearchDTO.userId} AND delete_status = 0
        <if test="orderSearchDTO.orderId != null ">
            AND order_id LIKE CONCAT('%', #{orderSearchDTO.orderId}, '%')
        </if>
        <if test="orderSearchDTO.shopId != null ">
            AND shop_id = #{orderSearchDTO.shopId}
        </if>
        <if test="orderSearchDTO.status != null and orderSearchDTO.status == 1">
            AND status IN (1,9)
        </if>
        <if test="orderSearchDTO.status != null and orderSearchDTO.status != 1">
            AND status = #{orderSearchDTO.status}
        </if>
        <if test="orderSearchDTO.orderType != null">
             and order_type = #{orderSearchDTO.orderType}
        </if>
        <if test="orderSearchDTO.startTime != null">
            AND create_time &gt;= #{orderSearchDTO.startTime}
        </if>
        <if test="orderSearchDTO.endTime != null">
            AND create_time <![CDATA[ <= ]]> #{orderSearchDTO.endTime}
        </if>
        ORDER BY create_time DESC, order_id DESC
        limit #{page.begin}, #{page.size}
    </select>

    <select id="userOrderList" resultMap="esOrderVO">
        SELECT
            <include refid="Join_Column_List" />,
            <include refid="Join_Order_item_Column_List" />,
            oil.lang oi_lang,oil.spu_name oi_spu_name,oil.sku_name oi_sku_name,
            ops.deposit_amount,ops.balance_amount,ops.pre_sale_delivery_type,ops.pre_sale_delivery_time,
            ops.balance_start_time,ops.balance_end_time,oiv.order_invoice_id
        FROM `order` AS o
        LEFT JOIN order_item oi ON o.order_id = oi.order_id
        LEFT JOIN order_item_lang oil ON oil.order_item_id = oi.order_item_id and oil.lang = #{lang}
        LEFT JOIN order_invoice oiv ON oiv.order_id = o.order_id
        LEFT JOIN order_pre_sale_info ops ON ops.order_id = o.order_id
        WHERE
        <foreach collection="orderIds" item="orderId" open="(" close=")" separator="OR">
            o.order_id = #{orderId}
        </foreach>
        ORDER BY o.create_time DESC
    </select>

    <select id="listOrderAndOrderItemByOrderIds" resultMap="orderVO">
        SELECT
            <include refid="Join_Column_List" />,
            <include refid="Join_Order_item_Column_List" />,
        oil.spu_name oi_spu_name,
        oil.sku_name oi_sku_name
        FROM `order` AS o
        LEFT JOIN order_item oi ON o.order_id = oi.order_id
        LEFT JOIN order_item_lang oil ON oil.order_item_id = oi.order_item_id
        WHERE
        <foreach collection="orderIds" item="orderId" open="(" close=")" separator="OR">
            o.order_id = #{orderId}
        </foreach>
    </select>

    <select id="listOrderAndLangByOrderIds" resultMap="orderVO">
        SELECT
            o.`shop_id`,
            o.`order_id`,
            o.`delivery_type`,
            o.user_id,
            o.actual_total,
            o.supplier_id,
            o.supplier_delivery_type,
            o.shop_change_free_amount,
            oil.lang oi_lang,
            oil.spu_name oi_spu_name,
            oil.sku_name oi_sku_name,
            oa.mobile
        FROM `order` o
        LEFT JOIN `order_item` oi ON oi.order_id = o.order_id
        LEFT JOIN order_item_lang oil ON oil.order_item_id = oi.order_item_id
        LEFT JOIN order_addr oa ON oa.order_addr_id = o.order_addr_id
        where o.order_id in
        <foreach collection="orderIds" open="(" item="orderId" close=")" separator=",">
            #{orderId}
        </foreach>
        GROUP BY o.order_id
    </select>

    <select id="getStationOrderByOrderIds" resultMap="orderVO">
        SELECT
            o.*,
            oil.lang oi_lang,
            oil.spu_name oi_spu_name,
            oil.sku_name oi_sku_name
        FROM `order` o
        LEFT JOIN `order_Item` oi ON o.order_id = oi.order_id
        LEFT JOIN `order_Item_lang` oil ON oi.order_item_id = oil.order_item_id
        LEFT JOIN `order_self_station` oss ON o.order_id = oss.order_id WHERE o.order_id IN
        <foreach collection="orderIdList" item="orderId" open="(" close=")" separator=",">
            #{orderId}
        </foreach>
        <if test="userId != null">
            AND o.user_id = #{userId}
        </if>
        <if test="stationId != null">
            AND oss.station_id = #{stationId}
        </if>
    </select>

    <select id="listStationOrder" resultType="com.tmerclub.cloud.common.order.vo.OrderVO">
        SELECT
            o.*
        FROM
            `order` o
            JOIN `order_self_station` oss ON o.order_id = oss.order_id
        <where>
            <if test="orderDTO.stationId != null">
                oss.station_id = #{orderDTO.stationId}
            </if>
            <if test="orderDTO.isSuccessPayStatus != null and orderDTO.isSuccessPayStatus">
                AND o.`status` IN (2, 3, 5, 7)
            </if>
            <if test="orderDTO.beginPayTime != null">
                AND o.pay_time &gt;= #{orderDTO.beginPayTime}
            </if>
        </where>
    </select>

    <select id="listWaitPurchaseAndUnPayBalanceOrderIds" resultType="com.tmerclub.cloud.common.order.vo.OrderVO">
        SELECT
            o.order_id,o.shop_id
        FROM
            `order` o
        WHERE
            o.is_payed = 1 and o.pay_sys_type = #{paySysType}
            AND (o.status = 2 AND o.is_payed = 1 AND o.wait_purchase = 1)
            OR  (o.STATUS = 9 AND o.pre_sale_type = 1)
    </select>

    <select id="listOrderByOrderIds" resultMap="orderVO">
        select * from `order` where order_id in
        <foreach collection="orderIds" open="(" item="orderId" close=")" separator=",">
            #{orderId}
        </foreach>
    </select>
</mapper>
