fixed number formats, added rollback new endpoint
This commit is contained in:
parent
efced51852
commit
31e5c04e0e
@ -22,7 +22,7 @@ function defaultDataResponseProcessor(data) {
|
|||||||
export const API_PATH_MAIN = "https://hostapay.trade/api/v1/";
|
export const API_PATH_MAIN = "https://hostapay.trade/api/v1/";
|
||||||
export const API_PATH_TEST = "https://test.0x000f.ru/api/v1/";
|
export const API_PATH_TEST = "https://test.0x000f.ru/api/v1/";
|
||||||
|
|
||||||
export const API_PATH_VALUE = API_PATH_MAIN;
|
export const API_PATH_VALUE = API_PATH_TEST;
|
||||||
|
|
||||||
async function makePost(
|
async function makePost(
|
||||||
url,
|
url,
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
export function isStringEmptyOrSpaces(str) {
|
export function isStringEmptyOrSpaces(str) {
|
||||||
if (typeof str === "string") return str == null || str?.trim() === "";
|
if (typeof str === "string") return str == null || str?.trim() === "";
|
||||||
else if (typeof str === "object") {
|
else if (typeof str === "object") {
|
||||||
@ -19,5 +18,23 @@ export function truncateMiddle(str, n) {
|
|||||||
const leftPart = str.slice(0, n); // Первые n символов
|
const leftPart = str.slice(0, n); // Первые n символов
|
||||||
const rightPart = str.slice(-n); // Последние n символов
|
const rightPart = str.slice(-n); // Последние n символов
|
||||||
|
|
||||||
return leftPart + '...' + rightPart; // Соединяем с "..."
|
return leftPart + "..." + rightPart; // Соединяем с "..."
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {string | number} number
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function toValidNumberFormat(number) {
|
||||||
|
if (isNaN(Number(number))) {
|
||||||
|
return "0.00";
|
||||||
|
}
|
||||||
|
|
||||||
|
return Number(number)
|
||||||
|
.toLocaleString("ru-RU", {
|
||||||
|
minimumFractionDigits: 2,
|
||||||
|
maximumFractionDigits: 2,
|
||||||
|
})
|
||||||
|
.replace(/,/g, ".");
|
||||||
}
|
}
|
@ -10,6 +10,7 @@
|
|||||||
import Pagination from "$lib/ui-components/pagination.svelte";
|
import Pagination from "$lib/ui-components/pagination.svelte";
|
||||||
import { redirect } from "$lib/tools/url/URLTools";
|
import { redirect } from "$lib/tools/url/URLTools";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { toValidNumberFormat } from "$lib/tools/strings/Strings";
|
||||||
|
|
||||||
const disputesStatusMap = {
|
const disputesStatusMap = {
|
||||||
"4": "Требует проверки",
|
"4": "Требует проверки",
|
||||||
@ -261,7 +262,7 @@
|
|||||||
<td>{dispute["requisite_cardnumber"]}</td>
|
<td>{dispute["requisite_cardnumber"]}</td>
|
||||||
<td>{dispute["requisite_phone"]}</td>
|
<td>{dispute["requisite_phone"]}</td>
|
||||||
<!-- <td>{dispute["order_rate"]}</td> -->
|
<!-- <td>{dispute["order_rate"]}</td> -->
|
||||||
<td>{dispute["amount"]}</td>
|
<td>{toValidNumberFormat(dispute["amount"])}</td>
|
||||||
<td>{dispute["order_creationtime"]}</td>
|
<td>{dispute["order_creationtime"]}</td>
|
||||||
<td
|
<td
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
@ -312,14 +313,14 @@
|
|||||||
<div class="rounded-box flex flex-col bg-base-100 p-4 gap-1 mt-4">
|
<div class="rounded-box flex flex-col bg-base-100 p-4 gap-1 mt-4">
|
||||||
<p class="text-lg font-bold">Сумма в споре</p>
|
<p class="text-lg font-bold">Сумма в споре</p>
|
||||||
<p>
|
<p>
|
||||||
{Number(selectedDispute.new_amount)}
|
{toValidNumberFormat(selectedDispute.new_amount)}
|
||||||
{selectedDispute.out_code}
|
{selectedDispute.out_code}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="rounded-box flex flex-col bg-base-100 p-4 gap-1 mt-4">
|
<div class="rounded-box flex flex-col bg-base-100 p-4 gap-1 mt-4">
|
||||||
<p class="text-lg font-bold">Сумма в заявке</p>
|
<p class="text-lg font-bold">Сумма в заявке</p>
|
||||||
<p>
|
<p>
|
||||||
{Number(selectedDispute.amount)}
|
{toValidNumberFormat(selectedDispute.amount)}
|
||||||
{selectedDispute.out_code}
|
{selectedDispute.out_code}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
totpValid = true;
|
totpValid = true;
|
||||||
showLoadingSpinner = true;
|
showLoadingSpinner = true;
|
||||||
const result = await makePost("client/login", {
|
const result = await makePost("client/login", {
|
||||||
user_token: input_token.value,
|
user_token: input_token.value.trim(),
|
||||||
totp: input_totp.value,
|
totp: input_totp.value,
|
||||||
});
|
});
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
|
@ -7,7 +7,10 @@
|
|||||||
import Pagination from "$lib/ui-components/pagination.svelte";
|
import Pagination from "$lib/ui-components/pagination.svelte";
|
||||||
import { redirect } from "$lib/tools/url/URLTools";
|
import { redirect } from "$lib/tools/url/URLTools";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { isStringEmptyOrSpaces } from "$lib/tools/strings/Strings";
|
import {
|
||||||
|
isStringEmptyOrSpaces,
|
||||||
|
toValidNumberFormat,
|
||||||
|
} from "$lib/tools/strings/Strings";
|
||||||
import {
|
import {
|
||||||
ChevronLeftIcon,
|
ChevronLeftIcon,
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
@ -299,7 +302,7 @@
|
|||||||
<td class="font-semibold">{merch["code"]}</td>
|
<td class="font-semibold">{merch["code"]}</td>
|
||||||
<td>{merch["is_active"] === "t" ? "Активен" : "Отключен"}</td>
|
<td>{merch["is_active"] === "t" ? "Активен" : "Отключен"}</td>
|
||||||
<td
|
<td
|
||||||
>{merch["balance"]}
|
>{toValidNumberFormat(merch["balance"])}
|
||||||
{merch["balance_type"] === "0" ? "USDT" : merch["code"]}</td
|
{merch["balance_type"] === "0" ? "USDT" : merch["code"]}</td
|
||||||
>
|
>
|
||||||
<!-- <td>{merch["balance_type"] === "0" ? "crypto":"fiat"}</td> -->
|
<!-- <td>{merch["balance_type"] === "0" ? "crypto":"fiat"}</td> -->
|
||||||
@ -423,10 +426,10 @@
|
|||||||
{settle["code"]}
|
{settle["code"]}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{settle["amount"]} USDT
|
{toValidNumberFormat(settle["amount"])} USDT
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{settle["merchant_amount"]} USDT
|
{toValidNumberFormat(settle["merchant_amount"])} USDT
|
||||||
</td>
|
</td>
|
||||||
<td class="">
|
<td class="">
|
||||||
<p>{settle["settle_address"]}</p>
|
<p>{settle["settle_address"]}</p>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import { getAuthInfo, makeAuthHeaderForAxios } from "$lib/auth/Auth";
|
import { getAuthInfo, makeAuthHeaderForAxios } from "$lib/auth/Auth";
|
||||||
import { makePost } from "$lib/tools/requests/requests";
|
import { makePost } from "$lib/tools/requests/requests";
|
||||||
|
import { toValidNumberFormat } from "$lib/tools/strings/Strings";
|
||||||
import { sayError, sayInfo } from "$lib/tools/toaster/Toaster";
|
import { sayError, sayInfo } from "$lib/tools/toaster/Toaster";
|
||||||
|
|
||||||
const orderStatusMap = {
|
const orderStatusMap = {
|
||||||
@ -113,6 +114,29 @@
|
|||||||
showChangeSum = false;
|
showChangeSum = false;
|
||||||
showFoundedOrderWindow = false;
|
showFoundedOrderWindow = false;
|
||||||
}
|
}
|
||||||
|
async function changeSumWithoutBalance(uuid) {
|
||||||
|
showLoadingChangeSum = true;
|
||||||
|
const res = await makePost(
|
||||||
|
"admin/rollbackOrderWithoutBalance",
|
||||||
|
{
|
||||||
|
id: uuid,
|
||||||
|
summa: newSum.toString(),
|
||||||
|
},
|
||||||
|
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
||||||
|
);
|
||||||
|
if (res.error) {
|
||||||
|
if (res.status == 401) {
|
||||||
|
sayError("Данные авторизации устарели!");
|
||||||
|
}
|
||||||
|
sayError("Не удалось изменить сумму");
|
||||||
|
showLoadingChangeSum = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sayInfo("Сумма успешно изменена!");
|
||||||
|
showLoadingChangeSum = false;
|
||||||
|
showChangeSum = false;
|
||||||
|
showFoundedOrderWindow = false;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="w-full flex flex-col gap-8">
|
<div class="w-full flex flex-col gap-8">
|
||||||
@ -182,7 +206,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<p class="text-sm mt-3">Сумма</p>
|
<p class="text-sm mt-3">Сумма</p>
|
||||||
<p>
|
<p>
|
||||||
{foundedDispute["summa"]}
|
{toValidNumberFormat(foundedDispute["summa"])}
|
||||||
{foundedDispute["currency_code"]}
|
{foundedDispute["currency_code"]}
|
||||||
<!-- ({(
|
<!-- ({(
|
||||||
Number(foundedDispute["summa"]) / Number(foundedDispute["rate"])
|
Number(foundedDispute["summa"]) / Number(foundedDispute["rate"])
|
||||||
@ -241,7 +265,7 @@
|
|||||||
<div
|
<div
|
||||||
class="fixed inset-0 z-[1001] bg-black bg-opacity-50 flex justify-center items-center"
|
class="fixed inset-0 z-[1001] bg-black bg-opacity-50 flex justify-center items-center"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col p-4 bg-base-100 rounded-md">
|
<div class="flex flex-col p-4 bg-base-100 rounded-md gap-1">
|
||||||
<p>Укажите новую сумму ({foundedDispute["currency_code"]})</p>
|
<p>Укажите новую сумму ({foundedDispute["currency_code"]})</p>
|
||||||
<input
|
<input
|
||||||
bind:value={newSum}
|
bind:value={newSum}
|
||||||
@ -260,6 +284,18 @@
|
|||||||
{"Изменить сумму ручками"}
|
{"Изменить сумму ручками"}
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
on:click={() => {
|
||||||
|
changeSumWithoutBalance(foundedDispute["uuid"]);
|
||||||
|
}}
|
||||||
|
class="btn btn-outline btn-info"
|
||||||
|
>
|
||||||
|
{#if showLoadingChangeSum}
|
||||||
|
<span class="loading loading-dots loading-xs"></span>
|
||||||
|
{:else}
|
||||||
|
{"Изменить сумму ручками (без списания баланса)"}
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
showChangeSum = false;
|
showChangeSum = false;
|
||||||
|
@ -12,7 +12,10 @@
|
|||||||
import Pagination from "$lib/ui-components/pagination.svelte";
|
import Pagination from "$lib/ui-components/pagination.svelte";
|
||||||
import { redirect } from "$lib/tools/url/URLTools";
|
import { redirect } from "$lib/tools/url/URLTools";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { isStringEmptyOrSpaces } from "$lib/tools/strings/Strings";
|
import {
|
||||||
|
isStringEmptyOrSpaces,
|
||||||
|
toValidNumberFormat,
|
||||||
|
} from "$lib/tools/strings/Strings";
|
||||||
import { CopyIcon, SearchIcon, XCircleIcon } from "svelte-feather-icons";
|
import { CopyIcon, SearchIcon, XCircleIcon } from "svelte-feather-icons";
|
||||||
|
|
||||||
const payoutsStatusMap = {
|
const payoutsStatusMap = {
|
||||||
@ -566,7 +569,8 @@
|
|||||||
>{payoutsStatusMap[payout["status"]]}</td
|
>{payoutsStatusMap[payout["status"]]}</td
|
||||||
>
|
>
|
||||||
<!-- <td>{payout["is_sbp"] === "t" ? "да" : "нет"}</td> -->
|
<!-- <td>{payout["is_sbp"] === "t" ? "да" : "нет"}</td> -->
|
||||||
<td>{payout["amount"]} {payout["code"]}</td>
|
<td>{toValidNumberFormat(payout["amount"])} {payout["code"]}</td
|
||||||
|
>
|
||||||
<td>{payout["pan"]}</td>
|
<td>{payout["pan"]}</td>
|
||||||
<!-- <td>{payout["rate"]} {payout["code"]}</td> -->
|
<!-- <td>{payout["rate"]} {payout["code"]}</td> -->
|
||||||
<!-- <td>{payout["amount"]}</td> -->
|
<!-- <td>{payout["amount"]}</td> -->
|
||||||
@ -626,7 +630,7 @@
|
|||||||
<div class="rounded-box flex flex-col bg-base-100 p-4 gap-1 mt-4">
|
<div class="rounded-box flex flex-col bg-base-100 p-4 gap-1 mt-4">
|
||||||
<p class="text-lg font-bold opacity-50">Сумма</p>
|
<p class="text-lg font-bold opacity-50">Сумма</p>
|
||||||
<p>
|
<p>
|
||||||
{selectedPayout.amount}
|
{toValidNumberFormat(selectedPayout.amount)}
|
||||||
{selectedPayout.code}
|
{selectedPayout.code}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import { browser } from "$app/environment";
|
import { browser } from "$app/environment";
|
||||||
import { getAuthInfo, makeAuthHeaderForAxios } from "$lib/auth/Auth.js";
|
import { getAuthInfo, makeAuthHeaderForAxios } from "$lib/auth/Auth.js";
|
||||||
import { makePost } from "$lib/tools/requests/requests.js";
|
import { makePost } from "$lib/tools/requests/requests.js";
|
||||||
|
import { toValidNumberFormat } from "$lib/tools/strings/Strings.js";
|
||||||
import { sayError } from "$lib/tools/toaster/Toaster.js";
|
import { sayError } from "$lib/tools/toaster/Toaster.js";
|
||||||
import { redirect } from "$lib/tools/url/URLTools.js";
|
import { redirect } from "$lib/tools/url/URLTools.js";
|
||||||
import Pagination from "$lib/ui-components/pagination.svelte";
|
import Pagination from "$lib/ui-components/pagination.svelte";
|
||||||
@ -212,7 +213,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2 p-2 items-center text-lg">
|
<div class="flex gap-2 p-2 items-center text-lg">
|
||||||
<p class="font-bold">Баланс:</p>
|
<p class="font-bold">Баланс:</p>
|
||||||
<p class="text-info">{Number(userData.balance)} {userData?.code}</p>
|
<p class="text-info">
|
||||||
|
{toValidNumberFormat(userData.balance)}
|
||||||
|
{userData?.code}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2 p-2 items-center text-lg">
|
<div class="flex gap-2 p-2 items-center text-lg">
|
||||||
<p class="font-bold">Страховка:</p>
|
<p class="font-bold">Страховка:</p>
|
||||||
@ -315,8 +319,8 @@
|
|||||||
<td>{requisite["phone"]}</td>
|
<td>{requisite["phone"]}</td>
|
||||||
<td>{requisite["name"]}</td>
|
<td>{requisite["name"]}</td>
|
||||||
<td>{requisite["device_uuid"]}</td>
|
<td>{requisite["device_uuid"]}</td>
|
||||||
<td>{requisite["total_volume"]}</td>
|
<td>{toValidNumberFormat(requisite["total_volume"])}</td>
|
||||||
<td>{requisite["daily_volume_limit"]}</td>
|
<td>{toValidNumberFormat(requisite["daily_volume_limit"])}</td>
|
||||||
<td class="flex gap-2">
|
<td class="flex gap-2">
|
||||||
<a
|
<a
|
||||||
href={"/admin/user/edit/req/" +
|
href={"/admin/user/edit/req/" +
|
||||||
@ -401,7 +405,7 @@
|
|||||||
<td class="font-semibold">{order["uuid"]}</td>
|
<td class="font-semibold">{order["uuid"]}</td>
|
||||||
<td class="font-semibold">{order["external_user_id"]}</td>
|
<td class="font-semibold">{order["external_user_id"]}</td>
|
||||||
<td class="">{order["status"]}</td>
|
<td class="">{order["status"]}</td>
|
||||||
<td>{order["summa"]} {userData?.code}</td>
|
<td>{toValidNumberFormat(order["summa"])} {userData?.code}</td>
|
||||||
<td>{orderTypesMap[order["order_type"]]}</td>
|
<td>{orderTypesMap[order["order_type"]]}</td>
|
||||||
<!-- <td>{order["rate"]} {userData?.code}</td> -->
|
<!-- <td>{order["rate"]} {userData?.code}</td> -->
|
||||||
<!-- <td>{order["is_sbp"] === "t" ? "да" : "нет"}</td> -->
|
<!-- <td>{order["is_sbp"] === "t" ? "да" : "нет"}</td> -->
|
||||||
@ -457,7 +461,7 @@
|
|||||||
{#each userDeposits as depo}
|
{#each userDeposits as depo}
|
||||||
<tr class="hover:bg-neutral group">
|
<tr class="hover:bg-neutral group">
|
||||||
<td class="">{depoStatusMap[depo["pending"]]}</td>
|
<td class="">{depoStatusMap[depo["pending"]]}</td>
|
||||||
<td>{Number(depo["amount"]).toFixed(4)} USDT</td>
|
<td>{toValidNumberFormat(depo["amount"])} USDT</td>
|
||||||
<td>{depo["creationtime"]}</td>
|
<td>{depo["creationtime"]}</td>
|
||||||
<!-- <td class="flex gap-2">
|
<!-- <td class="flex gap-2">
|
||||||
<a href="" class="btn btn-info">Изменить</a>
|
<a href="" class="btn btn-info">Изменить</a>
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<script>
|
<script>
|
||||||
import { browser } from "$app/environment";
|
import { browser } from "$app/environment";
|
||||||
import { checkAuthSync, getAuthInfo, makeAuthHeaderForAxios } from "$lib/auth/Auth";
|
import {
|
||||||
|
checkAuthSync,
|
||||||
|
getAuthInfo,
|
||||||
|
makeAuthHeaderForAxios,
|
||||||
|
} from "$lib/auth/Auth";
|
||||||
import { makeGet } from "$lib/tools/requests/requests";
|
import { makeGet } from "$lib/tools/requests/requests";
|
||||||
|
import { toValidNumberFormat } from "$lib/tools/strings/Strings";
|
||||||
import { sayError } from "$lib/tools/toaster/Toaster";
|
import { sayError } from "$lib/tools/toaster/Toaster";
|
||||||
import { redirect } from "$lib/tools/url/URLTools";
|
import { redirect } from "$lib/tools/url/URLTools";
|
||||||
|
|
||||||
@ -9,15 +14,15 @@
|
|||||||
let usersReady = false;
|
let usersReady = false;
|
||||||
|
|
||||||
async function getUsers() {
|
async function getUsers() {
|
||||||
if(checkAuthSync())
|
if (checkAuthSync()) {
|
||||||
{
|
const result = await makeGet(
|
||||||
const result = await makeGet("getUsers", makeAuthHeaderForAxios(getAuthInfo()?.a));
|
"getUsers",
|
||||||
|
makeAuthHeaderForAxios(getAuthInfo()?.a)
|
||||||
|
);
|
||||||
users = result.data;
|
users = result.data;
|
||||||
usersReady = true;
|
usersReady = true;
|
||||||
// console.log(result);
|
// console.log(result);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
sayError("Данные авторизации устарели");
|
sayError("Данные авторизации устарели");
|
||||||
// window.location.href = "/";
|
// window.location.href = "/";
|
||||||
redirect("/admin/");
|
redirect("/admin/");
|
||||||
@ -25,8 +30,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(browser)
|
if (browser) {
|
||||||
{
|
|
||||||
getUsers();
|
getUsers();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -55,9 +59,13 @@
|
|||||||
<tr class="hover:bg-neutral group">
|
<tr class="hover:bg-neutral group">
|
||||||
<th class="font-normal">{user["token"]}</th>
|
<th class="font-normal">{user["token"]}</th>
|
||||||
<td class="font-semibold">{user["name"]} {user["surname"]}</td>
|
<td class="font-semibold">{user["name"]} {user["surname"]}</td>
|
||||||
<td>{(Number(user["balance"]))} {user["code"]}</td>
|
<td>{toValidNumberFormat(user["balance"])} {user["code"]}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href={"/admin/user/profile/"+user["token"]} class="btn btn-outline btn-info group-hover:btn-warning">Профиль</a>
|
<a
|
||||||
|
href={"/admin/user/profile/" + user["token"]}
|
||||||
|
class="btn btn-outline btn-info group-hover:btn-warning"
|
||||||
|
>Профиль</a
|
||||||
|
>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/each}
|
{/each}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user