fix wallet ui

This commit is contained in:
2026-06-26 22:19:51 +03:30
parent 1247a5ca07
commit 14d417d9ec
3 changed files with 20 additions and 3 deletions
@@ -16,6 +16,7 @@ use Rooyesh\Wallet\interfaces\WalletInterface;
use Rooyesh\Wallet\models\Transaction;
use Rooyesh\Wallet\models\Wallet;
use App\Models\Setting;
use App\Services\AssetSummaryService;
use App\Services\BalanceReportService;
use App\Services\ConfigService;
use App\Services\WalletBalanceService;
@@ -23,6 +24,11 @@ use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
class CustomerController extends SuperController
{
/** فیلدهای محصول لازم برای محاسبهٔ صحیح وزن موجودی */
private const WALLET_PRODUCT_COLUMNS = [
'id', 'metal_id', 'unit', 'amount', 'group_type', 'trade_by_quantity', 'direct_price', 'title',
];
public function __construct()
{
$this->with = [];
@@ -134,7 +140,8 @@ class CustomerController extends SuperController
return response()->json(true);
}
public function tableWallets(Request $request){
$query_table = Customer::with(['wallet.product:id,metal_id', 'referral'])->where("is_archive",false)/*->where('type',1)*/;
$productSelect = 'product:'.implode(',', self::WALLET_PRODUCT_COLUMNS);
$query_table = Customer::with(['wallet.'.$productSelect, 'referral'])->where('is_archive', false);
TableEngine::create($query_table, $request)
->initSearch($this->search)
->select(['*',Customer::$SELECT_TYPE_STR])
@@ -163,6 +170,15 @@ class CustomerController extends SuperController
return response()->json($query_table);
}
public function assetsSummary($customerId, AssetSummaryService $assetSummaryService)
{
$customer = Customer::findOrFail($customerId);
return response()->json(
$assetSummaryService->buildForCustomer((int) $customer->id, (int) $customer->type)
);
}
public function archiveTable(Request $request)
{
$query_table = Customer::with($this->with)->where("is_archive",true)/*->where('type',1)*/;
@@ -490,7 +490,7 @@ class WalletController extends Controller
TableEngine::create($sumQuery, $request->all())
->initSearch(['customer.name']);
$sumRows = (clone $sumQuery)->with('product:id,metal_id')->get();
$sumRows = (clone $sumQuery)->with('product:id,metal_id,unit,amount,group_type,trade_by_quantity,direct_price,title')->get();
$metalBalances = $balanceService->buildWalletMetalSums($sumRows, $catalogMetalIds);
$totalGold = array_sum(array_column($metalBalances, 'gold'));
$totalGoldToCash = array_sum(array_column($metalBalances, 'goldToCash'));
@@ -504,7 +504,7 @@ class WalletController extends Controller
'metalBalances' => $metalBalances,
];
$records = Wallet::with(['customer', 'product:id,metal_id']);
$records = Wallet::with(['customer', 'product:id,metal_id,unit,amount,group_type,trade_by_quantity,direct_price,title']);
TableEngine::create($records, $request->all())
->initSearch(['customer.name'])
->select(['*'])