<?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.marketing.mapper.PromotionSkuMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.fzm.mall.server.admin.marketing.model.PromotionSku">
        <id column="id" property="id" />
        <result column="promotion_sku_id" property="promotionSkuId" />
        <result column="promotion_id" property="promotionId" />
        <result column="goods_id" property="goodsId" />
        <result column="sku_id" property="skuId" />
        <result column="status" property="status" />
        <result column="merchant_id" property="merchantId" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <select id="listSku" resultMap="BaseResultMap">
        select cs.*, s.name as goodsName, s.description
        from (select * from marketing_promotion_sku where status = '1' and merchant_id = #{merchantId} and promotion_id = #{promotionId}) cs
        left join goods_spu s on cs.goods_id = s.goods_id and cs.merchant_id = s.merchant_id
    </select>
</mapper>
