|
|
|
|
@ -413,14 +413,10 @@ func (s *MonthlyOrderService) SubmitOrdersToTelegram(ctx context.Context, manage
|
|
|
|
|
order.Items = append(order.Items, *item)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Заполняем поле Files у структуры Approval, чтобы Notifier мог их отправить как медиа
|
|
|
|
|
var approvalFiles []*typescore.ApprovalFile
|
|
|
|
|
for _, f := range files {
|
|
|
|
|
fileCopy := f
|
|
|
|
|
approvalFiles = append(approvalFiles, &typescore.ApprovalFile{
|
|
|
|
|
FileName: fileCopy.FileName,
|
|
|
|
|
FileBase64: fileCopy.FileBase64,
|
|
|
|
|
})
|
|
|
|
|
if f != nil {
|
|
|
|
|
order.Files = append(order.Files, *f)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if order.ManagerComment != nil {
|
|
|
|
|
@ -439,20 +435,42 @@ func (s *MonthlyOrderService) SubmitOrdersToTelegram(ctx context.Context, manage
|
|
|
|
|
TopicID: &topicID,
|
|
|
|
|
Content: &contentStr,
|
|
|
|
|
Status: &status,
|
|
|
|
|
Files: approvalFiles, // 👈 Передаем файлы сюда
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Если у структуры Approval или в методе CreateApprovalDB есть возможность пробросить файлы/вложения,
|
|
|
|
|
// передайте их здесь. Если ваш бэкенд-сервис согласований поддерживает передачу файлов,
|
|
|
|
|
// добавьте их в структуру approval. Например:
|
|
|
|
|
// approval.Files = files (в зависимости от вашей реализации typescore.Approval)
|
|
|
|
|
|
|
|
|
|
createdApproval, _, err := s.ipc.Database.Approval.CreateApprovalDB(ctx, nil, approval, true)
|
|
|
|
|
if err == nil && createdApproval != nil {
|
|
|
|
|
var approvalFiles []*typescore.ApprovalFile
|
|
|
|
|
for _, f := range files {
|
|
|
|
|
if f == nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
appFile := &typescore.ApprovalFile{
|
|
|
|
|
ApprovalID: createdApproval.ID, // Привязываем к ID созданной заявки
|
|
|
|
|
FileName: f.FileName,
|
|
|
|
|
FileBase64: f.FileBase64,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
savedFile, _, fileErr := s.ipc.Database.ApprovalFile.CreateApprovalFileDB(ctx, nil, appFile, true)
|
|
|
|
|
if fileErr != nil {
|
|
|
|
|
logrus.Errorf("❌ [SubmitOrders] Ошибка сохранения файла в БД (ApprovalID: %v): %v", createdApproval.ID, fileErr)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if savedFile != nil {
|
|
|
|
|
approvalFiles = append(approvalFiles, savedFile)
|
|
|
|
|
} else {
|
|
|
|
|
approvalFiles = append(approvalFiles, appFile)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createdApproval.Files = approvalFiles
|
|
|
|
|
|
|
|
|
|
order.ApprovalID = createdApproval.ID
|
|
|
|
|
orderStatus := "submitted"
|
|
|
|
|
order.Status = &orderStatus
|
|
|
|
|
s.ipc.Database.MonthlyOrders.SaveClientOrder(ctx, nil, order)
|
|
|
|
|
_, err = s.ipc.Database.MonthlyOrders.SaveClientOrder(ctx, nil, order)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("❌ [SubmitOrders] Ошибка сохранения заказа от клиента (MonthlyOrders.SaveClientOrder): %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.flowStarter != nil {
|
|
|
|
|
if err := s.flowStarter.StartFlowForOrder(ctx, createdApproval); err != nil {
|
|
|
|
|
|