<?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.qs.mp.channel.mapper.ChannelGoodsMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qs.mp.channel.domain.ChannelGoods">
        <id column="id" property="id" />
        <result column="channel_id" property="channelId" />
        <result column="goods_id" property="goodsId" />
        <result column="order_id" property="orderId" />
        <result column="title" property="title" />
        <result column="pic_url" property="picUrl" />
        <result column="type" property="type" />
        <result column="ref_id" property="refId" />
        <result column="purchase_price" property="purchasePrice" />
        <result column="purchase_cost" property="purchaseCost" />
        <result column="quantity" property="quantity" />
        <result column="verify_qty" property="verifyQty" />
        <result column="status" property="status" />
        <result column="supplier_id" property="supplierId" />
        <result column="sort_weight" property="sortWeight" />
        <result column="multi_sku" property="multiSku" />
        <result column="sku_prop" property="skuProp" />
        <result column="is_deleted" property="isDeleted" />
        <result column="created_time" property="createdTime" />
        <result column="updated_time" property="updatedTime" />
        <result column="settle_time" property="settleTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, channel_id, goods_id, order_id, title, pic_url, type, description, ref_id, purchase_price, purchase_cost, quantity, verify_qty, status, merchant_info, supplier_id, sort_weight, multi_sku, sku_prop, is_deleted, created_time, updated_time, settle_time
    </sql>
    <select id="listChannelGoods" resultType="com.qs.mp.channel.domain.vo.ChannelGoodsVO">
        select t1.*,t3.name as supplierName
        from mp_channel_goods t1
        left join mp_channel_goods_order_item t2 on t1.order_id = t2.order_id
        left join mp_supplier t3 on t2.supplier_id = t3.id
            ${ew.customSqlSegment}
    </select>
    <select id="listChannelGoodsUnderChannel" resultType="com.qs.mp.channel.domain.vo.ChannelGoodsVO">
        select t1.*,t2.name as channelName
        from mp_channel_goods t1
        left join mp_channel t2 on t1.channel_id = t2.channel_id
        left join mp_channel t3 on t2.parent_id = t3.channel_id
            ${ew.customSqlSegment}
    </select>

</mapper>