2025-03-03 11:38:13 +08:00
|
|
|
<?php
|
|
|
|
|
2025-03-10 11:31:34 +08:00
|
|
|
namespace app\psi\lists;
|
2025-03-03 11:38:13 +08:00
|
|
|
|
2025-03-12 10:24:13 +08:00
|
|
|
use app\common\enum\OrderEnum;
|
2025-03-03 11:38:13 +08:00
|
|
|
use app\common\lists\BaseDataLists;
|
2025-03-12 10:24:13 +08:00
|
|
|
use app\common\model\auth\Admin;
|
2025-03-10 11:31:34 +08:00
|
|
|
use app\common\model\OutboundOrder;
|
2025-03-03 11:38:13 +08:00
|
|
|
use app\common\lists\ListsSearchInterface;
|
2025-03-12 10:24:13 +08:00
|
|
|
use app\common\model\psi\warehouse\Warehouse;
|
|
|
|
use app\common\model\supplier\Supplier;
|
|
|
|
use app\common\model\system_store\SystemStore;
|
2025-03-03 11:38:13 +08:00
|
|
|
|
|
|
|
/**
|
2025-03-10 11:31:34 +08:00
|
|
|
* PsiOutboundOrder列表
|
|
|
|
* Class OutboundOrderLists
|
|
|
|
* @package app\psi\lists
|
2025-03-03 11:38:13 +08:00
|
|
|
*/
|
2025-03-10 11:31:34 +08:00
|
|
|
class OutboundOrderLists extends BaseDataLists implements ListsSearchInterface
|
2025-03-03 11:38:13 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @notes 设置搜索条件
|
|
|
|
* @return \string[][]
|
|
|
|
* @author admin
|
2025-03-10 11:31:34 +08:00
|
|
|
* @date 2025/03/10 11:08
|
2025-03-03 11:38:13 +08:00
|
|
|
*/
|
|
|
|
public function setSearch(): array
|
|
|
|
{
|
|
|
|
return [
|
2025-03-12 10:24:13 +08:00
|
|
|
'=' => ['supplier_id', 'warehouse_id', 'store_id'],
|
|
|
|
'%like' => ['code'],
|
|
|
|
'between_time' => 'create_time'
|
2025-03-03 11:38:13 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @notes 获取列表
|
|
|
|
* @return array
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
* @throws \think\db\exception\DbException
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
* @author admin
|
2025-03-10 11:31:34 +08:00
|
|
|
* @date 2025/03/10 11:08
|
2025-03-03 11:38:13 +08:00
|
|
|
*/
|
|
|
|
public function lists(): array
|
|
|
|
{
|
2025-03-10 11:31:34 +08:00
|
|
|
return OutboundOrder::where($this->searchWhere)
|
2025-03-12 10:24:13 +08:00
|
|
|
->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'type', 'oid', 'admin_id', 'batch', 'order_type', 'code', 'mark', 'nums', 'purchase', 'total_price', 'completed_amount', 'outstanding_amount', 'create_time'])
|
2025-03-03 11:38:13 +08:00
|
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
|
|
->order(['id' => 'desc'])
|
2025-03-12 10:24:13 +08:00
|
|
|
->select()->each(function ($item) {
|
|
|
|
if ($item->store_id) {
|
|
|
|
$item->system_store = SystemStore::where('id', $item->store_id)->value('name');
|
|
|
|
} else {
|
|
|
|
$item->system_store = '';
|
|
|
|
}
|
|
|
|
if ($item->admin_id) {
|
|
|
|
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
|
|
|
|
} else {
|
|
|
|
$item->admin_name = '';
|
|
|
|
}
|
|
|
|
if ($item->warehouse_id) {
|
|
|
|
$item->warehouse_name = Warehouse::where('id', $item->warehouse_id)->value('name');
|
|
|
|
} else {
|
|
|
|
$item->warehouse_name = '';
|
|
|
|
}
|
|
|
|
if ($item->supplier_id) {
|
|
|
|
$item->supplier_name = Supplier::where('id', $item->supplier_id)->value('name');
|
|
|
|
}else{
|
|
|
|
$item->supplier_name = '';
|
|
|
|
}
|
|
|
|
if (!empty($item['order_type'])) {
|
|
|
|
$item->order_type_name = OrderEnum::getOrderTypeName($item->order_type);
|
|
|
|
} else {
|
|
|
|
$item->order_type_name = '';
|
|
|
|
}
|
|
|
|
})
|
2025-03-03 11:38:13 +08:00
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @notes 获取数量
|
|
|
|
* @return int
|
|
|
|
* @author admin
|
2025-03-10 11:31:34 +08:00
|
|
|
* @date 2025/03/10 11:08
|
2025-03-03 11:38:13 +08:00
|
|
|
*/
|
|
|
|
public function count(): int
|
|
|
|
{
|
2025-03-10 11:31:34 +08:00
|
|
|
return OutboundOrder::where($this->searchWhere)->count();
|
2025-03-03 11:38:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|