|
@@ -1,14 +1,12 @@
|
|
<?php
|
|
<?php
|
|
|
|
|
|
-namespace storage;
|
|
|
|
|
|
+namespace App\Http\Controllers;
|
|
|
|
|
|
-use App\Http\Controllers\Controller;
|
|
|
|
use App\Repositories\Enums\ResponseCodeEnum;
|
|
use App\Repositories\Enums\ResponseCodeEnum;
|
|
use App\Repositories\Models\Wechat\Account;
|
|
use App\Repositories\Models\Wechat\Account;
|
|
use App\Support\Traits\WeChat;
|
|
use App\Support\Traits\WeChat;
|
|
use EasyWeChat\Factory;
|
|
use EasyWeChat\Factory;
|
|
use EasyWeChat\Kernel\Messages\Image;
|
|
use EasyWeChat\Kernel\Messages\Image;
|
|
-use Illuminate\Filesystem\Cache;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
|
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
|
|
|
|
|
@@ -17,7 +15,7 @@ use Symfony\Component\Cache\Adapter\RedisAdapter;
|
|
*/
|
|
*/
|
|
class WatchController extends Controller
|
|
class WatchController extends Controller
|
|
{
|
|
{
|
|
-// use WeChat;
|
|
|
|
|
|
+ use WeChat;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 处理微信消息
|
|
* 处理微信消息
|
|
@@ -42,8 +40,9 @@ class WatchController extends Controller
|
|
// $cache = new RedisAdapter($client);
|
|
// $cache = new RedisAdapter($client);
|
|
// $app->rebind('cache', $cache);
|
|
// $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) {
|
|
$app->server->push(function ($message) use ($app, $account) {
|
|
log_record('消息', compact('message'));
|
|
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);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 处理微信消息【自动】
|
|
* 处理微信消息【自动】
|