KwoWantBuyMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. , kba.name addressName
  19. , kba.city_name cityName
  20. , kba.detail_address detailAddress
  21. </sql>
  22. <resultMap id="wangBuyResultMap" type="com.sckw.order.model.vo.res.WantBuySelectRes">
  23. <id column="id" property="id"/>
  24. <result column="name" property="name"/>
  25. <result column="goodsType" property="goodsType"/>
  26. <result column="spec" property="spec"/>
  27. <result column="price" property="price"/>
  28. <result column="amount" property="amount"/>
  29. <result column="contacts" property="contacts"/>
  30. <result column="phone" property="phone"/>
  31. <result column="status" property="status"/>
  32. <result column="remark" property="remark"/>
  33. <result column="createTime" property="createTime"/>
  34. <result column="updateTime" property="updateTime"/>
  35. </resultMap>
  36. <sql id="managerWhere">
  37. kb.del_flag = 0
  38. <if test="authEntIdList != null and authEntIdList.size() != 0">
  39. and kb.ent_id in
  40. <foreach collection="authEntIdList" item="item" open="(" close=")" separator=",">
  41. #{item}
  42. </foreach>
  43. </if>
  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. <sql id="where">
  110. kb.del_flag = 0
  111. <if test="wantBuyReq.startCreateTime != null">
  112. and kb.create_time &gt;= #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP}
  113. </if>
  114. <if test="wantBuyReq.endCreateTime != null">
  115. and kb.create_time &lt;= #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
  116. </if>
  117. <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
  118. <!--私用and条件-->
  119. <!-- and kt.trading in-->
  120. <!-- <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">-->
  121. <!-- #{item,jdbcType=VARCHAR}-->
  122. <!-- </foreach>-->
  123. <!-- 使用 AND 条件 -->
  124. <!-- and (-->
  125. <!-- <foreach collection="wantBuyReq.tradings" item="item" separator=" and ">-->
  126. <!-- kt.trading = #{item,jdbcType=VARCHAR}-->
  127. <!-- </foreach>-->
  128. <!-- )-->
  129. <foreach collection="wantBuyReq.tradings" item="value" separator="">
  130. AND EXISTS (
  131. SELECT 1
  132. FROM kwo_want_buy_trading kt2
  133. WHERE kt2.want_buy_id = kb.id
  134. AND kt2.trading = #{value}
  135. )
  136. </foreach>
  137. </if>
  138. <if test="wantBuyReq.wantBuyIds != null and wantBuyReq.wantBuyIds.size() > 0">
  139. and kb.id in
  140. <foreach collection="wantBuyReq.wantBuyIds" item="item" open="(" close=")" separator=",">
  141. #{item,jdbcType=BIGINT}
  142. </foreach>
  143. </if>
  144. <if test="wantBuyReq.status != null">
  145. and kb.status = #{wantBuyReq.status}
  146. </if>
  147. <if test="wantBuyReq.entId != null ">
  148. and kb.ent_id = #{wantBuyReq.entId}
  149. </if>
  150. <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
  151. <if test="wantBuyReq.entIds != null and wantBuyReq.entIds.size() > 0">
  152. and (kb.ent_id in
  153. <foreach collection="wantBuyReq.entIds" item="item" open="(" close=")" separator=",">
  154. #{item,jdbcType=BIGINT}
  155. </foreach>
  156. or kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
  157. )
  158. </if>
  159. <if test="wantBuyReq.entIds == null or wantBuyReq.entIds.size() == 0">
  160. and (kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%'))
  161. </if>
  162. </if>
  163. <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
  164. and kb.goods_type in
  165. <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
  166. #{item}
  167. </foreach>
  168. </if>
  169. <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
  170. and (kba.`city_code` like concat(#{wantBuyReq.cityCode,jdbcType=VARCHAR}, '%'))
  171. </if>
  172. <if test="wantBuyReq.systemType != null and wantBuyReq.systemType == 1">
  173. and kb.status in (1,2)
  174. </if>
  175. <if test="wantBuyReq.specialEntIds != null and wantBuyReq.specialEntIds.size() > 0">
  176. and kb.ent_id in
  177. <foreach collection="wantBuyReq.specialEntIds" item="item" open="(" close=")" separator=",">
  178. #{item,jdbcType=BIGINT}
  179. </foreach>
  180. </if>
  181. </sql>
  182. <select id="pageSelect" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  183. select
  184. <include refid="Base_Column_List" />
  185. from kwo_want_buy kb
  186. left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  187. <where>
  188. <include refid="where" />
  189. </where>
  190. order by kb.create_time desc
  191. </select><select id="pageSelectAllByManager" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  192. select
  193. <include refid="Base_Column_List" />
  194. from kwo_want_buy kb
  195. left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  196. <where>
  197. <include refid="managerWhere" />
  198. </where>
  199. order by kb.create_time desc
  200. </select>
  201. <!-- <resultMap id="tradIngMap" type="com.sckw.order.model.KwoWantBuyTrading">-->
  202. <resultMap id="tradIngMap" type="com.sckw.order.model.vo.res.WantBuyTradingRes">
  203. <id column="wantBuyId" property="wantBuyId"/>
  204. <result column="trading" property="trading"/>
  205. </resultMap>
  206. <select id="tradingSql" resultMap="tradIngMap">
  207. select want_buy_id wantBuyId, trading
  208. from kwo_want_buy_trading
  209. where want_buy_id = #{wantBuyId} and del_flag = 0
  210. </select>
  211. <select id="statisticsCount" resultType="com.sckw.order.model.vo.res.TableTopRes" parameterType="java.util.Map">
  212. select kb.`status` value
  213. from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
  214. <where>
  215. <include refid="where" />
  216. </where>
  217. group by kb.id
  218. order by kb.create_time desc
  219. </select>
  220. <select id="queryBuyHallList" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
  221. select
  222. <include refid="Base_Column_List" />
  223. from kwo_want_buy kb
  224. left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
  225. <where>
  226. <include refid="where" />
  227. </where>
  228. order by RAND()
  229. </select>
  230. </mapper>