fix(delivery): 硬化自动发货可靠性,避免双发与无限 Webhook 重试
恢复 ship_failed 可重试 UI;DLC 断点续传 queue;乐玩未绑定禁止进 delivering;Webhook 原子 nonce 与业务拒绝回 200。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -548,8 +548,21 @@ func (s *DeliveryService) submit(orderNo, gameAccount, bindUUID string, apiClien
|
||||
activeProvider := providers[0]
|
||||
|
||||
submitRes, err := activeProvider.Submit(context.Background(), claimed, gameAccount, bindUUID)
|
||||
if submitRes != nil && len(submitRes.PatchResultData) > 0 {
|
||||
stage := deliveryStageCreateOrder
|
||||
if v, ok := submitRes.PatchResultData["provider_order_stage"].(string); ok && v != "" {
|
||||
stage = v
|
||||
}
|
||||
_ = s.recordDeliverySubmissionStage(claimed, stage, submitRes.PatchResultData)
|
||||
}
|
||||
if err != nil {
|
||||
s.markDeliverySubmissionFailed(claimed, apiClientID, deliveryStageCreateOrder, err.Error())
|
||||
failStage := deliveryStageCreateOrder
|
||||
if submitRes != nil {
|
||||
if v, ok := submitRes.PatchResultData["provider_order_stage"].(string); ok && v != "" {
|
||||
failStage = v
|
||||
}
|
||||
}
|
||||
s.markDeliverySubmissionFailed(claimed, apiClientID, failStage, err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -563,6 +576,8 @@ func (s *DeliveryService) submit(orderNo, gameAccount, bindUUID string, apiClien
|
||||
ResultData: resultData,
|
||||
})
|
||||
if err != nil {
|
||||
// 上游已有身份时先固化 result_data,避免重试双发
|
||||
_ = s.recordDeliverySubmissionStage(claimed, deliveryStageSubmitted, submitRes.PatchResultData)
|
||||
return nil, err
|
||||
}
|
||||
return &DeliverySubmitResult{
|
||||
@@ -599,7 +614,10 @@ func (s *DeliveryService) claimDeliverySubmission(merchantID, apiClientID uint,
|
||||
}
|
||||
now := time.Now()
|
||||
stage := resultDataString(order.ResultData, "provider_order_stage")
|
||||
if deliverySubmissionInProgress(stage) && !deliverySubmissionStale(&order, now) {
|
||||
// ship_failed 可立即重试;仅对仍处于 paid 等提交中态拦截并发双发
|
||||
if orderStatus != model.OrderStatusShipFailed &&
|
||||
deliverySubmissionInProgress(stage) &&
|
||||
!deliverySubmissionStale(&order, now) {
|
||||
updated = order
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user