OfferMapper.xml 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.OfferMapper">
  4. <!--插入置换报价-->
  5. <insert id="insert">
  6. INSERT INTO tb_offer(id, displace_id, offer_users, offer_times, max_offer, show_status, offer_bj_status, offer_gj_status, agent_show, plat_show, gj_price, is_kxc, gj_desc, gj_push_id, is_push, push_content)
  7. VALUES(#{offerId}, #{displaceId}, 1, 1, #{price}, 1, 0, 0, 1, 1, null, #{isKxc}, null, null, 0, null)
  8. </insert>
  9. <!--更新置换报价信息-->
  10. <update id="update">
  11. UPDATE tb_offer t, (
  12. SELECT o.offer_id, o.price, o.is_kxc, (
  13. SELECT COUNT(1)
  14. FROM tb_offer_detail t1
  15. WHERE t1.offer_id = #{existsOfferId}
  16. ) offer_times, (
  17. SELECT COUNT(DISTINCT t1.da_id)
  18. FROM tb_offer_detail t1
  19. WHERE t1.offer_id = #{existsOfferId}
  20. ) offer_users
  21. FROM tb_offer_detail o
  22. WHERE o.price = (
  23. SELECT MAX(d.price)
  24. FROM tb_offer_detail d
  25. WHERE d.offer_id = #{existsOfferId}
  26. ) AND o.offer_id = #{existsOfferId}
  27. ) a SET t.max_offer = a.price, t.is_kxc = a.is_kxc, t.offer_times = a.offer_times, t.offer_users = a.offer_users
  28. WHERE t.id = a.offer_id
  29. </update>
  30. <!--查询是否已支付保证金-->
  31. <select id="selectBeforePay" resultType="integer">
  32. SELECT COUNT(1)
  33. FROM tb_weixin_pay p JOIN tb_displace_audit a ON p.product_id = a.displace_id
  34. JOIN tb_deposit t ON p.order_no = t.agent_pay_no
  35. WHERE p.digger_agent_id = #{daId} AND p.deposit > 0 AND a.displace_id = #{displaceId}
  36. AND p.order_status = 2 AND t.pay_status = '1' AND t.refund_no IS NULL
  37. </select>
  38. <!--查询车商置换保证金-->
  39. <select id="selectDisplaceDeposit" resultType="java.lang.Integer">
  40. SELECT IFNULL(a.bail, 0)
  41. FROM tb_displace_audit a
  42. WHERE a.displace_id = #{displaceId}
  43. </select>
  44. <!--查询置换报价数量-->
  45. <select id="selectDisplaceOffer" resultType="java.lang.String">
  46. SELECT o.id
  47. FROM tb_offer o
  48. WHERE o.displace_id = #{displaceId}
  49. </select>
  50. <!--查询相同报价的数量-->
  51. <select id="selectSamePriceCount" resultType="java.lang.Integer">
  52. SELECT COUNT(1)
  53. FROM tb_offer_detail d JOIN tb_offer o ON d.offer_id = o.id
  54. WHERE d.price = #{price} AND o.displace_id = #{displaceId}
  55. </select>
  56. <!--查询旧支付订单编号-->
  57. <select id="selectOldOrderNo" resultType="java.lang.String">
  58. SELECT order_no
  59. FROM tb_weixin_pay
  60. WHERE order_status = '2' AND digger_agent_id = #{diggerAgentId} AND product_id = #{displaceId}
  61. ORDER BY create_time DESC
  62. LIMIT 1
  63. </select>
  64. <select id="selectOne" resultType="com.demo.wjj.po.Offer">
  65. SELECT o.id id,
  66. o.displace_id displaceId,
  67. o.max_offer maxOffer
  68. from tb_offer o
  69. WHERE o.displace_id = #{displaceId}
  70. </select>
  71. </mapper>