package com.hfkj.dao;

import com.hfkj.entity.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * mapper扩展类
 */
public interface BsOrderMapperExt {
    @Insert({
            "<script>",
            "insert into bs_order (user_id, user_name, ",
            "user_phone, order_no, ",
            "pay_channel, pay_channel_order_no, ",
            "pay_serial_no, pay_type, ",
            "total_price, pay_real_price, ",
            "product_total_price, create_time, ",
            "update_time, pay_time, ",
            "finish_time, cancel_time, ",
            "refund_time, order_status, ",
            "remarks, ext_1, ext_2, ",
            "ext_3)",
            "values ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(" +
                    "#{item.userId,jdbcType=BIGINT}, " +
                    "#{item.userName,jdbcType=VARCHAR}, ",
                    "#{item.userPhone,jdbcType=VARCHAR}, " +
                    "#{item.orderNo,jdbcType=VARCHAR}, ",
                    "#{item.payChannel,jdbcType=INTEGER}, " +
                    "#{item.payChannelOrderNo,jdbcType=VARCHAR}, ",
                    "#{item.paySerialNo,jdbcType=VARCHAR}, " +
                    "#{item.payType,jdbcType=INTEGER}, ",
                    "#{item.totalPrice,jdbcType=DECIMAL}, " +
                    "#{item.payRealPrice,jdbcType=DECIMAL}, ",
                    "#{item.productTotalPrice,jdbcType=DECIMAL}," +
                    "#{item.createTime,jdbcType=TIMESTAMP}, ",
                    "#{item.updateTime,jdbcType=TIMESTAMP}, " +
                    "#{item.payTime,jdbcType=TIMESTAMP}, ",
                    "#{item.finishTime,jdbcType=TIMESTAMP}, " +
                    "#{item.cancelTime,jdbcType=TIMESTAMP}, ",
                    "#{item.refundTime,jdbcType=TIMESTAMP}, " +
                    "#{item.orderStatus,jdbcType=INTEGER}, ",
                    "#{item.remarks,jdbcType=VARCHAR}, " +
                    "#{item.ext1,jdbcType=VARCHAR}, " +
                    "#{item.ext2,jdbcType=VARCHAR}, ",
                    "#{item.ext3,jdbcType=VARCHAR}" +
                        ")",
            "</foreach>",
            "</script>"
    })
    void insertOrderBatch(@Param(value = "list") List<BsOrder> list);

    @Insert({
            "<script>",
            "insert into bs_order_child (order_no, child_order_no, ",
            "mer_id, product_type, ",
            "product_id, product_name, ",
            "product_img, product_spec_id, ",
            "product_spec_name, product_price, ",
            "product_count, product_total_price, ",
            "total_deduction_price, coupon_discount_price, ",
            "integral_discount_price, product_actual_price, ",
            "surplus_refund_count, surplus_refund_price, ",
            "surplus_refund_integral, `status`, ",
            "settle_account, settle_account_key, ",
            "create_time, update_time, ",
            "finish_time, ext_1, ",
            "ext_2, ext_3)",
            "values ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.orderNo,jdbcType=VARCHAR}, " +
                "#{item.childOrderNo,jdbcType=VARCHAR}, ",
                "#{item.merId,jdbcType=BIGINT}, " +
                "#{item.productType,jdbcType=INTEGER}, ",
                "#{item.productId,jdbcType=BIGINT}, " +
                "#{item.productName,jdbcType=VARCHAR}, ",
                "#{item.productImg,jdbcType=VARCHAR}, " +
                "#{item.productSpecId,jdbcType=BIGINT}, ",
                "#{item.productSpecName,jdbcType=VARCHAR}, " +
                "#{item.productPrice,jdbcType=DECIMAL}, ",
                "#{item.productCount,jdbcType=INTEGER}, " +
                "#{item.productTotalPrice,jdbcType=DECIMAL}, ",
                "#{item.totalDeductionPrice,jdbcType=DECIMAL}, " +
                "#{item.couponDiscountPrice,jdbcType=DECIMAL}, ",
                "#{item.integralDiscountPrice,jdbcType=DECIMAL}, " +
                "#{item.productActualPrice,jdbcType=DECIMAL}, ",
                "#{item.surplusRefundCount,jdbcType=INTEGER}, " +
                "#{item.surplusRefundPrice,jdbcType=DECIMAL}, ",
                "#{item.surplusRefundIntegral,jdbcType=BIGINT}, " +
                "#{item.status,jdbcType=INTEGER}, ",
                "#{item.settleAccount,jdbcType=VARCHAR}," +
                "#{item.settleAccountKey,jdbcType=VARCHAR}, ",
                "#{item.createTime,jdbcType=TIMESTAMP}, " +
                "#{item.updateTime,jdbcType=TIMESTAMP}, ",
                "#{item.finishTime,jdbcType=TIMESTAMP}, " +
                "#{item.ext1,jdbcType=VARCHAR}, ",
                "#{item.ext2,jdbcType=VARCHAR}, " +
                "#{item.ext3,jdbcType=VARCHAR})",
            "</foreach>",
            "</script>"
    })
    void insertOrderChildBatch(@Param(value = "list") List<BsOrderChild> list);

    @Insert({
            "<script>",
            "insert into bs_order_coupon (order_no, child_order_no, ",
            "mer_id, user_id, user_phone, ",
            "goods_id, goods_name, ",
            "goods_type_id, goods_type_name, ",
            "goods_brand_id, goods_brand_name, ",
            "goods_specs_id, goods_specs_name, ",
            "goods_spesc_original_price, goods_vpd_id, ",
            "goods_vpd_key, goods_vpd_source, ",
            "goods_count, total_price, ",
            "total_deduction_price, coupon_discount_price, ",
            "integral_discount_price, pay_real_price, ",
            "pay_channel, pay_serial_no, ",
            "pay_type, `status`, ",
            "create_time, pay_time, ",
            "cancel_time, refund_time, ",
            "finish_time, update_time, ",
            "ext_1, ext_2, ext_3)",
            "values ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.orderNo,jdbcType=VARCHAR}, " +
                "#{item.childOrderNo,jdbcType=VARCHAR}, ",
                "#{item.merId,jdbcType=BIGINT}, " +
                "#{item.userId,jdbcType=BIGINT}," +
                 "#{item.userPhone,jdbcType=VARCHAR}, ",
                "#{item.goodsId,jdbcType=BIGINT}, " +
                "#{item.goodsName,jdbcType=VARCHAR}, ",
                "#{item.goodsTypeId,jdbcType=BIGINT}, " +
                "#{item.goodsTypeName,jdbcType=VARCHAR}, ",
                "#{item.goodsBrandId,jdbcType=BIGINT}, " +
                "#{item.goodsBrandName,jdbcType=VARCHAR}, ",
                "#{item.goodsSpecsId,jdbcType=BIGINT}, " +
                "#{item.goodsSpecsName,jdbcType=VARCHAR}, ",
                "#{item.goodsSpescOriginalPrice,jdbcType=DECIMAL}, " +
                 "#{item.goodsVpdId,jdbcType=BIGINT}, ",
                "#{item.goodsVpdKey,jdbcType=VARCHAR}, " +
                "#{item.goodsVpdSource,jdbcType=INTEGER}, ",
                "#{item.goodsCount,jdbcType=INTEGER}, " +
                "#{item.totalPrice,jdbcType=DECIMAL}, ",
                "#{item.totalDeductionPrice,jdbcType=DECIMAL}, " +
                "#{item.couponDiscountPrice,jdbcType=DECIMAL}, ",
                "#{item.integralDiscountPrice,jdbcType=DECIMAL}, " +
                "#{item.payRealPrice,jdbcType=DECIMAL}, ",
                "#{item.payChannel,jdbcType=INTEGER}, " +
                "#{item.paySerialNo,jdbcType=VARCHAR}, ",
                "#{item.payType,jdbcType=INTEGER}, " +
                "#{item.status,jdbcType=INTEGER}, ",
                "#{item.createTime,jdbcType=TIMESTAMP}, " +
                "#{item.payTime,jdbcType=TIMESTAMP}, ",
                "#{item.cancelTime,jdbcType=TIMESTAMP}, " +
                "#{item.refundTime,jdbcType=TIMESTAMP}, ",
                "#{item.finishTime,jdbcType=TIMESTAMP}, " +
                "#{item.updateTime,jdbcType=TIMESTAMP}, ",
                "#{item.ext1,jdbcType=VARCHAR}, " +
                "#{item.ext2,jdbcType=VARCHAR}, " +
                "#{item.ext3,jdbcType=VARCHAR})",
            "</foreach>",
            "</script>"
    })
    void insertOrderCouponBatch(@Param(value = "list") List<BsOrderCoupon> list);

    @Insert({
            "<script>",
            "insert into bs_order_coupon_no (coupon_order_id, order_no, ",
            "channel_order_no, goods_vpd_source, ",
            "goods_vpd_key, goods_vpd_source_cou_no, ",
            "expire_status, expire_time, ",
            "`status`, exception_status, ",
            "create_time, deliver_time, ",
            "finish_time, update_time, ",
            "ext_1, ext_2, ext_3)",
            "values ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.couponOrderId,jdbcType=BIGINT}, " +
                "#{item.orderNo,jdbcType=VARCHAR}, ",
                "#{item.channelOrderNo,jdbcType=VARCHAR}, " +
                "#{item.goodsVpdSource,jdbcType=INTEGER}, ",
                "#{item.goodsVpdKey,jdbcType=VARCHAR}, " +
                "#{item.goodsVpdSourceCouNo,jdbcType=VARCHAR}, ",
                "#{item.expireStatus,jdbcType=BIT}, " +
                "#{item.expireTime,jdbcType=TIMESTAMP}, ",
                "#{item.status,jdbcType=INTEGER}, " +
                "#{item.exceptionStatus,jdbcType=BIT}, ",
                "#{item.createTime,jdbcType=TIMESTAMP}, " +
                "#{item.deliverTime,jdbcType=TIMESTAMP}, ",
                "#{item.finishTime,jdbcType=TIMESTAMP}, " +
                "#{item.updateTime,jdbcType=TIMESTAMP}, ",
                "#{item.ext1,jdbcType=VARCHAR}, " +
                "#{item.ext2,jdbcType=VARCHAR}, " +
                "#{item.ext3,jdbcType=VARCHAR})",
            "</foreach>",
            "</script>"
    })
    void insertOrderCouponNoBatch(@Param(value = "list") List<BsOrderCouponNo> list);

    @Insert({
            "<script>",
            "insert into bs_order_goods (logistics_no, freight_price, ",
            "delivery_address_id, delivery_address, ",
            "order_no, child_order_no, ",
            "mer_id, user_id, user_phone, ",
            "goods_id, img, goods_name, ",
            "goods_type_id, goods_type_name, ",
            "goods_brand_id, goods_brand_name, ",
            "goods_specs_id, goods_specs_name, ",
            "goods_specs_original_price, goods_count, ",
            "total_price, total_deduction_price, ",
            "coupon_discount_price, integral_discount_price, ",
            "pay_real_price, pay_channel, ",
            "pay_serial_no, pay_type, ",
            "`status`, logistics_status_desc, ",
            "logistics_status, create_time, ",
            "pay_time, cancel_time, ",
            "refund_time, finish_time, ",
            "update_time, exception_status, ",
            "exception_msg, ext_1, ",
            "ext_2, ext_3)",
            "values ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.logisticsNo,jdbcType=VARCHAR}, " +
                "#{item.freightPrice,jdbcType=DECIMAL}, ",
                "#{item.deliveryAddressId,jdbcType=BIGINT}, " +
                "#{item.deliveryAddress,jdbcType=VARCHAR}, ",
                "#{item.orderNo,jdbcType=VARCHAR}, " +
                "#{item.childOrderNo,jdbcType=VARCHAR}, ",
                "#{item.merId,jdbcType=BIGINT}, " +
                "#{item.userId,jdbcType=BIGINT}, " +
                "#{item.userPhone,jdbcType=VARCHAR}, ",
                "#{item.goodsId,jdbcType=BIGINT}, " +
                "#{item.img,jdbcType=VARCHAR}, " +
                 "#{item.goodsName,jdbcType=VARCHAR}, ",
                "#{item.goodsTypeId,jdbcType=BIGINT}, " +
                "#{item.goodsTypeName,jdbcType=VARCHAR}, ",
                "#{item.goodsBrandId,jdbcType=BIGINT}, " +
                "#{item.goodsBrandName,jdbcType=VARCHAR}, ",
                "#{item.goodsSpecsId,jdbcType=BIGINT}, " +
                "#{item.goodsSpecsName,jdbcType=VARCHAR}, ",
                "#{item.goodsSpecsOriginalPrice,jdbcType=DECIMAL}, " +
                "#{item.goodsCount,jdbcType=INTEGER}, ",
                "#{item.totalPrice,jdbcType=DECIMAL}, " +
                "#{item.totalDeductionPrice,jdbcType=DECIMAL}, ",
                "#{item.couponDiscountPrice,jdbcType=DECIMAL}, " +
                "#{item.integralDiscountPrice,jdbcType=DECIMAL}, ",
                "#{item.payRealPrice,jdbcType=DECIMAL}, " +
                "#{item.payChannel,jdbcType=INTEGER}, ",
                "#{item.paySerialNo,jdbcType=VARCHAR}, " +
                "#{item.payType,jdbcType=INTEGER}, ",
                "#{item.status,jdbcType=INTEGER}, " +
                "#{item.logisticsStatusDesc,jdbcType=VARCHAR}, ",
                "#{item.logisticsStatus,jdbcType=VARCHAR}, " +
                "#{item.createTime,jdbcType=TIMESTAMP}, ",
                "#{item.payTime,jdbcType=TIMESTAMP}, " +
                "#{item.cancelTime,jdbcType=TIMESTAMP}, ",
                "#{item.refundTime,jdbcType=TIMESTAMP}, " +
                "#{item.finishTime,jdbcType=TIMESTAMP}, ",
                "#{item.updateTime,jdbcType=TIMESTAMP}, " +
                "#{item.exceptionStatus,jdbcType=BIT}, ",
                "#{item.exceptionMsg,jdbcType=VARCHAR}, " +
                "#{item.ext1,jdbcType=VARCHAR}, ",
                "#{item.ext2,jdbcType=VARCHAR}, " +
                "#{item.ext3,jdbcType=VARCHAR})",
            "</foreach>",
            "</script>"
    })
    void insertOrderGoodsBatch(@Param(value = "list") List<BsOrderGoods> list);

    @Insert({
            "<script>",
            "insert into bs_order_deduction (order_id, order_no, ",
            "total_deduction_price, user_coupon_discount_id, ",
            "coupon_discount_id, coupon_discount_type, ",
            "coupon_discount_price, coupon_discount_actual_price, ",
            "integral_discount_price, ext_1, ",
            "ext_2, ext_3)",
            "values ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.orderId,jdbcType=BIGINT}, " +
                "#{item.orderNo,jdbcType=VARCHAR}, ",
                "#{item.totalDeductionPrice,jdbcType=DECIMAL}, " +
                "#{item.userCouponDiscountId,jdbcType=BIGINT}, ",
                "#{item.couponDiscountId,jdbcType=BIGINT}, " +
                "#{item.couponDiscountType,jdbcType=INTEGER}, ",
                "#{item.couponDiscountPrice,jdbcType=DECIMAL}, " +
                "#{item.couponDiscountActualPrice,jdbcType=DECIMAL}, ",
                "#{item.integralDiscountPrice,jdbcType=BIGINT}, " +
                "#{item.ext1,jdbcType=VARCHAR}, ",
                "#{item.ext2,jdbcType=VARCHAR}, " +
                "#{item.ext3,jdbcType=VARCHAR})",
            "</foreach>",
            "</script>"
    })
    void insertOrderDeductionBatch(@Param(value = "list") List<BsOrderDeduction> list);
}