<?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.mall.order.mapper.OrderItemMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.order.domain.entity.OrderItem">
        <id column="id" property="id"/>
        <id column="order_id" property="orderId"/>
        <id column="order_sn" property="orderSn"/>
        <id column="spu_id" property="spuId"/>
        <id column="spu_name" property="spuName"/>
        <id column="spu_pic" property="spuPic"/>
        <id column="spu_brand" property="spuBrand"/>
        <id column="category_id" property="categoryId"/>
        <id column="sku_id" property="skuId"/>
        <id column="sku_name" property="skuName"/>
        <id column="sku_pic" property="skuPic"/>
        <id column="sku_price" property="skuPrice"/>
        <id column="sku_quantity" property="skuQuantity"/>
        <id column="sku_attrs_vals" property="skuAttrsVals"/>
        <id column="promotion_amount" property="promotionAmount"/>
        <id column="coupon_amount" property="couponAmount"/>
        <id column="integration_amount" property="integrationAmount"/>
        <id column="real_amount" property="realAmount"/>
        <id column="gift_integration" property="giftIntegration"/>
        <id column="gift_growth" property="giftGrowth"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,order_id,order_sn,spu_id,spu_name,spu_pic,spu_brand,category_id,sku_id,sku_name,sku_pic,sku_price,sku_quantity,sku_attrs_vals,promotion_amount,coupon_amount,integration_amount,real_amount,gift_integration,gift_growth
    </sql>

    <!-- 分页查询订单项信息内容 -->
    <select id="selectListByPage" resultType="com.mall.order.domain.vo.OrderItemVo">
        select
        <include refid="Base_Column_List"/>
        from oms_order_item
        <where>
            <if test="dto.id != null and dto.id != ''">
                and id like CONCAT('%',#{dto.id},'%')
            </if>
            <if test="dto.orderId != null and dto.orderId != ''">
                and order_id like CONCAT('%',#{dto.orderId},'%')
            </if>
            <if test="dto.orderSn != null and dto.orderSn != ''">
                and order_sn like CONCAT('%',#{dto.orderSn},'%')
            </if>
            <if test="dto.spuId != null and dto.spuId != ''">
                and spu_id like CONCAT('%',#{dto.spuId},'%')
            </if>
            <if test="dto.spuName != null and dto.spuName != ''">
                and spu_name like CONCAT('%',#{dto.spuName},'%')
            </if>
            <if test="dto.spuPic != null and dto.spuPic != ''">
                and spu_pic like CONCAT('%',#{dto.spuPic},'%')
            </if>
            <if test="dto.spuBrand != null and dto.spuBrand != ''">
                and spu_brand like CONCAT('%',#{dto.spuBrand},'%')
            </if>
            <if test="dto.categoryId != null and dto.categoryId != ''">
                and category_id like CONCAT('%',#{dto.categoryId},'%')
            </if>
            <if test="dto.skuId != null and dto.skuId != ''">
                and sku_id like CONCAT('%',#{dto.skuId},'%')
            </if>
            <if test="dto.skuName != null and dto.skuName != ''">
                and sku_name like CONCAT('%',#{dto.skuName},'%')
            </if>
            <if test="dto.skuPic != null and dto.skuPic != ''">
                and sku_pic like CONCAT('%',#{dto.skuPic},'%')
            </if>
            <if test="dto.skuPrice != null and dto.skuPrice != ''">
                and sku_price like CONCAT('%',#{dto.skuPrice},'%')
            </if>
            <if test="dto.skuQuantity != null and dto.skuQuantity != ''">
                and sku_quantity like CONCAT('%',#{dto.skuQuantity},'%')
            </if>
            <if test="dto.skuAttrsVals != null and dto.skuAttrsVals != ''">
                and sku_attrs_vals like CONCAT('%',#{dto.skuAttrsVals},'%')
            </if>
            <if test="dto.promotionAmount != null and dto.promotionAmount != ''">
                and promotion_amount like CONCAT('%',#{dto.promotionAmount},'%')
            </if>
            <if test="dto.couponAmount != null and dto.couponAmount != ''">
                and coupon_amount like CONCAT('%',#{dto.couponAmount},'%')
            </if>
            <if test="dto.integrationAmount != null and dto.integrationAmount != ''">
                and integration_amount like CONCAT('%',#{dto.integrationAmount},'%')
            </if>
            <if test="dto.realAmount != null and dto.realAmount != ''">
                and real_amount like CONCAT('%',#{dto.realAmount},'%')
            </if>
            <if test="dto.giftIntegration != null and dto.giftIntegration != ''">
                and gift_integration like CONCAT('%',#{dto.giftIntegration},'%')
            </if>
            <if test="dto.giftGrowth != null and dto.giftGrowth != ''">
                and gift_growth like CONCAT('%',#{dto.giftGrowth},'%')
            </if>
        </where>
    </select>

</mapper>
