diff --git a/src/api/dashboard.ts b/src/api/dashboard.ts index bd71746..926a123 100644 --- a/src/api/dashboard.ts +++ b/src/api/dashboard.ts @@ -6,6 +6,8 @@ import type { DashboardMaster, DashboardOrderPeakHours, PriceChartPoint, + ProfitConversion, + ProfitConversionsResponse, } from '@/model/dashboard' import type { Order } from '@/model/order' import type { Balance } from '@/model/product' @@ -51,3 +53,20 @@ export const getRecentOrders = async (limit = 10) => { } export const toggleGateway = async () => await useAxios.post('/admin/gateway') + +export const getProfitConversions = async (startDate?: string, endDate?: string) => + await useAxios.post('/admin/dashboard/profit-conversions', { + startDate, + endDate, + }) + +export const storeProfitConversion = async (payload: { + rial_amount?: number | null + gram_amount?: number | null + unit_price?: number | null + converted_at?: string | null + description?: string | null +}) => await useAxios.post('/admin/dashboard/profit-conversions/store', payload) + +export const deleteProfitConversion = async (id: number) => + await useAxios.delete(`/admin/dashboard/profit-conversions/${id}`) diff --git a/src/model/dashboard.ts b/src/model/dashboard.ts index 7b790a6..332d031 100644 --- a/src/model/dashboard.ts +++ b/src/model/dashboard.ts @@ -31,6 +31,17 @@ export interface DashboardMaster { }> } +export interface DashboardDailyProfit { + date: string + /** سود طلایی روز: کارمزد کسرشده از طلا (گرم) */ + profit_gold: number + /** سود ریالی روز: کارمزد کسرشده از ریال */ + profit_rial: number + /** سود اختلاف قیمت روز (ریال) */ + spread_rial: number + order_count: number +} + export interface DashboardFinance { fullPriceM1?: number fullPriceM2?: number @@ -43,6 +54,31 @@ export interface DashboardFinance { Gifts?: string GiftsPrise?: number sumAll?: number + /** سود طلایی: مجموع کارمزدهای کسرشده از طلا (گرم) */ + profitGoldGrams?: number + /** سود ریالی: مجموع کارمزدهای کسرشده از ریال */ + profitRial?: number + /** ارزش ریالی سود طلایی با قیمت روز */ + profitGoldValueRial?: number + /** تفکیک روزانهٔ سود طلایی/ریالی */ + daily?: DashboardDailyProfit[] +} + +export interface ProfitConversion { + id: number + user_id?: number | null + rial_amount: number + gram_amount: number + unit_price: number + converted_at?: string | null + description?: string | null + created_at?: string +} + +export interface ProfitConversionsResponse { + items: ProfitConversion[] + totalRial: number + totalGram: number } export interface DashboardFlowPoint { diff --git a/src/pages/dashboard/components/DashboardProfitSplit.vue b/src/pages/dashboard/components/DashboardProfitSplit.vue new file mode 100644 index 0000000..091b1e8 --- /dev/null +++ b/src/pages/dashboard/components/DashboardProfitSplit.vue @@ -0,0 +1,503 @@ + + + + + diff --git a/src/pages/dashboard/index.vue b/src/pages/dashboard/index.vue index b556d69..5b58929 100644 --- a/src/pages/dashboard/index.vue +++ b/src/pages/dashboard/index.vue @@ -47,6 +47,13 @@ + +