Ver Fonte

客服消息测试

liuzejian há 1 ano atrás
pai
commit
99192c0bb6

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

@@ -91,7 +91,7 @@ class KFMessageController extends CatchController
                 'name' => $request->input('name'),
                 'message_type' => $request->input('message_type'),
                 'message_content' => \json_encode($request->input('message_content'), JSON_UNESCAPED_UNICODE),
-                'u_type' => $request->input('u_type'),
+                'u_type' => $request->input('u_type', 1),
                 'uc_unique_key' => $request->input('uc_unique_key', ''),
                 'send_at' => $request->input('send_at'),
                 'status' => WechatPlatformConstService::KF_MESSAGE_STATUS_PRE_SEND,
@@ -110,6 +110,8 @@ class KFMessageController extends CatchController
     public function updateContent(Request $request) {
         $this->validate($request, [
             'id' => 'required',
+            'name' => 'required', 'message_type' => 'required|in:1', 'message_content' => 'required|array',
+            'u_type' => 'required|in:1,2', 'uc_unique_key' => 'required_if:u_type,2', 'send_at' => 'required|date_format:Y-m-d H:i:s',
         ]);
         $now = date('Y-m-d H:i:s');
         DB::table('wechat_kf_messages')
@@ -122,7 +124,7 @@ class KFMessageController extends CatchController
                 'name' => $request->input('name'),
                 'message_type' => $request->input('message_type'),
                 'message_content' =>  \json_encode($request->input('message_content'), JSON_UNESCAPED_UNICODE),
-                'u_type' => $request->input('u_type'),
+                'u_type' => $request->input('u_type', '1'),
                 'uc_unique_key' => $request->input('uc_unique_key', ''),
                 'send_at' => $request->input('send_at'),
                 'updated_at' => $now,

+ 21 - 1
tests/WechatPlatform/Http/KFMessageControllerTest.php

@@ -43,7 +43,27 @@ AAA;
     {
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
-        ])->json('get','http://localhost/api/wechatPlatform/kfMessage/list', [
+        ])->json('post','http://localhost/api/wechatPlatform/kfMessage/updateContent', [
+            'id' => 4,
+            'name' => 'change-'.uniqid(),
+            'message_type' => 1,
+            'message_content' => [
+                ['text' => 'changexxxx']
+            ],
+            'u_type' => 2,
+            'uc_unique_key' => uniqid('',true),
+            'send_at' => date('Y-m-d H:i:s', strtotime('+2 hour'))
+        ]);
+        $this->dumpJson($res);
+    }
+
+    public function testupdateGZH()
+    {
+        $res = $this->withHeaders([
+            'Authorization' => 'Bearer '. $this->token,
+        ])->json('post','http://localhost/api/wechatPlatform/kfMessage/updateGZH', [
+            'id' => 4,
+            'gzh_ids' => [1,2]
         ]);
         $this->dumpJson($res);
     }