This commit is contained in:
parent
fafb229295
commit
bb80df5786
@ -59,9 +59,6 @@ func (l *AttachTransactionLogic) Attach(req *types.AttachAppleTransactionRequest
|
|||||||
l.Errorw("无效访问,用户信息缺失")
|
l.Errorw("无效访问,用户信息缺失")
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "invalid access")
|
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
|
|
||||||
}
|
|
||||||
if strings.TrimSpace(req.OrderNo) == "" {
|
if strings.TrimSpace(req.OrderNo) == "" {
|
||||||
l.Errorw("参数错误,orderNo 不能为空")
|
l.Errorw("参数错误,orderNo 不能为空")
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidParams), "order_no is required")
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidParams), "order_no is required")
|
||||||
|
|||||||
@ -41,9 +41,6 @@ func (l *RestoreLogic) Restore(req *types.RestoreAppleTransactionsRequest) error
|
|||||||
if !ok || u == nil {
|
if !ok || u == nil {
|
||||||
return errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "invalid access")
|
return errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "invalid access")
|
||||||
}
|
}
|
||||||
if err := commonLogic.DenyIfFamilyMemberReadonly(l.ctx, l.svcCtx.DB, u.Id); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
pm, _ := iapapple.ParseProductMap(l.svcCtx.Config.Site.CustomData)
|
pm, _ := iapapple.ParseProductMap(l.svcCtx.Config.Site.CustomData)
|
||||||
// Load Apple Server API config from payment table
|
// Load Apple Server API config from payment table
|
||||||
apiCfgPtr, err := LoadAppleServerAPIConfig(l.ctx, l.svcCtx)
|
apiCfgPtr, err := LoadAppleServerAPIConfig(l.ctx, l.svcCtx)
|
||||||
|
|||||||
@ -46,10 +46,6 @@ func (l *PreCreateOrderLogic) PreCreateOrder(req *types.PurchaseOrderRequest) (r
|
|||||||
logger.Error("current user is not found in context")
|
logger.Error("current user is not found in context")
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "Invalid Access")
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
if req.Quantity <= 0 {
|
if req.Quantity <= 0 {
|
||||||
l.Debugf("[PreCreateOrder] Quantity is less than or equal to 0, setting to 1")
|
l.Debugf("[PreCreateOrder] Quantity is less than or equal to 0, setting to 1")
|
||||||
req.Quantity = 1
|
req.Quantity = 1
|
||||||
|
|||||||
@ -49,8 +49,10 @@ func (l *RenewalLogic) Renewal(req *types.RenewalOrderRequest) (resp *types.Rene
|
|||||||
logger.Error("current user is not found in context")
|
logger.Error("current user is not found in context")
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "Invalid Access")
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "Invalid Access")
|
||||||
}
|
}
|
||||||
if err = commonLogic.DenyIfFamilyMemberReadonly(l.ctx, l.svcCtx.DB, u.Id); err != nil {
|
// Resolve entitlement: member's subscription goes to owner
|
||||||
return nil, err
|
entitlement, entErr := commonLogic.ResolveEntitlementUser(l.ctx, l.svcCtx.DB, u.Id)
|
||||||
|
if entErr != nil {
|
||||||
|
return nil, entErr
|
||||||
}
|
}
|
||||||
if req.Quantity <= 0 {
|
if req.Quantity <= 0 {
|
||||||
l.Debugf("[Renewal] Quantity is less than or equal to 0, setting to 1")
|
l.Debugf("[Renewal] Quantity is less than or equal to 0, setting to 1")
|
||||||
@ -169,8 +171,9 @@ func (l *RenewalLogic) Renewal(req *types.RenewalOrderRequest) (resp *types.Rene
|
|||||||
|
|
||||||
// create order
|
// create order
|
||||||
orderInfo := order.Order{
|
orderInfo := order.Order{
|
||||||
UserId: u.Id,
|
UserId: u.Id,
|
||||||
ParentId: userSubscribe.OrderId,
|
SubscriptionUserId: entitlement.EffectiveUserID,
|
||||||
|
ParentId: userSubscribe.OrderId,
|
||||||
OrderNo: orderNo,
|
OrderNo: orderNo,
|
||||||
Type: 2,
|
Type: 2,
|
||||||
Quantity: req.Quantity,
|
Quantity: req.Quantity,
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
commonLogic "github.com/perfect-panel/server/internal/logic/common"
|
|
||||||
"github.com/perfect-panel/server/internal/model/log"
|
"github.com/perfect-panel/server/internal/model/log"
|
||||||
"github.com/perfect-panel/server/pkg/constant"
|
"github.com/perfect-panel/server/pkg/constant"
|
||||||
"github.com/perfect-panel/server/pkg/xerr"
|
"github.com/perfect-panel/server/pkg/xerr"
|
||||||
@ -44,9 +43,6 @@ func (l *ResetTrafficLogic) ResetTraffic(req *types.ResetTrafficOrderRequest) (r
|
|||||||
logger.Error("current user is not found in context")
|
logger.Error("current user is not found in context")
|
||||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidAccess), "Invalid Access")
|
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
|
|
||||||
}
|
|
||||||
// find user subscription
|
// find user subscription
|
||||||
userSubscribe, err := l.svcCtx.UserModel.FindOneUserSubscribe(l.ctx, req.UserSubscribeID)
|
userSubscribe, err := l.svcCtx.UserModel.FindOneUserSubscribe(l.ctx, req.UserSubscribeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user