<?php
/**
 * 加盟管理Model
 * Created by PhpStorm.
 * User: 小威
 * Date: 2020/03/25
 * Time: 16:20
 */

namespace JinDouYun\Model\Manage;

use Exception;

use Mall\Framework\Core\ErrorCode;
use Mall\Framework\Core\StatusCode;
use Mall\Framework\Core\ResultWrapper;

use JinDouYun\Dao\Manage\DJoin;
use JinDouYun\Dao\Manage\DReservation;

use JinDouYun\Model\Shop\MShop;
use JinDouYun\Model\Department\MStaff;

class MJoin
{
    private $objDJoin;
    private $objDReservation;

    public function __construct()
    {
        $this->objDJoin = new DJoin('manage');
        $this->objDReservation = new DReservation('manage');

    }

    /**
     * 加盟列表
     * @return ResultWrapper
     * @throws Exception
     */
    public function getAllJoin()
    {
        $dbResult = $this->objDJoin->select();
        if($dbResult === false){
            return ResultWrapper::fail($this->objDJoin->error(), ErrorCode::$dberror);
        }
        return ResultWrapper::success($dbResult);
    }

    /**
     * 加盟添加
     * @param $params
     * @return ResultWrapper
     */
    public function addJoin($params)
    {
        $dbResult = $this->objDJoin->insert($params);
        if($dbResult === false){
            return ResultWrapper::fail($this->objDJoin->error(), ErrorCode::$dberror);
        }
        return ResultWrapper::success($dbResult);
    }

    /**
     * 预约列表
     */
    public function getAllReservation()
    {
        $dbResult = $this->objDReservation->select();
        if($dbResult === false){
            return ResultWrapper::fail($this->objDReservation->error(), ErrorCode::$dberror);
        }
        return ResultWrapper::success($dbResult);
    }

    /**
     * 预约添加
     * @param $params
     * @return ResultWrapper
     */
    public function addReservation($params)
    {
        $dbResult = $this->objDReservation->insert($params);
        if($dbResult === false){
            return ResultWrapper::fail($this->objDReservation->error(), ErrorCode::$dberror);
        }
        return ResultWrapper::success($dbResult);
    }
}
