fix(delivery): 硬化自动发货可靠性,避免双发与无限 Webhook 重试
恢复 ship_failed 可重试 UI;DLC 断点续传 queue;乐玩未绑定禁止进 delivering;Webhook 原子 nonce 与业务拒绝回 200。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -1155,3 +1156,32 @@ func TestBuildShipNotifyResultDataSuccessRemovesFailureReason(t *testing.T) {
|
||||
t.Fatalf("success result data should keep ship_status, got %s", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleShipNotifyRejectedOnCancelledReturnsTypedError(t *testing.T) {
|
||||
db := newServiceTestDB(t)
|
||||
merchantID, product := seedFulfillmentMerchant(t, db, "merchant-notify-cancel", 1000, 2, 100)
|
||||
svc := NewFulfillmentService(db, nil)
|
||||
created, err := svc.CreateOrder(CreateFulfillmentOrderInput{
|
||||
MerchantID: merchantID,
|
||||
APIClientID: 41,
|
||||
ClientOrderNo: "client-notify-cancel",
|
||||
SKU: product.SKU,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("create order: %v", err)
|
||||
}
|
||||
now := time.Now()
|
||||
if err := db.Model(&model.FulfillmentOrder{}).Where("id = ?", created.Order.ID).Updates(map[string]interface{}{
|
||||
"order_status": model.OrderStatusCancelled,
|
||||
"cancelled_at": now,
|
||||
}).Error; err != nil {
|
||||
t.Fatalf("cancel order: %v", err)
|
||||
}
|
||||
_, err = svc.HandleShipNotify(ShipNotifyInput{
|
||||
OrderNo: created.Order.OrderNo,
|
||||
ShipStatus: "success",
|
||||
})
|
||||
if !errors.Is(err, ErrShipNotifyRejected) {
|
||||
t.Fatalf("expected ErrShipNotifyRejected, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user