lvhao 9 時間 前
コミット
743b1be52f
1 ファイル変更41 行追加3 行削除
  1. 41 3
      core/CoreApp/controllers/Sdzxlist.php

+ 41 - 3
core/CoreApp/controllers/Sdzxlist.php

@@ -145,6 +145,10 @@ class Sdzxlist extends Start_Controller {
 
 
     private function _zczxttznx(){
+        echo json_encode([
+              'code'=>-1,
+              'msg'=>'执行失败'
+            ]);exit;
         if($this->input->method() == 'post'){
             $id = $this->input->post('id');
             $info = $this->sdzxlist->read($id);
@@ -153,9 +157,43 @@ class Sdzxlist extends Start_Controller {
             $list = [];
             $list['user_id'] = $params['post']['buyer_user_id'];
             $res = $this->apitt->openZnxWindow($list,$shop);
-            echo "<pre>";
-            var_dump($res);
-            die;
+            if(empty($res)){
+               echo json_encode([
+                  'code'=>-1,
+                  'msg'=>'获取会话ID失败'
+              ]);exit;
+            }
+            if(!isset($res['data']['conversation_id'])){
+              echo json_encode([
+                  'code'=>-1,
+                  'msg'=>$res['message']
+              ]);exit;
+            }
+            $conversation_id = $res['data']['conversation_id'];
+            $notice = $params['content'];
+
+            $rr = $this->apitt->sendZnxMessage($shop,$notice,$conversation_id);
+            if(empty($rr)){
+              echo json_encode([
+                  'code'=>-1,
+                  'msg'=>'发送消息失败'
+              ]);exit;  
+            }
+            if(isset($rr['data']['message_id']))
+            {
+                echo json_encode([
+                  'code'=>1,
+                  'msg'=>'发送成功'
+                ]);exit;
+            }
+            else
+            {
+                echo json_encode([
+                  'code'=>-1,
+                  'msg'=>$rr['message'] 
+                ]);exit;
+            }
+           
         }else{
             echo json_encode([
               'code'=>-1,