1
0

ApiGoodsGroupMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.ApiGoodsGroupMapper">
  4. <resultMap type="com.kmall.api.entity.GoodsGroupVo" id="goodsGroupMap">
  5. <result property="id" column="id"/>
  6. <result property="title" column="title"/>
  7. <result property="item_pic_url" column="item_pic_url"/>
  8. <result property="abbr_pic_url" column="abbr_pic_url"/>
  9. <result property="market_price" column="market_price"/>
  10. <result property="retail_price" column="retail_price"/>
  11. <result property="goods_id" column="goods_id"/>
  12. <result property="sort_order" column="sort_order"/>
  13. <result property="subtitle" column="subtitle"/>
  14. <result property="open_time" column="open_time"/>
  15. <result property="end_time" column="end_time"/>
  16. <result property="open_status" column="open_status"/>
  17. <result property="valid_days" column="valid_days"/>
  18. <result property="retail_min_price" column="retail_min_price"/>
  19. <result property="min_open_group" column="min_open_group"/>
  20. <result property="ad_desc" column="ad_desc"/>
  21. <result property="stock_num" column="stock_num"/>
  22. </resultMap>
  23. <select id="queryObject" resultMap="goodsGroupMap">
  24. select
  25. a.`id`,
  26. a.`title`,
  27. a.`item_pic_url`,
  28. a.`abbr_pic_url`,
  29. b.`market_price`,
  30. a.`goods_id`,
  31. a.`sort_order`,
  32. a.`min_open_group`,
  33. a.`subtitle`,
  34. a.`open_time`,
  35. a.`end_time`,
  36. a.`open_status`,
  37. a.`valid_days`,
  38. a.`retail_min_price`,
  39. a.`ad_desc`,
  40. b.retail_price as retail_price,
  41. b.stock_num
  42. from mall_goods_group a
  43. left join mall_product_store_rela b on b.goods_id = a.goods_id
  44. where a.id = #{id}
  45. </select>
  46. <select id="queryObjectByStoreId" resultMap="goodsGroupMap">
  47. select
  48. a.`id`,
  49. a.`title`,
  50. a.`item_pic_url`,
  51. a.`abbr_pic_url`,
  52. b.`market_price`,
  53. a.`goods_id`,
  54. a.`sort_order`,
  55. a.`min_open_group`,
  56. a.`subtitle`,
  57. a.`open_time`,
  58. a.`end_time`,
  59. a.`open_status`,
  60. a.`valid_days`,
  61. a.`retail_min_price`,
  62. a.`ad_desc`,
  63. b.retail_price as retail_price,
  64. b.stock_num
  65. from mall_goods_group a
  66. left join mall_product_store_rela b on b.goods_id = a.goods_id
  67. where a.id = #{id} AND b.store_id = #{storeId}
  68. </select>
  69. <select id="queryList" resultMap="goodsGroupMap">
  70. select
  71. a.`id`,
  72. a.`title`,
  73. a.`item_pic_url`,
  74. a.`abbr_pic_url`,
  75. b.`market_price`,
  76. a.`goods_id`,
  77. a.`sort_order`,
  78. a.`min_open_group`,
  79. a.`subtitle`,
  80. a.`open_time`,
  81. a.`end_time`,
  82. a.`open_status`,
  83. a.`valid_days`,
  84. a.`retail_min_price`,
  85. a.`ad_desc`,
  86. b.retail_price as retail_price,
  87. b.stock_num
  88. from mall_goods_group a
  89. left join mall_product_store_rela b on b.goods_id = a.goods_id
  90. WHERE 1 = 1 and b.id is not null and a.open_status != 3 and b.stock_num > 0
  91. <if test="end_time != null">
  92. AND a.end_time > #{end_time}
  93. </if>
  94. <if test="storeId != null">
  95. AND b.store_id = #{storeId}
  96. </if>
  97. <choose>
  98. <when test="sidx != null and sidx.trim() != ''">
  99. order by ${sidx} ${order}
  100. </when>
  101. <otherwise>
  102. order by a.sort_order asc
  103. </otherwise>
  104. </choose>
  105. <if test="offset != null and limit != null">
  106. limit #{offset}, #{limit}
  107. </if>
  108. </select>
  109. <select id="queryTotal" resultType="int">
  110. select
  111. count(a.id)
  112. from mall_goods_group a
  113. left join mall_product_store_rela b on b.goods_id = a.goods_id
  114. WHERE 1 = 1 and b.id is not null and a.open_status != 3 and b.stock_num > 0
  115. <if test="end_time != null">
  116. AND a.end_time > #{end_time}
  117. </if>
  118. <if test="storeId != null">
  119. AND b.store_id = #{storeId}
  120. </if>
  121. <choose>
  122. <when test="sidx != null and sidx.trim() != ''">
  123. order by ${sidx} ${order}
  124. </when>
  125. <otherwise>
  126. order by a.sort_order desc
  127. </otherwise>
  128. </choose>
  129. </select>
  130. </mapper>