fix: sync StarGift prepaid upgrade message refs
This commit is contained in:
parent
8cfb6f74c1
commit
045e0f6db4
8 changed files with 754 additions and 148 deletions
|
|
@ -9,9 +9,11 @@ import (
|
|||
|
||||
// registerUserStarGiftMessageRef records an owner-scoped service-message alias
|
||||
// for a user-owned gift. Official clients may continue from a freshly emitted
|
||||
// messageActionStarGiftUnique and pass that message id to a lifecycle RPC,
|
||||
// while payments.getSavedStarGifts may still expose the original received gift
|
||||
// message as the aggregate's primary msg_id.
|
||||
// messageActionStarGiftUnique or a separate prepaid-upgrade notification and
|
||||
// pass that message id to a lifecycle RPC, while payments.getSavedStarGifts may
|
||||
// still expose the original received gift message as the aggregate's primary
|
||||
// msg_id. expectedUniqueGiftID is zero for an ordinary gift and positive for a
|
||||
// unique gift; the write boundary never aliases across lifecycle states.
|
||||
func registerUserStarGiftMessageRef(
|
||||
ctx context.Context,
|
||||
tx pgx.Tx,
|
||||
|
|
@ -20,7 +22,7 @@ func registerUserStarGiftMessageRef(
|
|||
savedGiftID int64,
|
||||
uniqueGiftID int64,
|
||||
) error {
|
||||
if ownerUserID <= 0 || msgID <= 0 || savedGiftID <= 0 || uniqueGiftID <= 0 {
|
||||
if ownerUserID <= 0 || msgID <= 0 || savedGiftID <= 0 || uniqueGiftID < 0 {
|
||||
return fmt.Errorf("register user star gift message ref: invalid identity")
|
||||
}
|
||||
tag, err := tx.Exec(ctx, `
|
||||
|
|
@ -28,7 +30,8 @@ INSERT INTO star_gift_user_message_refs(owner_user_id,msg_id,saved_gift_id)
|
|||
SELECT $1,$2,p.id
|
||||
FROM peer_star_gifts p
|
||||
WHERE p.id=$3 AND p.owner_peer_type='user' AND p.owner_peer_id=$1
|
||||
AND p.unique_gift_id=$4 AND p.lifecycle_status='active'
|
||||
AND (($4::bigint=0 AND p.unique_gift_id IS NULL) OR ($4::bigint>0 AND p.unique_gift_id=$4::bigint))
|
||||
AND p.lifecycle_status='active'
|
||||
ON CONFLICT(owner_user_id,msg_id) DO UPDATE
|
||||
SET saved_gift_id=EXCLUDED.saved_gift_id
|
||||
WHERE star_gift_user_message_refs.saved_gift_id=EXCLUDED.saved_gift_id`, ownerUserID, msgID, savedGiftID, uniqueGiftID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue