<?php

namespace App\Services\NoticeService\Channels;

use App\Http\Controllers\Wechat\Kfaccount;
use App\Models\User\Openid;

class KfAccountChannel extends Channel
{


    public $uuid;


    public $notice_type = "公众号客服消息";


    public function __construct($uid, $content)
    {
        $this->uid = $uid;
        $this->content = $content;
    }


    /**
     * 发送
     * @return bool
     */
    public function send()
    {
        $openid = Openid::ofPublic($this->uid)->value('openid');
        // 客服消息
        $kf_content = $this->content;
        $result = Kfaccount::text([
            'touser' => $openid,
            'content' => $kf_content,
            'kf_account' => 'notice@admin',
        ]);
        if ($result['code'] == 0) {
            return true;
        }

        return false;
    }
}
