فهرست منبع

客服消息配置公众号,可删除

liuzejian 1 سال پیش
والد
کامیت
1f264b122d

+ 4 - 3
modules/WechatPlatform/Http/Controllers/KFMessageController.php

@@ -91,7 +91,9 @@ class KFMessageController extends CatchController
         }
         $gzh_names = collect();
         foreach (explode('#', trim($gzh_ids, '#')) as $gzh_id) {
-            $gzh_names->push($gzhs->get($gzh_id)->nick_name ?? 'ID:'. $gzh_id);
+            if($gzh_id) {
+                $gzh_names->push($gzhs->get($gzh_id)->nick_name ?? 'ID:'. $gzh_id);
+            }
         }
 
         return $gzh_names->unique()->join(', ');
@@ -161,7 +163,6 @@ class KFMessageController extends CatchController
     public function updateGZH(Request $request){
         $this->validate($request, [
             'id' => 'required',
-            'gzh_ids' => 'required|array'
         ]);
 
         $message  = WechatKfMessageModel::where([
@@ -172,7 +173,7 @@ class KFMessageController extends CatchController
         ])->first();
         if($message) {
             $allGzhIds = $request->input('gzh_ids');
-            if(2 == $message->u_type) {
+            if(2 == $message->u_type && collect($allGzhIds)->isNotEmpty()) {
                 $configGzhIds = DB::table('gzh_ug_maps')
                     ->where([
                         ['is_enabled', '=', 1],

+ 3 - 3
tests/WechatPlatform/Http/KFMessageControllerTest.php

@@ -35,7 +35,7 @@ AAA;
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
         ])->json('get','http://localhost/api/wechatPlatform/kfMessage/list', [
-            'id' => 8
+            'id' => 4
         ]);
         $this->dumpJson($res);
     }
@@ -63,8 +63,8 @@ AAA;
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
         ])->json('post','http://localhost/api/wechatPlatform/kfMessage/updateGZH', [
-            'id' => 2,
-            'gzh_ids' => [1,2,3]
+            'id' => 4,
+            'gzh_ids' => []
         ]);
         $this->dumpJson($res);
     }