69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace app\admin\lists\supplier;
|
|
|
|
|
|
use app\admin\lists\BaseAdminDataLists;
|
|
use app\common\model\supplier\Supplier;
|
|
use app\common\lists\ListsSearchInterface;
|
|
use app\common\model\warehouse_product\WarehouseProduct;
|
|
|
|
/**
|
|
* 供应链列表
|
|
* Class SupplierLists
|
|
* @package app\admin\listssupplier
|
|
*/
|
|
class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 设置搜索条件
|
|
* @return \string[][]
|
|
* @author admin
|
|
* @date 2024/08/15 14:10
|
|
*/
|
|
public function setSearch(): array
|
|
{
|
|
return [
|
|
'=' => ['phone'],
|
|
'%like%'=>['mer_name']
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取供应链列表
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
* @author admin
|
|
* @date 2024/08/15 14:10
|
|
*/
|
|
public function lists(): array
|
|
{
|
|
return Supplier::where($this->searchWhere)
|
|
->field(['id', 'category_id', 'mer_name', 'phone', 'settle_cycle', 'address', 'mark'])
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->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');
|
|
})
|
|
->toArray();
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取供应链数量
|
|
* @return int
|
|
* @author admin
|
|
* @date 2024/08/15 14:10
|
|
*/
|
|
public function count(): int
|
|
{
|
|
return Supplier::where($this->searchWhere)->count();
|
|
}
|
|
|
|
} |