<?php

namespace app\admin\service\statistics;

use app\model\Appointment;
use app\model\ChatMessage;
use support\Db;

class ChatMessageService
{
    public static function getChatMessage()
    {
        // 今日咨询
        $todayStartUnix = strtotime(date('Y-m-d'));
        $chats= ChatMessage::whereBetween('chat_message_addtimes',[$todayStartUnix,time()])->get()->toArray();
        $memberIds = [];
        foreach ($chats as $chat){
            if (substr($chat['join_message_send_id'],0,2) == 'MR'){
                $memberIds[$chat['join_message_send_id']] = $chat['join_message_send_id'];
            }
        }

        $data['todayChat'] = count($memberIds);

        return $data;
    }
}