feat: 完善 Rock 发货异常闭环与绑定判定
This commit is contained in:
@@ -16,11 +16,13 @@ import (
|
||||
|
||||
// BindingSnapshot 保存分配 Token 时上游的绑定快照
|
||||
type BindingSnapshot struct {
|
||||
Bound bool `json:"bound"`
|
||||
RoleName string `json:"role_name"`
|
||||
RoleID string `json:"role_id"`
|
||||
Channel string `json:"channel"`
|
||||
BindChangedAt string `json:"bind_changed_at"`
|
||||
Bound bool `json:"bound"`
|
||||
RoleName string `json:"role_name"`
|
||||
RoleID string `json:"role_id"`
|
||||
Channel string `json:"channel"`
|
||||
BindChangedAt string `json:"bind_changed_at"`
|
||||
BindChangeType string `json:"bind_change_type,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// rockOrderTokenLockedMessage 一单只能占用一个提货号。绑定失败后不再发新号。
|
||||
@@ -166,12 +168,15 @@ func (s *RockService) AssignTokenForOrder(ctx context.Context, orderNo, expected
|
||||
if token.InitialBoundSnapshot == "" && cfg.BearerToken != "" {
|
||||
ref, refErr := s.client.RefreshToken(ctx, cfg.BearerToken, token.UpstreamTokenID)
|
||||
if refErr == nil && ref != nil {
|
||||
currentBound, _ := rockCurrentCycleBinding(&token, ref)
|
||||
snap := BindingSnapshot{
|
||||
Bound: ref.IsBound(),
|
||||
RoleName: ref.GetRoleName(),
|
||||
RoleID: ref.GetRoleID(),
|
||||
Channel: ref.GetChannel(),
|
||||
BindChangedAt: ref.Token.BindChangedAt,
|
||||
Bound: currentBound,
|
||||
RoleName: ref.GetRoleName(),
|
||||
RoleID: ref.GetRoleID(),
|
||||
Channel: ref.GetChannel(),
|
||||
BindChangedAt: ref.Token.BindChangedAt,
|
||||
BindChangeType: ref.Token.BindChangeType,
|
||||
Status: ref.Token.Status,
|
||||
}
|
||||
snapBytes, _ := json.Marshal(snap)
|
||||
token.InitialBoundSnapshot = string(snapBytes)
|
||||
|
||||
Reference in New Issue
Block a user