PlatformGoodsExtMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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.foonsu.efenxiao.platform.mapper.PlatformGoodsExtMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="goodsResultMap" type="com.foonsu.efenxiao.platform.vo.PlatformGoodsVO"
  6. extends="com.foonsu.efenxiao.platform.mapper.PlatformGoodsMapper.platformGoodsResultMap">
  7. <result column="shop_name" property="shopName"/>
  8. <result column="goods_pic_path" property="picPath"/>
  9. <collection property="goodsSkuList" ofType="com.foonsu.efenxiao.platform.vo.PlatformGoodsSkuVO">
  10. <id column="goodsSkuId" property="id"/>
  11. <result column="goodsSkuBizId" property="bizId"/>
  12. <result column="productId" property="productId"/>
  13. <result column="sku_id" property="skuId"/>
  14. <result column="sku_name" property="skuName"/>
  15. <result column="sku_out_id" property="skuOutId"/>
  16. <result column="sku_price" property="skuPrice"/>
  17. <result column="sku_weight" property="skuWeight"/>
  18. <result column="sku_short_name" property="skuShortName"/>
  19. <result column="shopBizId" property="shopBizId"/>
  20. <result column="shopTenantId" property="shopTenantId"/>
  21. <result column="skuOnSale" property="onSale"/>
  22. <result column="sku_pic_path" property="picPath"/>
  23. <result column="color_spec" property="colorSpec"/>
  24. <result column="size_spec" property="sizeSpec"/>
  25. </collection>
  26. <collection property="distributeList" ofType="com.foonsu.efenxiao.platform.vo.PlatformGoodsDistributeVO">
  27. <id column="goodsDistributeId" property="id"/>
  28. <result column="goodsDistributeBizId" property="bizId"/>
  29. <result column="seller_tenant_id" property="sellerTenantId"/>
  30. <result column="factory_tenant_id" property="factoryTenantId"/>
  31. <result column="factory_tenant_account" property="factoryTenantAccount"/>
  32. <result column="dGoodsBizId" property="goodsBizId"/>
  33. <result column="dSkuBizId" property="skuBizId"/>
  34. <result column="allocation_status" property="allocationStatus"/>
  35. </collection>
  36. </resultMap>
  37. <sql id="Base_Column_List">
  38. pg.id,
  39. pg.biz_id,
  40. pg.product_id,
  41. pg.product_name,
  42. pg.product_out_id,
  43. pg.price,
  44. pg.weight,
  45. pg.short_name,
  46. pg.shop_biz_id,
  47. pg.shop_tenant_id,
  48. pg.shop_platform,
  49. pg.on_sale,
  50. pg.create_time,
  51. pg.pic_path goods_pic_path
  52. </sql>
  53. <sql id="Base_sku_Column_List">
  54. pgs.id goodsSkuId,
  55. pgs.biz_id goodsSkuBizId,
  56. pgs.product_id productId,
  57. pgs.sku_id,
  58. pgs.sku_name,
  59. pgs.sku_out_id,
  60. pgs.sku_price,
  61. pgs.sku_weight,
  62. pgs.sku_short_name,
  63. pgs.shop_biz_id shopBizId,
  64. pgs.shop_tenant_id shopTenantId,
  65. pgs.on_sale skuOnSale,
  66. pgs.pic_path sku_pic_path,
  67. pgs.color_spec,
  68. pgs.size_spec
  69. </sql>
  70. <!-- <sql id="Base_distribute_Column_List">
  71. pgd.id goodsDistributeId,
  72. pgd.biz_id goodsDistributeBizId,
  73. pgd.seller_tenant_id,
  74. pgd.factory_tenant_id,
  75. pgd.goods_biz_id dGoodsBizId,
  76. pgd.sku_biz_id dSkuBizId,
  77. pgd.allocation_status,
  78. pgd.factory_tenant_account
  79. </sql>-->
  80. <select id="countPlatformGoodsPage" resultType="int">
  81. select count(distinct biz_id) from(
  82. select pg.biz_id from i_platform_goods pg
  83. inner join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
  84. inner join i_shop s on s.biz_id = pg.shop_biz_id
  85. 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}
  86. 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}
  87. where pgs.id is not null
  88. <include refid="search_condition" />
  89. union
  90. select pg.biz_id from i_platform_goods pg
  91. left join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
  92. inner join i_shop s on s.biz_id = pg.shop_biz_id
  93. 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} )
  94. 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} )
  95. where pgs.id is null
  96. <include refid="search_condition" />
  97. ) temp
  98. </select>
  99. <select id="selectPlatformGoodsPageBizId" resultType="int">
  100. select distinct biz_id from(
  101. select pg.biz_id from i_platform_goods pg
  102. inner join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
  103. inner join i_shop s on s.biz_id = pg.shop_biz_id
  104. 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}
  105. 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}
  106. where pgs.id is not null
  107. <include refid="search_condition" />
  108. union
  109. select pg.biz_id from i_platform_goods pg
  110. left join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
  111. inner join i_shop s on s.biz_id = pg.shop_biz_id
  112. 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} )
  113. 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} )
  114. where pgs.id is null
  115. <include refid="search_condition" />
  116. ) temp
  117. <include refid="sort_condition" />
  118. </select>
  119. <select id="selectPlatformGoodsPageData" resultMap="goodsResultMap">
  120. select <include refid="Base_Column_List" />, <include refid="Base_sku_Column_List" />, s.shop_name
  121. from i_platform_goods pg
  122. left join i_platform_goods_sku pgs on pg.product_id = pgs.product_id and pg.shop_biz_id = pgs.shop_biz_id
  123. inner join i_shop s on s.biz_id = pg.shop_biz_id
  124. where pg.biz_id in <foreach collection="req.productBizIds" item="item" open="(" close=")" separator=",">#{item}</foreach>
  125. </select>
  126. <sql id="search_condition">
  127. <if test="req.shopPlatforms != null">
  128. and pg.shop_platform in <foreach collection="req.shopPlatforms" open="(" close=")" separator="," item="item">#{item}</foreach>
  129. </if>
  130. <if test="req.shopBizId != null">
  131. and pg.shop_biz_id = #{req.shopBizId}
  132. </if>
  133. <if test="req.factoryTenantId != null">
  134. and pgd1.factory_tenant_id = #{req.factoryTenantId}
  135. </if>
  136. <if test="req.sellerTenantId != null">
  137. and pgd.seller_tenant_id = #{req.sellerTenantId}
  138. </if>
  139. <if test="req.factoryTenantId != null and (req.fillInStater != null || req.compareStater != null)">
  140. and (
  141. <if test="req.fillInStater == 0">
  142. pgd1.distribute_price is not null
  143. </if>
  144. <if test="req.fillInStater == 1">
  145. pgd1.distribute_price is null
  146. </if>
  147. <if test="req.compareStater == 0">
  148. <if test="req.fillInStater != null">
  149. and
  150. </if>
  151. pgd1.distribute_price &gt;= #{req.distributePrice}
  152. </if>
  153. <if test="req.compareStater == 1">
  154. <if test="req.fillInStater != null">
  155. and
  156. </if>
  157. pgd1.distribute_price &lt;= #{req.distributePrice}
  158. </if>
  159. )
  160. </if>
  161. <if test="req.sellerTenantId != null and (req.fillInStater != null || req.compareStater != null)">
  162. and (
  163. <if test="req.fillInStater == 0">
  164. pgd.distribute_price is not null
  165. </if>
  166. <if test="req.fillInStater == 1">
  167. pgd.distribute_price is null
  168. </if>
  169. <if test="req.compareStater == 0">
  170. <if test="req.fillInStater != null">
  171. and
  172. </if>
  173. pgd.distribute_price &gt;= #{req.distributePrice}
  174. </if>
  175. <if test="req.compareStater == 1">
  176. <if test="req.fillInStater != null">
  177. and
  178. </if>
  179. pgd.distribute_price &lt;= #{req.distributePrice}
  180. </if>
  181. )
  182. </if>
  183. <if test="req.onSale != null">
  184. and pg.on_sale = #{req.onSale}
  185. </if>
  186. <if test="req.productName != null">
  187. <if test="req.isGoodsInclude == 1">
  188. and pg.product_name like concat('%',#{req.productName},'%')
  189. </if>
  190. <if test="req.isGoodsInclude == 0">
  191. and pg.product_name not like concat('%',#{req.productName},'%')
  192. </if>
  193. </if>
  194. <if test="req.shortName != null and req.shortName != ''">
  195. and pg.short_name = #{req.shortName}
  196. </if>
  197. <if test="req.shortNameFlag != null and req.shortNameFlag == 1">
  198. and pg.short_name is not null and pg.short_name != ''
  199. </if>
  200. <if test="req.weightFlag != null and req.weightFlag == 1">
  201. and (pg.weight is not null and pg.weight > 0)
  202. </if>
  203. <if test="req.weightFlag != null and req.weightFlag == 0">
  204. and (pg.weight is null or pg.weight = '' or pg.weight = 0)
  205. </if>
  206. <if test="req.skuShortName != null and req.skuShortName != ''">
  207. and pgs.sku_short_name = #{req.skuShortName}
  208. </if>
  209. <if test="req.skuShortNameFlag != null and req.skuShortNameFlag == 1">
  210. and pgs.sku_short_name is not null and pgs.sku_short_name != ''
  211. </if>
  212. <if test="req.skuWeightFlag != null and req.skuWeightFlag == 1">
  213. and (pgs.sku_weight is not null and pgs.sku_weight > 0)
  214. </if>
  215. <if test="req.skuWeightFlag != null and req.skuWeightFlag == 0">
  216. and (pgs.sku_weight is null or pgs.sku_weight = '' or pgs.sku_weight = 0)
  217. </if>
  218. <if test="req.productOutIdList != null">
  219. and pg.product_out_id in
  220. <foreach collection="req.productOutIdList" item="productOutId" open="("
  221. close=")" separator=",">
  222. #{productOutId}
  223. </foreach>
  224. </if>
  225. <if test="req.skuName != null and req.skuName != ''">
  226. <if test="req.isSkuInclude == 1">
  227. and pgs.sku_name like concat('%',#{req.skuName},'%')
  228. </if>
  229. <if test="req.isSkuInclude == 0">
  230. and pgs.sku_name not like concat('%',#{req.skuName},'%')
  231. </if>
  232. </if>
  233. <if test="req.productId != null and req.productId != ''">
  234. and pg.product_id = #{req.productId}
  235. </if>
  236. <if test="req.skuId != null and req.skuId != ''">
  237. and pgs.sku_id = #{req.skuId}
  238. </if>
  239. <if test="req.allocationStatus != null and req.allocationStatus != ''">
  240. and pgd.allocation_status = #{req.allocationStatus}
  241. </if>
  242. <if test="req.productBizIds != null">
  243. and pg.biz_id in <foreach collection="req.productBizIds" item="item" open="(" close=")" separator=",">#{item}</foreach>
  244. </if>
  245. </sql>
  246. <sql id="sort_condition">
  247. <if test="req.sort == '0'">
  248. order BY temp.create_time asc
  249. </if>
  250. <if test="req.sort == '1'">
  251. order BY temp.create_time desc
  252. </if>
  253. limit #{req.pageStart},#{req.pageSize}
  254. </sql>
  255. </mapper>