webman-admin/app/admin/lists/OrderLists.php

73 lines
1.8 KiB
PHP

<?php
namespace app\admin\lists;
use app\admin\lists\BaseAdminDataLists;
use app\common\model\Order;
use app\common\lists\ListsSearchInterface;
/**
* Order列表
* Class OrderLists
* @package app\admin\lists
*/
class OrderLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2025/07/17 17:16
*/
public function setSearch(): array
{
return [
'=' => ['order_sn', 'uid', 'project_id', 'order_type', 'status', 'paid', 'pay_time', 'customer_name', 'phone'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2025/07/17 17:16
*/
public function lists(): array
{
return Order::where($this->searchWhere)
->with(['project'])
->field(['id', 'order_sn', 'uid', 'project_id', 'order_type', 'total_amount', 'pay_amount', 'status', 'paid', 'pay_time', 'customer_name', 'phone', 'address', 'delivery_time', 'create_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->each(function ($item) {
$item['status_text'] = $item->statusText;
$item['pay_status_text'] = $item->payStatusText;
$item['order_type_text'] = $item->orderTypeText;
})
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2025/07/17 17:16
*/
public function count(): int
{
return Order::where($this->searchWhere)->count();
}
}