feat: 苹果支付uuid 及设备逻辑
Build docker and publish / build (20.15.1) (push) Successful in 8m3s

This commit is contained in:
2026-03-10 19:53:19 -07:00
parent 662ef6edb3
commit 26f6400e74
10 changed files with 142 additions and 25 deletions
+15 -8
View File
@@ -6,6 +6,8 @@ import (
"math"
"time"
"github.com/google/uuid"
commonLogic "github.com/perfect-panel/server/internal/logic/common"
"github.com/perfect-panel/server/internal/model/log"
"github.com/perfect-panel/server/pkg/constant"
@@ -31,7 +33,7 @@ type PurchaseLogic struct {
}
const (
CloseOrderTimeMinutes = 5
CloseOrderTimeMinutes = 15
)
// NewPurchaseLogic creates a new purchase logic instance for subscription purchase operations.
@@ -54,8 +56,10 @@ func (l *PurchaseLogic) Purchase(req *types.PurchaseOrderRequest) (resp *types.P
logger.Error("current user is not found in context")
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "Invalid Access")
}
if err = commonLogic.DenyIfFamilyMemberReadonly(l.ctx, l.svcCtx.DB, u.Id); err != nil {
return nil, err
// Resolve entitlement: member's subscription goes to owner
entitlement, entErr := commonLogic.ResolveEntitlementUser(l.ctx, l.svcCtx.DB, u.Id)
if entErr != nil {
return nil, entErr
}
if req.Quantity <= 0 {
@@ -221,8 +225,9 @@ func (l *PurchaseLogic) Purchase(req *types.PurchaseOrderRequest) (resp *types.P
}
// create order
orderInfo := &order.Order{
UserId: u.Id,
ParentId: parentOrderID,
UserId: u.Id,
SubscriptionUserId: entitlement.EffectiveUserID,
ParentId: parentOrderID,
OrderNo: tool.GenerateTradeNo(),
Type: orderType,
Quantity: req.Quantity,
@@ -237,8 +242,9 @@ func (l *PurchaseLogic) Purchase(req *types.PurchaseOrderRequest) (resp *types.P
FeeAmount: feeAmount,
Status: 1,
IsNew: isNew,
SubscribeId: targetSubscribeID,
SubscribeToken: subscribeToken,
SubscribeId: targetSubscribeID,
SubscribeToken: subscribeToken,
AppAccountToken: uuid.New().String(),
}
if isSingleModeRenewal {
l.Infow("[Purchase] single mode purchase order created as renewal",
@@ -368,6 +374,7 @@ func (l *PurchaseLogic) Purchase(req *types.PurchaseOrderRequest) (resp *types.P
}
return &types.PurchaseOrderResponse{
OrderNo: orderInfo.OrderNo,
OrderNo: orderInfo.OrderNo,
AppAccountToken: orderInfo.AppAccountToken,
}, nil
}