KwoWantBuyMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. </resultMap>
  38. <sql id="managerWhere">
  39. kb.del_flag = 0
  40. <if test="authEntIdList != null and authEntIdList.size() != 0">
  41. and kb.ent_id in
  42. <foreach collection="authEntIdList" item="item" open="(" close=")" separator=",">
  43. #{item}
  44. </foreach>
  45. </if>
  46. <if test="wantBuyReq.startCreateTime != null">
  47. and kb.create_time &gt;= #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP}
  48. </if>
  49. <if test="wantBuyReq.endCreateTime != null">
  50. and kb.create_time &lt;= #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
  51. </if>
  52. <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
  53. <!--私用and条件-->
  54. <!-- and kt.trading in-->
  55. <!-- <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">-->
  56. <!-- #{item,jdbcType=VARCHAR}-->
  57. <!-- </foreach>-->
  58. <!-- 使用 AND 条件 -->
  59. <!-- and (-->
  60. <!-- <foreach collection="wantBuyReq.tradings" item="item" separator=" and ">-->
  61. <!-- kt.trading = #{item,jdbcType=VARCHAR}-->
  62. <!-- </foreach>-->
  63. <!-- )-->
  64. <foreach collection="wantBuyReq.tradings" item="value" separator="">
  65. AND EXISTS (
  66. SELECT 1
  67. FROM kwo_want_buy_trading kt2
  68. WHERE kt2.want_buy_id = kb.id
  69. AND kt2.trading = #{value}
  70. )
  71. </foreach>
  72. </if>
  73. <if test="wantBuyReq.wantBuyIds != null and wantBuyReq.wantBuyIds.size() > 0">
  74. and kb.id in
  75. <foreach collection="wantBuyReq.wantBuyIds" item="item" open="(" close=")" separator=",">
  76. #{item,jdbcType=BIGINT}
  77. </foreach>
  78. </if>
  79. <if test="wantBuyReq.status != null">
  80. and kb.status = #{wantBuyReq.status}
  81. </if>
  82. <if test="wantBuyReq.entId != null ">
  83. and kb.ent_id = #{wantBuyReq.entId}
  84. </if>
  85. <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
  86. <if test="wantBuyReq.entIds != null and wantBuyReq.entIds.size() > 0">
  87. and (kb.ent_id in
  88. <foreach collection="wantBuyReq.entIds" item="item" open="(" close=")" separator=",">
  89. #{item,jdbcType=BIGINT}
  90. </foreach>
  91. or kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
  92. )
  93. </if>
  94. <if test="wantBuyReq.entIds == null or wantBuyReq.entIds.size() == 0">
  95. and (kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%'))
  96. </if>
  97. </if>
  98. <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
  99. and kb.goods_type in
  100. <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
  101. #{item}
  102. </foreach>
  103. </if>
  104. <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
  105. and (kba.`city_code` like concat(#{wantBuyReq.cityCode,jdbcType=VARCHAR}, '%'))
  106. </if>
  107. <if test="wantBuyReq.systemType != null and wantBuyReq.systemType == 1">
  108. and kb.status in (1,2)
  109. </if>
  110. </sql>
  111. <sql id="where">
  112. kb.del_flag = 0
  113. <if test="wantBuyReq.startCreateTime != null">
  114. and kb.create_time &gt;= #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP}
  115. </if>
  116. <if test="wantBuyReq.endCreateTime != null">
  117. and kb.create_time &lt;= #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
  118. </if>
  119. <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
  120. <!--私用and条件-->
  121. <!-- and kt.trading in-->
  122. <!-- <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">-->
  123. <!-- #{item,jdbcType=VARCHAR}-->
  124. <!-- </foreach>-->
  125. <!-- 使用 AND 条件 -->
  126. <!-- and (-->
  127. <!-- <foreach collection="wantBuyReq.tradings" item="item" separator=" and ">-->
  128. <!-- kt.trading = #{item,jdbcType=VARCHAR}-->
  129. <!-- </foreach>-->
  130. <!-- )-->
  131. <foreach collection="wantBuyReq.tradings" item="value" separator="">
  132. AND EXISTS (
  133. SELECT 1
  134. FROM kwo_want_buy_trading kt2
  135. WHERE kt2.want_buy_id = kb.id
  136. AND kt2.trading = #{value}
  137. )
  138. </foreach>
  139. </if>
  140. <if test="wantBuyReq.wantBuyIds != null and wantBuyReq.wantBuyIds.size() > 0">
  141. and kb.id in
  142. <foreach collection="wantBuyReq.wantBuyIds" item="item" open="(" close=")" separator=",">
  143. #{item,jdbcType=BIGINT}
  144. </foreach>
  145. </if>
  146. <if test="wantBuyReq.status != null">
  147. and kb.status = #{wantBuyReq.status}
  148. </if>
  149. <if test="wantBuyReq.entId != null ">
  150. and kb.ent_id = #{wantBuyReq.entId}
  151. </if>
  152. <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
  153. <if test="wantBuyReq.entIds != null and wantBuyReq.entIds.size() > 0">
  154. and (kb.ent_id in
  155. <foreach collection="wantBuyReq.entIds" item="item" open="(" close=")" separator=",">
  156. #{item,jdbcType=BIGINT}
  157. </foreach>
  158. or kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
  159. )
  160. </if>
  161. <if test="wantBuyReq.entIds == null or wantBuyReq.entIds.size() == 0">
  162. and (kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%'))
  163. </if>
  164. </if>
  165. <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
  166. and kb.goods_type in
  167. <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
  168. #{item}
  169. </foreach>
  170. </if>
  171. <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
  172. and (kba.`city_code` like concat(#{wantBuyReq.cityCode,jdbcType=VARCHAR}, '%'))
  173. </if>
  174. <if test="wantBuyReq.systemType != null and wantBuyReq.systemType == 1">
  175. and kb.status in (1,2)
  176. </if>
  177. <if test="wantBuyReq.specialEntIds != null and wantBuyReq.specialEntIds.size() > 0">
  178. and kb.ent_id in
  179. <foreach collection="wantBuyReq.specialEntIds" item="item" open="(" close=")" separator=",">
  180. #{item,jdbcType=BIGINT}
  181. </foreach>
  182. </if>
  183. </sql>
  184. <select id="pageSelect" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  185. select
  186. <include refid="Base_Column_List" />
  187. from kwo_want_buy kb
  188. left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  189. <where>
  190. <include refid="where" />
  191. </where>
  192. order by kb.create_time desc
  193. </select><select id="pageSelectAllByManager" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  194. select
  195. <include refid="Base_Column_List" />
  196. from kwo_want_buy kb
  197. left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  198. <where>
  199. <include refid="managerWhere" />
  200. </where>
  201. order by kb.create_time desc
  202. </select>
  203. <!-- <resultMap id="tradIngMap" type="com.sckw.order.model.KwoWantBuyTrading">-->
  204. <resultMap id="tradIngMap" type="com.sckw.order.model.vo.res.WantBuyTradingRes">
  205. <id column="wantBuyId" property="wantBuyId"/>
  206. <result column="trading" property="trading"/>
  207. </resultMap>
  208. <select id="tradingSql" resultMap="tradIngMap">
  209. select want_buy_id wantBuyId, trading
  210. from kwo_want_buy_trading
  211. where want_buy_id = #{wantBuyId} and del_flag = 0
  212. </select>
  213. <select id="statisticsCount" resultType="com.sckw.order.model.vo.res.TableTopRes" parameterType="java.util.Map">
  214. select kb.`status` value
  215. from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
  216. <where>
  217. <include refid="where" />
  218. </where>
  219. group by kb.id
  220. order by kb.create_time desc
  221. </select>
  222. <select id="queryBuyHallList" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  223. select
  224. <include refid="Base_Column_List" />
  225. from kwo_want_buy kb
  226. left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  227. <where>
  228. <include refid="where" />
  229. </where>
  230. order by RAND()
  231. </select>
  232. </mapper>