FlashDeliveryLinePaymentMapper.xml 2.6 KB

123456789101112131415
  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.ruoyi.system.mapper.flash.FlashDeliveryLinePaymentMapper">
  4. <sql id="columns">id,order_id AS orderId,rider_id AS riderId,credential_id AS credentialId,line_order_id AS lineOrderId,transaction_id AS transactionId,amount AS amount,captured_amount AS capturedAmount,currency AS currency,payment_url AS paymentUrl,status AS status,active_order_id AS activeOrderId,version AS version,lease_until AS leaseUntil,next_reconcile_at AS nextReconcileAt,reconcile_deadline AS reconcileDeadline,paid_at AS paidAt,create_time AS createTime,update_time AS updateTime</sql>
  5. <select id="selectForUpdate" resultType="com.ruoyi.system.domain.flash.FlashDeliveryLinePayment">SELECT <include refid="columns"/> FROM flash_delivery_line_payment WHERE id=#{id} FOR UPDATE</select>
  6. <select id="selectLatest" resultType="com.ruoyi.system.domain.flash.FlashDeliveryLinePayment">SELECT <include refid="columns"/> FROM flash_delivery_line_payment WHERE order_id=#{orderId} ORDER BY id DESC LIMIT 1</select>
  7. <!-- 订单锁后必须当前读,不能使用取得订单锁前建立的旧事务快照。 -->
  8. <select id="selectLatestForUpdate" resultType="com.ruoyi.system.domain.flash.FlashDeliveryLinePayment">SELECT <include refid="columns"/> FROM flash_delivery_line_payment WHERE order_id=#{orderId} ORDER BY id DESC LIMIT 1 FOR UPDATE</select>
  9. <select id="selectByLineOrderId" resultType="com.ruoyi.system.domain.flash.FlashDeliveryLinePayment">SELECT <include refid="columns"/> FROM flash_delivery_line_payment WHERE line_order_id=#{lineOrderId}</select>
  10. <!-- 版本门禁防止旧网关响应或过期任务覆盖新事实。 -->
  11. <update id="updateVersioned">UPDATE flash_delivery_line_payment SET transaction_id=#{row.transactionId},captured_amount=#{row.capturedAmount},payment_url=#{row.paymentUrl},status=#{row.status},active_order_id=#{row.activeOrderId},lease_until=#{row.leaseUntil},next_reconcile_at=#{row.nextReconcileAt},reconcile_deadline=#{row.reconcileDeadline},paid_at=#{row.paidAt},update_time=#{row.updateTime},version=version+1 WHERE id=#{row.id} AND version=#{expectedVersion}</update>
  12. <select id="selectDue" resultType="com.ruoyi.system.domain.flash.FlashDeliveryLinePayment">SELECT <include refid="columns"/> FROM flash_delivery_line_payment
  13. WHERE status IN ('CREATED','REQUESTING','WAITING_AUTH','CONFIRMING','REQUEST_UNKNOWN','CONFIRM_UNKNOWN')
  14. AND (next_reconcile_at IS NULL OR next_reconcile_at &lt;= #{now}) AND (lease_until IS NULL OR lease_until &lt;= #{now}) ORDER BY next_reconcile_at, id LIMIT #{limit}</select>
  15. </mapper>