DiverseYouthNightSchool/application/api/controller/school/worker/HourOrder.php

130 lines
4.0 KiB
PHP
Raw Normal View History

<?php
namespace app\api\controller\school\worker;
use app\common\model\school\classes\hourorder\Order as OrderModel;
/**
* 员工端:课时订单管理接口
*/
class HourOrder extends Base
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $model = null;
/**
* 初始化操作
* @access protected
*/
protected function _initialize()
{
$this->model = new OrderModel;
parent::_initialize();
//判断登录用户是否是员工
}
/**
* @ApiTitle( 课时订单详情)
* @ApiSummary(课时订单详情)
* @ApiRoute(/api/school/worker/hour_order/detail)
* @ApiMethod(GET)
* @ApiParams(name = "id", type = "int",required=true,description = "订单id或订单号")
* @ApiReturn({
*
*})
*/
public function detail(){
$id = $this->request->get('id/d','');
if(empty($id)){
$this->error(__('缺少必要参数'));
}
try {
$res = OrderModel::getDetail($id,$this->classes_lib_ids);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', ['detail' => $res]);
}
/**
* @ApiTitle( 我的课时订单列表接口)
* @ApiSummary(我的课时订单列表接口)
* @ApiRoute(/api/school/worker/hour_order/order_list)
* @ApiMethod(GET)
* @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
* @ApiParams(name = "page", type = "string",required=true,description = "页数")
* @ApiParams(name = "limit", type = "string",required=true,description = "条数")
* @ApiParams(name = "status", type = "string",required=false,description = "订单状态:-3=已取消,-1=已报名待审核,0=已预约,3=已完成")
* @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id")
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function order_list()
{
$page = $this->request->get('page/d', 0); //页数
$limit = $this->request->get('limit/d', 0); //条数
$keywords = $this->request->get('keywords/s', ''); //搜索关键字
$status = $this->request->get('status/s', ''); //搜索关键字
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
try{
//当前申请状态
$res = $this->model::workList($page, $limit,$keywords,$status,$classes_order_id,0,$this->classes_lib_ids,$classes_lib_ids);
// if($user_id =='670153'){
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
// }
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
/**
* @ApiTitle( 课时订单数量接口)
* @ApiSummary(课时订单各个数量)
* @ApiRoute(/api/school/worker/hour_order/order_count)
* @ApiMethod(GET)
* @ApiParams(name = "classes_order_id", type = "int",required=true,description = "课程订单id")
* @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
* @ApiReturn({
*
*})
*/
public function order_count(){
$classes_order_id = $this->request->get('classes_order_id/d', 0); //搜索关键字
$classes_lib_ids = $this->request->get('classes_lib_id/s', 0); //搜索关键字
try{
$res = $this->model::workCount($this->classes_lib_ids,$classes_lib_ids,$classes_order_id);
}catch (\Throwable $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
}