This commit is contained in:
@@ -3,6 +3,7 @@ package apple
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -153,6 +154,26 @@ SIRDAVLcWemp0fMlnfDE4EHmqcD58arEJWsr3aWEhc4BHocOUIGjko0cVWGchrFa
|
||||
// But for now, we only rely on appAccountToken or just skip order linking.
|
||||
|
||||
exp := iapapple.CalcExpire(txp.PurchaseDate, m.DurationDays)
|
||||
if l.svcCtx.Config.Subscribe.SingleModel {
|
||||
anchorSub, anchorErr := findSingleModeMergeTarget(l.ctx, l.svcCtx, u.Id, m.SubscribeId)
|
||||
switch {
|
||||
case errors.Is(anchorErr, commonLogic.ErrSingleModePlanMismatch):
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.SingleSubscribePlanMismatch), "single subscribe mode plan mismatch")
|
||||
case anchorErr == nil && anchorSub != nil && anchorSub.Id > 0:
|
||||
if exp.After(anchorSub.ExpireTime) {
|
||||
anchorSub.ExpireTime = exp
|
||||
}
|
||||
anchorSub.Status = 1
|
||||
anchorSub.FinishedAt = nil
|
||||
if err := l.svcCtx.UserModel.UpdateSubscribe(l.ctx, anchorSub, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
case errors.Is(anchorErr, gorm.ErrRecordNotFound):
|
||||
case anchorErr != nil:
|
||||
return anchorErr
|
||||
}
|
||||
}
|
||||
userSub := user.Subscribe{
|
||||
UserId: u.Id,
|
||||
SubscribeId: m.SubscribeId,
|
||||
@@ -161,7 +182,7 @@ SIRDAVLcWemp0fMlnfDE4EHmqcD58arEJWsr3aWEhc4BHocOUIGjko0cVWGchrFa
|
||||
Traffic: 0,
|
||||
Download: 0,
|
||||
Upload: 0,
|
||||
Token: txp.OriginalTransactionId,
|
||||
Token: fmt.Sprintf("iap:%s", txp.OriginalTransactionId),
|
||||
UUID: uuid.New().String(),
|
||||
Status: 1,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user