lihaiMiddleOffice/app/psi/lists/purchase_order/PurchaseOrderLists.php
mkm cda9d2404e refactor(psi): 删除进销存相关无用代码
- 移除 PsiOrder、PsiProduct、Warehouse 等模型类
- 删除 PsiOrderController、PsiProductController 控制器
- 移除 PsiOrderLists 列表类
- 清理 StoreProductLists 中的冗余代码
- 更新 Warehouse 和 WarehouseStorege 模型的表名
2025-03-01 17:11:56 +08:00

119 lines
3.2 KiB
PHP

<?php
namespace app\psi\lists\purchase_order;
use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\supplier\Supplier;
use app\common\model\system_store\SystemStore;
use app\common\lists\ListsExcelInterface;
use app\common\model\psi\purchase_order\PurchaseOrder;
use app\common\model\psi\warehouse\Warehouse;
/**
* 进销存单列表
* Class PurchaseOrderLists
* @package app\admin\listswarehouse_order
*/
class PurchaseOrderLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author admin
* @date 2024/08/20 10:50
*/
public function setSearch(): array
{
return [
'=' => ['warehouse_id', 'id'],
'%like' => ['code'],
'between_time' => 'create_time'
];
}
/**
* @notes 获取仓储商品单列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author admin
* @date 2024/08/20 10:50
*/
public function lists(): array
{
return PurchaseOrder::where($this->searchWhere)
->field(['id', 'code', 'admin_id', 'batch', 'mark', 'total_price', 'status', 'create_time', 'oid', 'order_type'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {
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 (!empty($item['order_type'])) {
$item->order_type_name = getOrderTypeName($item->order_type);
}
})
->toArray();
}
/**
* @notes 获取仓储商品单数量
* @return int
* @author admin
* @date 2024/08/20 10:50
*/
public function count(): int
{
return PurchaseOrder::where($this->searchWhere)->count();
}
/**
* @notes 导出文件名
* @return string
* @date 2022/11/24 16:17
*/
public function setFileName(): string
{
$financial_pm = $this->request->get('financial_pm');
if ($financial_pm == 0) {
return '出库单列表';
} else {
return '入库单列表';
}
}
/**
* @notes 导出字段
* @return string[]
* @date 2022/11/24 16:17
*/
public function setExcelFields(): array
{
$data = [
'create_time' => '操作时间',
'warehouse_name' => '仓库',
'code' => '单号',
'admin_name' => '填写人员',
'total_price' => '总金额',
'mark' => '备注',
];
return $data;
}
}