Browse Source

Wesmiler OTC 提交更新 0729

APPLE 3 years ago
parent
commit
bca3fe9a12

+ 4 - 1
app/Http/Controllers/Admin/ChatController.php

@@ -66,11 +66,14 @@ class ChatController extends Backend
             $list = $this->service->getNewList($params, $pageSize);
             $list = $this->service->getNewList($params, $pageSize);
         }
         }
 
 
+        $userId = $this->userInfo['user_type']==2? $this->userInfo['user_id'] : 1;
+        $counts = $this->service->getNewCount($userId);
         $message = array(
         $message = array(
             "msg" => '操作成功',
             "msg" => '操作成功',
             "code" => 0,
             "code" => 0,
             "data" => isset($list['list'])? $list['list']:[],
             "data" => isset($list['list'])? $list['list']:[],
-            "count" => isset($list['total'])? $list['total']:0,
+            "count" => isset($counts['total'])? $counts['total']:0,
+            "count1" => isset($counts['total'])? $counts['total']:0,
         );
         );
         return $message;
         return $message;
     }
     }

+ 29 - 0
app/Services/ChatMessageService.php

@@ -136,6 +136,12 @@ class ChatMessageService extends BaseService
         ];
         ];
     }
     }
 
 
+    /**
+     * 消息列表
+     * @param $params
+     * @param int $pageSize
+     * @return array
+     */
     public function getNewList($params, $pageSize = 15)
     public function getNewList($params, $pageSize = 15)
     {
     {
         $where = ['a.mark' => 1,'status'=>1];
         $where = ['a.mark' => 1,'status'=>1];
@@ -195,6 +201,28 @@ class ChatMessageService extends BaseService
     }
     }
 
 
     /**
     /**
+     * 消息数量
+     * @param $userId
+     * @return int[]
+     */
+    public function getNewCount($userId)
+    {
+        $counts = ['notice'=>0,'message'=>0];
+
+        $counts['notice'] = (int) $this->model->where(['status'=>1,'mark'=>1,'type'=>3])
+            ->where(function($query) use($userId){
+            $query->where(['from_uid'=> $userId])->orWhere(['to_uid'=> $userId]);
+        })->count('id');
+
+        $counts['message'] = (int) $this->model->where(['status'=>1,'mark'=>1,'type'=>1])
+            ->where(function($query) use($userId){
+                $query->where(['from_uid'=> $userId])->orWhere(['to_uid'=> $userId]);
+            })->count('id');
+
+        return $counts;
+    }
+
+    /**
      * 获取最新的聊天消息
      * 获取最新的聊天消息
      * @param $chatKey 聊天窗口标识
      * @param $chatKey 聊天窗口标识
      * @return array|mixed
      * @return array|mixed
@@ -253,6 +281,7 @@ class ChatMessageService extends BaseService
      */
      */
     public function pushMessage($data)
     public function pushMessage($data)
     {
     {
+
         return $this->model->edit($data);
         return $this->model->edit($data);
     }
     }
 }
 }

+ 2 - 2
app/Services/Common/TradeOrderService.php

@@ -548,7 +548,7 @@ class TradeOrderService extends BaseService
             'type' => 2,
             'type' => 2,
             'order_no' => $orderNo,
             'order_no' => $orderNo,
             'chat_key' => getChatKey($userId, $businessInfo['id']),
             'chat_key' => getChatKey($userId, $businessInfo['id']),
-            'message' => "来自用户{$username}的购买订单,金额{$total},单号{$orderNo},时间" . date('Y-m-d H:i:s'),
+            'message' => "您有来自客户买单订单:{$orderNo}的消息,请尽快回复!",
             'message_type' => 1,
             'message_type' => 1,
             'create_time' => time(),
             'create_time' => time(),
             'update_time' => time(),
             'update_time' => time(),
@@ -724,7 +724,7 @@ class TradeOrderService extends BaseService
             'type' => 2,
             'type' => 2,
             'order_no' => $orderNo,
             'order_no' => $orderNo,
             'chat_key' => getChatKey($userId, $businessInfo['id']),
             'chat_key' => getChatKey($userId, $businessInfo['id']),
-            'message' => "来自用户{$username}的出售订单,金额{$total},单号{$orderNo},时间" . date('Y-m-d H:i:s'),
+            'message' => "您有来自客户卖单订单:{$orderNo}的消息,请尽快回复!",
             'message_type' => 1,
             'message_type' => 1,
             'create_time' => time(),
             'create_time' => time(),
             'update_time' => time(),
             'update_time' => time(),