added merge wallet 2
This commit is contained in:
@@ -51,10 +51,13 @@ class CustomerController extends Controller
|
||||
->whereNull('fund_id')
|
||||
->first() ?? new Wallet();
|
||||
|
||||
// کیفهای قدیمیِ محصولات متصل به کیف اصلی (main_wallet_products) در محاسبات نمیآیند؛ موجودیشان همان gold کیف اصلی است
|
||||
$mainWalletProductIds = app(\App\Services\ConfigService::class)->mainWalletProductIds();
|
||||
|
||||
$treasureGrams = 0;
|
||||
$wallet->wp = Wallet::with('product')->where('owner', $user->id)->get();
|
||||
foreach ($wallet->wp as $row) {
|
||||
if ($row->product_id != null) {
|
||||
if ($row->product_id != null && !in_array((int) $row->product_id, $mainWalletProductIds, true)) {
|
||||
$treasureGrams += self::productLineWeightToGrams($row->product, $row->gold);
|
||||
}
|
||||
}
|
||||
@@ -80,6 +83,9 @@ class CustomerController extends Controller
|
||||
$count_product = 0;
|
||||
foreach ($user->wallets as $walletSingle) {
|
||||
if ($walletSingle->product_id) {
|
||||
if (in_array((int) $walletSingle->product_id, $mainWalletProductIds, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($walletSingle->product->metal_id == 1) {
|
||||
if (!($walletSingle->product->group_type == "سکه")) {
|
||||
@@ -128,6 +134,10 @@ class CustomerController extends Controller
|
||||
$user->pwallet = Wallet::with("product")->where('owner', $user->id)
|
||||
->where('owner_type', $user->type) // Ensures the wallet's owner type matches the user's type
|
||||
->whereNotNull('product_id') // Filters wallets that have a non-null product_id
|
||||
->when($mainWalletProductIds !== [], function ($q) use ($mainWalletProductIds) {
|
||||
// کیف قدیمی محصولات متصل به کیف اصلی نمایش داده نمیشود
|
||||
$q->whereNotIn('product_id', $mainWalletProductIds);
|
||||
})
|
||||
->get() ?? new Wallet(); // If no wallet is found, assigns a new Wallet instance to the attribute
|
||||
|
||||
$forbiddenWords = ['tahesab', 'token']; // کلمات ممنوعه
|
||||
|
||||
Reference in New Issue
Block a user