|
|
@@ -1,7 +1,9 @@
|
|
|
package com.payment.platform.module.payment.notification.mapper;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
import com.payment.platform.module.payment.notification.entity.PayBillEntity;
|
|
|
+import org.apache.ibatis.annotations.Insert;
|
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
import org.apache.ibatis.annotations.Select;
|
|
|
@@ -33,5 +35,42 @@ public interface PayBillMapper extends BaseMapper<PayBillEntity> {
|
|
|
Map<String, BigDecimal> statConsumeAmount(@Param("tenantId") Long tenantId,
|
|
|
@Param("enterpriseId") String enterpriseId,
|
|
|
@Param("payeeType") String payeeType);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 原子 upsert(通知处理用,跳过租户过滤)
|
|
|
+ * 并发安全:同一 pay_no 的 COLLECT → ASSETS_UPDATE 无论到达顺序,
|
|
|
+ * 数据库层面保证最后一个写入的状态为最终状态。
|
|
|
+ */
|
|
|
+ @InterceptorIgnore(tenantLine = "true")
|
|
|
+ @Insert("""
|
|
|
+ INSERT INTO pay_bill (id, pay_no, account_id, employee_id, consume_type,
|
|
|
+ consume_amount, gmt_biz_create, gmt_recieve_pay, peer_pay_amount,
|
|
|
+ notify_reason, notify_msg, related_pay_no, expense_rule_group_id,
|
|
|
+ expense_scene_code, expense_type, status, ext_infos,
|
|
|
+ enterprise_id, tenant_id, created_time, updated_time)
|
|
|
+ VALUES (#{id}, #{payNo}, #{accountId}, #{employeeId}, #{consumeType},
|
|
|
+ #{consumeAmount}, #{gmtBizCreate}, #{gmtRecievePay}, #{peerPayAmount},
|
|
|
+ #{notifyReason}, #{notifyMsg}, #{relatedPayNo}, #{expenseRuleGroupId},
|
|
|
+ #{expenseSceneCode}, #{expenseType}, #{status}, #{extInfos}::jsonb,
|
|
|
+ #{enterpriseId}, #{tenantId}, #{createdTime}, #{updatedTime})
|
|
|
+ ON CONFLICT (pay_no) DO UPDATE SET
|
|
|
+ account_id = EXCLUDED.account_id,
|
|
|
+ employee_id = EXCLUDED.employee_id,
|
|
|
+ consume_type = EXCLUDED.consume_type,
|
|
|
+ consume_amount = EXCLUDED.consume_amount,
|
|
|
+ gmt_biz_create = EXCLUDED.gmt_biz_create,
|
|
|
+ gmt_recieve_pay = EXCLUDED.gmt_recieve_pay,
|
|
|
+ peer_pay_amount = EXCLUDED.peer_pay_amount,
|
|
|
+ notify_reason = EXCLUDED.notify_reason,
|
|
|
+ notify_msg = EXCLUDED.notify_msg,
|
|
|
+ related_pay_no = EXCLUDED.related_pay_no,
|
|
|
+ expense_rule_group_id = EXCLUDED.expense_rule_group_id,
|
|
|
+ expense_scene_code = EXCLUDED.expense_scene_code,
|
|
|
+ expense_type = EXCLUDED.expense_type,
|
|
|
+ status = EXCLUDED.status,
|
|
|
+ ext_infos = EXCLUDED.ext_infos,
|
|
|
+ updated_time = EXCLUDED.updated_time
|
|
|
+ """)
|
|
|
+ void upsert(PayBillEntity bill);
|
|
|
}
|
|
|
|