refactor(admin): 优化供应商列表查询

- 移除了对每个供应商的循环查询,减少数据库访问次数
- 删除了计算完成金额和未完成金额的逻辑,改在需要时单独计算
This commit is contained in:
mkm 2025-03-01 17:12:27 +08:00
parent cda9d2404e
commit ce19974294

View File

@ -47,10 +47,7 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
->field(['id', 'category_id', 'name', 'phone', 'settle_cycle', 'address', 'mark'])
->limit($this->limitOffset, 100)
->order(['id' => 'desc'])
->select()->each(function ($item) {
$item->total_completed_amount=WarehouseProduct::where('supplier_id',$item['id'])->where('financial_pm',1)->where('is_pay',1)->sum('total_price');
$item->total_outstanding_amount=WarehouseProduct::where('supplier_id',$item['id'])->where('financial_pm',1)->where('is_pay',0)->sum('total_price');
})
->select()
->toArray();
}