find(); if (empty($data)) { return $data; } // 是否是员工 $bindedObj = Employee::where([['uid', '=', $data['id']],['root_id', '=', $data['root_id']], ['state', '<>', '离职']])->find(); $data = $data->visible($field)->toArray(); if ($bindedObj) { $orgType = Org::where('id', $bindedObj->org_id)->value('org_type'); $binded = [ 'id' => $bindedObj->id, 'name' => $bindedObj->name, 'org_name' => $bindedObj->org->name, 'org_id' => $bindedObj->org_id, 'isManager' => $bindedObj->is_manager, 'isNewbie' => $bindedObj->is_newbie, 'state' => $bindedObj->state, 'qrcode' => $bindedObj->qrcode, 'org_type' => $orgType ]; $data['binded'] = $binded; } // 今日是否已签到 $data['sign'] = UserSignLog::where([['user_id', '=', $data['id']], ['date', '=', date('Y-m-d')]])->count(); return $data; } /** * 将小程序中获取到用户信息保存 */ public function saveMiniInfo($data) { // 保存个人信息 $miniUser = Model::where(['mini_openid'=>$data['mini_openid'], 'root_id'=>$data['root_id']])->findOrEmpty(); $miniUser->save($data); // // 检测是否存在 // if (isset($data['phone'])) { // $employee = Employee::where(['phone' => $data['phone'], 'root_id' => $data['root_id']])->find(); // if ($employee->uid !== $miniUser->id) $employee->uid = $miniUser->id; // } return $miniUser; } }