package com.hfkj.dao;

import com.hfkj.model.order.OrderCouponModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * mapper扩展类
 */
public interface BsOrderCouponMapperExt {

    @Select("<script>" +
            " SELECT" +
            " b.order_no orderNo," +
            " b.child_order_no childOrderNo," +
            " b.user_phone userPhone," +
            " b.goods_vpd_key goodsKey," +
            " b.goods_name goodsName," +
            " b.goods_specs_name goodsSpecsName, " +
            " b.goods_spesc_original_price goodsOriginalPrice," +
            " b.goods_spesc_sale_price goodsSalePrice," +
            " b.goods_count goodsCount," +
            " b.total_price totalPrice," +
            " b.total_deduction_price totalDeductionPrice," +
            " b.coupon_discount_price couponDiscountPrice," +
            " b.integral_discount_price integralDiscountPrice," +
            " b.pay_real_price payRealPrice," +
            " b.pay_channel payChannel," +
            " b.pay_type payType," +
            " b.pay_serial_no paySerialNo," +
            " b.platform_code platformCode," +
            " b.`status` tradeStatus," +
            " b.create_time createTime," +
            " b.pay_time payTime," +
            " a.channel_order_no channelOrderNo," +
            " a.goods_vpd_source_cou_no couNo," +
            " a.`status` couStatus," +
            " a.expire_time expireTime," +
            " a.exception_status exceptionStatus," +
            " a.finish_time finishTime" +
            " FROM" +
            " bs_order_coupon_no a" +
            " LEFT JOIN bs_order_coupon b on a.coupon_order_id = b.id" +
            " WHERE 1 = 1" +
            " <if test='param.merId != null'> and b.mer_id = #{param.merId} </if>" +
            " <if test='param.orderNo != null'> and b.order_no like concat('%',#{param.orderNo},'%') </if>" +
            " <if test='param.orderChildNo != null'> and b.child_order_no = #{param.orderChildNo} </if>" +
            " <if test='param.platformCode != null'> and b.platform_code = #{param.platformCode} </if>" +
            " <if test='param.userPhone != null'> and b.user_phone like concat('%',#{param.userPhone},'%') </if>" +
            " <if test='param.payType != null'> and b.pay_type = #{param.payType}</if>" +
            " <if test='param.tradeStatus != null'> and b.status = #{param.tradeStatus}</if>" +
            " <if test='param.goodsName != null'> and b.goods_name like concat('%',#{param.goodsName},'%') </if>" +
            " <if test='param.channelOrderNo != null'> and a.channel_order_no like concat('%',#{param.channelOrderNo},'%') </if>" +
            " <if test='param.couNo != null'> and a.goods_vpd_source_cou_no like concat('%',#{param.couNo},'%') </if>" +
            " <if test='param.couStatus != null'> and a.status = #{param.couStatus} </if>" +
            " <if test='param.createTimeS != null'><![CDATA[ and b.create_time >= #{param.createTimeS} ]]></if>" +
            " <if test='param.createTimeE != null'><![CDATA[ and b.create_time <= #{param.createTimeE} ]]></if>" +
            " GROUP BY a.id" +
            " ORDER BY b.create_time desc,b.child_order_no" +
            "</script>")
    List<OrderCouponModel> getOrderList(@Param("param") Map<String,Object> param);

}
