payment-history: payment detail with GBÜS response, sorting, newest-first logs
- GET /payment-history/payments/{id}: single payment attempt with the raw
gateway_response (last HALKBANK JSON) for the "storage" icon modal
- GET /payment-history: sort (id/created_at/status/amount) and order
(asc/desc, default desc) query params
- GET /payment-history/{id}: order logs now newest first
- index on visa_master_order_payments (gateway_status, id DESC)
- regenerate swagger docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
DROP INDEX IF EXISTS idx_visa_master_order_payments_status_id;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- payment-history lists newest-first (ORDER BY p.id DESC) and is commonly
|
||||||
|
-- filtered to one gateway_status; without this, a rare status (e.g.
|
||||||
|
-- pending) means walking the whole primary key backwards to fill a page.
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_visa_master_order_payments_status_id
|
||||||
|
ON visa_master_order_payments (gateway_status, id DESC)
|
||||||
|
WHERE deleted_at IS NULL;
|
||||||
711
docs/docs.go
711
docs/docs.go
@@ -2630,6 +2630,331 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/dashboard/analytics/backlog": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Open (unhandled) orders per order type aged under 1 day / 1-3 days / over 3 days, the oldest open order, and the average processing time of orders finished in range; plus exact visa/master payout timing from the payment log. Order types are limited to the modules the caller can open.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: backlog",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/branches": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Per-branch leaderboard (orders per type, open/approved/rejected, approval rate, average processing hours) and order counts per region, for orders created in range.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: branches",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/customers": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Loan applicants in range by age group, education, marriage status and number of guarantors, each with its approval rate. Needs the loans permission.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: customers",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/finance": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Successful visa/master payouts (amount, bank/GBÜS/TVEB fees), gateway status breakdown and success rate, monthly payout totals, and the total loan amount requested. Payouts need the cards permission, the loan total the loans permission.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: finance",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/products": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Loan orders by source (web/mobile) and loan type, card orders by card type, and paid vs unpaid card orders, for orders created in range.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: products",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/system": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Registration funnel (all-scope callers with the users permission), operator activity and error rate per module (activity-logs permission), order peak hours heatmap in Ashgabat time, and card balance check stats (cards permission). Widgets the caller cannot see are null or empty.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: system",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 10,
|
||||||
|
"description": "Number of operators to return",
|
||||||
|
"name": "operator_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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/dashboard/overview": {
|
"/dashboard/overview": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -2682,6 +3007,49 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/dashboard/server-stats": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Returns host CPU, RAM and disk usage plus the API process's own memory and uptime. CPU usage is sampled over ~250ms; host fields are null when the OS cannot report them.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard"
|
||||||
|
],
|
||||||
|
"summary": "Server statistics",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/appresult.AppSuccess"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/sysstats.Stats"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/file": {
|
"/file": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -4943,6 +5311,30 @@ const docTemplate = `{
|
|||||||
"name": "search",
|
"name": "search",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"status",
|
||||||
|
"amount"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"default": "id",
|
||||||
|
"description": "Sort column",
|
||||||
|
"name": "sort",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"asc",
|
||||||
|
"desc"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"default": "desc",
|
||||||
|
"description": "Sort direction",
|
||||||
|
"name": "order",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"default": 1,
|
"default": 1,
|
||||||
@@ -4980,6 +5372,64 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/payment-history/payments/{id}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Returns one visa/master/sber payout attempt by its payment ID, with the raw GBÜS response - the detail view behind a payment-history list row",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"payment-history"
|
||||||
|
],
|
||||||
|
"summary": "Get a single payment attempt",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Payment ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/paymenthistory.PaymentHistoryDetailDTO"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"403": {
|
||||||
|
"description": "Forbidden",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Not Found",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/payment-history/{id}": {
|
"/payment-history/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -9414,12 +9864,24 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"paymenthistory.PaymentHistoryItemDTO": {
|
"paymenthistory.PaymentHistoryDetailDTO": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"amountMinor": {
|
||||||
|
"description": "AmountMinor is the amount registered with GBÜS, in tetri.",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
"amountTmt": {
|
"amountTmt": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"amountUsd": {
|
||||||
|
"description": "AmountUsd is amount_tmt converted back at the attempt's own\nexchange_rate_usd - the USD figure the payout was quoted in.",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"apiClient": {
|
||||||
|
"description": "ApiClient is the branch's GBÜS merchant username for this order type\n(visa/master or sber) and Description the text sent with register.do -\nboth as visamasterpay's Pay picks them.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"bankFeeTmt": {
|
"bankFeeTmt": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
@@ -9429,6 +9891,10 @@ const docTemplate = `{
|
|||||||
"branchName": {
|
"branchName": {
|
||||||
"$ref": "#/definitions/shared.LocalizedText"
|
"$ref": "#/definitions/shared.LocalizedText"
|
||||||
},
|
},
|
||||||
|
"cardholderName": {
|
||||||
|
"description": "CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended\ncardAuthInfo, so they're only known once an attempt has been\nfinalized by the callback/status check (unset while pending, and for\nattempts that never reached the card form).",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"createdAt": {
|
"createdAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -9438,6 +9904,124 @@ const docTemplate = `{
|
|||||||
"createdByName": {
|
"createdByName": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"exchangeRateRub": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"exchangeRateUsd": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"formUrl": {
|
||||||
|
"description": "FormUrl/SuccessUrl are only set while the attempt is still pending\n(awaiting the customer to finish paying on GBÜS's hosted page) - once\nan attempt is finalized (success/failed), gateway_response no longer\nholds a formUrl, so there's nothing left to resume.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"gatewayReference": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"gatewayResponse": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"gatewayStatus": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"gbusFeeTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"maskedPan": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"orderId": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"orderNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"orderUniqueId": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"paid": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"passportName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"passportSurname": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"paymentPeriod": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"successUrl": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"totalAmountTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"tvebFeeTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"tvebFeeUsd": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"updatedAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"userId": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"paymenthistory.PaymentHistoryItemDTO": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"amountMinor": {
|
||||||
|
"description": "AmountMinor is the amount registered with GBÜS, in tetri.",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"amountTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"amountUsd": {
|
||||||
|
"description": "AmountUsd is amount_tmt converted back at the attempt's own\nexchange_rate_usd - the USD figure the payout was quoted in.",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"apiClient": {
|
||||||
|
"description": "ApiClient is the branch's GBÜS merchant username for this order type\n(visa/master or sber) and Description the text sent with register.do -\nboth as visamasterpay's Pay picks them.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"bankFeeTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"branchId": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"branchName": {
|
||||||
|
"$ref": "#/definitions/shared.LocalizedText"
|
||||||
|
},
|
||||||
|
"cardholderName": {
|
||||||
|
"description": "CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended\ncardAuthInfo, so they're only known once an attempt has been\nfinalized by the callback/status check (unset while pending, and for\nattempts that never reached the card form).",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"createdAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"createdById": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"createdByName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"exchangeRateRub": {
|
"exchangeRateRub": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
@@ -9460,6 +10044,9 @@ const docTemplate = `{
|
|||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"maskedPan": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"orderId": {
|
"orderId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -9840,6 +10427,128 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"sysstats.CPU": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"cores": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"loadAvg": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"usagePercent": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sysstats.Disk": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"freeBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"totalBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"usagePercent": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usedBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sysstats.Memory": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"availableBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"limitBytes": {
|
||||||
|
"description": "LimitBytes is the container (cgroup) memory limit, nil when unlimited.",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"swapTotalBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"swapUsedBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"totalBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"usagePercent": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usedBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sysstats.Process": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"goroutines": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"heapAllocBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"numGc": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"sysBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"uptimeSeconds": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sysstats.Stats": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"arch": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"collectedAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"cpu": {
|
||||||
|
"$ref": "#/definitions/sysstats.CPU"
|
||||||
|
},
|
||||||
|
"disks": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/sysstats.Disk"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"goVersion": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"hostUptimeSeconds": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"hostname": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"memory": {
|
||||||
|
"$ref": "#/definitions/sysstats.Memory"
|
||||||
|
},
|
||||||
|
"os": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"process": {
|
||||||
|
"$ref": "#/definitions/sysstats.Process"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"user.CreateUserDTO": {
|
"user.CreateUserDTO": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@@ -2624,6 +2624,331 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/dashboard/analytics/backlog": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Open (unhandled) orders per order type aged under 1 day / 1-3 days / over 3 days, the oldest open order, and the average processing time of orders finished in range; plus exact visa/master payout timing from the payment log. Order types are limited to the modules the caller can open.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: backlog",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/branches": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Per-branch leaderboard (orders per type, open/approved/rejected, approval rate, average processing hours) and order counts per region, for orders created in range.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: branches",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/customers": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Loan applicants in range by age group, education, marriage status and number of guarantors, each with its approval rate. Needs the loans permission.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: customers",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/finance": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Successful visa/master payouts (amount, bank/GBÜS/TVEB fees), gateway status breakdown and success rate, monthly payout totals, and the total loan amount requested. Payouts need the cards permission, the loan total the loans permission.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: finance",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/products": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Loan orders by source (web/mobile) and loan type, card orders by card type, and paid vs unpaid card orders, for orders created in range.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: products",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/dashboard/analytics/system": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Registration funnel (all-scope callers with the users permission), operator activity and error rate per module (activity-logs permission), order peak hours heatmap in Ashgabat time, and card balance check stats (cards permission). Widgets the caller cannot see are null or empty.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard-analytics"
|
||||||
|
],
|
||||||
|
"summary": "Dashboard analytics: system",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "Jan 1 of current year",
|
||||||
|
"description": "Start date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "from",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"default": "today",
|
||||||
|
"description": "End date YYYY-MM-DD (inclusive)",
|
||||||
|
"name": "to",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 10,
|
||||||
|
"description": "Number of operators to return",
|
||||||
|
"name": "operator_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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/dashboard/overview": {
|
"/dashboard/overview": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -2676,6 +3001,49 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/dashboard/server-stats": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Returns host CPU, RAM and disk usage plus the API process's own memory and uptime. CPU usage is sampled over ~250ms; host fields are null when the OS cannot report them.",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"dashboard"
|
||||||
|
],
|
||||||
|
"summary": "Server statistics",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/appresult.AppSuccess"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"data": {
|
||||||
|
"$ref": "#/definitions/sysstats.Stats"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/file": {
|
"/file": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -4937,6 +5305,30 @@
|
|||||||
"name": "search",
|
"name": "search",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"status",
|
||||||
|
"amount"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"default": "id",
|
||||||
|
"description": "Sort column",
|
||||||
|
"name": "sort",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enum": [
|
||||||
|
"asc",
|
||||||
|
"desc"
|
||||||
|
],
|
||||||
|
"type": "string",
|
||||||
|
"default": "desc",
|
||||||
|
"description": "Sort direction",
|
||||||
|
"name": "order",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"default": 1,
|
"default": 1,
|
||||||
@@ -4974,6 +5366,64 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/payment-history/payments/{id}": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"BearerAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Returns one visa/master/sber payout attempt by its payment ID, with the raw GBÜS response - the detail view behind a payment-history list row",
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"payment-history"
|
||||||
|
],
|
||||||
|
"summary": "Get a single payment attempt",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Payment ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/paymenthistory.PaymentHistoryDetailDTO"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"403": {
|
||||||
|
"description": "Forbidden",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Not Found",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal Server Error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/appresult.AppError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/payment-history/{id}": {
|
"/payment-history/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"security": [
|
"security": [
|
||||||
@@ -9408,12 +9858,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"paymenthistory.PaymentHistoryItemDTO": {
|
"paymenthistory.PaymentHistoryDetailDTO": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"amountMinor": {
|
||||||
|
"description": "AmountMinor is the amount registered with GBÜS, in tetri.",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
"amountTmt": {
|
"amountTmt": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"amountUsd": {
|
||||||
|
"description": "AmountUsd is amount_tmt converted back at the attempt's own\nexchange_rate_usd - the USD figure the payout was quoted in.",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"apiClient": {
|
||||||
|
"description": "ApiClient is the branch's GBÜS merchant username for this order type\n(visa/master or sber) and Description the text sent with register.do -\nboth as visamasterpay's Pay picks them.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"bankFeeTmt": {
|
"bankFeeTmt": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
@@ -9423,6 +9885,10 @@
|
|||||||
"branchName": {
|
"branchName": {
|
||||||
"$ref": "#/definitions/shared.LocalizedText"
|
"$ref": "#/definitions/shared.LocalizedText"
|
||||||
},
|
},
|
||||||
|
"cardholderName": {
|
||||||
|
"description": "CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended\ncardAuthInfo, so they're only known once an attempt has been\nfinalized by the callback/status check (unset while pending, and for\nattempts that never reached the card form).",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"createdAt": {
|
"createdAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@@ -9432,6 +9898,124 @@
|
|||||||
"createdByName": {
|
"createdByName": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"exchangeRateRub": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"exchangeRateUsd": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"formUrl": {
|
||||||
|
"description": "FormUrl/SuccessUrl are only set while the attempt is still pending\n(awaiting the customer to finish paying on GBÜS's hosted page) - once\nan attempt is finalized (success/failed), gateway_response no longer\nholds a formUrl, so there's nothing left to resume.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"gatewayReference": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"gatewayResponse": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"gatewayStatus": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"gbusFeeTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"maskedPan": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"orderId": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"orderNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"orderUniqueId": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"paid": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"passportName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"passportSurname": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"paymentPeriod": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"successUrl": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"totalAmountTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"tvebFeeTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"tvebFeeUsd": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"updatedAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"userId": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"paymenthistory.PaymentHistoryItemDTO": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"amountMinor": {
|
||||||
|
"description": "AmountMinor is the amount registered with GBÜS, in tetri.",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"amountTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"amountUsd": {
|
||||||
|
"description": "AmountUsd is amount_tmt converted back at the attempt's own\nexchange_rate_usd - the USD figure the payout was quoted in.",
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"apiClient": {
|
||||||
|
"description": "ApiClient is the branch's GBÜS merchant username for this order type\n(visa/master or sber) and Description the text sent with register.do -\nboth as visamasterpay's Pay picks them.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"bankFeeTmt": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"branchId": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"branchName": {
|
||||||
|
"$ref": "#/definitions/shared.LocalizedText"
|
||||||
|
},
|
||||||
|
"cardholderName": {
|
||||||
|
"description": "CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended\ncardAuthInfo, so they're only known once an attempt has been\nfinalized by the callback/status check (unset while pending, and for\nattempts that never reached the card form).",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"createdAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"createdById": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"createdByName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"exchangeRateRub": {
|
"exchangeRateRub": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
@@ -9454,6 +10038,9 @@
|
|||||||
"id": {
|
"id": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
"maskedPan": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"orderId": {
|
"orderId": {
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
@@ -9834,6 +10421,128 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"sysstats.CPU": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"cores": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"loadAvg": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"usagePercent": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sysstats.Disk": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"freeBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"totalBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"usagePercent": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usedBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sysstats.Memory": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"availableBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"limitBytes": {
|
||||||
|
"description": "LimitBytes is the container (cgroup) memory limit, nil when unlimited.",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"swapTotalBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"swapUsedBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"totalBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"usagePercent": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"usedBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sysstats.Process": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"goroutines": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"heapAllocBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"numGc": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"sysBytes": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"uptimeSeconds": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sysstats.Stats": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"arch": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"collectedAt": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"cpu": {
|
||||||
|
"$ref": "#/definitions/sysstats.CPU"
|
||||||
|
},
|
||||||
|
"disks": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/sysstats.Disk"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"goVersion": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"hostUptimeSeconds": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"hostname": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"memory": {
|
||||||
|
"$ref": "#/definitions/sysstats.Memory"
|
||||||
|
},
|
||||||
|
"os": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"process": {
|
||||||
|
"$ref": "#/definitions/sysstats.Process"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"user.CreateUserDTO": {
|
"user.CreateUserDTO": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@@ -1304,22 +1304,136 @@ definitions:
|
|||||||
$ref: '#/definitions/paymenthistory.PaymentHistoryItemDTO'
|
$ref: '#/definitions/paymenthistory.PaymentHistoryItemDTO'
|
||||||
type: array
|
type: array
|
||||||
type: object
|
type: object
|
||||||
paymenthistory.PaymentHistoryItemDTO:
|
paymenthistory.PaymentHistoryDetailDTO:
|
||||||
properties:
|
properties:
|
||||||
|
amountMinor:
|
||||||
|
description: AmountMinor is the amount registered with GBÜS, in tetri.
|
||||||
|
type: integer
|
||||||
amountTmt:
|
amountTmt:
|
||||||
type: number
|
type: number
|
||||||
|
amountUsd:
|
||||||
|
description: |-
|
||||||
|
AmountUsd is amount_tmt converted back at the attempt's own
|
||||||
|
exchange_rate_usd - the USD figure the payout was quoted in.
|
||||||
|
type: number
|
||||||
|
apiClient:
|
||||||
|
description: |-
|
||||||
|
ApiClient is the branch's GBÜS merchant username for this order type
|
||||||
|
(visa/master or sber) and Description the text sent with register.do -
|
||||||
|
both as visamasterpay's Pay picks them.
|
||||||
|
type: string
|
||||||
bankFeeTmt:
|
bankFeeTmt:
|
||||||
type: number
|
type: number
|
||||||
branchId:
|
branchId:
|
||||||
type: integer
|
type: integer
|
||||||
branchName:
|
branchName:
|
||||||
$ref: '#/definitions/shared.LocalizedText'
|
$ref: '#/definitions/shared.LocalizedText'
|
||||||
|
cardholderName:
|
||||||
|
description: |-
|
||||||
|
CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended
|
||||||
|
cardAuthInfo, so they're only known once an attempt has been
|
||||||
|
finalized by the callback/status check (unset while pending, and for
|
||||||
|
attempts that never reached the card form).
|
||||||
|
type: string
|
||||||
createdAt:
|
createdAt:
|
||||||
type: string
|
type: string
|
||||||
createdById:
|
createdById:
|
||||||
type: integer
|
type: integer
|
||||||
createdByName:
|
createdByName:
|
||||||
type: string
|
type: string
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
exchangeRateRub:
|
||||||
|
type: number
|
||||||
|
exchangeRateUsd:
|
||||||
|
type: number
|
||||||
|
formUrl:
|
||||||
|
description: |-
|
||||||
|
FormUrl/SuccessUrl are only set while the attempt is still pending
|
||||||
|
(awaiting the customer to finish paying on GBÜS's hosted page) - once
|
||||||
|
an attempt is finalized (success/failed), gateway_response no longer
|
||||||
|
holds a formUrl, so there's nothing left to resume.
|
||||||
|
type: string
|
||||||
|
gatewayReference:
|
||||||
|
type: string
|
||||||
|
gatewayResponse:
|
||||||
|
type: object
|
||||||
|
gatewayStatus:
|
||||||
|
type: string
|
||||||
|
gbusFeeTmt:
|
||||||
|
type: number
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
maskedPan:
|
||||||
|
type: string
|
||||||
|
orderId:
|
||||||
|
type: integer
|
||||||
|
orderNumber:
|
||||||
|
type: string
|
||||||
|
orderUniqueId:
|
||||||
|
type: string
|
||||||
|
paid:
|
||||||
|
type: boolean
|
||||||
|
passportName:
|
||||||
|
type: string
|
||||||
|
passportSurname:
|
||||||
|
type: string
|
||||||
|
paymentPeriod:
|
||||||
|
type: string
|
||||||
|
successUrl:
|
||||||
|
type: string
|
||||||
|
totalAmountTmt:
|
||||||
|
type: number
|
||||||
|
tvebFeeTmt:
|
||||||
|
type: number
|
||||||
|
tvebFeeUsd:
|
||||||
|
type: number
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
updatedAt:
|
||||||
|
type: string
|
||||||
|
userId:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
paymenthistory.PaymentHistoryItemDTO:
|
||||||
|
properties:
|
||||||
|
amountMinor:
|
||||||
|
description: AmountMinor is the amount registered with GBÜS, in tetri.
|
||||||
|
type: integer
|
||||||
|
amountTmt:
|
||||||
|
type: number
|
||||||
|
amountUsd:
|
||||||
|
description: |-
|
||||||
|
AmountUsd is amount_tmt converted back at the attempt's own
|
||||||
|
exchange_rate_usd - the USD figure the payout was quoted in.
|
||||||
|
type: number
|
||||||
|
apiClient:
|
||||||
|
description: |-
|
||||||
|
ApiClient is the branch's GBÜS merchant username for this order type
|
||||||
|
(visa/master or sber) and Description the text sent with register.do -
|
||||||
|
both as visamasterpay's Pay picks them.
|
||||||
|
type: string
|
||||||
|
bankFeeTmt:
|
||||||
|
type: number
|
||||||
|
branchId:
|
||||||
|
type: integer
|
||||||
|
branchName:
|
||||||
|
$ref: '#/definitions/shared.LocalizedText'
|
||||||
|
cardholderName:
|
||||||
|
description: |-
|
||||||
|
CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended
|
||||||
|
cardAuthInfo, so they're only known once an attempt has been
|
||||||
|
finalized by the callback/status check (unset while pending, and for
|
||||||
|
attempts that never reached the card form).
|
||||||
|
type: string
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
createdById:
|
||||||
|
type: integer
|
||||||
|
createdByName:
|
||||||
|
type: string
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
exchangeRateRub:
|
exchangeRateRub:
|
||||||
type: number
|
type: number
|
||||||
exchangeRateUsd:
|
exchangeRateUsd:
|
||||||
@@ -1339,6 +1453,8 @@ definitions:
|
|||||||
type: number
|
type: number
|
||||||
id:
|
id:
|
||||||
type: integer
|
type: integer
|
||||||
|
maskedPan:
|
||||||
|
type: string
|
||||||
orderId:
|
orderId:
|
||||||
type: integer
|
type: integer
|
||||||
orderNumber:
|
orderNumber:
|
||||||
@@ -1600,6 +1716,86 @@ definitions:
|
|||||||
tm:
|
tm:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
sysstats.CPU:
|
||||||
|
properties:
|
||||||
|
cores:
|
||||||
|
type: integer
|
||||||
|
loadAvg:
|
||||||
|
items:
|
||||||
|
type: number
|
||||||
|
type: array
|
||||||
|
usagePercent:
|
||||||
|
type: number
|
||||||
|
type: object
|
||||||
|
sysstats.Disk:
|
||||||
|
properties:
|
||||||
|
freeBytes:
|
||||||
|
type: integer
|
||||||
|
path:
|
||||||
|
type: string
|
||||||
|
totalBytes:
|
||||||
|
type: integer
|
||||||
|
usagePercent:
|
||||||
|
type: number
|
||||||
|
usedBytes:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
sysstats.Memory:
|
||||||
|
properties:
|
||||||
|
availableBytes:
|
||||||
|
type: integer
|
||||||
|
limitBytes:
|
||||||
|
description: LimitBytes is the container (cgroup) memory limit, nil when unlimited.
|
||||||
|
type: integer
|
||||||
|
swapTotalBytes:
|
||||||
|
type: integer
|
||||||
|
swapUsedBytes:
|
||||||
|
type: integer
|
||||||
|
totalBytes:
|
||||||
|
type: integer
|
||||||
|
usagePercent:
|
||||||
|
type: number
|
||||||
|
usedBytes:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
sysstats.Process:
|
||||||
|
properties:
|
||||||
|
goroutines:
|
||||||
|
type: integer
|
||||||
|
heapAllocBytes:
|
||||||
|
type: integer
|
||||||
|
numGc:
|
||||||
|
type: integer
|
||||||
|
sysBytes:
|
||||||
|
type: integer
|
||||||
|
uptimeSeconds:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
sysstats.Stats:
|
||||||
|
properties:
|
||||||
|
arch:
|
||||||
|
type: string
|
||||||
|
collectedAt:
|
||||||
|
type: string
|
||||||
|
cpu:
|
||||||
|
$ref: '#/definitions/sysstats.CPU'
|
||||||
|
disks:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/sysstats.Disk'
|
||||||
|
type: array
|
||||||
|
goVersion:
|
||||||
|
type: string
|
||||||
|
hostUptimeSeconds:
|
||||||
|
type: integer
|
||||||
|
hostname:
|
||||||
|
type: string
|
||||||
|
memory:
|
||||||
|
$ref: '#/definitions/sysstats.Memory'
|
||||||
|
os:
|
||||||
|
type: string
|
||||||
|
process:
|
||||||
|
$ref: '#/definitions/sysstats.Process'
|
||||||
|
type: object
|
||||||
user.CreateUserDTO:
|
user.CreateUserDTO:
|
||||||
properties:
|
properties:
|
||||||
active:
|
active:
|
||||||
@@ -3588,6 +3784,228 @@ paths:
|
|||||||
summary: Update currency rate
|
summary: Update currency rate
|
||||||
tags:
|
tags:
|
||||||
- currencies
|
- currencies
|
||||||
|
/dashboard/analytics/backlog:
|
||||||
|
get:
|
||||||
|
description: Open (unhandled) orders per order type aged under 1 day / 1-3 days
|
||||||
|
/ over 3 days, the oldest open order, and the average processing time of orders
|
||||||
|
finished in range; plus exact visa/master payout timing from the payment log.
|
||||||
|
Order types are limited to the modules the caller can open.
|
||||||
|
parameters:
|
||||||
|
- default: Jan 1 of current year
|
||||||
|
description: Start date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: from
|
||||||
|
type: string
|
||||||
|
- default: today
|
||||||
|
description: End date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: to
|
||||||
|
type: string
|
||||||
|
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: 'Dashboard analytics: backlog'
|
||||||
|
tags:
|
||||||
|
- dashboard-analytics
|
||||||
|
/dashboard/analytics/branches:
|
||||||
|
get:
|
||||||
|
description: Per-branch leaderboard (orders per type, open/approved/rejected,
|
||||||
|
approval rate, average processing hours) and order counts per region, for
|
||||||
|
orders created in range.
|
||||||
|
parameters:
|
||||||
|
- default: Jan 1 of current year
|
||||||
|
description: Start date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: from
|
||||||
|
type: string
|
||||||
|
- default: today
|
||||||
|
description: End date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: to
|
||||||
|
type: string
|
||||||
|
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: 'Dashboard analytics: branches'
|
||||||
|
tags:
|
||||||
|
- dashboard-analytics
|
||||||
|
/dashboard/analytics/customers:
|
||||||
|
get:
|
||||||
|
description: Loan applicants in range by age group, education, marriage status
|
||||||
|
and number of guarantors, each with its approval rate. Needs the loans permission.
|
||||||
|
parameters:
|
||||||
|
- default: Jan 1 of current year
|
||||||
|
description: Start date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: from
|
||||||
|
type: string
|
||||||
|
- default: today
|
||||||
|
description: End date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: to
|
||||||
|
type: string
|
||||||
|
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: 'Dashboard analytics: customers'
|
||||||
|
tags:
|
||||||
|
- dashboard-analytics
|
||||||
|
/dashboard/analytics/finance:
|
||||||
|
get:
|
||||||
|
description: Successful visa/master payouts (amount, bank/GBÜS/TVEB fees), gateway
|
||||||
|
status breakdown and success rate, monthly payout totals, and the total loan
|
||||||
|
amount requested. Payouts need the cards permission, the loan total the loans
|
||||||
|
permission.
|
||||||
|
parameters:
|
||||||
|
- default: Jan 1 of current year
|
||||||
|
description: Start date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: from
|
||||||
|
type: string
|
||||||
|
- default: today
|
||||||
|
description: End date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: to
|
||||||
|
type: string
|
||||||
|
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: 'Dashboard analytics: finance'
|
||||||
|
tags:
|
||||||
|
- dashboard-analytics
|
||||||
|
/dashboard/analytics/products:
|
||||||
|
get:
|
||||||
|
description: Loan orders by source (web/mobile) and loan type, card orders by
|
||||||
|
card type, and paid vs unpaid card orders, for orders created in range.
|
||||||
|
parameters:
|
||||||
|
- default: Jan 1 of current year
|
||||||
|
description: Start date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: from
|
||||||
|
type: string
|
||||||
|
- default: today
|
||||||
|
description: End date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: to
|
||||||
|
type: string
|
||||||
|
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: 'Dashboard analytics: products'
|
||||||
|
tags:
|
||||||
|
- dashboard-analytics
|
||||||
|
/dashboard/analytics/system:
|
||||||
|
get:
|
||||||
|
description: Registration funnel (all-scope callers with the users permission),
|
||||||
|
operator activity and error rate per module (activity-logs permission), order
|
||||||
|
peak hours heatmap in Ashgabat time, and card balance check stats (cards permission).
|
||||||
|
Widgets the caller cannot see are null or empty.
|
||||||
|
parameters:
|
||||||
|
- default: Jan 1 of current year
|
||||||
|
description: Start date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: from
|
||||||
|
type: string
|
||||||
|
- default: today
|
||||||
|
description: End date YYYY-MM-DD (inclusive)
|
||||||
|
in: query
|
||||||
|
name: to
|
||||||
|
type: string
|
||||||
|
- default: 10
|
||||||
|
description: Number of operators to return
|
||||||
|
in: query
|
||||||
|
name: operator_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: 'Dashboard analytics: system'
|
||||||
|
tags:
|
||||||
|
- dashboard-analytics
|
||||||
/dashboard/overview:
|
/dashboard/overview:
|
||||||
get:
|
get:
|
||||||
description: Returns the KPI cards, loan/card trend, loan status breakdown,
|
description: Returns the KPI cards, loan/card trend, loan status breakdown,
|
||||||
@@ -3622,6 +4040,32 @@ paths:
|
|||||||
summary: Dashboard overview
|
summary: Dashboard overview
|
||||||
tags:
|
tags:
|
||||||
- dashboard
|
- dashboard
|
||||||
|
/dashboard/server-stats:
|
||||||
|
get:
|
||||||
|
description: Returns host CPU, RAM and disk usage plus the API process's own
|
||||||
|
memory and uptime. CPU usage is sampled over ~250ms; host fields are null
|
||||||
|
when the OS cannot report them.
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/appresult.AppSuccess'
|
||||||
|
- properties:
|
||||||
|
data:
|
||||||
|
$ref: '#/definitions/sysstats.Stats'
|
||||||
|
type: object
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppError'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: Server statistics
|
||||||
|
tags:
|
||||||
|
- dashboard
|
||||||
/file:
|
/file:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@@ -5069,6 +5513,24 @@ paths:
|
|||||||
in: query
|
in: query
|
||||||
name: search
|
name: search
|
||||||
type: string
|
type: string
|
||||||
|
- default: id
|
||||||
|
description: Sort column
|
||||||
|
enum:
|
||||||
|
- id
|
||||||
|
- created_at
|
||||||
|
- status
|
||||||
|
- amount
|
||||||
|
in: query
|
||||||
|
name: sort
|
||||||
|
type: string
|
||||||
|
- default: desc
|
||||||
|
description: Sort direction
|
||||||
|
enum:
|
||||||
|
- asc
|
||||||
|
- desc
|
||||||
|
in: query
|
||||||
|
name: order
|
||||||
|
type: string
|
||||||
- default: 1
|
- default: 1
|
||||||
description: Page number
|
description: Page number
|
||||||
in: query
|
in: query
|
||||||
@@ -5138,6 +5600,45 @@ paths:
|
|||||||
summary: Get payment logs for an order
|
summary: Get payment logs for an order
|
||||||
tags:
|
tags:
|
||||||
- payment-history
|
- payment-history
|
||||||
|
/payment-history/payments/{id}:
|
||||||
|
get:
|
||||||
|
description: Returns one visa/master/sber payout attempt by its payment ID,
|
||||||
|
with the raw GBÜS response - the detail view behind a payment-history list
|
||||||
|
row
|
||||||
|
parameters:
|
||||||
|
- description: Payment ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/paymenthistory.PaymentHistoryDetailDTO'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppError'
|
||||||
|
"403":
|
||||||
|
description: Forbidden
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppError'
|
||||||
|
"404":
|
||||||
|
description: Not Found
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppError'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/appresult.AppError'
|
||||||
|
security:
|
||||||
|
- BearerAuth: []
|
||||||
|
summary: Get a single payment attempt
|
||||||
|
tags:
|
||||||
|
- payment-history
|
||||||
/payment-settings:
|
/payment-settings:
|
||||||
get:
|
get:
|
||||||
description: Returns the admin-configurable bank and GBÜS commission fees used
|
description: Returns the admin-configurable bank and GBÜS commission fees used
|
||||||
|
|||||||
25
internal/payment/paymenthistory/db/order_test.go
Normal file
25
internal/payment/paymenthistory/db/order_test.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"online-back/internal/payment/paymenthistory"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOrderByClause(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
filter paymenthistory.ListFilter
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{paymenthistory.ListFilter{Desc: true}, "p.id DESC"},
|
||||||
|
{paymenthistory.ListFilter{Sort: "id"}, "p.id ASC"},
|
||||||
|
{paymenthistory.ListFilter{Sort: "status", Desc: true}, "p.gateway_status DESC, p.id DESC"},
|
||||||
|
{paymenthistory.ListFilter{Sort: "amount"}, "p.amount_tmt ASC, p.id DESC"},
|
||||||
|
{paymenthistory.ListFilter{Sort: "p.id; DROP TABLE users", Desc: true}, "p.id DESC"},
|
||||||
|
}
|
||||||
|
for _, tc := range cases {
|
||||||
|
if got := orderByClause(tc.filter); got != tc.want {
|
||||||
|
t.Errorf("orderByClause(%+v) = %q, want %q", tc.filter, got, tc.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -25,23 +24,41 @@ func NewRepository(client postgresql.Client, logger *logging.Logger, publicBaseU
|
|||||||
return &repository{client: client, logger: logger, publicBaseURL: strings.TrimRight(publicBaseURL, "/")}
|
return &repository{client: client, logger: logger, publicBaseURL: strings.TrimRight(publicBaseURL, "/")}
|
||||||
}
|
}
|
||||||
|
|
||||||
const historyFromClause = ` FROM visa_master_order_payments p
|
// historyCountFromClause is historyFromClause without the display-only
|
||||||
JOIN visa_master_payment_orders o ON o.id = p.order_id
|
// joins, so COUNT(*) never touches branches/users.
|
||||||
|
const historyCountFromClause = ` FROM visa_master_order_payments p
|
||||||
|
JOIN visa_master_payment_orders o ON o.id = p.order_id`
|
||||||
|
|
||||||
|
const historyFromClause = historyCountFromClause + `
|
||||||
LEFT JOIN branches b ON b.id = o.branch_id
|
LEFT JOIN branches b ON b.id = o.branch_id
|
||||||
LEFT JOIN users u ON u.id = p.created_by`
|
LEFT JOIN users u ON u.id = p.created_by`
|
||||||
|
|
||||||
|
// isSberSQL mirrors visamasterpay's isSber for the order joined as o.
|
||||||
|
const isSberSQL = `LOWER(TRIM(COALESCE(o.type, ''))) = 'sber'`
|
||||||
|
|
||||||
|
// historySelectColumns pulls only the handful of gateway_response fields a
|
||||||
|
// row needs (formUrl, cardAuthInfo) out in SQL rather than shipping every
|
||||||
|
// row's whole jsonb blob to Go and decoding it there.
|
||||||
const historySelectColumns = `p.id, p.order_id, COALESCE(p.order_number, ''), COALESCE(o.unique_id, ''), COALESCE(o.type, ''),
|
const historySelectColumns = `p.id, p.order_id, COALESCE(p.order_number, ''), COALESCE(o.unique_id, ''), COALESCE(o.type, ''),
|
||||||
o.branch_id, b.name, COALESCE(o.passport_name, ''), COALESCE(o.passport_surname, ''), p.user_id,
|
o.branch_id, b.name, COALESCE(o.passport_name, ''), COALESCE(o.passport_surname, ''), p.user_id,
|
||||||
p.amount_tmt, p.bank_fee_tmt, p.gbus_fee_tmt, p.tveb_fee_usd, p.tveb_fee_tmt, p.total_amount_tmt,
|
p.amount_tmt, p.bank_fee_tmt, p.gbus_fee_tmt, p.tveb_fee_usd, p.tveb_fee_tmt, p.total_amount_tmt,
|
||||||
|
ROUND(p.amount_tmt * 100)::bigint,
|
||||||
|
COALESCE(ROUND(p.amount_tmt / NULLIF(p.exchange_rate_usd, 0), 2), 0),
|
||||||
p.exchange_rate_usd, p.exchange_rate_rub, p.payment_period,
|
p.exchange_rate_usd, p.exchange_rate_rub, p.payment_period,
|
||||||
p.gateway_status, p.gateway_reference, p.gateway_response, p.created_by, ` + shared.UserDisplaySQL + `,
|
p.gateway_status, p.gateway_reference,
|
||||||
|
CASE WHEN ` + isSberSQL + ` THEN COALESCE(b.billing_sber_username, '') ELSE COALESCE(b.billing_visa_master_username, '') END,
|
||||||
|
CASE WHEN ` + isSberSQL + ` THEN 'Sber tölegi' ELSE 'Visa/Master tölegi' END,
|
||||||
|
NULLIF(p.gateway_response->'cardAuthInfo'->>'cardholderName', ''),
|
||||||
|
NULLIF(COALESCE(p.gateway_response->'cardAuthInfo'->>'maskedPan', p.gateway_response->'cardAuthInfo'->>'pan'), ''),
|
||||||
|
NULLIF(p.gateway_response->>'formUrl', ''),
|
||||||
|
p.created_by, ` + shared.UserDisplaySQL + `,
|
||||||
p.created_at, p.updated_at`
|
p.created_at, p.updated_at`
|
||||||
|
|
||||||
func (r *repository) List(ctx context.Context, filter paymenthistory.ListFilter) (paymenthistory.ListPaymentHistoryDTO, error) {
|
func (r *repository) List(ctx context.Context, filter paymenthistory.ListFilter) (paymenthistory.ListPaymentHistoryDTO, error) {
|
||||||
whereClause, args := buildListQuery(filter)
|
whereClause, args := buildListQuery(filter)
|
||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
countQuery := `SELECT COUNT(*)` + historyFromClause + whereClause
|
countQuery := `SELECT COUNT(*)` + historyCountFromClause + whereClause
|
||||||
if err := r.client.QueryRow(ctx, countQuery, args...).Scan(&count); err != nil {
|
if err := r.client.QueryRow(ctx, countQuery, args...).Scan(&count); err != nil {
|
||||||
return paymenthistory.ListPaymentHistoryDTO{}, err
|
return paymenthistory.ListPaymentHistoryDTO{}, err
|
||||||
}
|
}
|
||||||
@@ -50,8 +67,8 @@ func (r *repository) List(ctx context.Context, filter paymenthistory.ListFilter)
|
|||||||
limitPlaceholder := len(args) + 1
|
limitPlaceholder := len(args) + 1
|
||||||
offsetPlaceholder := len(args) + 2
|
offsetPlaceholder := len(args) + 2
|
||||||
query := fmt.Sprintf(
|
query := fmt.Sprintf(
|
||||||
`SELECT %s%s%s ORDER BY p.id DESC LIMIT $%d OFFSET $%d`,
|
`SELECT %s%s%s ORDER BY %s LIMIT $%d OFFSET $%d`,
|
||||||
historySelectColumns, historyFromClause, whereClause, limitPlaceholder, offsetPlaceholder,
|
historySelectColumns, historyFromClause, whereClause, orderByClause(filter), limitPlaceholder, offsetPlaceholder,
|
||||||
)
|
)
|
||||||
|
|
||||||
rows, err := r.client.Query(ctx, query, append(args, filter.Limit, offset)...)
|
rows, err := r.client.Query(ctx, query, append(args, filter.Limit, offset)...)
|
||||||
@@ -60,7 +77,7 @@ func (r *repository) List(ctx context.Context, filter paymenthistory.ListFilter)
|
|||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
var items []paymenthistory.PaymentHistoryItemDTO
|
items := make([]paymenthistory.PaymentHistoryItemDTO, 0, filter.Limit)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
item, err := r.scanHistoryItem(rows)
|
item, err := r.scanHistoryItem(rows)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -75,6 +92,19 @@ func (r *repository) List(ctx context.Context, filter paymenthistory.ListFilter)
|
|||||||
return paymenthistory.ListPaymentHistoryDTO{Count: count, Items: items}, nil
|
return paymenthistory.ListPaymentHistoryDTO{Count: count, Items: items}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *repository) Get(ctx context.Context, paymentID int64) (paymenthistory.PaymentHistoryDetailDTO, error) {
|
||||||
|
query := `SELECT ` + historySelectColumns + `, p.gateway_response` +
|
||||||
|
historyFromClause + ` WHERE p.id = $1 AND p.deleted_at IS NULL AND o.deleted_at IS NULL`
|
||||||
|
|
||||||
|
var detail paymenthistory.PaymentHistoryDetailDTO
|
||||||
|
item, err := r.scanHistoryItem(r.client.QueryRow(ctx, query, paymentID), &detail.GatewayResponse)
|
||||||
|
if err != nil {
|
||||||
|
return paymenthistory.PaymentHistoryDetailDTO{}, err
|
||||||
|
}
|
||||||
|
detail.PaymentHistoryItemDTO = item
|
||||||
|
return detail, nil
|
||||||
|
}
|
||||||
|
|
||||||
// OwnerInfo returns orderID's owning user/branch, so the handler can run
|
// OwnerInfo returns orderID's owning user/branch, so the handler can run
|
||||||
// rbac.GuardOrder before returning its logs to a branch/own-scoped caller.
|
// rbac.GuardOrder before returning its logs to a branch/own-scoped caller.
|
||||||
func (r *repository) OwnerInfo(ctx context.Context, orderID int64) (*int64, int64, error) {
|
func (r *repository) OwnerInfo(ctx context.Context, orderID int64) (*int64, int64, error) {
|
||||||
@@ -92,7 +122,7 @@ func (r *repository) Logs(ctx context.Context, orderID int64) ([]paymenthistory.
|
|||||||
FROM visa_master_payment_logs l
|
FROM visa_master_payment_logs l
|
||||||
LEFT JOIN users u ON u.id = l.created_by
|
LEFT JOIN users u ON u.id = l.created_by
|
||||||
WHERE l.order_id = $1
|
WHERE l.order_id = $1
|
||||||
ORDER BY l.id ASC`,
|
ORDER BY l.id DESC`,
|
||||||
orderID,
|
orderID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -117,6 +147,20 @@ func (r *repository) Logs(ctx context.Context, orderID int64) ([]paymenthistory.
|
|||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// orderByClause sorts by the whitelisted filter.Sort column, falling back
|
||||||
|
// to newest-first; p.id breaks ties so paging stays stable.
|
||||||
|
func orderByClause(filter paymenthistory.ListFilter) string {
|
||||||
|
direction := "ASC"
|
||||||
|
if filter.Desc {
|
||||||
|
direction = "DESC"
|
||||||
|
}
|
||||||
|
column, ok := paymenthistory.SortColumns[filter.Sort]
|
||||||
|
if !ok || column == "p.id" {
|
||||||
|
return "p.id " + direction
|
||||||
|
}
|
||||||
|
return column + " " + direction + ", p.id DESC"
|
||||||
|
}
|
||||||
|
|
||||||
func buildListQuery(filter paymenthistory.ListFilter) (whereClause string, args []interface{}) {
|
func buildListQuery(filter paymenthistory.ListFilter) (whereClause string, args []interface{}) {
|
||||||
conditions := []string{"p.deleted_at IS NULL", "o.deleted_at IS NULL"}
|
conditions := []string{"p.deleted_at IS NULL", "o.deleted_at IS NULL"}
|
||||||
|
|
||||||
@@ -153,49 +197,42 @@ func buildListQuery(filter paymenthistory.ListFilter) (whereClause string, args
|
|||||||
return " WHERE " + strings.Join(conditions, " AND "), args
|
return " WHERE " + strings.Join(conditions, " AND "), args
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *repository) scanHistoryItem(row pgx.Row) (paymenthistory.PaymentHistoryItemDTO, error) {
|
// scanHistoryItem scans historySelectColumns, followed by any extra
|
||||||
|
// columns the caller appended (scanned into extra, in order).
|
||||||
|
func (r *repository) scanHistoryItem(row pgx.Row, extra ...interface{}) (paymenthistory.PaymentHistoryItemDTO, error) {
|
||||||
var item paymenthistory.PaymentHistoryItemDTO
|
var item paymenthistory.PaymentHistoryItemDTO
|
||||||
var gatewayStatus string
|
|
||||||
var branchNameJSON []byte
|
var branchNameJSON []byte
|
||||||
var gatewayResponse []byte
|
var formURL *string
|
||||||
if err := row.Scan(
|
dest := []interface{}{
|
||||||
&item.Id, &item.OrderId, &item.OrderNumber, &item.OrderUniqueId, &item.Type,
|
&item.Id, &item.OrderId, &item.OrderNumber, &item.OrderUniqueId, &item.Type,
|
||||||
&item.BranchId, &branchNameJSON, &item.PassportName, &item.PassportSurname, &item.UserId,
|
&item.BranchId, &branchNameJSON, &item.PassportName, &item.PassportSurname, &item.UserId,
|
||||||
&item.AmountTmt, &item.BankFeeTmt, &item.GbusFeeTmt, &item.TvebFeeUsd, &item.TvebFeeTmt, &item.TotalAmountTmt,
|
&item.AmountTmt, &item.BankFeeTmt, &item.GbusFeeTmt, &item.TvebFeeUsd, &item.TvebFeeTmt, &item.TotalAmountTmt,
|
||||||
|
&item.AmountMinor, &item.AmountUsd,
|
||||||
&item.ExchangeRateUsd, &item.ExchangeRateRub, &item.PaymentPeriod,
|
&item.ExchangeRateUsd, &item.ExchangeRateRub, &item.PaymentPeriod,
|
||||||
&gatewayStatus, &item.GatewayReference, &gatewayResponse, &item.CreatedById, &item.CreatedByName,
|
&item.GatewayStatus, &item.GatewayReference,
|
||||||
|
&item.ApiClient, &item.Description,
|
||||||
|
&item.CardholderName, &item.MaskedPan, &formURL,
|
||||||
|
&item.CreatedById, &item.CreatedByName,
|
||||||
&item.CreatedAt, &item.UpdatedAt,
|
&item.CreatedAt, &item.UpdatedAt,
|
||||||
); err != nil {
|
}
|
||||||
|
if err := row.Scan(append(dest, extra...)...); err != nil {
|
||||||
return paymenthistory.PaymentHistoryItemDTO{}, err
|
return paymenthistory.PaymentHistoryItemDTO{}, err
|
||||||
}
|
}
|
||||||
if err := shared.UnmarshalLocalized(branchNameJSON, &item.BranchName); err != nil {
|
if err := shared.UnmarshalLocalized(branchNameJSON, &item.BranchName); err != nil {
|
||||||
return paymenthistory.PaymentHistoryItemDTO{}, err
|
return paymenthistory.PaymentHistoryItemDTO{}, err
|
||||||
}
|
}
|
||||||
item.GatewayStatus = gatewayStatus
|
item.Paid = item.GatewayStatus == "success"
|
||||||
item.Paid = gatewayStatus == "success"
|
|
||||||
|
|
||||||
// formUrl only survives in gateway_response while the attempt is still
|
// formUrl only survives in gateway_response while the attempt is still
|
||||||
// pending - once finalized, gateway_response is overwritten with the
|
// pending - once finalized, gateway_response is overwritten with the
|
||||||
// status-check response, which has no formUrl, so there's nothing to
|
// status-check response, which has no formUrl, so there's nothing to
|
||||||
// resume for a paid/failed row.
|
// resume for a paid/failed row. SuccessUrl must match the ReturnURL
|
||||||
if formURL := extractFormURL(gatewayResponse); formURL != "" {
|
// visamasterpay registered with GBÜS (see its Pay).
|
||||||
item.FormUrl = &formURL
|
if formURL != nil {
|
||||||
successURL := fmt.Sprintf("%s/api/admin/visa-master-payment-orders/callback?paymentId=%d", r.publicBaseURL, item.Id)
|
item.FormUrl = formURL
|
||||||
|
successURL := r.publicBaseURL + "/online/visa-master"
|
||||||
item.SuccessUrl = &successURL
|
item.SuccessUrl = &successURL
|
||||||
}
|
}
|
||||||
|
|
||||||
return item, nil
|
return item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractFormURL(gatewayResponse []byte) string {
|
|
||||||
if len(gatewayResponse) == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
var parsed struct {
|
|
||||||
FormUrl string `json:"formUrl"`
|
|
||||||
}
|
|
||||||
if err := json.Unmarshal(gatewayResponse, &parsed); err != nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return parsed.FormUrl
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,28 +17,44 @@ import (
|
|||||||
// pending) enriched with the order/branch/client/operator context needed to
|
// pending) enriched with the order/branch/client/operator context needed to
|
||||||
// display it in a history list, without requiring a separate lookup per row.
|
// display it in a history list, without requiring a separate lookup per row.
|
||||||
type PaymentHistoryItemDTO struct {
|
type PaymentHistoryItemDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
OrderId int64 `json:"orderId"`
|
OrderId int64 `json:"orderId"`
|
||||||
OrderNumber string `json:"orderNumber"`
|
OrderNumber string `json:"orderNumber"`
|
||||||
OrderUniqueId string `json:"orderUniqueId"`
|
OrderUniqueId string `json:"orderUniqueId"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
BranchId int64 `json:"branchId"`
|
BranchId int64 `json:"branchId"`
|
||||||
BranchName shared.LocalizedText `json:"branchName"`
|
BranchName shared.LocalizedText `json:"branchName"`
|
||||||
PassportName string `json:"passportName"`
|
PassportName string `json:"passportName"`
|
||||||
PassportSurname string `json:"passportSurname"`
|
PassportSurname string `json:"passportSurname"`
|
||||||
UserId int64 `json:"userId"`
|
UserId int64 `json:"userId"`
|
||||||
Paid bool `json:"paid"`
|
Paid bool `json:"paid"`
|
||||||
AmountTmt float64 `json:"amountTmt"`
|
AmountTmt float64 `json:"amountTmt"`
|
||||||
BankFeeTmt float64 `json:"bankFeeTmt"`
|
BankFeeTmt float64 `json:"bankFeeTmt"`
|
||||||
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
||||||
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
||||||
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
||||||
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
||||||
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
// AmountMinor is the amount registered with GBÜS, in tetri.
|
||||||
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
AmountMinor int64 `json:"amountMinor"`
|
||||||
PaymentPeriod time.Time `json:"paymentPeriod"`
|
// AmountUsd is amount_tmt converted back at the attempt's own
|
||||||
GatewayStatus string `json:"gatewayStatus"`
|
// exchange_rate_usd - the USD figure the payout was quoted in.
|
||||||
GatewayReference *string `json:"gatewayReference,omitempty"`
|
AmountUsd float64 `json:"amountUsd"`
|
||||||
|
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
||||||
|
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
||||||
|
PaymentPeriod time.Time `json:"paymentPeriod"`
|
||||||
|
GatewayStatus string `json:"gatewayStatus"`
|
||||||
|
GatewayReference *string `json:"gatewayReference,omitempty"`
|
||||||
|
// ApiClient is the branch's GBÜS merchant username for this order type
|
||||||
|
// (visa/master or sber) and Description the text sent with register.do -
|
||||||
|
// both as visamasterpay's Pay picks them.
|
||||||
|
ApiClient string `json:"apiClient"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
// CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended
|
||||||
|
// cardAuthInfo, so they're only known once an attempt has been
|
||||||
|
// finalized by the callback/status check (unset while pending, and for
|
||||||
|
// attempts that never reached the card form).
|
||||||
|
CardholderName *string `json:"cardholderName,omitempty"`
|
||||||
|
MaskedPan *string `json:"maskedPan,omitempty"`
|
||||||
// FormUrl/SuccessUrl are only set while the attempt is still pending
|
// FormUrl/SuccessUrl are only set while the attempt is still pending
|
||||||
// (awaiting the customer to finish paying on GBÜS's hosted page) - once
|
// (awaiting the customer to finish paying on GBÜS's hosted page) - once
|
||||||
// an attempt is finalized (success/failed), gateway_response no longer
|
// an attempt is finalized (success/failed), gateway_response no longer
|
||||||
@@ -51,6 +67,14 @@ type PaymentHistoryItemDTO struct {
|
|||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PaymentHistoryDetailDTO is a single payout attempt with the raw GBÜS
|
||||||
|
// response kept alongside it - the list deliberately leaves the jsonb out
|
||||||
|
// so pages stay small.
|
||||||
|
type PaymentHistoryDetailDTO struct {
|
||||||
|
PaymentHistoryItemDTO
|
||||||
|
GatewayResponse json.RawMessage `json:"gatewayResponse,omitempty" swaggertype:"object"`
|
||||||
|
}
|
||||||
|
|
||||||
// ListFilter narrows the history list. BranchIds is populated by
|
// ListFilter narrows the history list. BranchIds is populated by
|
||||||
// rbac.BindBranchIDs and takes priority over BranchId when set (see
|
// rbac.BindBranchIDs and takes priority over BranchId when set (see
|
||||||
// rbac.AppendBranchIDs), the same way visamaster.ListFilter works.
|
// rbac.AppendBranchIDs), the same way visamaster.ListFilter works.
|
||||||
@@ -61,10 +85,20 @@ type ListFilter struct {
|
|||||||
UserId *int64
|
UserId *int64
|
||||||
Status *string // gateway_status: pending/success/failed
|
Status *string // gateway_status: pending/success/failed
|
||||||
Search string // matches order passport name/surname or unique id
|
Search string // matches order passport name/surname or unique id
|
||||||
|
Sort string // one of SortColumns' keys; empty means id
|
||||||
|
Desc bool
|
||||||
Page int
|
Page int
|
||||||
Limit int
|
Limit int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SortColumns maps the accepted ?sort= values to their SQL expressions.
|
||||||
|
var SortColumns = map[string]string{
|
||||||
|
"id": "p.id",
|
||||||
|
"created_at": "p.created_at",
|
||||||
|
"status": "p.gateway_status",
|
||||||
|
"amount": "p.amount_tmt",
|
||||||
|
}
|
||||||
|
|
||||||
type ListPaymentHistoryDTO struct {
|
type ListPaymentHistoryDTO struct {
|
||||||
Count int64 `json:"count"`
|
Count int64 `json:"count"`
|
||||||
Items []PaymentHistoryItemDTO `json:"items"`
|
Items []PaymentHistoryItemDTO `json:"items"`
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package paymenthistory
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"online-back/internal/appresult"
|
"online-back/internal/appresult"
|
||||||
"online-back/internal/handlers"
|
"online-back/internal/handlers"
|
||||||
@@ -29,6 +30,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.RequireStaff(perm.Cards))
|
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Cards))
|
||||||
group.GET("", h.list)
|
group.GET("", h.list)
|
||||||
|
group.GET("/payments/:id", h.get)
|
||||||
group.GET("/:id", h.logs)
|
group.GET("/:id", h.logs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +45,8 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param user_id query int false "Filter by order owner (client) user ID"
|
// @Param user_id query int false "Filter by order owner (client) user ID"
|
||||||
// @Param status query string false "Filter by gateway status (pending, success, failed)"
|
// @Param status query string false "Filter by gateway status (pending, success, failed)"
|
||||||
// @Param search query string false "Filter by passport name/surname or order unique ID"
|
// @Param search query string false "Filter by passport name/surname or order unique ID"
|
||||||
|
// @Param sort query string false "Sort column" Enums(id, created_at, status, amount) default(id)
|
||||||
|
// @Param order query string false "Sort direction" Enums(asc, desc) default(desc)
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
// @Success 200 {object} ListPaymentHistoryDTO
|
// @Success 200 {object} ListPaymentHistoryDTO
|
||||||
@@ -66,6 +70,44 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get godoc
|
||||||
|
// @Summary Get a single payment attempt
|
||||||
|
// @Description Returns one visa/master/sber payout attempt by its payment ID, with the raw GBÜS response - the detail view behind a payment-history list row
|
||||||
|
// @Tags payment-history
|
||||||
|
// @Produce json
|
||||||
|
// @Security BearerAuth
|
||||||
|
// @Param id path int true "Payment ID"
|
||||||
|
// @Success 200 {object} PaymentHistoryDetailDTO
|
||||||
|
// @Failure 400 {object} appresult.AppError
|
||||||
|
// @Failure 403 {object} appresult.AppError
|
||||||
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
// @Failure 500 {object} appresult.AppError
|
||||||
|
// @Router /payment-history/payments/{id} [get]
|
||||||
|
func (h *handler) get(c *gin.Context) {
|
||||||
|
paymentID, ok := shared.ParseID(c.Param("id"))
|
||||||
|
if !ok {
|
||||||
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := h.repository.Get(c.Request.Context(), paymentID)
|
||||||
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
|
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
h.logger.Errorf("get payment history failed (payment %d): %v", paymentID, err)
|
||||||
|
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !h.guardOrder(c, result.OrderId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||||
|
}
|
||||||
|
|
||||||
// logs godoc
|
// logs godoc
|
||||||
// @Summary Get payment logs for an order
|
// @Summary Get payment logs for an order
|
||||||
// @Description Returns the full step-by-step audit trail (visa_master_payment_logs) recorded while processing an order's payout - evidence of what actually happened, independent of the summary rows returned by the list endpoint
|
// @Description Returns the full step-by-step audit trail (visa_master_payment_logs) recorded while processing an order's payout - evidence of what actually happened, independent of the summary rows returned by the list endpoint
|
||||||
@@ -151,6 +193,20 @@ func parseListFilter(c *gin.Context) (ListFilter, bool) {
|
|||||||
|
|
||||||
filter.Search = shared.QueryValue(c, "search", "q")
|
filter.Search = shared.QueryValue(c, "search", "q")
|
||||||
|
|
||||||
|
if raw := shared.QueryValue(c, "sort", "sort_by", "sortBy"); raw != "" {
|
||||||
|
if _, ok := SortColumns[raw]; !ok {
|
||||||
|
return ListFilter{}, false
|
||||||
|
}
|
||||||
|
filter.Sort = raw
|
||||||
|
}
|
||||||
|
switch strings.ToLower(shared.QueryValue(c, "order", "direction")) {
|
||||||
|
case "", "desc":
|
||||||
|
filter.Desc = true
|
||||||
|
case "asc":
|
||||||
|
default:
|
||||||
|
return ListFilter{}, false
|
||||||
|
}
|
||||||
|
|
||||||
rbac.BindBranchIDs(c, &filter.BranchIds)
|
rbac.BindBranchIDs(c, &filter.BranchIds)
|
||||||
return filter, true
|
return filter, true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import "context"
|
|||||||
|
|
||||||
type Repository interface {
|
type Repository interface {
|
||||||
List(ctx context.Context, filter ListFilter) (ListPaymentHistoryDTO, error)
|
List(ctx context.Context, filter ListFilter) (ListPaymentHistoryDTO, error)
|
||||||
|
// Get returns a single payout attempt by its visa_master_order_payments id.
|
||||||
|
Get(ctx context.Context, paymentID int64) (PaymentHistoryDetailDTO, error)
|
||||||
// Logs returns the full visa_master_payment_logs audit trail for a
|
// Logs returns the full visa_master_payment_logs audit trail for a
|
||||||
// single order, oldest first.
|
// single order, newest first.
|
||||||
Logs(ctx context.Context, orderID int64) ([]PaymentLogDTO, error)
|
Logs(ctx context.Context, orderID int64) ([]PaymentLogDTO, error)
|
||||||
// OwnerInfo returns an order's owning user/branch, for rbac.GuardOrder.
|
// OwnerInfo returns an order's owning user/branch, for rbac.GuardOrder.
|
||||||
OwnerInfo(ctx context.Context, orderID int64) (*int64, int64, error)
|
OwnerInfo(ctx context.Context, orderID int64) (*int64, int64, error)
|
||||||
|
|||||||
Reference in New Issue
Block a user