/** * reply subscribe command * * @param $replyArr * @return Message string */ public static function subscribe($app, $openId, $replyArr) { $isDelete = UserOpenid::isDelete($app['id'], $openId); if ($isDelete) { $model = UserOpenid::where(['wechat_id' => $app['id'], 'open_id' => $openId, 'is_delete' => 1])->get()->first(); if ($model) { $model->is_delete = 0; $model->updated_at = Carbon::now(); if ($model->save()) { if (UserCache::addUser($app, $openId)) { return ReplyFormat::replyPublic($replyArr); } } } } else { $model = new UserOpenid(); $model->open_id = $openId; $model->is_delete = 0; $model->created_at = Carbon::now(); $model->updated_at = Carbon::now(); if ($model->save()) { if (UserCache::addUser($app, $openId)) { return ReplyFormat::replyPublic($replyArr); } } } return false; }