55 lines
1.7 KiB
PHP
Executable File
55 lines
1.7 KiB
PHP
Executable File
<?php
|
|
namespace app\coachapi\lists;
|
|
use app\common\enum\OrderEnum;
|
|
use app\common\enum\PayEnum;
|
|
use app\common\model\order\Order;
|
|
|
|
/**
|
|
* 订单列表
|
|
* Class OrderLists
|
|
* @package app\coachapi\lists
|
|
*/
|
|
class CoachOrderLists extends BaseCoachApiDataLists
|
|
{
|
|
public function setWhere()
|
|
{
|
|
$where = [];
|
|
$where[] = ['coach_id','=',$this->coachId];
|
|
$where[] = ['pay_status','=',PayEnum::ISPAID];
|
|
$where[] = ['order_status','in',[
|
|
OrderEnum::ORDER_STATUS_WAIT_RECEIVING,
|
|
OrderEnum::ORDER_STATUS_WAIT_DEPART,
|
|
OrderEnum::ORDER_STATUS_DEPART,
|
|
OrderEnum::ORDER_STATUS_START_SERVER,
|
|
OrderEnum::ORDER_STATUS_ARRIVE,
|
|
OrderEnum::ORDER_STATUS_SERVER_FINISH
|
|
]];
|
|
return $where;
|
|
}
|
|
|
|
public function lists(): array
|
|
{
|
|
$lists = Order::field('id,sn,order_status,user_remark,pay_status,appoint_time,order_amount,user_remark,address_snap,server_finish_time,create_time,coach_id,order_distance')
|
|
->order('appoint_time','asc')
|
|
->append(['order_distance_desc','appoint_time','appoint_date','order_status_desc','order_cancel_time'])
|
|
->with(['order_goods' => function($query){
|
|
$query->field('order_id,goods_snap,duration,goods_image,goods_name,goods_price')->hidden(['goods_snap']);
|
|
}])
|
|
->where($this->setWhere())
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->select()
|
|
->toArray();
|
|
return $lists;
|
|
|
|
|
|
}
|
|
|
|
public function count(): int
|
|
{
|
|
|
|
return Order::where($this->setWhere())
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->count();
|
|
|
|
}
|
|
} |