<?php
namespace app\admin\controller\life;

use app\admin\controller\BaseController;
use app\admin\model\BookCourse;
use app\admin\server\goods\GoodsServer;
use app\admin\server\life\BookCourseOrderServer;
use app\admin\server\medical\MedicalCareOrderServer;

class BookCourseOrder extends BaseController
{

    /**
     * Notes:订单列表
     * @return \support\Response
     * User: ZQ
     * Date: 2022/10/14
     */
    public function getOrderList()
    {
        [$page, $limit] = $this->getPage();
        $keywords = $this->request->get('keywords');//订单号
        $result         = BookCourseOrderServer::getOrderList($page, $limit, $keywords);
        return json_success($result, '成功');
    }

    /**
     * Notes:订单详情
     * @return \support\Response
     * User: QJF
     * Date: 2022/10/14
     */
    public function getOrderInfo()
    {
        $order_id = $this->request->get('order_id');
        $result         = BookCourseOrderServer::getOrderInfo($order_id);
        if ($result){
            return json_success($result, '获取成功');
        }else{
            throw new \Exception('获取失败！');
        }

    }

    /**
     * Notes:删除订单
     * @return \support\Response
     * User: ZQ
     * Date: 2022/10/14
     */
    public function delOrder()
    {
        $order_id = $this->request->get('order_id');
        $result         = BookCourseOrderServer::delOrder($order_id);
        if ($result){
            return json_success($result, '删除成功');
        }else{
            throw new \Exception('删除失败！');
        }

    }

    /**
     * Notes:修改订单支付状态
     * @return \support\Response
     * User: YCP
     * Date: 2022/11/28
     */
    public function updatePayStatus()
    {
        $order_id = $this->request->post('order_id');
        $order_status = $this->request->post('order_status');
        if(!$order_id){
            throw new \Exception('订单ID不能为空');
        }
        $result       = BookCourseOrderServer::updatePayStatus($order_id, $order_status);
        return json_success($result, '修改成功');
    }

}
