<?php
namespace app\common\model;
use think\Model;
class Service extends Model
{
	public $page_info;

	/**
     * 客服管理
     */
    public function getServiceList($condition = array(), $field = '*', $page = 0, $order = 'service_id desc')
    {
        if ($page) {
            $service_list = db('service')->where($condition)->order($order)->paginate($page, false, ['query' => request()->param()]);
            $this->page_info = $service_list;
            return $service_list->items();
        } else {
            return db('service')->where($condition)->order($order)->select();
        }
    }

     /**
     * 新增客服
     */
    public function addService($data)
    {
        return db('service')->insertGetId($data);
    }

    /**
     * 编辑用户
     */
    public function editService($condition, $data)
    {
        return db('service')->where($condition)->update($data);
    }

    /**
     * 删除用户
     */
    public function delService($condition)
    {
        return db('service')->where($condition)->delete();
    }

    /**
     * 取单个用户
     */
    public function getServiceInfo($condition, $field = '*')
    {
        return db('service')->field($field)->where($condition)->find();
    }

    //公司下所有客服
    public function allkef($condition, $field = '*'){
        return db('service')->field($field)->where($condition)->select();
    }

    // /**
    //  * 更新信息
    //  *
    //  * @param array $param 更新数据
    //  * @return bool 布尔类型的返回结果
    //  */
    // public function updateService($param,$whe)
    // {
    //     if (empty($param)) {
    //         return false;
    //     }
    //     if (is_array($param)) {                
    //         $tmp = array();
    //         $tmp['service_imgurl'] = $param;
    //         $result = db('service')->where($whe, $k)->update($tmp);
    //         return true;
    //     } else {
    //         return false;
    //     }
    // }


}