DiggerAgentDisplaceManageMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.demo.wjj.mapper.DiggerAgentDisplaceManageMapper">
  4. <resultMap id="displaceListBo" type="com.demo.wjj.bo.DisplaceListBo">
  5. <result column="id" property="id"/>
  6. <result column="displace_id" property="displaceId"/>
  7. <result column="look_time" property="lookTimes"/>
  8. <result column="offer_times" property="offerTimes"/>
  9. <result column="first_pic_url" property="picUrl"/>
  10. <result column="current_price" property="currentPrice"/>
  11. <result column="up_type" property="upType"/>
  12. <result column="is_kxc" property="isKxc"/>
  13. <result column="start_time" property="startTime"/>
  14. <result column="end_time" property="endTime"/>
  15. </resultMap>
  16. <!--更新围观记录-->
  17. <update id="updateLookTimes">
  18. UPDATE tb_displace_audit SET look_times = IFNULL(look_times, 0) + 1 WHERE id = #{displaceId}
  19. </update>
  20. <!--查询待报价的置换列表-->
  21. <select id="selectWaitingList" resultMap="displaceListBo">
  22. SELECT a.id,a.is_kxc, a.up_type,a.start_time ,a.end_time, a.displace_id, IFNULL(a.look_times, 0) look_time, IFNULL(o.offer_times, 0) offer_times, a.first_pic_url, IFNULL(o.max_offer, a.min_money) current_price,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  23. FROM tb_displace_audit a LEFT JOIN tb_offer o ON a.displace_id = o.displace_id
  24. JOIN tb_agent g ON a.agent_id = g.agent_id AND g.state = '1'
  25. WHERE a.audit_status IN ('1', '3') AND a.state = '1' AND a.start_time > #{now}
  26. <if test="hasAuthority">
  27. AND (a.agent_id = #{agentId} OR g.is_attent = '1')
  28. </if>
  29. <if test="!hasAuthority">
  30. AND a.agent_id = #{agentId}
  31. </if>
  32. ORDER BY a.start_time DESC
  33. </select>
  34. <!--查询进行中的置换列表-->
  35. <select id="selectDoingList" resultMap="displaceListBo">
  36. SELECT a.id, a.is_kxc,a.start_time ,a.end_time, a.up_type, a.displace_id, IFNULL(a.look_times, 0) look_time, IFNULL(o.offer_times, 0) offer_times, a.first_pic_url, IFNULL(o.max_offer, a.min_money) current_price,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  37. FROM tb_displace_audit a LEFT JOIN tb_offer o ON a.displace_id = o.displace_id
  38. JOIN tb_agent g ON a.agent_id = g.agent_id AND g.state = '1'
  39. WHERE a.audit_status IN ('1', '3') AND a.state = '1' AND #{now} BETWEEN a.start_time AND a.end_time
  40. <if test="hasAuthority">
  41. AND (a.agent_id = #{agentId} OR g.is_attent = '1')
  42. </if>
  43. <if test="!hasAuthority">
  44. AND a.agent_id = #{agentId}
  45. </if>
  46. ORDER BY a.start_time DESC
  47. </select>
  48. <!--查询已结束的置换列表-->
  49. <select id="selectEndList" resultMap="displaceListBo">
  50. SELECT a.id, a.is_kxc, a.up_type, a.displace_id, IFNULL(a.look_times, 0) look_time, IFNULL(o.offer_times, 0) offer_times, a.first_pic_url, a.start_time , a.end_time, IFNULL(o.max_offer, a.min_money) current_price,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  51. FROM tb_displace_audit a LEFT JOIN tb_offer o ON a.displace_id = o.displace_id
  52. JOIN tb_agent g ON a.agent_id = g.agent_id AND g.state = '1'
  53. WHERE a.audit_status IN ('1', '3') AND a.state = '1' AND a.end_time &lt; #{now}
  54. <if test="hasAuthority">
  55. AND (a.agent_id = #{agentId} OR g.is_attent = '1')
  56. </if>
  57. <if test="!hasAuthority">
  58. AND a.agent_id = #{agentId}
  59. </if>
  60. <if test="date eq 'Day' ">
  61. AND to_days(a.end_time) = to_days(now())
  62. </if>
  63. <if test="date eq 'Week' ">
  64. AND YEARWEEK(a.end_time) = YEARWEEK(now()) AND to_days(a.end_time) != to_days(now())
  65. </if>
  66. <if test="date eq 'WeekEnd' ">
  67. AND YEARWEEK(a.end_time) = YEARWEEK(now())-1
  68. </if>
  69. ORDER BY a.start_time DESC
  70. </select>
  71. <!--查询我的报价置换列表-->
  72. <select id="selectMyList" resultMap="displaceListBo">
  73. SELECT a.id,a.is_kxc, a.up_type, a.displace_id, IFNULL(a.look_times, 0) look_time, IFNULL(o.offer_times, 0) offer_times, a.first_pic_url, a.start_time , a.end_time, IFNULL(o.max_offer, a.min_money) current_price,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  74. FROM (
  75. SELECT DISTINCT o.displace_id
  76. FROM tb_offer_detail d JOIN tb_offer o ON d.offer_id = o.id
  77. WHERE d.da_id = #{diggerAgentId}
  78. ) t JOIN tb_displace_audit a ON t.displace_id = a.displace_id LEFT JOIN tb_offer o ON a.displace_id = o.displace_id
  79. WHERE a.audit_status IN ('1', '3') AND a.state = '1' AND a.agent_id = #{agentId}
  80. ORDER BY a.start_time DESC
  81. </select>
  82. <resultMap id="displaceDetailBo" type="com.demo.wjj.bo.DisplaceDetailBo">
  83. <result column="id" property="id"/>
  84. <result column="agent_name" property="agentName"/>
  85. <result column="displace_id" property="displaceId"/>
  86. <result column="warranty_desc" property="warrantyDesc"/>
  87. <result column="idea_price" property="ideaPrice"/>
  88. <result column="look_times" property="lookTimes"/>
  89. <result column="offer_times" property="offerTimes"/>
  90. <result column="start_time" property="startTime"/>
  91. <result column="end_time" property="endTime"/>
  92. <result column="offer_status" property="offerStatus"/>
  93. <result column="agent_id" property="agentId"/>
  94. <result column="money_range" property="moneyRange"/>
  95. <result column="min_money" property="minMoney"/>
  96. <result column="others_desc" property="othersDesc"/>
  97. <result column="up_type" property="upType"/>
  98. <result column="is_kxc" property="isKxc"/>
  99. </resultMap>
  100. <!--查询置换详情-->
  101. <select id="selectDetails" resultMap="displaceDetailBo">
  102. SELECT a.id, a.displace_id,a.agent_name,a.agent_id, a.is_kxc, a.up_type, a.warranty_desc, a.idea_price, a.start_time , a.end_time, IFNULL(a.look_times, 0) look_times, IFNULL(a.money_range, '0') money_range,
  103. IFNULL(o.offer_times, 0) offer_times, a.end_time, a.time_delay, a.min_money, a.others_desc,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price,
  104. CASE WHEN a.start_time > #{now} THEN 1
  105. WHEN #{now} BETWEEN a.start_time AND a.end_time THEN 2
  106. ELSE 3
  107. END offer_status, a.agent_id
  108. FROM tb_displace_audit a LEFT JOIN tb_offer o ON a.displace_id = o.displace_id
  109. WHERE a.id = #{id}
  110. </select>
  111. <!--查询置换报价详情-->
  112. <select id="selectOfferList" resultType="com.demo.wjj.po.OfferDetail">
  113. SELECT d.da_id daId, DATE_FORMAT(d.offer_time, '%m-%d %H:%i:%s') offerTimeStr, a.start_time , a.end_time, d.price, d.offer_nc offerNc, d.is_kxc isKxc,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  114. FROM tb_offer_detail d JOIN tb_offer o ON d.offer_id = o.id
  115. JOIN tb_displace_audit a ON o.displace_id = a.displace_id
  116. WHERE a.id = #{id} AND d.is_show = '1'
  117. ORDER BY d.price DESC
  118. </select>
  119. </mapper>