<?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="org.springblade.modules.mall.mapper.GoodsSpecMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="goodsSpecResultMap" type="org.springblade.modules.mall.vo.GoodsSpecVO">
        <id column="id" property="id"/>
        <result column="spce_name" property="spceName"/>
        <result column="spce_no" property="spceNo"/>
        <result column="goods_id" property="goodsId"/>
        <result column="cover" property="cover"/>
        <result column="stock" property="stock"/>
        <result column="sale" property="sale"/>
        <result column="is_default" property="isDefault"/>
        <result column="market_price" property="marketPrice"/>
        <result column="guide_price" property="guidePrice"/>
        <result column="agreement_price" property="agreementPrice"/>
        <result column="activity_price" property="activityPrice"/>
        <result column="sale_price" property="salePrice"/>
        <result column="cost_price" property="costPrice"/>
        <result column="is_integral_deduction" property="isIntegralDeduction"/>
        <result column="need_integral" property="needIntegral"/>
        <result column="obtain_integral" property="obtainIntegral"/>
        <result column="is_sale" property="isSale"/>
        <result column="rate" property="rate"/>
        <result column="is_delete" property="isDelete"/>
        <result column="create_user_id" property="createUserId"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user_id" property="updateUserId"/>
        <result column="update_time" property="updateTime"/>
        <result column="goods_no" property="goodsNo"/>
        <result column="zone_type" property="zoneType"/>
    </resultMap>


    <select id="selectGoodsSpecPage" resultMap="goodsSpecResultMap">
        select i.goods_no, i.zone_type, s.* FROM biz_goods_info i LEFT JOIN biz_goods_spec s on i.id = s.goods_id
        WHERE i.is_delete = 0 and s.is_delete = 0
        <if test="goodsSpec.goodsId != null" >
            and i.id = #{goodsSpec.goodsId}
        </if>
        <if test="goodsSpec.zoneType != null" >
            and i.zone_type = #{goodsSpec.zoneType}
        </if>
        <if test="goodsSpec.goodsNo != null" >
            and i.goods_no = #{goodsSpec.goodsNo}
        </if>
        <if test="goodsSpec.spceNo != null" >
            and s.spce_no = #{goodsSpec.spceNo}
        </if>
        <if test="goodsSpec.spceName != null" >
            and INSTR(s.spce_name, #{goodsSpec.spceName})
        </if>
        ORDER BY i.create_time desc
    </select>

</mapper>
