erp/app/api/lists/order/RetailOrderList.php
2024-04-30 16:12:18 +08:00

68 lines
1.7 KiB
PHP

<?php
namespace app\api\lists\order;
use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\goods\Goods;
use app\common\model\retail\Cashierclass;
use app\common\model\retail\Cashierinfo;
/**
* 零售订单列表
* Class RetailOrderList
* @package app\api\order
*/
class RetailOrderList extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
*/
public function setSearch(): array
{
return [
'=' => ['number', 'paid',],
'between_time' => 'create_time',
];
}
/**
* @notes 零售订单列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @date 2024/04/27 11:26
*/
public function lists($where=[]): array
{
$userId=$this->request->userId;
if(!$userId) return [];
return Cashierclass::where($this->searchWhere)->where('uid',$userId)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->each(function($item){
$item['goods_list']=Cashierinfo::where('pid',$item['id'])->with('goodsName')->field('goods,nums,price sell')->limit(3)->select();
})
->toArray();
}
/**
* @notes 零售订单数量
* @return int
* @date 2024/04/27 11:26
*/
public function count(): int
{
return Cashierclass::where($this->searchWhere)->count();
}
}