mead 4 달 전
부모
커밋
04f6789208
1개의 변경된 파일5개의 추가작업 그리고 62개의 파일을 삭제
  1. 5 62
      app/Http/Controllers/WatchController.php

+ 5 - 62
storage/WatchController.php → app/Http/Controllers/WatchController.php

@@ -1,14 +1,12 @@
 <?php
 
-namespace storage;
+namespace App\Http\Controllers;
 
-use App\Http\Controllers\Controller;
 use App\Repositories\Enums\ResponseCodeEnum;
 use App\Repositories\Models\Wechat\Account;
 use App\Support\Traits\WeChat;
 use EasyWeChat\Factory;
 use EasyWeChat\Kernel\Messages\Image;
-use Illuminate\Filesystem\Cache;
 use Illuminate\Http\Request;
 use Symfony\Component\Cache\Adapter\RedisAdapter;
 
@@ -17,7 +15,7 @@ use Symfony\Component\Cache\Adapter\RedisAdapter;
  */
 class WatchController extends Controller
 {
-//    use WeChat;
+    use WeChat;
 
     /**
      * 处理微信消息
@@ -42,8 +40,9 @@ class WatchController extends Controller
 //        $cache = new RedisAdapter($client);
 //        $app->rebind('cache', $cache);
 
-//        $cache = new RedisAdapter(app('redis')->connection()->client());
-//        $app->rebind('cache', $cache);
+        $cache = new RedisAdapter(app('redis')->connection()->client());
+        $app->rebind('cache', $cache);
+
 
         $app->server->push(function ($message) use ($app, $account) {
             log_record('消息', compact('message'));
@@ -172,62 +171,6 @@ class WatchController extends Controller
     }
 
 
-    /**
-     * 编辑标签
-     * @param $account_name
-     * @param $tag_name
-     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
-     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     */
-    public static function userAddTag($account_name, $open_id, $tag)
-    {
-        $app = self::getApp($account_name);
-
-
-        $re = $app->user_tag->tagUsers([$open_id], $tag);
-        return $re;
-    }
-
-    /**
-     * 移除标签
-     * @param $account_name
-     * @param $open_id
-     * @param $tag
-     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
-     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     */
-    public static function userDelTag($account_name, $open_id, $tag)
-    {
-        $app = self::getApp($account_name);
-
-
-        $re = $app->user_tag->untagUsers([$open_id], $tag);
-        return $re;
-    }
-
-    /**
-     * @param $account_name
-     * @return \EasyWeChat\OfficialAccount\Application
-     */
-    public static function getApp($account_name){
-        $account = self::getAccount($account_name);
-        $app = Factory::officialAccount($account['settings']);
-//        $cache = new RedisAdapter(app('redis')->connection()->client());
-//        $app->rebind('cache', $cache);
-        return $app;
-    }
-
-    public static function getAccount($val)
-    {
-        if (is_numeric($val)) {
-            return Account::byIdGetModel($val);
-        }
-        return Account::byNameGetModel($val);
-    }
-
-
 
     /**
      * 处理微信消息【自动】