初始版本
This commit is contained in:
97
server/app/shopapi/lists/CoachOrderLists.php
Executable file
97
server/app/shopapi/lists/CoachOrderLists.php
Executable file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace app\shopapi\lists;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\shop\ShopEnum;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\order\Order;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* Class OrderLists
|
||||
* @package app\coachapi\lists
|
||||
*/
|
||||
class CoachOrderLists extends BaseShopApiDataLists implements ListsExtendInterface
|
||||
{
|
||||
public function setWhere()
|
||||
{
|
||||
$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
|
||||
]];
|
||||
$where[] = ['pay_status','=',PayEnum::ISPAID];
|
||||
$coachId = $this->params['coach_id'] ?? '';
|
||||
if($coachId){
|
||||
$where[] = ['coach_id','=',$coachId];
|
||||
$where[] = ['shop_id','=',$this->shopId];
|
||||
}else{
|
||||
$where[] = ['shop_id','=',$this->shopId];
|
||||
}
|
||||
if(isset($this->params['start_time']) && $this->params['start_time']){
|
||||
$where[] = ['create_time','>',strtotime($this->params['start_time'])];
|
||||
}
|
||||
if(isset($this->params['end_time']) && $this->params['end_time']){
|
||||
$where[] = ['create_time','<',strtotime($this->params['end_time'])];
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Order::field('id,sn,order_status,user_remark,pay_status,appoint_time,total_order_amount,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,goods_num,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();
|
||||
|
||||
}
|
||||
|
||||
public function extend()
|
||||
{
|
||||
|
||||
$where = $this->setWhere();
|
||||
unset($where[0]);
|
||||
$where = array_values($where);
|
||||
return [
|
||||
'wait_take_num' => Order::where($where)
|
||||
->where(['order_status'=>OrderEnum::ORDER_STATUS_WAIT_RECEIVING])
|
||||
->count(),
|
||||
'wait_server_num' => Order::where($where)
|
||||
->where('order_status','in',[
|
||||
OrderEnum::ORDER_STATUS_WAIT_DEPART,
|
||||
OrderEnum::ORDER_STATUS_DEPART,
|
||||
OrderEnum::ORDER_STATUS_START_SERVER,
|
||||
OrderEnum::ORDER_STATUS_ARRIVE
|
||||
])
|
||||
->count(),
|
||||
'wait_settle_num' => Order::where($where)
|
||||
->where('order_status','in',[OrderEnum::ORDER_STATUS_SERVER_FINISH,OrderEnum::ORDER_STATUS_CLOSE])
|
||||
->where(['is_settle'=>0])
|
||||
->whereRaw('total_order_amount>total_refund_amount')
|
||||
->count(),
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user