KwoWantBuyMapper.xml 5.6 KB

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