// +---------------------------------------------------------------------- // | Date: 2020-9-28 10:55:00 // +---------------------------------------------------------------------- namespace bw\gatewayworker; use app\admin\model\Admin; /** 系统 * Class Common * @package app\bwmall\model */ class System extends Base { public $identity = 'system'; public $super_admin_id = 1; /**得到平台身份通信token * @param $admin * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getToken($params=[]){ extract($params); $admin = $admin ?? $this->super_admin_id; $expire_time = $expire_time ?? null; if(is_numeric($admin))$admin = Admin::find($admin); if(!$admin) throw new \Exception("找不到用户"); if(!$expire_time)$expire_time = time(); $current_token = md5($admin['username'] . $expire_time); // 组装数据 return [ 'token' => $current_token, 'expire_time' => $expire_time, 'identify'=>'system', 'admin_id'=>$admin['id'], ]; } /** * 学员匹配通知 */ public function matchSuccess($params){ return $this->msg(['data'=>$params,'type'=>'match_success','message'=>$params['message']]); } public function msg($options=[]){ $defoalut = [ 'identify'=>$this->identity, 'admin_id'=>$this->super_admin_id, 'type'=>'', 'data'=>[], 'message'=>'', ]; return array_merge($defoalut,$options); } }