1
0

ApiMkStoreTicketDiscountGoodsMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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.ApiMkStoreTicketDiscountGoodsMapper">
  4. <resultMap type="com.kmall.api.entity.mk.MkStoreTicketDiscountGoodsVo" id="mkStoreTicketDiscountGoodsMap">
  5. <result property="discGoodId" column="disc_good_id"/>
  6. <result property="tickDiscId" column="tick_disc_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.MkStoreTicketDiscountGoodsVo">
  68. select
  69. `disc_good_id`,
  70. `tick_disc_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_ticket_discount_goods
  81. where disc_good_id = #{id}
  82. </select>
  83. <select id="queryObjectByStoreReal" resultType="com.kmall.api.entity.mk.MkStoreTicketDiscountGoodsVo">
  84. select
  85. `disc_good_id`,
  86. `tick_disc_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_ticket_discount_goods
  97. where tick_disc_id = #{tickDiscId} and store_rela_id = #{storeRelaId} and apply_type = #{applyType}
  98. </select>
  99. <select id="queryList" resultType="com.kmall.api.entity.mk.MkStoreTicketDiscountGoodsVo">
  100. select
  101. `disc_good_id`,
  102. `tick_disc_id`,
  103. `apply_type`,
  104. `store_rela_id`,
  105. `is_valid`,
  106. `note`,
  107. `creater_sn`,
  108. `create_time`,
  109. `moder_sn`,
  110. `mod_time`,
  111. `tstm`
  112. from mk_store_ticket_discount_goods
  113. WHERE 1=1
  114. <if test="name != null and name.trim() != ''">
  115. AND name LIKE concat('%',#{name},'%')
  116. </if>
  117. <choose>
  118. <when test="sidx != null and sidx.trim() != ''">
  119. order by ${sidx} ${order}
  120. </when>
  121. <otherwise>
  122. order by disc_good_id desc
  123. </otherwise>
  124. </choose>
  125. <if test="offset != null and limit != null">
  126. limit #{offset}, #{limit}
  127. </if>
  128. </select>
  129. <select id="queryTotal" resultType="int">
  130. select count(*) from mk_store_ticket_discount_goods
  131. WHERE 1=1
  132. <if test="name != null and name.trim() != ''">
  133. AND name LIKE concat('%',#{name},'%')
  134. </if>
  135. </select>
  136. <select id="queryDiscountGoodsList" resultMap="goodsMap">
  137. select
  138. <if test="fields != null and fields != ''">
  139. ${fields}
  140. </if>
  141. <if test="fields == null or fields == ''">
  142. a.*,b.id as product_id,psr1.category_id,psr1.brand_id,psr1.attribute_category
  143. </if>
  144. ,a.goods_biz_type,
  145. a.goods_number,
  146. a.third_party_merch_code third_party_merch_code,
  147. mb.is_stock_share isStockShare,psr1.store_id,
  148. ( SELECT sum( number ) FROM mall_cart WHERE goods_id = a.id AND store_id = psr1.store_id ) cart_num
  149. FROM
  150. mall_goods a
  151. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id
  152. AND a.merch_sn = psr1.merch_sn
  153. LEFT JOIN mk_store_ticket_discount_goods g ON psr1.id = g.store_rela_id
  154. <if test="tickDiscId != null and tickDiscId != ''">
  155. and g.tick_disc_id = #{tickDiscId}
  156. </if>
  157. LEFT JOIN third_merchant_biz mb ON mb.third_party_merch_code = a.third_party_merch_code
  158. AND mb.merch_sn = a.merch_sn
  159. LEFT JOIN mall_product b ON b.id = psr1.product_id
  160. LEFT JOIN mall_category c ON psr1.category_id = c.id
  161. WHERE 1 = 1
  162. <if test="applyType != null and applyType == '01'">
  163. <if test="tickDiscId != null and tickDiscId != ''">
  164. and g.tick_disc_id = #{tickDiscId}
  165. </if>
  166. </if>
  167. <if test="applyType != null and applyType == '02'">
  168. and psr1.id not in(SELECT store_rela_id FROM mk_store_ticket_discount_goods WHERE tick_disc_id = #{tickDiscId})
  169. </if>
  170. <if test="isStockShare == 1">
  171. and (a.goods_number > 0 or psr1.stock_num > 0 )
  172. </if>
  173. <if test="isStockShare == 0">
  174. and psr1.stock_num > 0
  175. </if>
  176. and b.id is not null and a.is_delete != 1 and psr1.retail_price is not null and a.is_on_sale = 1
  177. <if test="is_new != null and is_new != ''">
  178. and a.is_new = #{is_new}
  179. </if>
  180. <if test="brand_id != null and brand_id != ''">
  181. and psr1.brand_id = #{brand_id}
  182. </if>
  183. <if test="category_id != null and category_id != ''">
  184. and psr1.category_id = #{category_id}
  185. </if>
  186. <if test="keyword != null">
  187. and a.keywords like concat('%',#{keyword},'%')
  188. </if>
  189. <if test="categoryIds != null">
  190. and psr1.category_id in
  191. <foreach item="item" collection="categoryIds" open="(" separator="," close=")">
  192. #{item}
  193. </foreach>
  194. </if>
  195. <if test="category_parent_id != null and category_parent_id != null and category_parent_id != 0">
  196. and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
  197. </if>
  198. <if test="goodsId != null and goodsId != ''">
  199. and a.id = #{goodsId}
  200. </if>
  201. <!--<if test="category_parent_id != null and category_parent_id != null and category_parent_id == 0">-->
  202. <!--and FIND_IN_SET(c.parent_id, getCategoryChildLst(#{category_parent_id}))-->
  203. <!--</if>-->
  204. <if test="store_id != null and store_id != ''">
  205. and psr1.store_id = #{store_id}
  206. </if>
  207. <if test="goodsBizType != null and goodsBizType != ''">
  208. and a.goods_biz_type = #{goodsBizType}
  209. </if>
  210. <choose>
  211. <when test="sidx != null and sidx.trim() != ''">
  212. order by ${sidx} ${order}
  213. </when>
  214. <otherwise>
  215. order by a.id desc
  216. </otherwise>
  217. </choose>
  218. <if test="offset != null and limit != null">
  219. limit #{offset}, #{limit}
  220. </if>
  221. </select>
  222. <select id="queryDiscountGoodsTotal" resultType="int">
  223. select count(*)
  224. FROM
  225. mall_goods a
  226. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id
  227. AND a.merch_sn = psr1.merch_sn
  228. LEFT JOIN mk_store_ticket_discount_goods g ON psr1.id = g.store_rela_id
  229. <if test="tickDiscId != null and tickDiscId != ''">
  230. and g.tick_disc_id = #{tickDiscId}
  231. </if>
  232. LEFT JOIN third_merchant_biz mb ON mb.third_party_merch_code = a.third_party_merch_code
  233. AND mb.merch_sn = a.merch_sn
  234. LEFT JOIN mall_product b ON b.id = psr1.product_id
  235. LEFT JOIN mall_category c ON psr1.category_id = c.id
  236. WHERE 1 = 1
  237. <if test="applyType != null and applyType == '01'">
  238. <if test="tickDiscId != null and tickDiscId != ''">
  239. and g.tick_disc_id = #{tickDiscId}
  240. </if>
  241. </if>
  242. <if test="applyType != null and applyType == '02'">
  243. and psr1.id not in(SELECT store_rela_id FROM mk_store_ticket_discount_goods WHERE tick_disc_id = #{tickDiscId})
  244. </if>
  245. <if test="isStockShare == 1">
  246. and (a.goods_number > 0 or psr1.stock_num > 0 )
  247. </if>
  248. <if test="isStockShare == 0">
  249. and psr1.stock_num > 0
  250. </if>
  251. and b.id is not null and a.is_delete != 1 and psr1.retail_price is not null and a.is_on_sale = 1
  252. <if test="is_new != null and is_new != ''">
  253. and a.is_new = #{is_new}
  254. </if>
  255. <if test="brand_id != null and brand_id != ''">
  256. and psr1.brand_id = #{brand_id}
  257. </if>
  258. <if test="category_id != null and category_id != ''">
  259. and psr1.category_id = #{category_id}
  260. </if>
  261. <if test="keyword != null">
  262. and a.keywords like concat('%',#{keyword},'%')
  263. </if>
  264. <if test="categoryIds != null">
  265. and psr1.category_id in
  266. <foreach item="item" collection="categoryIds" open="(" separator="," close=")">
  267. #{item}
  268. </foreach>
  269. </if>
  270. <if test="category_parent_id != null and category_parent_id != null and category_parent_id != 0">
  271. and FIND_IN_SET(psr1.category_id, getCategoryChildLst(#{category_parent_id}))
  272. </if>
  273. <if test="goodsId != null and goodsId != ''">
  274. and a.id = #{goodsId}
  275. </if>
  276. <!--<if test="category_parent_id != null and category_parent_id != null and category_parent_id == 0">-->
  277. <!--and FIND_IN_SET(c.parent_id, getCategoryChildLst(#{category_parent_id}))-->
  278. <!--</if>-->
  279. <if test="store_id != null and store_id != ''">
  280. and psr1.store_id = #{store_id}
  281. </if>
  282. <if test="goodsBizType != null and goodsBizType != ''">
  283. and a.goods_biz_type = #{goodsBizType}
  284. </if>
  285. </select>
  286. </mapper>