feat:2、刷新绑定信息,操作加一个刷新绑定状态的按钮,3、绑定错误有提示,手动上报异常,拿到包ID做链接跳转(定位)
This commit is contained in:
@@ -20,6 +20,7 @@ func (s *RockService) importPackageDetail(ctx context.Context, detail *RockPacka
|
||||
}
|
||||
|
||||
packageID := detail.Package.ID
|
||||
shareCode := strings.TrimSpace(detail.Package.ShareCode)
|
||||
inserted, updated, skipped := 0, 0, 0
|
||||
err := s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
for _, pt := range detail.Tokens {
|
||||
@@ -44,6 +45,15 @@ func (s *RockService) importPackageDetail(ctx context.Context, detail *RockPacka
|
||||
if _, ok := forceAvailableIDs[upstreamID]; ok {
|
||||
insertStatus = model.RockStatusAvailable
|
||||
}
|
||||
// 上游不提供“进入 using”的时间,用 Token 创建时间近似(与 017 回填口径一致)。
|
||||
var usingAt *time.Time
|
||||
if insertStatus == model.RockStatusUsing {
|
||||
usingAt = claimedAt
|
||||
if usingAt == nil {
|
||||
now := time.Now()
|
||||
usingAt = &now
|
||||
}
|
||||
}
|
||||
rec := model.RockToken{
|
||||
UpstreamTokenID: upstreamID,
|
||||
Token: strings.TrimSpace(pt.Token),
|
||||
@@ -52,6 +62,7 @@ func (s *RockService) importPackageDetail(ctx context.Context, detail *RockPacka
|
||||
Region: defaultValue(strings.TrimSpace(pt.Region), "Q/V可用"),
|
||||
Status: insertStatus,
|
||||
PackageID: &packageID,
|
||||
PackageShareCode: shareCode,
|
||||
ActualRoleName: strings.TrimSpace(pt.BoundAccount),
|
||||
ActualRoleID: strings.TrimSpace(pt.BoundAccountID),
|
||||
ActualChannel: strings.TrimSpace(pt.Region),
|
||||
@@ -61,6 +72,7 @@ func (s *RockService) importPackageDetail(ctx context.Context, detail *RockPacka
|
||||
RawData: string(raw),
|
||||
Source: "package",
|
||||
ClaimedAt: claimedAt,
|
||||
UsingAt: usingAt,
|
||||
BoundAt: boundAt,
|
||||
RedeemedAt: redeemedAt,
|
||||
}
|
||||
@@ -78,6 +90,9 @@ func (s *RockService) importPackageDetail(ctx context.Context, detail *RockPacka
|
||||
"package_id": packageID,
|
||||
"raw_data": string(raw),
|
||||
}
|
||||
if existing.PackageShareCode == "" && shareCode != "" {
|
||||
updates["package_share_code"] = shareCode
|
||||
}
|
||||
// 已存在的本地 Token 只补空字段,避免覆盖手动采购/正在履约的本地状态。
|
||||
if existing.Token == "" {
|
||||
updates["token"] = strings.TrimSpace(pt.Token)
|
||||
@@ -102,6 +117,13 @@ func (s *RockService) importPackageDetail(ctx context.Context, detail *RockPacka
|
||||
existing.Status != model.RockStatusAvailable
|
||||
if canRefreshUpstream {
|
||||
updates["status"] = status
|
||||
if status == model.RockStatusUsing && existing.UsingAt == nil {
|
||||
if claimedAt != nil {
|
||||
updates["using_at"] = claimedAt
|
||||
} else {
|
||||
updates["using_at"] = time.Now()
|
||||
}
|
||||
}
|
||||
if strings.TrimSpace(pt.BoundAccount) != "" {
|
||||
updates["actual_role_name"] = strings.TrimSpace(pt.BoundAccount)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user