ApiGoodsActivityMapper.xml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.ApiGoodsActivityMapper">
  4. <resultMap type="com.kmall.api.dto.GoodsActivityVo" id="activityMap">
  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="market_price" column="market_price"/>
  9. <result property="retail_price" column="retail_price"/>
  10. <result property="retail_min_price" column="retail_min_price"/>
  11. <result property="open_time" column="open_time"/>
  12. <result property="end_time" column="end_time"/>
  13. <result property="goods_id" column="goods_id"/>
  14. <result property="subtitle" column="subtitle"/>
  15. <result property="type" column="type"/>
  16. </resultMap>
  17. <select id="queryList" resultMap="activityMap">
  18. SELECT
  19. *
  20. FROM
  21. (
  22. SELECT
  23. 2 as type,
  24. a.`id`,
  25. a.`title`,
  26. a.`item_pic_url`,
  27. b.`market_price`,
  28. a.`retail_min_price`,
  29. a.`goods_id`,
  30. a.`subtitle`,
  31. a.`open_time`,
  32. a.`end_time`,
  33. b.retail_price AS retail_price
  34. FROM
  35. mall_goods_group a
  36. left join mall_product_store_rela b on b.goods_id = a.goods_id
  37. where 1 = 1 and a.end_time > now() and b.stock_num > 0 and a.open_status != 3
  38. and b.store_id = #{store_id}
  39. ) tmp
  40. WHERE 1 = 1
  41. <if test="type != null and type != 0">
  42. and tmp.type = #{type}
  43. </if>
  44. order by tmp.end_time,tmp.type desc
  45. <if test="offset != null and limit != null">
  46. limit #{offset}, #{limit}
  47. </if>
  48. </select>
  49. <select id="queryTotal" resultType="int">
  50. SELECT
  51. count(id)
  52. FROM
  53. (
  54. SELECT
  55. a.`id`
  56. FROM
  57. mall_goods_group a
  58. LEFT JOIN mall_goods b ON b.id = a.goods_id
  59. <if test="store_id != null and store_id != ''">
  60. left join mall_product_store_rela s on b.id = s.goods_id
  61. </if>
  62. where 1 = 1
  63. <if test="store_id != null and store_id != ''">
  64. and s.store_id = #{store_id}
  65. </if>
  66. ) temp
  67. WHERE 1 = 1
  68. <if test="type != null and type != 0">
  69. and tmp.type = #{type}
  70. </if>
  71. </select>
  72. </mapper>