ApiMkStoreCampMinusGoodsMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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.kmall.api.dao.mk.ApiMkStoreCampMinusGoodsMapper">
  4. <resultMap type="com.kmall.api.entity.mk.MkStoreCampMinusGoodsVo" id="mkStoreCampMinusGoodsMap">
  5. <result property="minusGoodId" column="minus_good_id"/>
  6. <result property="campMinusId" column="camp_minus_id"/>
  7. <result property="applyType" column="apply_type"/>
  8. <result property="storeRelaId" column="store_rela_id"/>
  9. <result property="isValid" column="is_valid"/>
  10. <result property="note" column="note"/>
  11. <result property="createrSn" column="creater_sn"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="moderSn" column="moder_sn"/>
  14. <result property="modTime" column="mod_time"/>
  15. <result property="tstm" column="tstm"/>
  16. </resultMap>
  17. <!-- 可根据自己的需求,是否要使用 -->
  18. <resultMap type="com.kmall.api.entity.GoodsVo" id="goodsMap">
  19. <result property="id" column="id"/>
  20. <result property="category_id" column="category_id"/>
  21. <result property="goods_sn" column="goods_sn"/>
  22. <result property="name" column="name"/>
  23. <result property="brand_id" column="brand_id"/>
  24. <result property="goods_number" column="goods_number"/>
  25. <result property="keywords" column="keywords"/>
  26. <result property="goods_brief" column="goods_brief"/>
  27. <result property="goods_desc" column="goods_desc"/>
  28. <result property="is_on_sale" column="is_on_sale"/>
  29. <result property="add_time" column="add_time"/>
  30. <result property="sort_order" column="sort_order"/>
  31. <result property="is_delete" column="is_delete"/>
  32. <result property="attribute_category" column="attribute_category"/>
  33. <result property="counter_price" column="counter_price"/>
  34. <result property="extra_price" column="extra_price"/>
  35. <result property="is_new" column="is_new"/>
  36. <result property="goods_unit" column="goods_unit"/>
  37. <result property="primary_pic_url" column="primary_pic_url"/>
  38. <result property="list_pic_url" column="list_pic_url"/>
  39. <result property="retail_price" column="retail_price"/>
  40. <result property="market_price" column="market_price"/>
  41. <result property="sell_volume" column="sell_volume"/>
  42. <result property="primary_product_id" column="primary_product_id"/>
  43. <result property="unit_price" column="unit_price"/>
  44. <result property="promotion_desc" column="promotion_desc"/>
  45. <result property="promotion_tag" column="promotion_tag"/>
  46. <result property="app_exclusive_price" column="app_exclusive_price"/>
  47. <result property="is_app_exclusive" column="is_app_exclusive"/>
  48. <result property="is_limited" column="is_limited"/>
  49. <result property="is_hot" column="is_hot"/>
  50. <result property="product_id" column="product_id"/>
  51. <result property="sku" column="sku"/>
  52. <result property="goodsBizType" column="goods_biz_type"/>
  53. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  54. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  55. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  56. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  57. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  58. <result property="goodsRate" column="goods_rate"/>
  59. <result property="stockNum" column="stock_num"/>
  60. <result property="storeId" column="store_id"/>
  61. <result property="merchSn" column="merch_sn"/>
  62. <result property="merchName" column="merch_name"/>
  63. <result column="third_party_merch_code" property="thirdPartyMerchCode" />
  64. <result column="isStockShare" property="isStockShare" />
  65. <result property="goods_sell_volume" column="goods_sell_volume"/>
  66. </resultMap>
  67. <select id="queryObject" resultType="com.kmall.api.entity.mk.MkStoreCampMinusGoodsVo">
  68. select
  69. `minus_good_id`,
  70. `camp_minus_id`,
  71. `apply_type`,
  72. `store_rela_id`,
  73. `is_valid`,
  74. `note`,
  75. `creater_sn`,
  76. `create_time`,
  77. `moder_sn`,
  78. `mod_time`,
  79. `tstm`
  80. from mk_store_camp_minus_goods
  81. where minus_good_id = #{id}
  82. </select>
  83. <select id="queryList" resultType="com.kmall.api.entity.mk.MkStoreCampMinusGoodsVo">
  84. select
  85. `minus_good_id`,
  86. `camp_minus_id`,
  87. `apply_type`,
  88. `store_rela_id`,
  89. `is_valid`,
  90. `note`,
  91. `creater_sn`,
  92. `create_time`,
  93. `moder_sn`,
  94. `mod_time`,
  95. `tstm`
  96. from mk_store_camp_minus_goods
  97. WHERE 1=1
  98. <if test="name != null and name.trim() != ''">
  99. AND name LIKE concat('%',#{name},'%')
  100. </if>
  101. <choose>
  102. <when test="sidx != null and sidx.trim() != ''">
  103. order by ${sidx} ${order}
  104. </when>
  105. <otherwise>
  106. order by minus_good_id desc
  107. </otherwise>
  108. </choose>
  109. <if test="offset != null and limit != null">
  110. limit #{offset}, #{limit}
  111. </if>
  112. </select>
  113. <select id="queryTotal" resultType="int">
  114. select count(*) from mk_store_camp_minus_goods
  115. WHERE 1=1
  116. <if test="name != null and name.trim() != ''">
  117. AND name LIKE concat('%',#{name},'%')
  118. </if>
  119. </select>
  120. <select id="queryCampMinusGoodsList" resultMap="goodsMap">
  121. select
  122. <if test="fields != null and fields != ''">
  123. ${fields}
  124. </if>
  125. <if test="fields == null or fields == ''">
  126. a.*,b.id as product_id,psr1.category_id,psr1.brand_id,psr1.attribute_category
  127. </if>
  128. ,a.goods_biz_type,
  129. a.goods_number,
  130. a.third_party_merch_code third_party_merch_code,
  131. mb.is_stock_share isStockShare,psr1.store_id,
  132. ( SELECT sum( number ) FROM mall_cart WHERE goods_id = a.id AND store_id = psr1.store_id ) cart_num
  133. FROM
  134. mall_goods a
  135. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id
  136. AND a.merch_sn = psr1.merch_sn
  137. LEFT JOIN mk_store_camp_minus_goods g ON psr1.id = g.store_rela_id
  138. <if test="campMinusId != null and campMinusId != ''">
  139. and g.camp_minus_id = #{campMinusId}
  140. </if>
  141. LEFT JOIN third_merchant_biz mb ON mb.third_party_merch_code = a.third_party_merch_code
  142. AND mb.merch_sn = a.merch_sn
  143. LEFT JOIN mall_product b ON b.id = psr1.product_id
  144. LEFT JOIN mall_category c ON psr1.category_id = c.id
  145. WHERE 1 = 1
  146. <if test="applyType != null and applyType == '01'">
  147. <if test="campMinusId != null and campMinusId != ''">
  148. and g.camp_minus_id = #{campMinusId}
  149. </if>
  150. </if>
  151. <if test="applyType != null and applyType == '02'">
  152. and psr1.id not in(SELECT store_rela_id FROM mk_store_camp_minus_goods WHERE camp_minus_id = #{campMinusId})
  153. </if>
  154. <if test="isStockShare == 1">
  155. and (a.goods_number > 0 or psr1.stock_num > 0 )
  156. </if>
  157. <if test="isStockShare == 0">
  158. and psr1.stock_num > 0
  159. </if>
  160. and b.id is not null and a.is_delete != 1 and psr1.retail_price is not null and a.is_on_sale = 1
  161. <if test="is_new != null and is_new != ''">
  162. and a.is_new = #{is_new}
  163. </if>
  164. <if test="brand_id != null and brand_id != ''">
  165. and psr1.brand_id = #{brand_id}
  166. </if>
  167. <if test="category_id != null and category_id != ''">
  168. and psr1.category_id = #{category_id}
  169. </if>
  170. <if test="keyword != null">
  171. and a.keywords like concat('%',#{keyword},'%')
  172. </if>
  173. <if test="categoryIds != null">
  174. and psr1.category_id in
  175. <foreach item="item" collection="categoryIds" open="(" separator="," close=")">
  176. #{item}
  177. </foreach>
  178. </if>
  179. <if test="category_parent_id != null and category_parent_id != null and category_parent_id != 0">
  180. and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
  181. </if>
  182. <if test="goodsId != null and goodsId != ''">
  183. and a.id = #{goodsId}
  184. </if>
  185. <if test="store_id != null and store_id != ''">
  186. and psr1.store_id = #{store_id}
  187. </if>
  188. <if test="goodsBizType != null and goodsBizType != ''">
  189. and a.goods_biz_type = #{goodsBizType}
  190. </if>
  191. <choose>
  192. <when test="sidx != null and sidx.trim() != ''">
  193. order by ${sidx} ${order}
  194. </when>
  195. <otherwise>
  196. order by a.id desc
  197. </otherwise>
  198. </choose>
  199. <if test="offset != null and limit != null">
  200. limit #{offset}, #{limit}
  201. </if>
  202. </select>
  203. <select id="queryCampMinusGoodsTotal" resultType="int">
  204. select count(*)
  205. FROM
  206. mall_goods a
  207. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id
  208. AND a.merch_sn = psr1.merch_sn
  209. LEFT JOIN mk_store_camp_minus_goods g ON psr1.id = g.store_rela_id
  210. <if test="campMinusId != null and campMinusId != ''">
  211. and g.camp_minus_id = #{campMinusId}
  212. </if>
  213. LEFT JOIN third_merchant_biz mb ON mb.third_party_merch_code = a.third_party_merch_code
  214. AND mb.merch_sn = a.merch_sn
  215. LEFT JOIN mall_product b ON b.id = psr1.product_id
  216. LEFT JOIN mall_category c ON psr1.category_id = c.id
  217. WHERE 1 = 1
  218. <if test="applyType != null and applyType == '01'">
  219. <if test="campMinusId != null and campMinusId != ''">
  220. and g.camp_minus_id = #{campMinusId}
  221. </if>
  222. </if>
  223. <if test="applyType != null and applyType == '02'">
  224. and psr1.id not in(SELECT store_rela_id FROM mk_store_camp_minus_goods WHERE camp_minus_id = #{campMinusId})
  225. </if>
  226. <if test="isStockShare == 1">
  227. and (a.goods_number > 0 or psr1.stock_num > 0 )
  228. </if>
  229. <if test="isStockShare == 0">
  230. and psr1.stock_num > 0
  231. </if>
  232. and b.id is not null and a.is_delete != 1 and psr1.retail_price is not null and a.is_on_sale = 1
  233. <if test="is_new != null and is_new != ''">
  234. and a.is_new = #{is_new}
  235. </if>
  236. <if test="brand_id != null and brand_id != ''">
  237. and psr1.brand_id = #{brand_id}
  238. </if>
  239. <if test="category_id != null and category_id != ''">
  240. and psr1.category_id = #{category_id}
  241. </if>
  242. <if test="keyword != null">
  243. and a.keywords like concat('%',#{keyword},'%')
  244. </if>
  245. <if test="categoryIds != null">
  246. and psr1.category_id in
  247. <foreach item="item" collection="categoryIds" open="(" separator="," close=")">
  248. #{item}
  249. </foreach>
  250. </if>
  251. <if test="category_parent_id != null and category_parent_id != null and category_parent_id != 0">
  252. and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
  253. </if>
  254. <if test="goodsId != null and goodsId != ''">
  255. and a.id = #{goodsId}
  256. </if>
  257. <if test="store_id != null and store_id != ''">
  258. and psr1.store_id = #{store_id}
  259. </if>
  260. <if test="goodsBizType != null and goodsBizType != ''">
  261. and a.goods_biz_type = #{goodsBizType}
  262. </if>
  263. </select>
  264. </mapper>