From d9e36dffcac9a75ce68d6ca9c5d1ec101a483731 Mon Sep 17 00:00:00 2001 From: adonis Date: Thu, 11 Jun 2026 14:54:30 +0330 Subject: [PATCH] fix migrations 7 --- app/Http/Controllers/Customer/CustomerController.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Customer/CustomerController.php b/app/Http/Controllers/Customer/CustomerController.php index 4f8b3bd..ca5a425 100644 --- a/app/Http/Controllers/Customer/CustomerController.php +++ b/app/Http/Controllers/Customer/CustomerController.php @@ -66,9 +66,14 @@ class CustomerController extends Controller $userGoldGrams = self::weightToGrams((float) $user->gold); $wallet->treasure = round(self::gramsToTradeUnit($treasureGrams), 3); - $wallet->treasure_sum = round(self::gramsToTradeUnit($userGoldGrams + $treasureGrams), 3); + // وقتی main_wallet_products فعال است، customers.gold (legacy) همان طلای کیف اصلی است + // و نباید دوباره به treasure_sum اضافه شود — وگرنه gold_sum بعد از رفرش ~۱ گرم بیشتر نشان می‌دهد. + if ($mainWalletProductIds !== []) { + $wallet->treasure_sum = round(self::gramsToTradeUnit($treasureGrams), 3); + } else { + $wallet->treasure_sum = round(self::gramsToTradeUnit($userGoldGrams + $treasureGrams), 3); + } $wallet->gold_ab = round(self::gramsToTradeUnit($goldAbGrams), 2); - $wallet->gold_sum = round($wallet->treasure_sum + $wallet->gold_ab, 2); $user->wallets = Wallet::with(['product'])->where('owner', $user->id)->get() ?? new Wallet(); @@ -128,7 +133,8 @@ class CustomerController extends Controller $wallet->cash_from_copper = $count_cash_from_copper; $wallet->count_cash_total = $count_cash_total; - + // جمع واقعی طلا از کیف‌ها — هم‌تراز wallet/me و کارت محصول (بدون دوباره‌شماری customers.gold) + $wallet->gold_sum = round((float) $wallet->count_gold, 2); $user->wallet = $wallet; $user->pwallet = Wallet::with("product")->where('owner', $user->id)