账单-雪花主键-无锁化唯一主键插入

This commit is contained in:
2025-09-09 15:54:05 +08:00
parent 7f54afc166
commit d2f00bb7f8
7 changed files with 109 additions and 68 deletions

View File

@@ -21,10 +21,8 @@ public interface BillRecordMapper extends BaseMapper<BillRecord> {
/**
* 批量插入账单记录,使用 INSERT IGNORE 忽略重复记录
* @param billRecords 账单记录列表
* @return 插入的记录数
*/
int insertIgnore(@Param("billRecords") List<BillRecord> billRecords);
int insertIgnore(@Param("record") BillRecord billRecord);
Long getGiftSumByGift();

View File

@@ -15,49 +15,47 @@
<insert id="insertIgnore">
INSERT IGNORE INTO bill_record (
bill_id,
uid,
partition_id,
target_uid,
room_uid,
bill_type,
obj_id,
obj_type,
gift_id,
gift_num,
gift_total_gold_num,
currency,
before_amount,
amount,
actual_amount,
after_amount,
create_time,
remark,
mess_id
bill_id,
uid,
partition_id,
target_uid,
room_uid,
bill_type,
obj_id,
obj_type,
gift_id,
gift_num,
gift_total_gold_num,
currency,
before_amount,
amount,
actual_amount,
after_amount,
create_time,
remark,
mess_id
) VALUES
<foreach collection="billRecords" item="record" separator=",">
(
#{record.billId},
#{record.uid},
#{record.partitionId},
#{record.targetUid},
#{record.roomUid},
#{record.billType},
#{record.objId},
#{record.objType},
#{record.giftId},
#{record.giftNum},
#{record.giftTotalGoldNum},
#{record.currency},
#{record.beforeAmount},
#{record.amount},
#{record.actualAmount},
#{record.afterAmount},
#{record.createTime},
#{record.remark},
#{record.messId}
)
</foreach>
(
#{record.billId},
#{record.uid},
#{record.partitionId},
#{record.targetUid},
#{record.roomUid},
#{record.billType},
#{record.objId},
#{record.objType},
#{record.giftId},
#{record.giftNum},
#{record.giftTotalGoldNum},
#{record.currency},
#{record.beforeAmount},
#{record.amount},
#{record.actualAmount},
#{record.afterAmount},
#{record.createTime},
#{record.remark},
#{record.messId}
)
</insert>
<select id="getGiftSumByGift" resultType="long">