$data['open_id'], 'applet_id' => $applet_id ]; $password = rand(100000,999999); $user_name = time(); $data['password'] = hema_hash($password); if(!$model = User::where($filter)->where('status','>',10)->find()){ $model = $this; $data['user_name'] = $user_name; $data['status'] = 20; $data['applet_id'] = $applet_id; }else{ if(empty($model['user_name'])){ $data['user_name'] = $user_name; }else{ $user_name = $model['user_name']; } } $model->save($data); return [ 'password' => $password, 'user_name' => $user_name ]; } /** * 找回账号 */ public function retrieve() { return $this->save(['password' => hema_hash('123456')]) !== false; } /** * 公众号取消关注 */ public function unSubscribe() { return $this->save(['is_subscribe' => 0]) !== false; } }