账单-雪花主键-mq批量消费-sql

This commit is contained in:
2025-09-09 11:50:00 +08:00
parent fffe747456
commit 7f54afc166
3 changed files with 83 additions and 0 deletions

View File

@@ -19,6 +19,13 @@ import java.util.Map;
*/
public interface BillRecordMapper extends BaseMapper<BillRecord> {
/**
* 批量插入账单记录,使用 INSERT IGNORE 忽略重复记录
* @param billRecords 账单记录列表
* @return 插入的记录数
*/
int insertIgnore(@Param("billRecords") List<BillRecord> billRecords);
Long getGiftSumByGift();
Long getGiftTypeSumByRoom();

View File

@@ -13,6 +13,53 @@
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<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
) 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>
</insert>
<select id="getGiftSumByGift" resultType="long">
select COUNT(bill_id) FROM bill_record
</select>