Files
GuwandykA 11e1fa4972
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled
visamaster: record order actions for the "Ammallar" table
Every create, update and delete of a visa/master or sber order is now
recorded in visa_master_order_actions: who did it, finished or failed
(with the exception), and for an update only the columns that changed -
original before, changes after. Marking an order paid when a payment is
finalized is recorded the same way, with no user when the GBÜS callback
did it.

Actions are written in the transaction that changes the order, so one is
on record exactly when its change is; failed ones are written after the
rollback with the values they attempted. The payment finalize records
after its commit instead, so recording never holds up a payment GBÜS has
already taken. Updates that change nothing and creates that fail (no
order to attach to) are not recorded.

GET /visa-master-payment-orders/{id}/actions lists them, newest first;
GET /visa-master-payment-orders/{id}/actions/{actionId} adds original,
changes and exception. Both are staff-only and order-scoped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 22:39:42 +05:00

155 lines
8.0 KiB
Go

package visamaster
import (
"encoding/json"
"time"
"online-back/internal/shared"
)
type BranchInfo struct {
Id int64 `json:"id"`
UniqueCode string `json:"uniqueCode"`
Name shared.LocalizedText `json:"name"`
Region string `json:"region"`
ProvinceId *int64 `json:"provinceId"`
ProvinceName shared.LocalizedText `json:"provinceName"`
}
type VisaMasterPaymentOrderDTO struct {
Id int64 `json:"id"`
UniqueId *string `json:"uniqueId"`
Type *string `json:"type"`
PassportName string `json:"passportName"`
PassportSurname string `json:"passportSurname"`
Phone string `json:"phone"`
Email *string `json:"email"`
Region string `json:"region"`
RegionName shared.LocalizedText `json:"regionName,omitempty"`
BranchId int64 `json:"-"`
Branch BranchInfo `json:"branch"`
UserId *int64 `json:"-"`
User *shared.UserInfo `json:"user,omitempty"`
Address string `json:"address"`
SenderDatas json.RawMessage `json:"senderDatas" swaggertype:"object"`
PaymentReciever json.RawMessage `json:"paymentReciever" swaggertype:"array,object"`
Documents json.RawMessage `json:"documents" swaggertype:"object"`
Status *string `json:"status"`
Notes *string `json:"notes"`
SenderFullName string `json:"senderFullName"`
SenderPassportSerie string `json:"senderPassportSerie"`
SenderPassportNumber string `json:"senderPassportNumber"`
SenderDepositAccount string `json:"senderDepositAccount"`
RecieverFullName *string `json:"recieverFullName"`
RecieverPassportSerie *string `json:"recieverPassportSerie"`
RecieverPassportNumber *string `json:"recieverPassportNumber"`
RecieverDepositAccount *string `json:"recieverDepositAccount"`
AmountUsd *float64 `json:"amountUsd"`
Paid bool `json:"paid"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type CreateVisaMasterPaymentOrderDTO struct {
UniqueId *string `json:"uniqueId"`
Type *string `json:"type"`
PassportName string `json:"passportName" binding:"required"`
PassportSurname string `json:"passportSurname" binding:"required"`
Phone string `json:"phone" binding:"required"`
Email *string `json:"email"`
Region string `json:"region" binding:"required"`
BranchId int64 `json:"branchId" binding:"required"`
UserId *int64 `json:"userId"`
Address string `json:"address" binding:"required"`
SenderDatas json.RawMessage `json:"senderDatas" swaggertype:"object"`
PaymentReciever json.RawMessage `json:"paymentReciever" swaggertype:"array,object"`
Documents json.RawMessage `json:"documents" swaggertype:"object"`
Status *string `json:"status"`
Notes *string `json:"notes"`
SenderFullName string `json:"senderFullName" binding:"required"`
SenderPassportSerie string `json:"senderPassportSerie" binding:"required"`
SenderPassportNumber string `json:"senderPassportNumber" binding:"required"`
SenderDepositAccount string `json:"senderDepositAccount" binding:"required"`
RecieverFullName *string `json:"recieverFullName"`
RecieverPassportSerie *string `json:"recieverPassportSerie"`
RecieverPassportNumber *string `json:"recieverPassportNumber"`
RecieverDepositAccount *string `json:"recieverDepositAccount"`
AmountUsd float64 `json:"amountUsd"`
Paid *bool `json:"paid"`
// CreatedBy is the caller, recorded on the order's create action.
CreatedBy *int64 `json:"-"`
}
type UpdateVisaMasterPaymentOrderDTO struct {
UniqueId *string `json:"uniqueId"`
Type *string `json:"type"`
PassportName string `json:"passportName" binding:"required"`
PassportSurname string `json:"passportSurname" binding:"required"`
Phone string `json:"phone" binding:"required"`
Email *string `json:"email"`
Region string `json:"region" binding:"required"`
BranchId int64 `json:"branchId" binding:"required"`
UserId *int64 `json:"userId"`
Address string `json:"address" binding:"required"`
SenderDatas json.RawMessage `json:"senderDatas" swaggertype:"object"`
PaymentReciever json.RawMessage `json:"paymentReciever" swaggertype:"array,object"`
Documents json.RawMessage `json:"documents" swaggertype:"object"`
Status *string `json:"status"`
Notes *string `json:"notes"`
SenderFullName string `json:"senderFullName" binding:"required"`
SenderPassportSerie string `json:"senderPassportSerie" binding:"required"`
SenderPassportNumber string `json:"senderPassportNumber" binding:"required"`
SenderDepositAccount string `json:"senderDepositAccount" binding:"required"`
RecieverFullName *string `json:"recieverFullName"`
RecieverPassportSerie *string `json:"recieverPassportSerie"`
RecieverPassportNumber *string `json:"recieverPassportNumber"`
RecieverDepositAccount *string `json:"recieverDepositAccount"`
AmountUsd float64 `json:"amountUsd"`
Paid bool `json:"paid"`
// UpdatedBy is the caller, recorded on the order's update action.
UpdatedBy *int64 `json:"-"`
}
type ListFilter struct {
Name string
// Type narrows to one order type; ExcludeType drops one (the Visa/Master
// page hides sber, which has its own page).
Type string
ExcludeType string
Status *string
BranchId *int64
BranchIds []int64
UserId *int64
Region string
Page int
Limit int
}
// VisaMasterPaymentOrderListItemDTO is the list row (visa/master and sber);
// sender, receiver, documents and amounts come from GET /visa-master-payment-orders/:id.
type VisaMasterPaymentOrderListItemDTO struct {
Id int64 `json:"id"`
UniqueId *string `json:"uniqueId"`
Type *string `json:"type"`
CreatedAt time.Time `json:"createdAt"`
Region string `json:"region"`
// RegionName is the welaýat of the branch's province (Mary, Lebap, ...).
RegionName shared.LocalizedText `json:"regionName"`
Branch *shared.NamedInfo `json:"branch,omitempty"`
// ProvinceName is the branch's province (etrap).
ProvinceName shared.LocalizedText `json:"provinceName"`
PassportName string `json:"passportName"`
PassportSurname string `json:"passportSurname"`
Phone string `json:"phone"`
Status *string `json:"status"`
Paid bool `json:"paid"`
// PaidThisMonth: a successful payment exists for the current month's
// payment period (Ashgabat time).
PaidThisMonth bool `json:"paidThisMonth"`
}
type ListVisaMasterPaymentOrderDTO struct {
Count int64 `json:"count"`
VisaMasterPaymentOrders []VisaMasterPaymentOrderListItemDTO `json:"visaMasterPaymentOrders"`
}