初始版本
This commit is contained in:
94
server/app/coachapi/lists/OrderLists.php
Executable file
94
server/app/coachapi/lists/OrderLists.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?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 OrderLists extends BaseCoachApiDataLists
|
||||
{
|
||||
public function setWhere()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['coach_id','=',$this->coachId];
|
||||
$where[] = ['pay_status','=',PayEnum::ISPAID];
|
||||
// if (isset($this->params['date_type']) && '' != $this->params['date_type']){
|
||||
// $todayDate = date('Y-m-d',time());
|
||||
// //今天的时间戳
|
||||
// $todayStart = strtotime($todayDate);
|
||||
// $todayEnd = strtotime($todayDate . ' 23:59:59');
|
||||
// switch ($this->params['date_type']){
|
||||
// case 1:
|
||||
// $where[] = ['appoint_time','>=',$todayStart];
|
||||
// $where[] = ['appoint_time','<=',$todayEnd];
|
||||
// break;
|
||||
// case 2:
|
||||
// //明天的时间戳
|
||||
// $tomorrowStart = strtotime('+1 day',$todayStart);
|
||||
// $tomorrowEnd = strtotime('+1 day',$todayEnd);
|
||||
// $where[] = ['appoint_time','>=',$tomorrowStart];
|
||||
// $where[] = ['appoint_time','<=',$tomorrowEnd];
|
||||
// break;
|
||||
// case 3:
|
||||
// //后天的时间戳
|
||||
// $dayAfterTomorrowStart = strtotime('+2 day',$todayStart);
|
||||
// $dayAfterTomorrowEnd = strtotime('+2 day',$todayEnd);
|
||||
// $where[] = ['appoint_time','>=',$dayAfterTomorrowStart];
|
||||
// $where[] = ['appoint_time','<=',$dayAfterTomorrowEnd];
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
if (isset($this->params['order_status']) && $this->params['order_status'] != '') {
|
||||
switch ($this->params['order_status']) {
|
||||
case 1:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_WAIT_RECEIVING];
|
||||
break;
|
||||
case 2:
|
||||
$where[] = ['order_status','in',[OrderEnum::ORDER_STATUS_WAIT_DEPART,OrderEnum::ORDER_STATUS_DEPART,OrderEnum::ORDER_STATUS_START_SERVER,OrderEnum::ORDER_STATUS_ARRIVE]];
|
||||
break;
|
||||
case 3:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_SERVER_FINISH];
|
||||
break;
|
||||
case 4:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_CLOSE];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Order::field('id,sn,order_status,total_order_amount,user_remark,pay_status,appoint_time,order_amount,user_remark,address_snap,server_finish_time,create_time,coach_id,order_distance')
|
||||
->order('id','desc')
|
||||
->append(['order_distance_desc','appoint_time','appoint_date','order_status_desc','take_order_btn','depart_btn','arrive_btn','server_start_btn','server_finish_btn','order_cancel_time'])
|
||||
->with(['order_goods' => function($query){
|
||||
$query->field('order_id,goods_snap,duration,goods_num,goods_image,goods_name,goods_price')->hidden(['goods_snap']);
|
||||
}])
|
||||
->where($this->setWhere())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($lists as $key => $order){
|
||||
if(!isset($order['address_snap']['house_number'])){
|
||||
$lists[$key]['address_snap']['house_number'] = '';
|
||||
}
|
||||
}
|
||||
return $lists;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
|
||||
return Order::where($this->setWhere())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->count();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user