ch something
This commit is contained in:
1 parent
3b33e25703
commit
60787c8149
8 files changed
+383
-23
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 396 KiB |
+26
@@ -657,6 +657,32 @@ INSERT INTO visa_master_payment_orders (
|
|||||||
'Atayew Kerim Begliýewiç', 'I-AG', '101010', '23202984200010101011',
|
'Atayew Kerim Begliýewiç', 'I-AG', '101010', '23202984200010101011',
|
||||||
'Gurbanowa Leyla Saparowna', 'I-AG', '303030', NULL,
|
'Gurbanowa Leyla Saparowna', 'I-AG', '303030', NULL,
|
||||||
true
|
true
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'VMP-2026-0003', 'sber', 'Batyr', 'Saparow', '+993 61 92 92 48', NULL,
|
||||||
|
'AG', 1, 5, 'Aşgabat, Bitarap Türkmenistan 12',
|
||||||
|
'{"fullName":"Saparow Batyr Annaýewiç","passportSerie":"I-AG","passportNumber":"202020","depositAccount":"23202984200020202022"}'::json,
|
||||||
|
'[{"fullName":"Saparowa Aýna Batyrowna","passportSerie":"I-AG","passportNumber":"404040"}]'::json,
|
||||||
|
'{
|
||||||
|
"student_visa_card_details":["sber-card-3.pdf"],
|
||||||
|
"student_enrollment_certificate":["enrollment-3.pdf"],
|
||||||
|
"student_ticket_copy":[],
|
||||||
|
"student_internal_passport":["student-internal-3.pdf"],
|
||||||
|
"student_foreign_passport":["student-foreign-3.pdf"],
|
||||||
|
"student_visa_page":[],
|
||||||
|
"student_stamp_page":[],
|
||||||
|
"student_enrollment_clarification":[],
|
||||||
|
"sender_internal_passport":["sender-internal-3.pdf"],
|
||||||
|
"sender_foreign_passport":[],
|
||||||
|
"sender_stamp_page":[],
|
||||||
|
"kinship_documents":["kinship-3.pdf"],
|
||||||
|
"first_passport_series_info":[],
|
||||||
|
"police_passport_series_info":[]
|
||||||
|
}'::json,
|
||||||
|
'pending', 'Sber tölegi garaşylýar',
|
||||||
|
'Saparow Batyr Annaýewiç', 'I-AG', '202020', '23202984200020202022',
|
||||||
|
'Saparowa Aýna Batyrowna', 'I-AG', '404040', NULL,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------------
|
-- ---------------------------------------------------------------------------
|
||||||
|
|||||||
+99
-1
@@ -6758,7 +6758,7 @@ const docTemplate = `{
|
|||||||
"BearerAuth": []
|
"BearerAuth": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Returns paginated visa/master payment orders with branch and user details",
|
"description": "Returns paginated visa/master payment orders; sber orders are excluded (see /visa-master-payment-orders/sber)",
|
||||||
"produces": [
|
"produces": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -6773,6 +6773,12 @@ const docTemplate = `{
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by order type (e.g. student), case-insensitive",
|
||||||
|
"name": "type",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Filter by status",
|
"description": "Filter by status",
|
||||||
@@ -6912,6 +6918,89 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/visa-master-payment-orders/sber": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Returns paginated payment orders of type sber",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"visa-master-payment-orders"
|
||||||
|
],
|
||||||
|
"summary": "List sber payment orders",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by passport name or surname",
|
||||||
|
"name": "name",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by status",
|
||||||
|
"name": "status",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by branch ID",
|
||||||
|
"name": "branch_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by user ID",
|
||||||
|
"name": "user_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by region",
|
||||||
|
"name": "region",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 1,
|
||||||
|
"description": "Page number",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 10,
|
||||||
|
"description": "Items per page",
|
||||||
|
"name": "limit",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppSuccess"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/visa-master-payment-orders/{id}": {
|
"/visa-master-payment-orders/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -9177,6 +9266,9 @@ const docTemplate = `{
|
|||||||
"orderId": {
|
"orderId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"orderNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"orderUniqueId": {
|
"orderUniqueId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -9824,6 +9916,9 @@ const docTemplate = `{
|
|||||||
"orderId": {
|
"orderId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"orderNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"paymentId": {
|
"paymentId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -9900,6 +9995,9 @@ const docTemplate = `{
|
|||||||
"orderId": {
|
"orderId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"orderNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"paid": {
|
"paid": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
|||||||
+99
-1
@@ -6752,7 +6752,7 @@
|
|||||||
"BearerAuth": []
|
"BearerAuth": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Returns paginated visa/master payment orders with branch and user details",
|
"description": "Returns paginated visa/master payment orders; sber orders are excluded (see /visa-master-payment-orders/sber)",
|
||||||
"produces": [
|
"produces": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -6767,6 +6767,12 @@
|
|||||||
"name": "name",
|
"name": "name",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by order type (e.g. student), case-insensitive",
|
||||||
|
"name": "type",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Filter by status",
|
"description": "Filter by status",
|
||||||
@@ -6906,6 +6912,89 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/visa-master-payment-orders/sber": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Returns paginated payment orders of type sber",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"visa-master-payment-orders"
|
||||||
|
],
|
||||||
|
"summary": "List sber payment orders",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by passport name or surname",
|
||||||
|
"name": "name",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by status",
|
||||||
|
"name": "status",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by branch ID",
|
||||||
|
"name": "branch_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Filter by user ID",
|
||||||
|
"name": "user_id",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Filter by region",
|
||||||
|
"name": "region",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 1,
|
||||||
|
"description": "Page number",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 10,
|
||||||
|
"description": "Items per page",
|
||||||
|
"name": "limit",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppSuccess"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/visa-master-payment-orders/{id}": {
|
"/visa-master-payment-orders/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -9171,6 +9260,9 @@
|
|||||||
"orderId": {
|
"orderId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"orderNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"orderUniqueId": {
|
"orderUniqueId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -9818,6 +9910,9 @@
|
|||||||
"orderId": {
|
"orderId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"orderNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"paymentId": {
|
"paymentId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -9894,6 +9989,9 @@
|
|||||||
"orderId": {
|
"orderId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"orderNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"paid": {
|
"paid": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
|||||||
+66
-2
@@ -1341,6 +1341,8 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
orderId:
|
orderId:
|
||||||
type: integer
|
type: integer
|
||||||
|
orderNumber:
|
||||||
|
type: string
|
||||||
orderUniqueId:
|
orderUniqueId:
|
||||||
type: string
|
type: string
|
||||||
paid:
|
paid:
|
||||||
@@ -1790,6 +1792,8 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
orderId:
|
orderId:
|
||||||
type: integer
|
type: integer
|
||||||
|
orderNumber:
|
||||||
|
type: string
|
||||||
paymentId:
|
paymentId:
|
||||||
type: integer
|
type: integer
|
||||||
successUrl:
|
successUrl:
|
||||||
@@ -1840,6 +1844,8 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
orderId:
|
orderId:
|
||||||
type: integer
|
type: integer
|
||||||
|
orderNumber:
|
||||||
|
type: string
|
||||||
paid:
|
paid:
|
||||||
type: boolean
|
type: boolean
|
||||||
paymentPeriod:
|
paymentPeriod:
|
||||||
@@ -6212,13 +6218,17 @@ paths:
|
|||||||
- user
|
- user
|
||||||
/visa-master-payment-orders:
|
/visa-master-payment-orders:
|
||||||
get:
|
get:
|
||||||
description: Returns paginated visa/master payment orders with branch and user
|
description: Returns paginated visa/master payment orders; sber orders are excluded
|
||||||
details
|
(see /visa-master-payment-orders/sber)
|
||||||
parameters:
|
parameters:
|
||||||
- description: Filter by passport name or surname
|
- description: Filter by passport name or surname
|
||||||
in: query
|
in: query
|
||||||
name: name
|
name: name
|
||||||
type: string
|
type: string
|
||||||
|
- description: Filter by order type (e.g. student), case-insensitive
|
||||||
|
in: query
|
||||||
|
name: type
|
||||||
|
type: string
|
||||||
- description: Filter by status
|
- description: Filter by status
|
||||||
in: query
|
in: query
|
||||||
name: status
|
name: status
|
||||||
@@ -6535,6 +6545,60 @@ paths:
|
|||||||
summary: GBÜS payment callback
|
summary: GBÜS payment callback
|
||||||
tags:
|
tags:
|
||||||
- visa-master-payment-orders
|
- visa-master-payment-orders
|
||||||
|
/visa-master-payment-orders/sber:
|
||||||
|
get:
|
||||||
|
description: Returns paginated payment orders of type sber
|
||||||
|
parameters:
|
||||||
|
- description: Filter by passport name or surname
|
||||||
|
in: query
|
||||||
|
name: name
|
||||||
|
type: string
|
||||||
|
- description: Filter by status
|
||||||
|
in: query
|
||||||
|
name: status
|
||||||
|
type: string
|
||||||
|
- description: Filter by branch ID
|
||||||
|
in: query
|
||||||
|
name: branch_id
|
||||||
|
type: integer
|
||||||
|
- description: Filter by user ID
|
||||||
|
in: query
|
||||||
|
name: user_id
|
||||||
|
type: integer
|
||||||
|
- description: Filter by region
|
||||||
|
in: query
|
||||||
|
name: region
|
||||||
|
type: string
|
||||||
|
- default: 1
|
||||||
|
description: Page number
|
||||||
|
in: query
|
||||||
|
name: page
|
||||||
|
type: integer
|
||||||
|
- default: 10
|
||||||
|
description: Items per page
|
||||||
|
in: query
|
||||||
|
name: limit
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppSuccess'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppError'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: List sber payment orders
|
||||||
|
tags:
|
||||||
|
- visa-master-payment-orders
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
BearerAuth:
|
BearerAuth:
|
||||||
in: header
|
in: header
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ func (r *repository) List(ctx context.Context, filter visamaster.ListFilter) (vi
|
|||||||
limitPlaceholder := len(args) + 1
|
limitPlaceholder := len(args) + 1
|
||||||
offsetPlaceholder := len(args) + 2
|
offsetPlaceholder := len(args) + 2
|
||||||
query := fmt.Sprintf(
|
query := fmt.Sprintf(
|
||||||
`SELECT o.id, o.type, o.created_at, o.region, o.branch_id, b.name, p.name,
|
`SELECT o.id, o.unique_id, o.type, o.created_at, o.region, p.region, o.branch_id, b.name, p.name,
|
||||||
o.passport_name, o.passport_surname, o.phone, o.status, o.paid
|
o.passport_name, o.passport_surname, o.phone, o.status, o.paid, `+paidThisMonthSQL+`
|
||||||
FROM visa_master_payment_orders o
|
FROM visa_master_payment_orders o
|
||||||
LEFT JOIN branches b ON b.id = o.branch_id
|
LEFT JOIN branches b ON b.id = o.branch_id
|
||||||
LEFT JOIN provinces p ON p.id = b.province_id%s ORDER BY o.id DESC LIMIT $%d OFFSET $%d`,
|
LEFT JOIN provinces p ON p.id = b.province_id%s ORDER BY o.id DESC LIMIT $%d OFFSET $%d`,
|
||||||
@@ -150,6 +150,18 @@ func buildListQuery(filter visamaster.ListFilter) (whereClause string, args []in
|
|||||||
)`, n))
|
)`, n))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Case-insensitive and trimmed, the same match visamasterpay uses to
|
||||||
|
// pick Sber fees and credentials.
|
||||||
|
if filter.Type != "" {
|
||||||
|
args = append(args, strings.TrimSpace(filter.Type))
|
||||||
|
conditions = append(conditions, fmt.Sprintf("LOWER(TRIM(o.type)) = LOWER($%d)", len(args)))
|
||||||
|
}
|
||||||
|
|
||||||
|
if filter.ExcludeType != "" {
|
||||||
|
args = append(args, strings.TrimSpace(filter.ExcludeType))
|
||||||
|
conditions = append(conditions, fmt.Sprintf("LOWER(TRIM(COALESCE(o.type, ''))) <> LOWER($%d)", len(args)))
|
||||||
|
}
|
||||||
|
|
||||||
if filter.Status != nil {
|
if filter.Status != nil {
|
||||||
args = append(args, *filter.Status)
|
args = append(args, *filter.Status)
|
||||||
conditions = append(conditions, fmt.Sprintf("o.status = $%d", len(args)))
|
conditions = append(conditions, fmt.Sprintf("o.status = $%d", len(args)))
|
||||||
@@ -296,18 +308,29 @@ func jsonOrDefault(raw []byte, fallback string) json.RawMessage {
|
|||||||
return json.RawMessage(raw)
|
return json.RawMessage(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// paidThisMonthSQL: the order has a successful payment whose payment_period
|
||||||
|
// falls in the current month in Ashgabat time (UTC+5, as visamasterpay).
|
||||||
|
const paidThisMonthSQL = `EXISTS (
|
||||||
|
SELECT 1 FROM visa_master_order_payments vp
|
||||||
|
WHERE vp.order_id = o.id AND vp.gateway_status = 'success' AND vp.deleted_at IS NULL
|
||||||
|
AND date_trunc('month', vp.payment_period) = date_trunc('month', (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') + INTERVAL '5 hours')
|
||||||
|
)`
|
||||||
|
|
||||||
func scanOrderListItem(row genericrepo.Scanner) (visamaster.VisaMasterPaymentOrderListItemDTO, error) {
|
func scanOrderListItem(row genericrepo.Scanner) (visamaster.VisaMasterPaymentOrderListItemDTO, error) {
|
||||||
var item visamaster.VisaMasterPaymentOrderListItemDTO
|
var item visamaster.VisaMasterPaymentOrderListItemDTO
|
||||||
var branchId int64
|
var branchId int64
|
||||||
var branchNameJSON, provinceNameJSON []byte
|
var regionNameJSON, branchNameJSON, provinceNameJSON []byte
|
||||||
|
|
||||||
if err := row.Scan(
|
if err := row.Scan(
|
||||||
&item.Id, &item.Type, &item.CreatedAt, &item.Region, &branchId, &branchNameJSON, &provinceNameJSON,
|
&item.Id, &item.UniqueId, &item.Type, &item.CreatedAt, &item.Region, ®ionNameJSON, &branchId, &branchNameJSON, &provinceNameJSON,
|
||||||
&item.PassportName, &item.PassportSurname, &item.Phone, &item.Status, &item.Paid,
|
&item.PassportName, &item.PassportSurname, &item.Phone, &item.Status, &item.Paid, &item.PaidThisMonth,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return visamaster.VisaMasterPaymentOrderListItemDTO{}, err
|
return visamaster.VisaMasterPaymentOrderListItemDTO{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := shared.UnmarshalLocalized(regionNameJSON, &item.RegionName); err != nil {
|
||||||
|
return visamaster.VisaMasterPaymentOrderListItemDTO{}, err
|
||||||
|
}
|
||||||
var branchName shared.LocalizedText
|
var branchName shared.LocalizedText
|
||||||
if err := shared.UnmarshalLocalized(branchNameJSON, &branchName); err != nil {
|
if err := shared.UnmarshalLocalized(branchNameJSON, &branchName); err != nil {
|
||||||
return visamaster.VisaMasterPaymentOrderListItemDTO{}, err
|
return visamaster.VisaMasterPaymentOrderListItemDTO{}, err
|
||||||
|
|||||||
@@ -107,24 +107,31 @@ type UpdateVisaMasterPaymentOrderDTO struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ListFilter struct {
|
type ListFilter struct {
|
||||||
Name string
|
Name string
|
||||||
Status *string
|
// Type narrows to one order type; ExcludeType drops one (the Visa/Master
|
||||||
BranchId *int64
|
// page hides sber, which has its own page).
|
||||||
BranchIds []int64
|
Type string
|
||||||
UserId *int64
|
ExcludeType string
|
||||||
Region string
|
Status *string
|
||||||
Page int
|
BranchId *int64
|
||||||
Limit int
|
BranchIds []int64
|
||||||
|
UserId *int64
|
||||||
|
Region string
|
||||||
|
Page int
|
||||||
|
Limit int
|
||||||
}
|
}
|
||||||
|
|
||||||
// VisaMasterPaymentOrderListItemDTO is the list row (visa/master and sber);
|
// VisaMasterPaymentOrderListItemDTO is the list row (visa/master and sber);
|
||||||
// sender, receiver, documents and amounts come from GET /visa-master-payment-orders/:id.
|
// sender, receiver, documents and amounts come from GET /visa-master-payment-orders/:id.
|
||||||
type VisaMasterPaymentOrderListItemDTO struct {
|
type VisaMasterPaymentOrderListItemDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Type *string `json:"type"`
|
UniqueId *string `json:"uniqueId"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
Type *string `json:"type"`
|
||||||
Region string `json:"region"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
Branch *shared.NamedInfo `json:"branch,omitempty"`
|
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 is the branch's province (etrap).
|
||||||
ProvinceName shared.LocalizedText `json:"provinceName"`
|
ProvinceName shared.LocalizedText `json:"provinceName"`
|
||||||
PassportName string `json:"passportName"`
|
PassportName string `json:"passportName"`
|
||||||
@@ -132,6 +139,9 @@ type VisaMasterPaymentOrderListItemDTO struct {
|
|||||||
Phone string `json:"phone"`
|
Phone string `json:"phone"`
|
||||||
Status *string `json:"status"`
|
Status *string `json:"status"`
|
||||||
Paid bool `json:"paid"`
|
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 {
|
type ListVisaMasterPaymentOrderDTO struct {
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ import (
|
|||||||
"github.com/jackc/pgx/v4"
|
"github.com/jackc/pgx/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// orderTypeSber is the type value of Sber orders, matched case-insensitively
|
||||||
|
// like visamasterpay does when it picks Sber fees and credentials.
|
||||||
|
const orderTypeSber = "sber"
|
||||||
|
|
||||||
const baseURL = "/visa-master-payment-orders"
|
const baseURL = "/visa-master-payment-orders"
|
||||||
|
|
||||||
type handler struct {
|
type handler struct {
|
||||||
@@ -29,6 +33,7 @@ func NewHandler(logger *logging.Logger, repository Repository) handlers.Handler
|
|||||||
func (h *handler) Register(router *gin.RouterGroup) {
|
func (h *handler) Register(router *gin.RouterGroup) {
|
||||||
group := rbac.Group(router, baseURL, rbac.Require(perm.Cards))
|
group := rbac.Group(router, baseURL, rbac.Require(perm.Cards))
|
||||||
group.GET("", h.list)
|
group.GET("", h.list)
|
||||||
|
group.GET("/sber", h.listSber)
|
||||||
group.GET("/:id", h.getByID)
|
group.GET("/:id", h.getByID)
|
||||||
group.POST("", h.create)
|
group.POST("", h.create)
|
||||||
group.PUT("/:id", h.update)
|
group.PUT("/:id", h.update)
|
||||||
@@ -37,11 +42,12 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
|
|
||||||
// list godoc
|
// list godoc
|
||||||
// @Summary List visa/master payment orders
|
// @Summary List visa/master payment orders
|
||||||
// @Description Returns paginated visa/master payment orders with branch and user details
|
// @Description Returns paginated visa/master payment orders; sber orders are excluded (see /visa-master-payment-orders/sber)
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-payment-orders
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param name query string false "Filter by passport name or surname"
|
// @Param name query string false "Filter by passport name or surname"
|
||||||
|
// @Param type query string false "Filter by order type (e.g. student), case-insensitive"
|
||||||
// @Param status query string false "Filter by status"
|
// @Param status query string false "Filter by status"
|
||||||
// @Param branch_id query int false "Filter by branch ID"
|
// @Param branch_id query int false "Filter by branch ID"
|
||||||
// @Param user_id query int false "Filter by user ID"
|
// @Param user_id query int false "Filter by user ID"
|
||||||
@@ -58,7 +64,38 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
filter.ExcludeType = orderTypeSber
|
||||||
|
h.respondList(c, filter)
|
||||||
|
}
|
||||||
|
|
||||||
|
// listSber godoc
|
||||||
|
// @Summary List sber payment orders
|
||||||
|
// @Description Returns paginated payment orders of type sber
|
||||||
|
// @Tags visa-master-payment-orders
|
||||||
|
// @Produce json
|
||||||
|
// @Security BearerAuth
|
||||||
|
// @Param name query string false "Filter by passport name or surname"
|
||||||
|
// @Param status query string false "Filter by status"
|
||||||
|
// @Param branch_id query int false "Filter by branch ID"
|
||||||
|
// @Param user_id query int false "Filter by user ID"
|
||||||
|
// @Param region query string false "Filter by region"
|
||||||
|
// @Param page query int false "Page number" default(1)
|
||||||
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
|
// @Failure 400 {object} appresult.AppError
|
||||||
|
// @Failure 500 {object} appresult.AppError
|
||||||
|
// @Router /visa-master-payment-orders/sber [get]
|
||||||
|
func (h *handler) listSber(c *gin.Context) {
|
||||||
|
filter, ok := parseListFilter(c)
|
||||||
|
if !ok {
|
||||||
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
filter.Type = orderTypeSber
|
||||||
|
h.respondList(c, filter)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *handler) respondList(c *gin.Context, filter ListFilter) {
|
||||||
result, err := h.repository.List(c.Request.Context(), filter)
|
result, err := h.repository.List(c.Request.Context(), filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.logger.Errorf("list visa master payment orders failed: %v", err)
|
h.logger.Errorf("list visa master payment orders failed: %v", err)
|
||||||
@@ -225,6 +262,10 @@ func parseListFilter(c *gin.Context) (ListFilter, bool) {
|
|||||||
filter.Name = raw
|
filter.Name = raw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if raw := shared.QueryValue(c, "type"); raw != "" {
|
||||||
|
filter.Type = raw
|
||||||
|
}
|
||||||
|
|
||||||
if raw := shared.QueryValue(c, "status"); raw != "" {
|
if raw := shared.QueryValue(c, "status"); raw != "" {
|
||||||
filter.Status = &raw
|
filter.Status = &raw
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user