123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?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.yonge.cooleshow.admin.dao.PmsProductDao">
- <resultMap id="updateInfoMap" type="com.yonge.cooleshow.admin.dto.PmsProductResult" extends="com.yonge.cooleshow.mbg.mapper.PmsProductMapper.ResultMapWithBLOBs">
- <result column="cateParentId" jdbcType="BIGINT" property="cateParentId" />
- <collection property="productLadderList" columnPrefix="ladder_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductLadderMapper.BaseResultMap">
- </collection>
- <collection property="productFullReductionList" columnPrefix="full_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductFullReductionMapper.BaseResultMap">
- </collection>
- <collection property="memberPriceList" columnPrefix="member_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsMemberPriceMapper.BaseResultMap">
- </collection>
- <collection property="skuStockList" columnPrefix="sku_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsSkuStockMapper.BaseResultMap">
- </collection>
- <collection property="productAttributeValueList" columnPrefix="attribute_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductAttributeValueMapper.BaseResultMap">
- </collection>
- <collection property="subjectProductRelationList" column="{productId=id}" select="selectSubjectProductRelationByProductId"/>
- <collection property="prefrenceAreaProductRelationList" column="{productId=id}" select="selectPrefrenceAreaProductRelationByProductId"/>
- </resultMap>
- <select id="getUpdateInfo" resultMap="updateInfoMap">
- SELECT *,
- pc.parent_id cateParentId,
- l.id ladder_id,l.product_id ladder_product_id,l.discount ladder_discount,l.count ladder_count,l.price ladder_price,
- pf.id full_id,pf.product_id full_product_id,pf.full_price full_full_price,pf.reduce_price full_reduce_price,
- m.id member_id,m.product_id member_product_id,m.member_level_id member_member_level_id,m.member_price member_member_price,m.member_level_name member_member_level_name,
- s.id sku_id,s.product_id sku_product_id,s.price sku_price,s.low_stock sku_low_stock,s.pic sku_pic,s.sale sku_sale,s.sku_code sku_sku_code,s.stock sku_stock,s.sp_data sku_sp_data,
- a.id attribute_id,a.product_id attribute_product_id,a.product_attribute_id attribute_product_attribute_id,a.value attribute_value
- FROM pms_product p
- LEFT JOIN pms_product_category pc on pc.id = p.product_category_id
- LEFT JOIN pms_product_ladder l ON p.id = l.product_id
- LEFT JOIN pms_product_full_reduction pf ON pf.product_id=p.id
- LEFT JOIN pms_member_price m ON m.product_id = p.id
- LEFT JOIN pms_sku_stock s ON s.product_id = p.id
- LEFT JOIN pms_product_attribute_value a ON a.product_id=p.id
- WHERE p.id=#{id} and (s.delete_status = 0 )
- </select>
- <select id="selectSubjectProductRelationByProductId" resultMap="com.yonge.cooleshow.mbg.mapper.CmsSubjectProductRelationMapper.BaseResultMap">
- select * from cms_subject_product_relation where product_id=#{productId}
- </select>
- <select id="selectPrefrenceAreaProductRelationByProductId" resultMap="com.yonge.cooleshow.mbg.mapper.CmsPrefrenceAreaProductRelationMapper.BaseResultMap">
- select * from cms_prefrence_area_product_relation where product_id=#{productId}
- </select>
- <select id="selectLowStockCount" resultType="com.yonge.cooleshow.admin.dto.HomeStatistical">
- select DISTINCT count(pp.id) as outStockProduct,
- count(pp.id) as outStock
- from
- pms_product pp
- left join
- (select DISTINCT pss.product_id
- from pms_sku_stock pss
- left join pms_product_sku_stock_record t3 on t3.product_sku_id= pss.id
- where pss.delete_status = 0
- group by pss.product_id,pss.id,pss.low_stock
- having sum(t3.internal_stock - t3.internal_sale_stock) <= pss.low_stock) b
- on b.product_id = pp.id
- where (pp.stock <= pp.low_stock or b.product_id is not null) and pp.delete_status = 0
- </select>
- <select id="selectProductShowStatusCount" resultType="com.yonge.cooleshow.admin.dto.HomeStatistical">
- select
- sum(if(publish_status = 1,1,0)) as shelves,
- sum(if(publish_status = 1,0,1)) as delisted,
- count(0) as productNum
- from pms_product where delete_status = 0
- </select>
- <select id="list" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductMapper.BaseResultMap">
- select DISTINCT pp.*
- from
- pms_product pp
- <if test="param.stock != null">
- left join
- (select DISTINCT pss.product_id
- from pms_sku_stock pss
- left join pms_product_sku_stock_record t3 on t3.product_sku_id= pss.id
- where pss.delete_status = 0
- group by pss.product_id,pss.id,pss.low_stock
- having sum(t3.internal_stock - t3.internal_sale_stock) <= pss.low_stock) b
- on b.product_id = pp.id
- </if>
- <where>
- pp.delete_status = 0
- <if test="param.publishStatus != null">
- and pp.publish_status = #{param.publishStatus}
- </if>
- <if test="param.verifyStatus != null">
- and pp.verify_status = #{param.verifyStatus}
- </if>
- <if test="param.keyword != null">
- and pp.name like concat('%',#{param.keyword},'%')
- </if>
- <if test="param.productSn != null">
- and pp.product_sn = #{param.productSn}
- </if>
- <if test="param.brandId != null">
- and pp.brand_id = #{param.brandId}
- </if>
- <if test="param.productCategoryId != null">
- and pp.product_category_id = #{param.productCategoryId}
- </if>
- <if test="param.stock == 1">
- and ( b.product_id is not null)
- </if>
- <if test="param.stock == 0">
- and (b.product_id is null)
- </if>
- </where>
- order by pp.sort desc,pp.id desc
- </select>
- <select id="getFeignProductList" resultType="com.ym.mec.common.dto.PmsProductDto">
- select t1.id as skuStockId,
- t.id as goodsId,
- t1.sku_code as skuCode,
- t.name as name,
- t.product_sn as productSn,
- t.delete_status as deleteStatus,
- t.publish_status as publishStatus,
- t1.price as price,
- t.brand_id as brandId,
- t.product_category_id as productCategoryId,
- t1.sp_data as spData
- from pms_product t
- left join pms_sku_stock t1 on t.id = t1.product_id
- <where>
- t.delete_status = 0 and (t1.delete_status = 0)
- <if test="param.publishStatus != null">
- and t.publish_status = #{param.publishStatus}
- </if>
- <if test="param.skuStockIds != null and param.skuStockIds != ''">
- and find_in_set(t1.id,#{param.skuStockIds})
- </if>
- <if test="param.skuStockCodes != null and param.skuStockCodes != ''">
- and find_in_set(t1.sku_code,#{param.skuStockCodes})
- </if>
- <if test="param.keyword != null and param.keyword != ''">
- and (t.name like concat('%',#{param.keyword},'%') )
- </if>
- <if test="param.productSn != null and param.productSn != ''">
- and t.product_sn like concat('%',#{param.productSn},'%')
- </if>
- <if test="param.brandId != null">
- and t.brand_id = #{param.brandId}
- </if>
- <if test="param.productCategoryId != null">
- and t.product_category_id = #{param.productCategoryId}
- </if>
- <if test="param.productIds != null and param.productIds != ''">
- and find_in_set(t.id,#{param.productIds})
- </if>
- <if test="param.excludeProductIds != null and param.excludeProductIds != ''">
- and find_in_set(t.id,#{param.excludeProductIds}) = 0
- </if>
- </where>
- </select>
- </mapper>
|