KwoWantBuyMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. </if>
  63. <if test="wantBuyReq.wantBuyIds != null and wantBuyReq.wantBuyIds.size() > 0">
  64. and kb.id in
  65. <foreach collection="wantBuyReq.wantBuyIds" item="item" open="(" close=")" separator=",">
  66. #{item,jdbcType=BIGINT}
  67. </foreach>
  68. </if>
  69. <if test="wantBuyReq.status != null">
  70. and kb.status = #{wantBuyReq.status}
  71. </if>
  72. <if test="wantBuyReq.entId != null ">
  73. and kb.ent_id = #{wantBuyReq.entId}
  74. </if>
  75. <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
  76. <if test="wantBuyReq.entIds != null and wantBuyReq.entIds.size() > 0">
  77. and (kb.ent_id in
  78. <foreach collection="wantBuyReq.entIds" item="item" open="(" close=")" separator=",">
  79. #{item,jdbcType=BIGINT}
  80. </foreach>
  81. or kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
  82. )
  83. </if>
  84. <if test="wantBuyReq.entIds == null or wantBuyReq.entIds.size() == 0">
  85. and (kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%'))
  86. </if>
  87. </if>
  88. <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
  89. and kb.goods_type in
  90. <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
  91. #{item}
  92. </foreach>
  93. </if>
  94. <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
  95. and (kba.`city_code` like concat(#{wantBuyReq.cityCode,jdbcType=VARCHAR}, '%'))
  96. </if>
  97. <if test="wantBuyReq.systemType != null and wantBuyReq.systemType == 1">
  98. and kb.status in (1,2)
  99. </if>
  100. </sql>
  101. <select id="pageSelect" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  102. select
  103. <include refid="Base_Column_List" />
  104. from kwo_want_buy kb left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  105. left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id and kt.del_flag = 0
  106. <where>
  107. <include refid="where" />
  108. </where>
  109. group by kb.id
  110. order by kb.create_time desc
  111. </select>
  112. <!-- <resultMap id="tradIngMap" type="com.sckw.order.model.KwoWantBuyTrading">-->
  113. <resultMap id="tradIngMap" type="com.sckw.order.model.vo.res.WantBuyTradingRes">
  114. <id column="wantBuyId" property="wantBuyId"/>
  115. <result column="trading" property="trading"/>
  116. </resultMap>
  117. <select id="tradingSql" resultMap="tradIngMap">
  118. select want_buy_id wantBuyId, trading
  119. from kwo_want_buy_trading
  120. where want_buy_id = #{wantBuyId} and del_flag = 0
  121. </select>
  122. <select id="statisticsCount" resultType="com.sckw.order.model.vo.res.TableTopRes" parameterType="java.util.Map">
  123. select kb.`status` value
  124. from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
  125. <where>
  126. <include refid="where" />
  127. </where>
  128. group by kb.id
  129. order by kb.create_time desc
  130. </select>
  131. <select id="queryBuyHallList" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  132. select
  133. <include refid="Base_Column_List" />
  134. from kwo_want_buy kb left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  135. left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id and kt.del_flag = 0
  136. <where>
  137. <include refid="where" />
  138. </where>
  139. group by kb.id
  140. order by RAND()
  141. </select>
  142. </mapper>