fix(*): 请求明细与画布主题 - 区分非计费下载日志并更新默认网格配色
This commit is contained in:
1 parent
1bbccaedc4
commit
58272e683f
14 files changed
+81
-47
No files matched your search
@@ -235,7 +235,7 @@ func (s *Service) decorateAPICallLogs(logs []model.ApiCallLog) error {
|
||||
taskIDs := make([]string, 0, len(logs))
|
||||
seenTaskIDs := make(map[string]struct{}, len(logs))
|
||||
for _, log := range logs {
|
||||
if log.BillingOrderID != "" {
|
||||
if log.Billable && log.BillingOrderID != "" {
|
||||
if _, exists := seenBillingOrderIDs[log.BillingOrderID]; !exists {
|
||||
seenBillingOrderIDs[log.BillingOrderID] = struct{}{}
|
||||
billingOrderIDs = append(billingOrderIDs, log.BillingOrderID)
|
||||
@@ -277,13 +277,15 @@ func (s *Service) decorateAPICallLogs(logs []model.ApiCallLog) error {
|
||||
logs[index].UserDisplayName = user.DisplayName
|
||||
logs[index].UserAccount = user.Username
|
||||
}
|
||||
if order, exists := billingOrderByID[logs[index].BillingOrderID]; exists && order.UserID == logs[index].UserID {
|
||||
logs[index].BillingAvailable = true
|
||||
logs[index].BillingStatus = order.Status
|
||||
if order.Status == model.BillingStatusSettled {
|
||||
logs[index].BillingAmount = order.ActualAmountMicrocredits
|
||||
} else if order.Status != model.BillingStatusRefunded {
|
||||
logs[index].BillingAmount = order.ReservedAmountMicrocredits
|
||||
if logs[index].Billable {
|
||||
if order, exists := billingOrderByID[logs[index].BillingOrderID]; exists && order.UserID == logs[index].UserID {
|
||||
logs[index].BillingAvailable = true
|
||||
logs[index].BillingStatus = order.Status
|
||||
if order.Status == model.BillingStatusSettled {
|
||||
logs[index].BillingAmount = order.ActualAmountMicrocredits
|
||||
} else if order.Status != model.BillingStatusRefunded {
|
||||
logs[index].BillingAmount = order.ReservedAmountMicrocredits
|
||||
}
|
||||
}
|
||||
}
|
||||
if task, exists := taskByID[logs[index].TaskID]; exists && task.UserID == logs[index].UserID {
|
||||
|
||||
@@ -37,12 +37,13 @@ func TestDecorateAPICallLogsUsesBillingOrderSnapshot(t *testing.T) {
|
||||
}
|
||||
|
||||
logs := []model.ApiCallLog{
|
||||
{ID: "log-settled", UserID: "user-1", BillingOrderID: "settled", Capability: "text"},
|
||||
{ID: "log-reserved", UserID: "user-1", BillingOrderID: "reserved", Capability: "text"},
|
||||
{ID: "log-uncertain", UserID: "user-1", BillingOrderID: "uncertain", Capability: "text"},
|
||||
{ID: "log-refunded", UserID: "user-1", BillingOrderID: "refunded", Capability: "text"},
|
||||
{ID: "log-missing", UserID: "user-1", BillingOrderID: "missing", Capability: "text"},
|
||||
{ID: "log-other-user", UserID: "user-1", BillingOrderID: "other-user", Capability: "text"},
|
||||
{ID: "log-settled", UserID: "user-1", BillingOrderID: "settled", Capability: "text", Billable: true},
|
||||
{ID: "log-reserved", UserID: "user-1", BillingOrderID: "reserved", Capability: "text", Billable: true},
|
||||
{ID: "log-uncertain", UserID: "user-1", BillingOrderID: "uncertain", Capability: "text", Billable: true},
|
||||
{ID: "log-refunded", UserID: "user-1", BillingOrderID: "refunded", Capability: "text", Billable: true},
|
||||
{ID: "log-missing", UserID: "user-1", BillingOrderID: "missing", Capability: "text", Billable: true},
|
||||
{ID: "log-other-user", UserID: "user-1", BillingOrderID: "other-user", Capability: "text", Billable: true},
|
||||
{ID: "log-download", UserID: "user-1", BillingOrderID: "settled", Capability: "image", RequestKind: "download", Billable: false},
|
||||
}
|
||||
|
||||
svc := &Service{repo: repository.New(db)}
|
||||
@@ -56,6 +57,7 @@ func TestDecorateAPICallLogsUsesBillingOrderSnapshot(t *testing.T) {
|
||||
assertBillingSnapshot(t, logs[3], true, model.BillingStatusRefunded, 0)
|
||||
assertBillingSnapshot(t, logs[4], false, "", 0)
|
||||
assertBillingSnapshot(t, logs[5], false, "", 0)
|
||||
assertBillingSnapshot(t, logs[6], false, "", 0)
|
||||
}
|
||||
|
||||
func assertBillingSnapshot(t *testing.T, log model.ApiCallLog, available bool, status model.BillingStatus, amount int64) {
|
||||
|
||||
Reference in new issue
Block a user