fix bug 2
This commit is contained in:
@@ -160,7 +160,13 @@ class ProductController extends SuperController
|
||||
$products = Product::with(['file'])->where('active', 1)->get();
|
||||
|
||||
if (str_contains(request()->path(), '/customer/')) {
|
||||
app(ProductDisplayPriceService::class)->enrichForApi($products);
|
||||
$displayPriceService = app(ProductDisplayPriceService::class);
|
||||
$displayPriceService->enrichForApi($products);
|
||||
$products->each(function (Product $product) use ($displayPriceService) {
|
||||
if (!$displayPriceService->hasCustomerDisplayPrice($product)) {
|
||||
$product->setAttribute('show', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Product::hasPriceOffsetColumn() && str_contains(request()->path(), '/customer/')) {
|
||||
|
||||
@@ -132,6 +132,8 @@ class CustomerController extends Controller
|
||||
$wallet->cash_from_silver = $count_cash_from_silver;
|
||||
$wallet->cash_from_copper = $count_cash_from_copper;
|
||||
$wallet->count_cash_total = $count_cash_total;
|
||||
// cash در پاسخ = موجودی ریالی کیف اصلی (نه کیف legacy محصولات main_wallet_products)
|
||||
$wallet->cash = $count_cash_pure;
|
||||
|
||||
// جمع واقعی طلا از کیفها — همتراز wallet/me و کارت محصول (بدون دوبارهشماری customers.gold)
|
||||
$wallet->gold_sum = round((float) $wallet->count_gold, 2);
|
||||
|
||||
@@ -40,11 +40,22 @@ class WalletController extends Controller
|
||||
|
||||
public function walletMe()
|
||||
{
|
||||
$wallet = Wallet::select(['owner', 'id', 'gold', 'cash'])->where('owner', auth('customer')->id())
|
||||
$customerId = auth('customer')->id();
|
||||
$wallet = Wallet::select(['owner', 'id', 'gold', 'cash'])
|
||||
->where('owner', $customerId)
|
||||
->whereNull('product_id')
|
||||
->whereNull('fund_id')
|
||||
->first();
|
||||
// $wallet['gold_sum'] = Wallet::where('owner', auth('customer')->id())->get();
|
||||
|
||||
$wallet['gold_sum'] = round(Wallet::where('owner', auth('customer')->id())->where('product_id', null)->sum('gold'), 2);
|
||||
if (!$wallet) {
|
||||
$wallet = Wallet::select(['owner', 'id', 'gold', 'cash'])
|
||||
->where('owner', $customerId)
|
||||
->whereNull('fund_id')
|
||||
->first() ?? new Wallet();
|
||||
}
|
||||
|
||||
$wallet['gold_sum'] = round(Wallet::where('owner', $customerId)->where('product_id', null)->sum('gold'), 2);
|
||||
|
||||
return response()->json($wallet);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user