70 lines
2.4 KiB
PHP
Executable File
70 lines
2.4 KiB
PHP
Executable File
<?php
|
|
namespace app\shopapi\lists;
|
|
use app\coachapi\lists\BaseCoachApiDataLists;
|
|
use app\common\enum\OrderEnum;
|
|
use app\common\enum\PayEnum;
|
|
use app\common\model\coach\Coach;
|
|
use app\common\model\order\Order;
|
|
|
|
/**
|
|
* 订单列表
|
|
* Class OrderLists
|
|
* @package app\coachapi\lists
|
|
*/
|
|
class OrderLists extends BaseShopApiDataLists
|
|
{
|
|
public function setWhere()
|
|
{
|
|
$where = [];
|
|
$where[] = ['shop_id','=',$this->shopId];
|
|
$where[] = ['pay_status','=',PayEnum::ISPAID];
|
|
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','order_cancel_time'])
|
|
->with(['order_goods' => function($query){
|
|
$query->field('order_id,goods_snap,goods_num,duration,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();
|
|
|
|
}
|
|
} |