27 lines
1.0 KiB
Go
27 lines
1.0 KiB
Go
package mysql
|
||
|
||
import (
|
||
"context"
|
||
"database/sql"
|
||
|
||
"hyapp/pkg/appcode"
|
||
)
|
||
|
||
// insertAgencyPointShare 把“当时属于哪个 Agency”与实际入账金额固化在同一送礼事务内;
|
||
// 后续主播转会时统计仍按这条快照归属,不能用当前成员关系重算历史收入。
|
||
func (r *Repository) insertAgencyPointShare(ctx context.Context, tx *sql.Tx, transactionID string, metadata giftMetadata, nowMS int64) error {
|
||
if metadata.AgencyPointAdded <= 0 || metadata.TargetAgencyOwnerUserID <= 0 {
|
||
return nil
|
||
}
|
||
_, err := tx.ExecContext(ctx, `
|
||
INSERT INTO agency_point_share_entries (
|
||
app_code, transaction_id, host_user_id, agency_owner_user_id, sender_user_id,
|
||
room_id, point_delta, ratio_ppm, policy_instance_code, created_at_ms
|
||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||
appcode.FromContext(ctx), transactionID, metadata.TargetUserID, metadata.TargetAgencyOwnerUserID,
|
||
metadata.SenderUserID, metadata.RoomID, metadata.AgencyPointAdded, metadata.AgencyPointRatioPPM,
|
||
metadata.HostPointPolicyInstanceCode, nowMS,
|
||
)
|
||
return err
|
||
}
|