<?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.fzm.mall.server.admin.goods_center.mapper.CategoryMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.goods_center.model.Category">
        <id column="id" property="id" />
        <result column="category_id" property="categoryId" />
        <result column="clazz_id" property="clazzId" />
        <result column="level" property="level" />
        <result column="name" property="name" />
        <result column="thumb" property="thumb" />
        <result column="status" property="status" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <select id="listByCoupon" resultMap="BaseResultMap">
        select c.*
        from goods_category c
        left join marketing_coupon_category cc on c.category_id = cc.category_id
        where cc.coupon_id = #{couponId} and cc.merchant_id = #{merchantId}
        order by c.create_time desc
    </select>

    <select id="listByPromotion" resultMap="BaseResultMap">
        select c.*
        from goods_category c
        left join marketing_promotion_category pc on c.category_id = pc.category_id
        where pc.promotion_id = #{promotionId} and pc.merchant_id = #{merchantId}
        order by c.create_time desc
    </select>

    <select id="listByReturn" resultMap="BaseResultMap">
        select c.*
        from goods_category c
                 left join opration_integral_return_category rc on c.category_id = rc.category_id
        where rc.return_id = #{returnId}
    </select>
</mapper>
