KwoWantBuyMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.sckw.order.dao.KwpWantBuyMapper">
  4. <sql id="Base_Column_List">
  5. kb.id
  6. ,kb.`name`
  7. ,kb.ent_id
  8. , kb.goods_type goodsType
  9. , kb.spec
  10. , kb.price
  11. , kb.amount
  12. , kb.status
  13. , kb.remark
  14. , kb.create_time createTime
  15. , kt.want_buy_id wantBuyId
  16. , kt.trading trading
  17. , kba.name addressName
  18. </sql>
  19. <resultMap id="wangBuyResultMap" type="com.sckw.order.model.vo.res.WantBuySelectRes">
  20. <id column="id" property="id"/>
  21. <result column="name" property="name"/>
  22. <result column="goodsType" property="goodsType"/>
  23. <result column="spec" property="spec"/>
  24. <result column="price" property="price"/>
  25. <result column="amount" property="amount"/>
  26. <result column="status" property="status"/>
  27. <result column="remark" property="remark"/>
  28. <result column="createTime" property="createTime"/>
  29. <result column="updateTime" property="updateTime"/>
  30. <collection property="wantBuyTradings" column="id" ofType="com.sckw.order.model.vo.res.WantBuyTradingRes" javaType="java.util.List" select="tradingSql" >
  31. <id column="wantBuyId" property="wantBuyId"/>
  32. <result column="trading" property="trading"/>
  33. </collection>
  34. </resultMap>
  35. <sql id="where">
  36. kb.del_flag = 0 and kt.del_flag = 0 and kba.del_flag = 0
  37. <if test="wantBuyReq.startCreateTime != null">
  38. and kb.create_time &gt;= #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP}
  39. </if>
  40. <if test="wantBuyReq.endCreateTime != null">
  41. and kb.create_time &lt;= #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
  42. </if>
  43. <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
  44. and kt.trading in
  45. <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">
  46. #{item,jdbcType=VARCHAR}
  47. </foreach>
  48. </if>
  49. <if test="wantBuyReq.status != null and wantBuyReq.status != ''">
  50. and kb.status = #{wantBuyReq.status}
  51. </if>
  52. <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
  53. and (
  54. kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
  55. )
  56. </if>
  57. <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
  58. and kb.goods_type in
  59. <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
  60. #{item}
  61. </foreach>
  62. </if>
  63. <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
  64. and kba.city_code = #{wantBuyReq.cityCode}
  65. </if>
  66. </sql>
  67. <select id="pageSelect" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  68. select
  69. <include refid="Base_Column_List" />
  70. from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
  71. join kwo_want_buy_address kba on kb.id = kba.want_buy_id
  72. <where>
  73. <include refid="where" />
  74. </where>
  75. group by kb.id
  76. order by kb.create_time desc
  77. </select>
  78. <!-- <resultMap id="tradIngMap" type="com.sckw.order.model.KwoWantBuyTrading">-->
  79. <resultMap id="tradIngMap" type="com.sckw.order.model.vo.res.WantBuyTradingRes">
  80. <id column="wantBuyId" property="wantBuyId"/>
  81. <result column="trading" property="trading"/>
  82. </resultMap>
  83. <select id="tradingSql" resultMap="tradIngMap">
  84. select want_buy_id wantBuyId, trading
  85. from kwo_want_buy_trading
  86. where want_buy_id = #{wantBuyId}
  87. </select>
  88. <select id="statisticsCount" resultType="com.sckw.order.model.vo.res.TableTopRes" parameterType="java.util.Map">
  89. select kb.`status` value
  90. from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
  91. <where>
  92. <include refid="where" />
  93. </where>
  94. group by kb.id
  95. order by kb.create_time desc
  96. </select>
  97. <select id="queryBuyHallList" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  98. select
  99. <include refid="Base_Column_List" />
  100. from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
  101. join kwo_want_buy_address kba on kb.id = kba.want_buy_id
  102. <where>
  103. <include refid="where" />
  104. </where>
  105. group by kb.id
  106. </select>
  107. </mapper>