KwoWantBuyMapper.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.contacts
  13. , kb.phone
  14. , kb.status
  15. , kb.remark
  16. , kb.create_time createTime
  17. , kb.update_time updateTime
  18. , kt.want_buy_id wantBuyId
  19. , kt.trading trading
  20. , kba.name addressName
  21. , kba.city_name cityName
  22. , kba.detail_address detailAddress
  23. </sql>
  24. <resultMap id="wangBuyResultMap" type="com.sckw.order.model.vo.res.WantBuySelectRes">
  25. <id column="id" property="id"/>
  26. <result column="name" property="name"/>
  27. <result column="goodsType" property="goodsType"/>
  28. <result column="spec" property="spec"/>
  29. <result column="price" property="price"/>
  30. <result column="amount" property="amount"/>
  31. <result column="contacts" property="contacts"/>
  32. <result column="phone" property="phone"/>
  33. <result column="status" property="status"/>
  34. <result column="remark" property="remark"/>
  35. <result column="createTime" property="createTime"/>
  36. <result column="updateTime" property="updateTime"/>
  37. <collection property="wantBuyTradings" column="id" ofType="com.sckw.order.model.vo.res.WantBuyTradingRes" javaType="java.util.List" select="tradingSql">
  38. <id column="wantBuyId" property="wantBuyId"/>
  39. <result column="trading" property="trading"/>
  40. </collection>
  41. </resultMap>
  42. <sql id="where">
  43. kb.del_flag = 0
  44. <if test="wantBuyReq.startCreateTime != null">
  45. and kb.create_time &gt;= #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP}
  46. </if>
  47. <if test="wantBuyReq.endCreateTime != null">
  48. and kb.create_time &lt;= #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
  49. </if>
  50. <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
  51. <!--私用and条件-->
  52. <!-- and kt.trading in-->
  53. <!-- <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">-->
  54. <!-- #{item,jdbcType=VARCHAR}-->
  55. <!-- </foreach>-->
  56. <!-- 使用 AND 条件 -->
  57. <!-- and (-->
  58. <!-- <foreach collection="wantBuyReq.tradings" item="item" separator=" and ">-->
  59. <!-- kt.trading = #{item,jdbcType=VARCHAR}-->
  60. <!-- </foreach>-->
  61. <!-- )-->
  62. <foreach collection="wantBuyReq.tradings" item="value" separator="">
  63. AND EXISTS (
  64. SELECT 1
  65. FROM kwo_want_buy_trading kt2
  66. WHERE kt2.want_buy_id = kb.id
  67. AND kt2.trading = #{value}
  68. )
  69. </foreach>
  70. </if>
  71. <if test="wantBuyReq.wantBuyIds != null and wantBuyReq.wantBuyIds.size() > 0">
  72. and kb.id in
  73. <foreach collection="wantBuyReq.wantBuyIds" item="item" open="(" close=")" separator=",">
  74. #{item,jdbcType=BIGINT}
  75. </foreach>
  76. </if>
  77. <if test="wantBuyReq.status != null">
  78. and kb.status = #{wantBuyReq.status}
  79. </if>
  80. <if test="wantBuyReq.entId != null ">
  81. and kb.ent_id = #{wantBuyReq.entId}
  82. </if>
  83. <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
  84. <if test="wantBuyReq.entIds != null and wantBuyReq.entIds.size() > 0">
  85. and (kb.ent_id in
  86. <foreach collection="wantBuyReq.entIds" item="item" open="(" close=")" separator=",">
  87. #{item,jdbcType=BIGINT}
  88. </foreach>
  89. or kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
  90. )
  91. </if>
  92. <if test="wantBuyReq.entIds == null or wantBuyReq.entIds.size() == 0">
  93. and (kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%'))
  94. </if>
  95. </if>
  96. <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
  97. and kb.goods_type in
  98. <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
  99. #{item}
  100. </foreach>
  101. </if>
  102. <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
  103. and (kba.`city_code` like concat(#{wantBuyReq.cityCode,jdbcType=VARCHAR}, '%'))
  104. </if>
  105. <if test="wantBuyReq.systemType != null and wantBuyReq.systemType == 1">
  106. and kb.status in (1,2)
  107. </if>
  108. </sql>
  109. <select id="pageSelect" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  110. select
  111. <include refid="Base_Column_List" />
  112. from kwo_want_buy kb left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  113. left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id and kt.del_flag = 0
  114. <where>
  115. <include refid="where" />
  116. </where>
  117. group by kb.id
  118. order by kb.create_time desc
  119. </select>
  120. <!-- <resultMap id="tradIngMap" type="com.sckw.order.model.KwoWantBuyTrading">-->
  121. <resultMap id="tradIngMap" type="com.sckw.order.model.vo.res.WantBuyTradingRes">
  122. <id column="wantBuyId" property="wantBuyId"/>
  123. <result column="trading" property="trading"/>
  124. </resultMap>
  125. <select id="tradingSql" resultMap="tradIngMap">
  126. select want_buy_id wantBuyId, trading
  127. from kwo_want_buy_trading
  128. where want_buy_id = #{wantBuyId} and del_flag = 0
  129. </select>
  130. <select id="statisticsCount" resultType="com.sckw.order.model.vo.res.TableTopRes" parameterType="java.util.Map">
  131. select kb.`status` value
  132. from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
  133. <where>
  134. <include refid="where" />
  135. </where>
  136. group by kb.id
  137. order by kb.create_time desc
  138. </select>
  139. <select id="queryBuyHallList" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  140. select
  141. <include refid="Base_Column_List" />
  142. from kwo_want_buy kb left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  143. left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id and kt.del_flag = 0
  144. <where>
  145. <include refid="where" />
  146. </where>
  147. group by kb.id
  148. order by RAND()
  149. </select>
  150. </mapper>