wallet handling

This commit is contained in:
2026-06-15 14:38:58 +03:30
parent f7b8121a98
commit c94e6b0424
2 changed files with 135 additions and 0 deletions
@@ -16,6 +16,8 @@ use Rooyesh\Wallet\interfaces\WalletInterface;
use Rooyesh\Wallet\models\Transaction;
use Rooyesh\Wallet\models\Wallet;
use App\Models\Setting;
use App\Services\ConfigService;
use App\Services\WalletBalanceService;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
class CustomerController extends SuperController
@@ -136,6 +138,19 @@ class CustomerController extends SuperController
->initSearch($this->search)
->select(['*',Customer::$SELECT_TYPE_STR])
->export($query_table);
$balanceService = app(WalletBalanceService::class);
$mainWalletProductIds = app(ConfigService::class)->mainWalletProductIds();
if (isset($query_table['rows'])) {
$query_table['rows'] = collect($query_table['rows'])->map(function ($row) use ($balanceService, $mainWalletProductIds) {
$wallets = collect($row['wallet'] ?? []);
$row['wallet_cash'] = $balanceService->mainWalletCash($wallets);
$row['wallet_gold'] = $balanceService->totalGoldWeight($wallets, $mainWalletProductIds);
return $row;
})->values();
}
return response()->json($query_table);
}