fix(iap/apple): 添加订单号回退逻辑以处理订阅信息缺失
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 6m23s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 6m23s
当请求中缺少duration或subscribeId时,优先从order_no查找订单信息作为回退方案,避免直接返回错误
This commit is contained in:
parent
72400ae054
commit
15fb9a1da5
@ -59,12 +59,26 @@ func (l *AttachTransactionLogic) Attach(req *types.AttachAppleTransactionRequest
|
||||
tier = m.Tier
|
||||
subscribeId = m.SubscribeId
|
||||
} else {
|
||||
if req.DurationDays <= 0 || req.SubscribeId <= 0 {
|
||||
// fallback from order_no if provided
|
||||
if req.OrderNo != "" {
|
||||
if ord, e := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, req.OrderNo); e == nil && ord != nil && ord.Id != 0 {
|
||||
duration = ord.Quantity
|
||||
subscribeId = ord.SubscribeId
|
||||
}
|
||||
}
|
||||
// final fallback: use request fields
|
||||
if duration <= 0 {
|
||||
duration = req.DurationDays
|
||||
}
|
||||
if tier == "" {
|
||||
tier = req.Tier
|
||||
}
|
||||
if subscribeId <= 0 {
|
||||
subscribeId = req.SubscribeId
|
||||
}
|
||||
if duration <= 0 || subscribeId <= 0 {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.ERROR), "unknown product")
|
||||
}
|
||||
duration = req.DurationDays
|
||||
tier = req.Tier
|
||||
subscribeId = req.SubscribeId
|
||||
}
|
||||
exp := iapapple.CalcExpire(txPayload.PurchaseDate, duration)
|
||||
sum := sha256.Sum256([]byte(req.SignedTransactionJWS))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user