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