refactor(core): 任务与模型协议治理 - 拆分服务职责并禁止已发起任务取消

This commit is contained in:
ddCat committed 2026-08-22 09:52:09 +08:00
1 parent 7418ddfa9c
commit 633560a5d8
91 files changed
+6380 -4247

No files matched your search

+5 -41
View File
@@ -793,59 +793,23 @@ func billingQuantity(capability string, value any) int64 {
}
func (s *Service) MarkBillingRunning(orderID string) error {
if orderID == "" {
return nil
}
return s.repo.MarkBillingRunning(orderID)
return s.taskBilling().MarkBillingRunning(orderID)
}
func (s *Service) SettleBilling(orderID string, providerRequestID string) error {
if orderID == "" {
return nil
}
return s.repo.SettleBillingOrder(orderID, providerRequestID)
return s.taskBilling().SettleBilling(orderID, providerRequestID)
}
func (s *Service) RefundBilling(orderID string, errorText string) error {
if orderID == "" {
return nil
}
return s.repo.RefundBillingOrder(orderID, truncateRunes(errorText, 1000))
return s.taskBilling().RefundBilling(orderID, errorText)
}
func (s *Service) MarkBillingUncertain(orderID string, errorText string) error {
if orderID == "" {
return nil
}
return s.repo.MarkBillingUncertain(orderID, truncateRunes(errorText, 1000))
return s.taskBilling().MarkBillingUncertain(orderID, errorText)
}
func (s *Service) BillingFailureRequiresReview(orderID string, taskID string, err error) bool {
if orderID == "" {
return false
}
if billingFailureUncertain(err) {
return true
}
order, orderErr := s.repo.BillingOrder(orderID)
if orderErr != nil || order.Status == model.BillingStatusUncertain {
return true
}
hasSuccessfulCall, logErr := s.repo.TaskHasSuccessfulBillableCall(taskID)
return logErr != nil || hasSuccessfulCall
}
func billingFailureUncertain(err error) bool {
if err == nil {
return false
}
message := strings.ToLower(err.Error())
for _, marker := range []string{"524", "timeout", "超时", "deadline exceeded", "context canceled", "connection reset", "unexpected eof", "broken pipe"} {
if strings.Contains(message, marker) {
return true
}
}
return false
return s.taskBilling().BillingFailureRequiresReview(orderID, taskID, err)
}
func newRedeemCode() (string, error) {