浏览代码

Merge branch 'liuzj-1001016-dev' into feature-wechat

liuzejian 1 年之前
父节点
当前提交
3b0cb8f596

+ 23 - 0
config/easywechat.php

@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * easywechat 5.0 公共配置
+ */
+return [
+    'response_type' => 'array',
+    'http' => [
+        'throw'  => true, // 状态码非 200、300 时是否抛出异常,默认为开启
+        'timeout' => 5.0,
+        'retry' => true, // 使用默认重试配置
+    ],
+    'log' => [
+        'default' => 'prod',
+        'channels' => [
+            'prod' => [
+                'driver' => 'daily',
+                'path' => storage_path('logs/easyWechat.log'),
+                'level' => env('EASY_WECHAT_LOG_LEVEL', 'debug'),
+            ]
+        ]
+    ]
+];

+ 1 - 1
config/logging.php

@@ -66,7 +66,7 @@ return [
 
         'daily' => [
             'driver' => 'daily',
-            'path' => storage_path('logs/'.$hostname. '/'. env('APP_NAME').'/system/laravel.log'),
+            'path' => storage_path('logs/laravel.log'),
             'level' => env('LOG_LEVEL', 'debug'),
             'days' => 14,
         ],

+ 4 - 1
modules/Channel/Http/Controllers/AdvertiserController.php

@@ -75,7 +75,10 @@ class AdvertiserController extends CatchController
         $userContext = $this->getUserContext(null);
         $res =   DB::table('users')
             ->leftJoin('user_has_miniprograms', 'users.id', 'user_has_miniprograms.uid')
-            ->leftJoin('wechat_authorization_infos as author', 'author.user_id', 'users.id')
+            ->leftJoin('wechat_authorization_infos as author', function($query){
+                    $query->on('author.user_id', '=', 'users.id')
+                        ->where('author.is_enabled', 1);
+            })
             ->where([
                 'users.deleted_at' => 0,
             ])->where('users.pid', '<>', 0)

+ 6 - 3
modules/Channel/Http/Controllers/WechatOpenPlatformController.php

@@ -4,6 +4,7 @@ namespace Modules\Channel\Http\Controllers;
 
 use Catch\Base\CatchController;
 use EasyWeChat\OpenPlatform\Application;
+use EasyWeChat\OpenPlatform\Server\Guard;
 use Illuminate\Foundation\Validation\ValidatesRequests;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Cache;
@@ -107,10 +108,12 @@ class WechatOpenPlatformController extends CatchController
 
         $server = $app->server;
 
-        $server->handleUnauthorized(function($message, \Closure $next) {
+        $server->push(function ($message) {
+            myLog('authorCommand')->info('取消授权', [
+                'message' => $message,
+            ]);
             WechatOpenPlatformService::handleUnauthorized($message);
-            return $next($message);
-        });
+        }, Guard::EVENT_UNAUTHORIZED);
 
         return $server->serve();
     }

+ 1 - 6
modules/Channel/Services/WechatOpenPlatform/WechatOpenPlatformService.php

@@ -51,13 +51,8 @@ class WechatOpenPlatformService
             'secret' => $componentInfo->secret,   // 开放平台账号的 secret
             'token' => $componentInfo->token,  // 开放平台账号的 token
             'aes_key' => $componentInfo->aes_key,   // 明文模式请勿填写 EncodingAESKey
-            'response_type' => 'array',
-            'http' => [
-                'throw'  => true, // 状态码非 200、300 时是否抛出异常,默认为开启
-                'timeout' => 5.0,
-                'retry' => true, // 使用默认重试配置
-            ],
         ];
+        $config  = array_merge($config, config('easywechat'));
         $app = Factory::openPlatform($config);
         $app->rebind('cache', Cache::store('redis'));
         return $app;