123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <?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.foonsu.efenxiao.platform.mapper.PlatformGoodsExtMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="goodsResultMap" type="com.foonsu.efenxiao.platform.vo.PlatformGoodsVO"
- extends="com.foonsu.efenxiao.platform.mapper.PlatformGoodsMapper.platformGoodsResultMap">
- <result column="shop_name" property="shopName"/>
- <result column="goods_pic_path" property="picPath"/>
- <collection property="goodsSkuList" ofType="com.foonsu.efenxiao.platform.vo.PlatformGoodsSkuVO">
- <id column="goodsSkuId" property="id"/>
- <result column="goodsSkuBizId" property="bizId"/>
- <result column="productId" property="productId"/>
- <result column="sku_id" property="skuId"/>
- <result column="sku_name" property="skuName"/>
- <result column="sku_out_id" property="skuOutId"/>
- <result column="sku_price" property="skuPrice"/>
- <result column="sku_weight" property="skuWeight"/>
- <result column="sku_short_name" property="skuShortName"/>
- <result column="shopBizId" property="shopBizId"/>
- <result column="shopTenantId" property="shopTenantId"/>
- <result column="skuOnSale" property="onSale"/>
- <result column="sku_pic_path" property="picPath"/>
- <result column="color_spec" property="colorSpec"/>
- <result column="size_spec" property="sizeSpec"/>
- </collection>
- <collection property="distributeList" ofType="com.foonsu.efenxiao.platform.vo.PlatformGoodsDistributeVO">
- <id column="goodsDistributeId" property="id"/>
- <result column="goodsDistributeBizId" property="bizId"/>
- <result column="seller_tenant_id" property="sellerTenantId"/>
- <result column="factory_tenant_id" property="factoryTenantId"/>
- <result column="factory_tenant_account" property="factoryTenantAccount"/>
- <result column="dGoodsBizId" property="goodsBizId"/>
- <result column="dSkuBizId" property="skuBizId"/>
- <result column="allocation_status" property="allocationStatus"/>
- </collection>
- </resultMap>
- <sql id="Base_Column_List">
- pg.id,
- pg.biz_id,
- pg.product_id,
- pg.product_name,
- pg.product_out_id,
- pg.price,
- pg.weight,
- pg.short_name,
- pg.shop_biz_id,
- pg.shop_tenant_id,
- pg.shop_platform,
- pg.on_sale,
- pg.create_time,
- pg.pic_path goods_pic_path
- </sql>
- <sql id="Base_sku_Column_List">
- pgs.id goodsSkuId,
- pgs.biz_id goodsSkuBizId,
- pgs.product_id productId,
- pgs.sku_id,
- pgs.sku_name,
- pgs.sku_out_id,
- pgs.sku_price,
- pgs.sku_weight,
- pgs.sku_short_name,
- pgs.shop_biz_id shopBizId,
- pgs.shop_tenant_id shopTenantId,
- pgs.on_sale skuOnSale,
- pgs.pic_path sku_pic_path,
- pgs.color_spec,
- pgs.size_spec
- </sql>
- <!-- <sql id="Base_distribute_Column_List">
- pgd.id goodsDistributeId,
- pgd.biz_id goodsDistributeBizId,
- pgd.seller_tenant_id,
- pgd.factory_tenant_id,
- pgd.goods_biz_id dGoodsBizId,
- pgd.sku_biz_id dSkuBizId,
- pgd.allocation_status,
- pgd.factory_tenant_account
- </sql>-->
- <select id="countPlatformGoodsPage" resultType="int">
- select count(distinct biz_id) from(
- select pg.biz_id from i_platform_goods pg
- inner join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
- inner join i_shop s on s.biz_id = pg.shop_biz_id
- inner join i_platform_goods_distribute pgd on pgd.sku_biz_id = pgs.biz_id and pgd.relation_type = '2' and pgd.factory_tenant_id = #{req.tenantId}
- left join i_platform_goods_distribute pgd1 on pgd1.sku_biz_id = pgs.biz_id and pgd1.relation_type = '2' and pgd1.seller_tenant_id = #{req.tenantId}
- where pgs.id is not null
- <include refid="search_condition" />
- union
- select pg.biz_id from i_platform_goods pg
- left join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
- inner join i_shop s on s.biz_id = pg.shop_biz_id
- inner join i_platform_goods_distribute pgd on pgd.goods_biz_id = pg.biz_id and pgd.relation_type = '1' and (pgd.factory_tenant_id = #{req.tenantId} )
- left join i_platform_goods_distribute pgd1 on pgd1.goods_biz_id = pg.biz_id and pgd1.relation_type = '1' and (pgd1.seller_tenant_id = #{req.tenantId} )
- where pgs.id is null
- <include refid="search_condition" />
- ) temp
- </select>
- <select id="selectPlatformGoodsPageBizId" resultType="int">
- select distinct biz_id from(
- select pg.biz_id from i_platform_goods pg
- inner join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
- inner join i_shop s on s.biz_id = pg.shop_biz_id
- inner join i_platform_goods_distribute pgd on pgd.sku_biz_id = pgs.biz_id and pgd.relation_type = '2' and pgd.factory_tenant_id = #{req.tenantId}
- left join i_platform_goods_distribute pgd1 on pgd1.sku_biz_id = pgs.biz_id and pgd1.relation_type = '2' and pgd1.seller_tenant_id = #{req.tenantId}
- where pgs.id is not null
- <include refid="search_condition" />
- union
- select pg.biz_id from i_platform_goods pg
- left join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
- inner join i_shop s on s.biz_id = pg.shop_biz_id
- inner join i_platform_goods_distribute pgd on pgd.goods_biz_id = pg.biz_id and pgd.relation_type = '1' and (pgd.factory_tenant_id = #{req.tenantId} )
- left join i_platform_goods_distribute pgd1 on pgd1.goods_biz_id = pg.biz_id and pgd1.relation_type = '1' and (pgd1.seller_tenant_id = #{req.tenantId} )
- where pgs.id is null
- <include refid="search_condition" />
- ) temp
- <include refid="sort_condition" />
- </select>
- <select id="selectPlatformGoodsPageData" resultMap="goodsResultMap">
- select <include refid="Base_Column_List" />, <include refid="Base_sku_Column_List" />, s.shop_name
- from i_platform_goods pg
- left join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
- inner join i_shop s on s.biz_id = pg.shop_biz_id
- where pg.biz_id in <foreach collection="req.productBizIds" item="item" open="(" close=")" separator=",">#{item}</foreach>
- </select>
- <sql id="search_condition">
- <if test="req.shopPlatforms != null">
- and pg.shop_platform in <foreach collection="req.shopPlatforms" open="(" close=")" separator="," item="item">#{item}</foreach>
- </if>
- <if test="req.shopBizId != null">
- and pg.shop_biz_id = #{req.shopBizId}
- </if>
- <if test="req.factoryTenantId != null">
- and pgd1.factory_tenant_id = #{req.factoryTenantId}
- </if>
- <if test="req.sellerTenantId != null">
- and pgd.seller_tenant_id = #{req.sellerTenantId}
- </if>
- <if test="req.factoryTenantId != null and (req.fillInStater != null || req.compareStater != null)">
- and (
- <if test="req.fillInStater == 0">
- pgd1.distribute_price is not null
- </if>
- <if test="req.fillInStater == 1">
- pgd1.distribute_price is null
- </if>
- <if test="req.compareStater == 0">
- <if test="req.fillInStater != null">
- and
- </if>
- pgd1.distribute_price >= #{req.distributePrice}
- </if>
- <if test="req.compareStater == 1">
- <if test="req.fillInStater != null">
- and
- </if>
- pgd1.distribute_price <= #{req.distributePrice}
- </if>
- )
- </if>
- <if test="req.sellerTenantId != null and (req.fillInStater != null || req.compareStater != null)">
- and (
- <if test="req.fillInStater == 0">
- pgd.distribute_price is not null
- </if>
- <if test="req.fillInStater == 1">
- pgd.distribute_price is null
- </if>
- <if test="req.compareStater == 0">
- <if test="req.fillInStater != null">
- and
- </if>
- pgd.distribute_price >= #{req.distributePrice}
- </if>
- <if test="req.compareStater == 1">
- <if test="req.fillInStater != null">
- and
- </if>
- pgd.distribute_price <= #{req.distributePrice}
- </if>
- )
- </if>
- <if test="req.onSale != null">
- and pg.on_sale = #{req.onSale}
- </if>
- <if test="req.productName != null">
- <if test="req.isGoodsInclude == 1">
- and pg.product_name like concat('%',#{req.productName},'%')
- </if>
- <if test="req.isGoodsInclude == 0">
- and pg.product_name not like concat('%',#{req.productName},'%')
- </if>
- </if>
- <if test="req.shortName != null and req.shortName != ''">
- and pg.short_name = #{req.shortName}
- </if>
- <if test="req.shortNameFlag != null and req.shortNameFlag == 1">
- and pg.short_name is not null and pg.short_name != ''
- </if>
- <if test="req.weightFlag != null and req.weightFlag == 1">
- and (pg.weight is not null and pg.weight > 0)
- </if>
- <if test="req.weightFlag != null and req.weightFlag == 0">
- and (pg.weight is null or pg.weight = '' or pg.weight = 0)
- </if>
- <if test="req.skuShortName != null and req.skuShortName != ''">
- and pgs.sku_short_name = #{req.skuShortName}
- </if>
- <if test="req.skuShortNameFlag != null and req.skuShortNameFlag == 1">
- and pgs.sku_short_name is not null and pgs.sku_short_name != ''
- </if>
- <if test="req.skuWeightFlag != null and req.skuWeightFlag == 1">
- and (pgs.sku_weight is not null and pgs.sku_weight > 0)
- </if>
- <if test="req.skuWeightFlag != null and req.skuWeightFlag == 0">
- and (pgs.sku_weight is null or pgs.sku_weight = '' or pgs.sku_weight = 0)
- </if>
- <if test="req.productOutIdList != null">
- and pg.product_out_id in
- <foreach collection="req.productOutIdList" item="productOutId" open="("
- close=")" separator=",">
- #{productOutId}
- </foreach>
- </if>
- <if test="req.skuName != null and req.skuName != ''">
- <if test="req.isSkuInclude == 1">
- and pgs.sku_name like concat('%',#{req.skuName},'%')
- </if>
- <if test="req.isSkuInclude == 0">
- and pgs.sku_name not like concat('%',#{req.skuName},'%')
- </if>
- </if>
- <if test="req.productId != null and req.productId != ''">
- and pg.product_id = #{req.productId}
- </if>
- <if test="req.skuId != null and req.skuId != ''">
- and pgs.sku_id = #{req.skuId}
- </if>
- <if test="req.allocationStatus != null and req.allocationStatus != ''">
- and pgd.allocation_status = #{req.allocationStatus}
- </if>
- <if test="req.productBizIds != null">
- and pg.biz_id in <foreach collection="req.productBizIds" item="item" open="(" close=")" separator=",">#{item}</foreach>
- </if>
- </sql>
- <sql id="sort_condition">
- <if test="req.sort == '0'">
- order BY temp.create_time asc
- </if>
- <if test="req.sort == '1'">
- order BY temp.create_time desc
- </if>
- limit #{req.pageStart},#{req.pageSize}
- </sql>
- </mapper>
|