fix bug 2
This commit is contained in:
@@ -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