fix migrations 7

This commit is contained in:
2026-06-11 14:54:30 +03:30
parent 241406301e
commit d9e36dffca
@@ -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)