<?php
namespace App\Modules\OfficialAccount\Services;


use App\Modules\OfficialAccount\Models\DistributionSelfDefineContent;
use App\Modules\OfficialAccount\Models\SelfDefinedMenu;
use Redis;
use App\Modules\Channel\Services\ChannelService;
use App\Jobs\SendNews;
use App\Jobs\SendTexts;

class SelfDefineService
{
    public static function getMenu($distribution_channel_id,$filter=[]){
        return SelfDefinedMenu::getMenu($distribution_channel_id,$filter);
    }

    public static function getMenuFormated($distribution_channel_id,$filter=[]) {
        return SelfDefinedMenu::getMenuFormated($distribution_channel_id,$filter);
    }
    #channel项目用到了相同的方法，如修改两边同时修改
    public static function getDefaultMenu($distribution_channel_id) {
        $WECHAT_CUSTOM_HOST = env('WECHAT_CUSTOM_HOST');
        if(in_array($distribution_channel_id,array('369','14'))){
            $WECHAT_CUSTOM_HOST = env('CUSTOM_HOST');
        }

        $encodeDistributionChannelId = encodeDistributionChannelId($distribution_channel_id);
        //\Log::info('officialMenusList：distribution_channel_id:'.$distribution_channel_id.' encodeDistributionChannelId:'.$encodeDistributionChannelId.' is_yq_move:'.$is_yq_move.' menu_type:'.$menu_type);

        $base_url = env('PROTOCOL') . '://site' . $encodeDistributionChannelId . '.' . $WECHAT_CUSTOM_HOST . '.com/';
        $help_url = 'https://help.'.$WECHAT_CUSTOM_HOST.'.com?distribution_channel_id='.$encodeDistributionChannelId;


        $buttons =
            [
                [
                    "type" => "click",
                    "name" => "最近阅读",
                    "key" => "recent_read",
                ],
                [
                    "type" => "click",
                    "name" => "今日签到",
                    "key" => 'daily_sign',
                ],
                [
                    "name" => "用户中心",
                    "sub_button" =>
                        [
                            [
                                "type" => "view",
                                "name" => "小说排行",
                                "url" => $base_url . 'rank',
                            ],
                            [
                                "type" => "view",
                                "name" => "个人中心",
                                "url" => $base_url . 'person',
                            ],
                            [
                                "type" => "view",
                                "name" => "书城首页",
                                "url" => $base_url,
                            ],
                            [
                                "type" => "view",
                                "name" => "优惠充值",
                                "url" => $base_url . 'pay',
                            ],
                            [
                                "type" => "view",
                                "name" => "帮助中心",
                                "url" => $help_url,
                            ],
                        ],
                ],
            ];


        return $buttons;

    }
}