PmsProductDao.xml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.yonge.cooleshow.admin.dao.PmsProductDao">
  4. <resultMap id="updateInfoMap" type="com.yonge.cooleshow.admin.dto.PmsProductResult" extends="com.yonge.cooleshow.mbg.mapper.PmsProductMapper.ResultMapWithBLOBs">
  5. <result column="cateParentId" jdbcType="BIGINT" property="cateParentId" />
  6. <collection property="productLadderList" columnPrefix="ladder_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductLadderMapper.BaseResultMap">
  7. </collection>
  8. <collection property="productFullReductionList" columnPrefix="full_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductFullReductionMapper.BaseResultMap">
  9. </collection>
  10. <collection property="memberPriceList" columnPrefix="member_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsMemberPriceMapper.BaseResultMap">
  11. </collection>
  12. <collection property="skuStockList" columnPrefix="sku_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsSkuStockMapper.BaseResultMap">
  13. </collection>
  14. <collection property="productAttributeValueList" columnPrefix="attribute_" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductAttributeValueMapper.BaseResultMap">
  15. </collection>
  16. <collection property="subjectProductRelationList" column="{productId=id}" select="selectSubjectProductRelationByProductId"/>
  17. <collection property="prefrenceAreaProductRelationList" column="{productId=id}" select="selectPrefrenceAreaProductRelationByProductId"/>
  18. </resultMap>
  19. <select id="getUpdateInfo" resultMap="updateInfoMap">
  20. SELECT *,
  21. pc.parent_id cateParentId,
  22. l.id ladder_id,l.product_id ladder_product_id,l.discount ladder_discount,l.count ladder_count,l.price ladder_price,
  23. pf.id full_id,pf.product_id full_product_id,pf.full_price full_full_price,pf.reduce_price full_reduce_price,
  24. 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,
  25. 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,
  26. a.id attribute_id,a.product_id attribute_product_id,a.product_attribute_id attribute_product_attribute_id,a.value attribute_value
  27. FROM pms_product p
  28. LEFT JOIN pms_product_category pc on pc.id = p.product_category_id
  29. LEFT JOIN pms_product_ladder l ON p.id = l.product_id
  30. LEFT JOIN pms_product_full_reduction pf ON pf.product_id=p.id
  31. LEFT JOIN pms_member_price m ON m.product_id = p.id
  32. LEFT JOIN pms_sku_stock s ON s.product_id = p.id
  33. LEFT JOIN pms_product_attribute_value a ON a.product_id=p.id
  34. WHERE p.id=#{id} and (s.delete_status = 0 )
  35. </select>
  36. <select id="selectSubjectProductRelationByProductId" resultMap="com.yonge.cooleshow.mbg.mapper.CmsSubjectProductRelationMapper.BaseResultMap">
  37. select * from cms_subject_product_relation where product_id=#{productId}
  38. </select>
  39. <select id="selectPrefrenceAreaProductRelationByProductId" resultMap="com.yonge.cooleshow.mbg.mapper.CmsPrefrenceAreaProductRelationMapper.BaseResultMap">
  40. select * from cms_prefrence_area_product_relation where product_id=#{productId}
  41. </select>
  42. <select id="selectLowStockCount" resultType="com.yonge.cooleshow.admin.dto.HomeStatistical">
  43. select DISTINCT count(pp.id) as outStockProduct,
  44. count(pp.id) as outStock
  45. from
  46. pms_product pp
  47. left join
  48. (select DISTINCT pss.product_id
  49. from pms_sku_stock pss
  50. left join pms_product_sku_stock_record t3 on t3.product_sku_id= pss.id
  51. where pss.delete_status = 0
  52. group by pss.product_id,pss.id,pss.low_stock
  53. having sum(t3.internal_stock - t3.internal_sale_stock) &lt;= pss.low_stock) b
  54. on b.product_id = pp.id
  55. where (pp.stock &lt;= pp.low_stock or b.product_id is not null) and pp.delete_status = 0
  56. </select>
  57. <select id="selectProductShowStatusCount" resultType="com.yonge.cooleshow.admin.dto.HomeStatistical">
  58. select
  59. sum(if(publish_status = 1,1,0)) as shelves,
  60. sum(if(publish_status = 1,0,1)) as delisted,
  61. count(0) as productNum
  62. from pms_product where delete_status = 0
  63. </select>
  64. <select id="list" resultMap="com.yonge.cooleshow.mbg.mapper.PmsProductMapper.BaseResultMap">
  65. select DISTINCT pp.*
  66. from
  67. pms_product pp
  68. <if test="param.stock != null">
  69. left join
  70. (select DISTINCT pss.product_id
  71. from pms_sku_stock pss
  72. left join pms_product_sku_stock_record t3 on t3.product_sku_id= pss.id
  73. where pss.delete_status = 0
  74. group by pss.product_id,pss.id,pss.low_stock
  75. having sum(t3.internal_stock - t3.internal_sale_stock) &lt;= pss.low_stock) b
  76. on b.product_id = pp.id
  77. </if>
  78. <where>
  79. pp.delete_status = 0
  80. <if test="param.publishStatus != null">
  81. and pp.publish_status = #{param.publishStatus}
  82. </if>
  83. <if test="param.verifyStatus != null">
  84. and pp.verify_status = #{param.verifyStatus}
  85. </if>
  86. <if test="param.keyword != null">
  87. and pp.name like concat('%',#{param.keyword},'%')
  88. </if>
  89. <if test="param.productSn != null">
  90. and pp.product_sn = #{param.productSn}
  91. </if>
  92. <if test="param.brandId != null">
  93. and pp.brand_id = #{param.brandId}
  94. </if>
  95. <if test="param.productCategoryId != null">
  96. and pp.product_category_id = #{param.productCategoryId}
  97. </if>
  98. <if test="param.stock == 1">
  99. and ( b.product_id is not null)
  100. </if>
  101. <if test="param.stock == 0">
  102. and (b.product_id is null)
  103. </if>
  104. </where>
  105. order by pp.sort desc,pp.id desc
  106. </select>
  107. <select id="getFeignProductList" resultType="com.ym.mec.common.dto.PmsProductDto">
  108. select t1.id as skuStockId,
  109. t.id as goodsId,
  110. t1.sku_code as skuCode,
  111. t.name as name,
  112. t.product_sn as productSn,
  113. t.delete_status as deleteStatus,
  114. t.publish_status as publishStatus,
  115. t1.price as price,
  116. t.brand_id as brandId,
  117. t.product_category_id as productCategoryId,
  118. t1.sp_data as spData
  119. from pms_product t
  120. left join pms_sku_stock t1 on t.id = t1.product_id
  121. <where>
  122. t.delete_status = 0 and (t1.delete_status = 0)
  123. <if test="param.publishStatus != null">
  124. and t.publish_status = #{param.publishStatus}
  125. </if>
  126. <if test="param.skuStockIds != null and param.skuStockIds != ''">
  127. and find_in_set(t1.id,#{param.skuStockIds})
  128. </if>
  129. <if test="param.skuStockCodes != null and param.skuStockCodes != ''">
  130. and find_in_set(t1.sku_code,#{param.skuStockCodes})
  131. </if>
  132. <if test="param.keyword != null and param.keyword != ''">
  133. and (t.name like concat('%',#{param.keyword},'%') )
  134. </if>
  135. <if test="param.productSn != null and param.productSn != ''">
  136. and t.product_sn like concat('%',#{param.productSn},'%')
  137. </if>
  138. <if test="param.brandId != null">
  139. and t.brand_id = #{param.brandId}
  140. </if>
  141. <if test="param.productCategoryId != null">
  142. and t.product_category_id = #{param.productCategoryId}
  143. </if>
  144. <if test="param.productIds != null and param.productIds != ''">
  145. and find_in_set(t.id,#{param.productIds})
  146. </if>
  147. <if test="param.excludeProductIds != null and param.excludeProductIds != ''">
  148. and find_in_set(t.id,#{param.excludeProductIds}) = 0
  149. </if>
  150. </where>
  151. </select>
  152. </mapper>