refactor(admin): 优化供应商列表查询
- 移除了对每个供应商的循环查询,减少数据库访问次数 - 删除了计算完成金额和未完成金额的逻辑,改在需要时单独计算
This commit is contained in:
parent
cda9d2404e
commit
ce19974294
@ -47,10 +47,7 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
->field(['id', 'category_id', 'name', 'phone', 'settle_cycle', 'address', 'mark'])
|
->field(['id', 'category_id', 'name', 'phone', 'settle_cycle', 'address', 'mark'])
|
||||||
->limit($this->limitOffset, 100)
|
->limit($this->limitOffset, 100)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) {
|
->select()
|
||||||
$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');
|
|
||||||
})
|
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user