DisplaceAuditMapper.xml 9.2 KB

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