fix pargar mande

This commit is contained in:
2026-07-25 16:47:30 +03:30
parent 22a5e566b4
commit 667e3736fb
@@ -17,10 +17,14 @@ use Carbon\Carbon;
use Hekmatinasser\Verta\Verta;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Rooyesh\Wallet\models\Transaction;
use Rooyesh\Wallet\models\Wallet;
class DashboardController extends Controller
{
/** نوع تراکنش‌های کیف که «هدیه» شمرده می‌شوند: ۸ پاداش معرفی/ثبت‌نام، ۹ سود زیرمجموعه */
private const GIFT_TRANSACTION_TYPES = [8, 9];
public function dashboardMaster(Request $request)
{
$tallaPrice = Price::latest()->first();
@@ -344,7 +348,6 @@ class DashboardController extends Controller
$ords = Order::with(['product' => function ($q) use ($productSelect) {
$q->withTrashed()->select($productSelect);
}])->whereBetween('created_at', [$startDate, $endDate])->get();
$TransactionsAdmin = TransactionsAdmin::whereBetween('created_at', [$startDate, $endDate])->get();
// Initialize response data
$response = [
@@ -365,11 +368,12 @@ class DashboardController extends Controller
"daily" => [],
];
// Calculate total gold gifts from transactions
$giftsGold = 0.0;
foreach ($TransactionsAdmin as $TransactionAdmin) {
$giftsGold += (float) $TransactionAdmin->gold;
}
// هدیه = فقط پاداش معرفی/ثبت‌نام و سود زیرمجموعه.
// معاملهٔ مشتری و شارژ دستی طلا توسط ادمین هدیه نیستند.
$giftsGold = (float) Transaction::query()
->whereIn('type', self::GIFT_TRANSACTION_TYPES)
->whereBetween('created_at', [$startDate, $endDate])
->sum('gold');
$response['Gifts'] = number_format($giftsGold, 3);
$lastGoldPrice = (float) (Price::latest()->first()?->price ?? 0);