DisplaceAuditMapper.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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.DisplaceAuditMapper">
  4. <!--插入置换审核-->
  5. <insert id="insert">
  6. <selectKey keyProperty="displaceId" resultType="string" order="BEFORE">
  7. SELECT CONCAT(#{agentId}, '-', 'ZH', LPAD(COUNT(1) + 1, 4, '0'))
  8. FROM tb_displace_audit
  9. WHERE agent_id = #{agentId}
  10. </selectKey>
  11. INSERT INTO tb_displace_audit(id, agent_id, agent_name, displace_id, idea_price, pub_time, audit_time, journalist_name, journalist_tel, audit_status, state, sale_id, others_desc, first_pic_url,is_good,storage)
  12. VALUES(#{id}, #{agentId}, #{agentName}, #{displaceId}, #{ideaPrice}, #{pubTime}, #{auditTime}, #{joumalistName}, #{joumalistTel}, #{auditStatus}, #{state}, #{saleId}, #{othersDesc}, #{firstPicUrl}, #{is_good}, #{storage})
  13. </insert>
  14. <!--更新置换审核-->
  15. <update id="update">
  16. UPDATE tb_displace_audit
  17. SET agent_id = #{agentId},
  18. agent_name = #{agentName},
  19. idea_price = #{ideaPrice},
  20. journalist_name = #{joumalistName},
  21. journalist_tel = #{joumalistTel},
  22. audit_status = #{auditStatus},
  23. state = #{state},
  24. sale_id = #{saleId},
  25. storage = #{storage},
  26. is_good = #{is_good},
  27. first_pic_url = #{firstPicUrl}
  28. WHERE id = #{id}
  29. </update>
  30. <!--更新报价结束时间-->
  31. <update id="updateEndTime">
  32. UPDATE tb_displace_audit SET end_time = #{endTime} WHERE id = #{id}
  33. </update>
  34. <!--查询置换-->
  35. <select id="selectDisplaceList" resultType="com.demo.wjj.bo.DisplaceListBo">
  36. SELECT a.id, a.displace_id displaceId, a.audit_status auditStatus, a.first_pic_url picUrl
  37. FROM tb_displace_audit a JOIN tb_sales s ON a.sale_id = s.sale_id
  38. WHERE
  39. <if test="auditStatus == 0">
  40. a.audit_status IN ('0', '2')
  41. </if>
  42. <if test="auditStatus == 1">
  43. a.audit_status IN ('1', '3')
  44. </if>
  45. AND a.agent_id = #{agentId} AND s.agent_id = #{agentId} AND s.wx_openid = #{openId}
  46. AND a.state = '1'
  47. ORDER BY a.displace_id DESC
  48. </select>
  49. <!--查询待确认-->
  50. <select id="selectDisplaceConfirmList" resultType="com.demo.wjj.bo.DisplaceListBo">
  51. SELECT a.id, a.displace_id displaceId, a.audit_status auditStatus, a.first_pic_url picUrl
  52. FROM tb_displace_audit a
  53. JOIN tb_sales s ON a.sale_id = s.sale_id
  54. JOIN tb_digger_agent d ON d.wx_openid = s.wx_openid
  55. JOIN tb_deposit b ON b.da_id = d.id
  56. WHERE
  57. a.audit_status = #{auditStatus}
  58. AND a.agent_id = #{agentId} AND s.agent_id = #{agentId} AND s.wx_openid = #{openId}
  59. AND a.state = '1'
  60. AND b.is_common='0'
  61. AND b.pay_status='0'
  62. ORDER BY a.displace_id DESC
  63. </select>
  64. <!--查询置换详情-->
  65. <select id="select" resultType="com.demo.wjj.po.DisplaceAudit">
  66. SELECT a.id, a.displace_id displaceId, a.idea_price ideaPrice, a.journalist_name joumalistName, a.journalist_tel joumalistTel, a.others_desc othersDesc
  67. FROM tb_displace_audit a
  68. WHERE a.state = '1' AND a.id = #{id}
  69. </select>
  70. <resultMap id="displaceAudit" type="com.demo.wjj.po.DisplaceAudit">
  71. <result column="id" property="id"/>
  72. <result column="displace_id" property="displaceId"/>
  73. <result column="agent_id" property="agentId"/>
  74. <result column="audit_status" property="auditStatus"/>
  75. <result column="start_time" property="startTime"/>
  76. <result column="end_time" property="endTime"/>
  77. <result column="time_delay" property="timeDelay"/>
  78. <result column="min_money" property="minMoney"/>
  79. </resultMap>
  80. <!--查询置换审核-->
  81. <select id="selectDisplaceAudit" resultMap="displaceAudit">
  82. SELECT a.id, a.displace_id, a.agent_id, a.audit_status, a.start_time, a.end_time, a.bail, a.time_delay, a.min_money,a.persist_price
  83. FROM tb_displace_audit a
  84. WHERE a.state = '1' AND a.displace_id = #{displaceId}
  85. </select>
  86. <!--查询被驳回的置换设备数量-->
  87. <select id="selectRejectedDisplaceCount" resultType="java.lang.Integer">
  88. SELECT COUNT(1)
  89. FROM tb_displace_audit a JOIN tb_sales s ON a.sale_id = s.sale_id
  90. WHERE a.agent_id = #{agentId} AND a.state = '1' AND s.agent_id = #{agentId} AND s.wx_openid = #{openId} AND a.audit_status = '2'
  91. </select>
  92. <!--在售设备-->
  93. <select id="selectDisplaceOnList" resultType="com.demo.wjj.bo.DisplaceListBo">
  94. SELECT a.id,a.is_kxc isKxc, a.up_type upType, a.displace_id displaceId, IFNULL(a.look_times, 0) lookTimes, IFNULL(d.offer_times, 0) offerTimes, a.first_pic_url picUrl, a.start_time , a.end_time startTime, IFNULL(d.max_offer, a.min_money) currentPrice,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  95. FROM tb_displace_audit a JOIN tb_offer d ON d.displace_id=a.displace_id
  96. WHERE
  97. a.audit_status IN ('1', '3')
  98. AND #{now} BETWEEN a.start_time AND a.end_time
  99. AND a.agent_id = #{agentId}
  100. AND a.state = '1'
  101. AND a.is_good='2'
  102. AND a.storage='1'
  103. ORDER BY a.start_time DESC
  104. </select>
  105. <!--已售设备-->
  106. <select id="selectDisplaceSaleList" resultType="com.demo.wjj.bo.DisplaceListBo">
  107. SELECT a.id,a.is_kxc isKxc, a.up_type upType, a.displace_id displaceId, IFNULL(a.look_times, 0) lookTimes, IFNULL(b.offer_times, 0) offerTimes, a.first_pic_url picUrl, a.start_time , a.end_time startTime, IFNULL(b.max_offer, a.min_money) currentPrice,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  108. FROM tb_displace_audit a JOIN tb_offer b ON b.displace_id=a.displace_id
  109. WHERE
  110. a.audit_status IN ('1', '3')
  111. AND #{now} > a.end_time
  112. AND a.agent_id = #{agentId}
  113. AND a.state = '1'
  114. AND b.displace_id=a.displace_id
  115. AND b.offer_times > 0
  116. AND a.is_good='2'
  117. AND a.storage='1'
  118. ORDER BY a.start_time DESC
  119. </select>
  120. <!--停售设备-->
  121. <select id="selectDisplaceHaltList" resultType="com.demo.wjj.bo.DisplaceListBo">
  122. SELECT a.id,a.is_kxc isKxc, a.up_type upType, a.displace_id displaceId, IFNULL(a.look_times, 0) lookTimes, IFNULL(b.offer_times, 0) offerTimes, a.first_pic_url picUrl, a.start_time , a.end_time startTime, IFNULL(b.max_offer, a.min_money) currentPrice,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  123. FROM tb_displace_audit a JOIN tb_offer b ON b.displace_id=a.displace_id
  124. WHERE
  125. a.audit_status IN ('1', '3')
  126. AND #{now} > a.end_time
  127. AND a.agent_id = #{agentId}
  128. AND a.state = '1'
  129. AND b.offer_times = 0
  130. AND b.displace_id=a.displace_id
  131. AND a.is_good='2'
  132. AND a.storage='1'
  133. ORDER BY a.start_time DESC
  134. </select>
  135. <!--我的秒杀-->
  136. <select id="selectDisplaceMyList" resultType="com.demo.wjj.bo.DisplaceListBo">
  137. SELECT a.id,a.is_kxc isKxc, a.up_type upType, a.displace_id displaceId, IFNULL(a.look_times, 0) lookTimes, IFNULL(d.offer_times, 0) offerTimes, a.first_pic_url picUrl, a.start_time , a.end_time startTime, IFNULL(d.max_offer, a.min_money) currentPrice,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  138. FROM tb_displace_audit a,tb_offer_detail b,tb_digger_agent c,tb_offer d
  139. WHERE
  140. a.state = '1'
  141. AND d.displace_id=a.displace_id
  142. AND c.da_id=b.da_id
  143. AND b.offer_id=d.id
  144. AND #{now} > a.end_time
  145. AND a.agent_id = #{agentId}
  146. AND a.state = '1'
  147. AND d.offer_times > 0
  148. AND c.wx_openid = #{openId}
  149. AND a.is_good='2'
  150. AND a.storage='1'
  151. ORDER BY a.start_time DESC
  152. </select>
  153. <!--我要卖精品机-->
  154. <select id="getDisplaceGoodSaleList" resultType="com.demo.wjj.bo.DisplaceListBo">
  155. SELECT a.id,a.is_kxc isKxc, a.up_type upType, a.displace_id displaceId, IFNULL(a.look_times, 0) lookTimes, IFNULL(d.offer_times, 0) offerTimes, a.first_pic_url picUrl, a.start_time , a.end_time startTime, IFNULL(d.max_offer, a.min_money) currentPrice,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  156. from tb_displace_audit a,tb_sales b,tb_digger_agent c,tb_offer d
  157. where
  158. a.audit_status = '1'
  159. and a.sale_id=b.sale_id
  160. and b.wx_openid=#{openId}
  161. and a.agent_id = #{agentId}
  162. AND d.displace_id=a.displace_id
  163. ORDER BY a.start_time DESC
  164. </select>
  165. <!--我的暂存列表-->
  166. <select id="getDisplaceStorageList" resultType="com.demo.wjj.bo.DisplaceListBo">
  167. SELECT a.id,a.is_kxc isKxc, a.up_type upType, a.displace_id displaceId, IFNULL(a.look_times, 0) lookTimes, a.first_pic_url picUrl, a.start_time , a.end_time startTime,a.storage,a.is_good,a.min_price,a.max_price,a.persist_price
  168. from tb_displace_audit a,tb_sales b
  169. where
  170. b.wx_openid= #{openId}
  171. and a.agent_id = #{agentId}
  172. AND a.storage= #{storageStatus}
  173. and a.sale_id=b.sale_id
  174. ORDER BY a.pub_time DESC
  175. </select>
  176. </mapper>