Merge pull request 'Updated monthly orders flow' (#197) from fix-permissions into main
Deploy / deploy (push) Failing after 1m7s
Details
Deploy / deploy (push) Failing after 1m7s
Details
Reviewed-on: https://72.56.235.246.nip.io/gitea/romanskijdev/ruspet_portal_back/pulls/197
This commit is contained in:
commit
eef27bfdf5
|
|
@ -220,6 +220,7 @@ func (db *MonthlyOrderDB) SaveClientOrder(ctx context.Context, tx pgx.Tx, order
|
||||||
Set("delivery", order.Delivery).
|
Set("delivery", order.Delivery).
|
||||||
Set("conditions", order.Conditions).
|
Set("conditions", order.Conditions).
|
||||||
Set("payment_form", order.PaymentForm).
|
Set("payment_form", order.PaymentForm).
|
||||||
|
Set("approval_id", order.ApprovalID).
|
||||||
Set("status", *order.Status).
|
Set("status", *order.Status).
|
||||||
Set("updated_at", squirrel.Expr("NOW()")).
|
Set("updated_at", squirrel.Expr("NOW()")).
|
||||||
Where(squirrel.Eq{"id": existingID})
|
Where(squirrel.Eq{"id": existingID})
|
||||||
|
|
|
||||||
|
|
@ -413,14 +413,10 @@ func (s *MonthlyOrderService) SubmitOrdersToTelegram(ctx context.Context, manage
|
||||||
order.Items = append(order.Items, *item)
|
order.Items = append(order.Items, *item)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Заполняем поле Files у структуры Approval, чтобы Notifier мог их отправить как медиа
|
|
||||||
var approvalFiles []*typescore.ApprovalFile
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
fileCopy := f
|
if f != nil {
|
||||||
approvalFiles = append(approvalFiles, &typescore.ApprovalFile{
|
order.Files = append(order.Files, *f)
|
||||||
FileName: fileCopy.FileName,
|
}
|
||||||
FileBase64: fileCopy.FileBase64,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if order.ManagerComment != nil {
|
if order.ManagerComment != nil {
|
||||||
|
|
@ -439,20 +435,42 @@ func (s *MonthlyOrderService) SubmitOrdersToTelegram(ctx context.Context, manage
|
||||||
TopicID: &topicID,
|
TopicID: &topicID,
|
||||||
Content: &contentStr,
|
Content: &contentStr,
|
||||||
Status: &status,
|
Status: &status,
|
||||||
Files: approvalFiles, // 👈 Передаем файлы сюда
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Если у структуры Approval или в методе CreateApprovalDB есть возможность пробросить файлы/вложения,
|
|
||||||
// передайте их здесь. Если ваш бэкенд-сервис согласований поддерживает передачу файлов,
|
|
||||||
// добавьте их в структуру approval. Например:
|
|
||||||
// approval.Files = files (в зависимости от вашей реализации typescore.Approval)
|
|
||||||
|
|
||||||
createdApproval, _, err := s.ipc.Database.Approval.CreateApprovalDB(ctx, nil, approval, true)
|
createdApproval, _, err := s.ipc.Database.Approval.CreateApprovalDB(ctx, nil, approval, true)
|
||||||
if err == nil && createdApproval != nil {
|
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
|
order.ApprovalID = createdApproval.ID
|
||||||
orderStatus := "submitted"
|
orderStatus := "submitted"
|
||||||
order.Status = &orderStatus
|
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 s.flowStarter != nil {
|
||||||
if err := s.flowStarter.StartFlowForOrder(ctx, createdApproval); err != nil {
|
if err := s.flowStarter.StartFlowForOrder(ctx, createdApproval); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue