소스 검색

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

liuzejian 1 년 전
부모
커밋
1f264b122d
2개의 변경된 파일7개의 추가작업 그리고 6개의 파일을 삭제
  1. 4 3
      modules/WechatPlatform/Http/Controllers/KFMessageController.php
  2. 3 3
      tests/WechatPlatform/Http/KFMessageControllerTest.php

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

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

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

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