SubsidyQueueMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.subsidy.mapper.SubsidyQueueMapper">
  6. <resultMap type="com.ruoyi.subsidy.domain.SubsidyQueue" id="SubsidyQueueResult">
  7. <result property="queueId" column="queue_id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="userName" column="user_name"/>
  10. <result property="userMobile" column="user_mobile"/>
  11. <result property="orderId" column="order_id"/>
  12. <result property="orderNo" column="order_no"/>
  13. <result property="currentBusinessId" column="current_business_id"/>
  14. <result property="currentBusinessName" column="current_business_name"/>
  15. <result property="originalBusinessId" column="original_business_id"/>
  16. <result property="originalBusinessName" column="original_business_name"/>
  17. <result property="queueOrder" column="queue_order"/>
  18. <result property="payAmount" column="pay_amount"/>
  19. <result property="shouldSubsidyAmount" column="should_subsidy_amount"/>
  20. <result property="actualSubsidyAmount" column="actual_subsidy_amount"/>
  21. <result property="subsidyPoints" column="subsidy_points"/>
  22. <result property="subsidyStatus" column="subsidy_status"/>
  23. <result property="cutIn" column="cut_in"/>
  24. <result property="cancelled" column="cancelled"/>
  25. <result property="exchanged" column="exchanged"/>
  26. <result property="exchangePoints" column="exchange_points"/>
  27. <result property="actualPointsAfterCancel" column="actual_points_after_cancel"/>
  28. <result property="consumeTime" column="consume_time"/>
  29. <result property="queueTime" column="queue_time"/>
  30. <result property="completeTime" column="complete_time"/>
  31. <result property="cancelTime" column="cancel_time"/>
  32. <result property="cancelType" column="cancel_type"/>
  33. <result property="exchangeTime" column="exchange_time"/>
  34. <result property="createTime" column="create_time"/>
  35. <result property="updateTime" column="update_time"/>
  36. <result property="moveTime" column="move_time"/>
  37. <result property="refundStatus" column="refund_status"/>
  38. <result property="purchaseSource" column="purchase_source"/>
  39. </resultMap>
  40. <select id="validQueueIds" resultType="java.lang.Long">
  41. select queue_id from tb_subsidy_queue
  42. where current_business_id = #{businessId}
  43. and subsidy_status = 0
  44. and cut_in = 0
  45. order by queue_order asc
  46. </select>
  47. <sql id="boWhere">
  48. <if test="query.bo!=null and query.bo.currentBusinessName!=null and query.bo.currentBusinessName!=''">
  49. and tsq.current_business_name like concat('%',#{query.bo.currentBusinessName},'%')
  50. </if>
  51. <if test="query.bo!=null and query.bo.orderNo!=null and query.bo.orderNo!=''">
  52. and tsq.order_no like concat('%',#{query.bo.orderNo},'%')
  53. </if>
  54. <if test="query.bo!=null and query.bo.userMobile!=null and query.bo.userMobile!=''">
  55. and tsq.user_mobile like concat('%',#{query.bo.userMobile},'%')
  56. </if>
  57. <if test="query.bo!=null and query.bo.userName!=null and query.bo.userName!=''">
  58. and tsq.user_name like concat('%',#{query.bo.userName},'%')
  59. </if>
  60. <if test="query.bo!=null and query.bo.subsidyStatus!=null">
  61. and tsq.subsidy_status = #{query.bo.subsidyStatus}
  62. </if>
  63. <if test="query.bo!=null and query.bo.consumeStartTime!=null">
  64. and tsq.consume_time &gt;= #{query.bo.consumeStartTime}
  65. </if>
  66. <if test="query.bo!=null and query.bo.consumeEndTime!=null">
  67. and tsq.consume_time &lt;= #{query.bo.consumeEndTime}
  68. </if>
  69. <if test="query.bo!=null and query.bo.queueStartTime!=null">
  70. and tsq.queue_time &gt;= #{query.bo.queueStartTime}
  71. </if>
  72. <if test="query.bo!=null and query.bo.queueEndTime!=null">
  73. and tsq.queue_time &lt;= #{query.bo.queueEndTime}
  74. </if>
  75. <if test="query.bo!=null and query.bo.refundStartTime!=null">
  76. and too.refund_time &gt;= #{query.bo.refundStartTime}
  77. </if>
  78. <if test="query.bo!=null and query.bo.refundEndTime!=null">
  79. and too.refund_time &lt;= #{query.bo.refundEndTime}
  80. </if>
  81. <if test="query.bo!=null and query.bo.orderStatus!=null">
  82. and too.order_status = #{query.bo.orderStatus.code}
  83. </if>
  84. <if test="query.bo!=null and query.bo.payType!=null">
  85. and too.pay_type = #{query.bo.payType.code}
  86. </if>
  87. </sql>
  88. <select id="getSubsidyAmount" resultType="java.math.BigDecimal">
  89. select
  90. <if test="query.countType == 1">
  91. IFNULL(sum(tsq.actual_subsidy_amount),0)
  92. </if>
  93. <if test="query.countType == 2">
  94. IFNULL(sum(tsq.subsidy_points),0)
  95. </if>
  96. <if test="query.countType == 3">
  97. IFNULL(sum(tsq.should_subsidy_amount-tsq.actual_subsidy_amount),0)
  98. </if>
  99. from tb_subsidy_queue as tsq
  100. left join tb_online_order as too on tsq.order_id = too.order_id
  101. <where>
  102. <if test="query.businessId != null">
  103. and tsq.current_business_id = #{query.businessId}
  104. </if>
  105. <if test="query.businessIds != null and query.businessIds.size>0">
  106. and tsq.current_business_id in
  107. <foreach item="item" collection="query.businessIds" separator="," open="(" close=")" index="">
  108. #{item}
  109. </foreach>
  110. </if>
  111. <if test="query.countType == 3">
  112. and tsq.subsidy_status = 0
  113. </if>
  114. <if test="query.countType == 1">
  115. and tsq.subsidy_status = 1
  116. </if>
  117. <include refid="boWhere" />
  118. </where>
  119. </select>
  120. <update id="validQueueOrderRearrange">
  121. update tb_subsidy_queue
  122. set queue_order = queue_order - 1
  123. where current_business_id = #{businessId}
  124. and subsidy_status = 0
  125. and queue_id != #{excludeQueueId}
  126. and queue_order &gt; #{currentQueueOrder}
  127. </update>
  128. </mapper>