wallet handling
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user