270 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			270 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						||
 | 
						||
namespace app\api\controller\school;
 | 
						||
 | 
						||
use app\common\model\school\classes\order\ServiceOrder as OrderModel;
 | 
						||
use app\common\model\school\classes\order\ServiceOrderLog;
 | 
						||
 | 
						||
/**
 | 
						||
 * 用户端:课程订单售后接口
 | 
						||
 */
 | 
						||
class ServiceOrder extends Base
 | 
						||
{
 | 
						||
    protected $noNeedLogin = [];
 | 
						||
    protected $noNeedRight = '*';
 | 
						||
 | 
						||
    protected $model = null;
 | 
						||
 | 
						||
    /**
 | 
						||
     * 初始化操作
 | 
						||
     * @access protected
 | 
						||
     */
 | 
						||
    protected function _initialize()
 | 
						||
    {
 | 
						||
 | 
						||
        $this->model = new OrderModel;
 | 
						||
        parent::_initialize();
 | 
						||
 | 
						||
        //判断登录用户是否是员工
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @ApiTitle( 售后订单详情)
 | 
						||
     * @ApiSummary(售后订单详情)
 | 
						||
     * @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);
 | 
						||
        } catch (\Exception $e){
 | 
						||
//            Log::log($e->getMessage());
 | 
						||
            $this->error($e->getMessage(),['errcode'=>$e->getCode()]);
 | 
						||
        }
 | 
						||
        $this->success('获取成功', ['detail' => $res]);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @ApiTitle( 订单申请售后接口 )
 | 
						||
     * @ApiSummary(订单申请售后)
 | 
						||
     * @ApiMethod(POST)
 | 
						||
     * @ApiParams(name = "classes_order_id", type = "int",required=true,description = "需要售后的课程订单id")
 | 
						||
     * @ApiParams(name = "reason", type = "string",required=true,description = "申请理由")
 | 
						||
     * @ApiReturn({
 | 
						||
     *
 | 
						||
     *})
 | 
						||
     */
 | 
						||
    public function create(){
 | 
						||
        $user_id = 0;
 | 
						||
        $user = $this->auth->getUser();//登录用户
 | 
						||
        if($user)$user_id = $user['id'];
 | 
						||
        $classes_order =  $this->request->post('classes_order_id/d', 0); //课程id
 | 
						||
        $reason  =  $this->request->post('reason/s', ''); //订单号
 | 
						||
       try{
 | 
						||
            //当前申请状态
 | 
						||
            $res = $this->model->afterSales($classes_order,$reason,'','user',$user_id,true);
 | 
						||
        }catch (\Exception $e){
 | 
						||
//            Log::log($e->getMessage());
 | 
						||
           $this->error($e->getMessage(),['errcode'=>$e->getCode()]);
 | 
						||
        }
 | 
						||
        $this->success('申请售后成功', $res);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @ApiTitle( 售后申请取消接口)
 | 
						||
     * @ApiSummary(售后申请取消(处理中的无法再取消))
 | 
						||
     * @ApiMethod(POST)
 | 
						||
     * @ApiParams(name = "order_no", type = "string",required=true,description = "售后订单id或售后订号")
 | 
						||
     * @ApiReturn({
 | 
						||
     *
 | 
						||
     *})
 | 
						||
     */
 | 
						||
    public function cancel(){
 | 
						||
        $user_id = 0;
 | 
						||
        $user = $this->auth->getUser();//登录用户
 | 
						||
        if($user)$user_id = $user['id'];
 | 
						||
        $order_no =  $this->request->post('order_no/s', ''); //订单号
 | 
						||
        try{
 | 
						||
            //当前申请状态
 | 
						||
            $res = $this->model->cancel($order_no,$user_id,true,'user',0,true);
 | 
						||
        }catch (\Throwable $e){
 | 
						||
            $this->error($e->getMessage());
 | 
						||
        }
 | 
						||
        $this->success('售后申请取消成功', $res);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @ApiTitle( 我的售后订单列表接口)
 | 
						||
     * @ApiSummary(我的售后订单列表接口)
 | 
						||
     * @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 = "状态搜索条件:售后状态:1=待处理,4=处理中,7=已结单,-3=已取消")
 | 
						||
     * @ApiParams(name = "service_stauts", type = "string",required=false,description = "售后处理状态:1=待机构处理,4=待用户确认,7=售后通过结单中,10=售后结单完成,-3=售后驳回结单")
 | 
						||
     * @ApiParams(name = "sales_type", type = "string",required=false,description = "结单类型:-3=未结单,1=机构驳回,4=用户驳回,7=平台驳回,10=成功退款")
 | 
						||
     * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
 | 
						||
     * @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id")
 | 
						||
     * @ApiParams(name = "classes_order_detail_id", type = "int",required=false,description = "订单课程id")
 | 
						||
     * @ApiReturn({
 | 
						||
     *
 | 
						||
     *})
 | 
						||
     */
 | 
						||
    public function order_list()
 | 
						||
    {
 | 
						||
        $user_id = 0;
 | 
						||
        $user = $this->auth->getUser();//登录用户
 | 
						||
        if($user)$user_id = $user['id'];
 | 
						||
        $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', ''); //搜索关键字
 | 
						||
         $service_stauts =  $this->request->get('service_stauts/s', ''); //搜索关键字
 | 
						||
         $sales_type =  $this->request->get('sales_type/s', ''); //搜索关键字
 | 
						||
         $classes_order_id =  $this->request->get('classes_order_id/s', ''); //搜索关键字
 | 
						||
         $classes_order_detail_id =  $this->request->get('classes_order_detail_id/s', ''); //搜索关键字
 | 
						||
         $classes_lib_id =  $this->request->get('classes_lib_id/s', ''); //搜索关键字
 | 
						||
//        $type =  $this->request->get('type/s', ''); //筛选学员和教练单
 | 
						||
 | 
						||
        try{
 | 
						||
            //当前申请状态
 | 
						||
            $res = $this->model::allList($user_id,$page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_order_id,$classes_order_detail_id,$classes_lib_id);
 | 
						||
//            if($user_id =='670153'){
 | 
						||
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
 | 
						||
//            }
 | 
						||
        }catch (\Exception $e){
 | 
						||
 | 
						||
            $this->error($e->getMessage());
 | 
						||
        }
 | 
						||
        $this->success('查询成功', $res);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @ApiTitle( 我的售后订单数量接口)
 | 
						||
     * @ApiSummary(返回售后订单各个数量)
 | 
						||
     * @ApiMethod(GET)
 | 
						||
     * @ApiParams(name = "classes_lib_id", type = "int",required=false,description = "课程id")
 | 
						||
     * @ApiParams(name = "classes_order_id", type = "int",required=false,description = "课程订单id")
 | 
						||
     * @ApiReturn({
 | 
						||
     *
 | 
						||
     *})
 | 
						||
     */
 | 
						||
    public function order_count(){
 | 
						||
        $user_id = 0;
 | 
						||
        $user = $this->auth->getUser();//登录用户
 | 
						||
        if($user)$user_id = $user['id'];
 | 
						||
 | 
						||
        $classes_lib_id =  $this->request->get('classes_lib_id/s', ''); //搜索关键字
 | 
						||
        $classes_order_id =  $this->request->get('classes_order_id/s', '');
 | 
						||
        try{
 | 
						||
            $res = $this->model::orderCount($user_id,$classes_order_id,$classes_lib_id);
 | 
						||
        }catch (\Throwable $e){
 | 
						||
            $this->error($e->getMessage());
 | 
						||
        }
 | 
						||
        $this->success('查询成功', $res);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    /**
 | 
						||
     * @ApiTitle( 我的售后订单记录列表接口)
 | 
						||
     * @ApiSummary(我的售后订单记录列表接口)
 | 
						||
     * @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 = "状态搜索条件:售后状态:1=待处理,4=处理中,7=已结单,-3=已取消")
 | 
						||
     * @ApiParams(name = "service_stauts", type = "string",required=false,description = "售后处理状态:1=待机构处理,4=待用户确认,7=售后通过结单中,10=售后结单完成,-3=售后驳回结单")
 | 
						||
     * @ApiParams(name = "sales_type", type = "string",required=false,description = "结单类型:-3=未结单,1=机构驳回,4=用户驳回,7=平台驳回,10=成功退款")
 | 
						||
     * @ApiParams(name = "classes_service_order_id", type = "int",required=false,description = "售后订单id")
 | 
						||
     * @ApiReturn({
 | 
						||
     *
 | 
						||
     *})
 | 
						||
     */
 | 
						||
    public function order_log_list()
 | 
						||
    {
 | 
						||
        $user_id = 0;
 | 
						||
        $user = $this->auth->getUser();//登录用户
 | 
						||
        if($user)$user_id = $user['id'];
 | 
						||
        $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', ''); //搜索关键字
 | 
						||
         $service_stauts =  $this->request->get('service_stauts/s', ''); //搜索关键字
 | 
						||
         $sales_type =  $this->request->get('sales_type/s', ''); //搜索关键字
 | 
						||
         $classes_service_order_id =  $this->request->get('classes_service_order_id/s', ''); //搜索关键字
 | 
						||
//        $type =  $this->request->get('type/s', ''); //筛选学员和教练单
 | 
						||
 | 
						||
        try{
 | 
						||
            //当前申请状态
 | 
						||
            $res = ServiceOrderLog::allList($user_id,$page, $limit,$keywords,$status,$service_stauts,$sales_type,$classes_service_order_id);
 | 
						||
//            if($user_id =='670153'){
 | 
						||
//               file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
 | 
						||
//            }
 | 
						||
        }catch (\Exception $e){
 | 
						||
            $this->error($e->getMessage());
 | 
						||
        }
 | 
						||
        $this->success('查询成功', $res);
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
        /**
 | 
						||
     * @ApiTitle( 用户处理售后接口)
 | 
						||
     * @ApiSummary(用户处理售后接口)
 | 
						||
     * @ApiMethod(POST)
 | 
						||
     * @ApiParams(name = "order_no", type = "string",required=true,description = "售后订单id或售后订号")
 | 
						||
     * @ApiParams(name = "status", type = "string",required=true,description = "yes=同意,no=驳回")
 | 
						||
     * @ApiParams(name = "reject_reason", type = "string",required=false,description = "驳回原因")
 | 
						||
     * @ApiParams(name = "reject_images", type = "string",required=false,description = "(非必填)驳回图片说明:多图逗号拼接")
 | 
						||
     * @ApiReturn({
 | 
						||
     *
 | 
						||
     *})
 | 
						||
     */
 | 
						||
    public function user_confirmation(){
 | 
						||
        $user_id = 0;
 | 
						||
        $user = $this->auth->getUser();//登录用户
 | 
						||
        if($user)$user_id = $user['id'];
 | 
						||
        $order_no =  $this->request->post('order_no/s', ''); //订单号
 | 
						||
        $status =  $this->request->post('status/s', 0); //审核状态
 | 
						||
        $reject_reason =  $this->request->post('reject_reason/s', '');
 | 
						||
        $reject_images =  $this->request->post('reject_images/s', '');
 | 
						||
 | 
						||
        try{
 | 
						||
           //当前申请状态
 | 
						||
           $res = $this->model->userConfirmation($order_no,$status,$reject_reason,$reject_images,$user_id,true,'user',$user_id,true);
 | 
						||
        }catch (\Throwable $e){
 | 
						||
            $this->error($e->getMessage());
 | 
						||
        }
 | 
						||
        $this->success('调用成功', $res);
 | 
						||
    }
 | 
						||
 | 
						||
}
 | 
						||
 |