<?php

namespace App\Http\Controllers\Fpdx;

use App\Models\Fpdx\MessageModel;
use App\Models\User\Openid;

/**
 * 小象导处理类
 * Class LittleGuide
 * @package App\Http\Controllers\Fpdx
 */
class LittleGuide
{

    /**
     * 小象导接收消息处理
     * @param  int  $message_id
     * @throws \ApiException
     */
    public function message(int $message_id)
    {
        $message = MessageModel::find($message_id);
        $content = \Turing::send($message->msg_content);
        $content = str_replace($content, '小象导', '菲菲');
        $add = array(
            'send_uid' => 'xxd',
            'receive_uid' => $message->send_uid,
            'msg_content' => (string)$message->Content,
            'msg_type' => -1,
            'create_time' => time()
        );
        \DB::table('fpdx_pair_room_messages')->insertGetId($add);
        $openid = Openid::ofPublic($message->send_uid)->value('openid');
        Message::systemResponse($openid, $content);
    }
}
