<?php

namespace App\Http\Controllers\Wechat\OfficialAccount;

use App\Http\Controllers\Channel\BaseController as ChannelBaseController;
use App\Modules\OfficialAccount\Services\OfficialAccountService;
use App\Modules\OfficialAccount\Models\OfficialAccount;
use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
use App\Http\Controllers\Wechat\OfficialAccount\Transformers\OfficialAccountTransformer;
use Illuminate\Http\Request;
use GuzzleHttp\Client;
use App\Libs\OSS;

class OfficialAccountsController extends ChannelBaseController
{


    /**
     * @apiDefine OfficialAccount 公众号
     */

    /**
     * @apiVersion 1.0.0
     * @api {GET} OfficialAccount/officialAccountByAppid 通过appid获取公众号
     * @apiGroup OfficialAccount
     * @apiName officialAccountByAppid
     * @apiParam   {String}  appid 微信appID.
     * @apiSuccess {Number}  distribution_channel_id 分销渠道id.
     * @apiSuccess {String}  name 公众号原始名称.
     * @apiSuccess {String}  nickname 公众号名称.
     * @apiSuccess {String}  alias 唯一ID.
     * @apiSuccess {String}  qrcode_url 二维码地址.
     * @apiSuccess {String}  principal_name 公司名称.
     * @apiSuccess {String}  func_info 功能信息.
     * @apiSuccess {String}  head_img 头像地址.
     * @apiSuccess {String}  appid 微信appID.
     * @apiSuccess {String}  appsecret 微信appsecret.
     * @apiSuccess {String}  verify_txt 验证文件.
     * @apiSuccess {String}  verify_type_info 授权方认证类型.
     * @apiSuccess {String}  authorizer_refresh_token 授权的刷新token.
     * @apiSuccess {String}  cancel_auth_time 取消授权时间.
     * @apiSuccess {String}  official_account_type 第三方平台关注公众号.
     * @apiSuccess {Number}  is_auth 是否授权.
     * @apiSuccess {String}  service_type_info 服务号类型.
     * @apiSuccess {Number}  subscribe_top_num 强制关注总额.
     * @apiSuccess {Number}  subscribe_day_maximum 强制关注日限额.
     * @apiSuccess {Number}  is_enabled 是否可用.
     * @apiSuccessExample {json} Success-Response:
     *
     *     {
     *       "code": 0,
     *       "msg": "",
     *       "data": {
     *           "name": "gh_0fdfe1e4f56c",
     *           "nickname": "丸子书屋",
     *           "alias": "wzsw166",
     *           "head_img": "http://wx.qlogo.cn/mmopen/BDDBmFtJlKECdQ3ZeFKiaBMjU0ovndaib5tQQ1e7eXIIUCuKHGgnfwnDMdXecbpPmlstnnOicuHsiapvG71JbicBR52bapunZUvuu/0",
     *           "appid": "wx6916de1267c67d50",
     *           "appsecret": "wx6916de1267c67d501212",
     *           "verify_txt": "",
     *           "is_auth": "1",
     *           "service_type_info": "2",
     *           "subscribe_top_num": "10000",
     *           "subscribe_day_maximum": "500",
     *           "distribution_channel_id": 2147483647,
     *           "qrcode_url": "fdhgfds435gsdfg43t",
     *           "principal_name": "dfgh435saf2332",
     *           "func_info": "ry3t342trwe",
     *           "authorizer_refresh_token": "4534dfsgdsgsdgsdg",
     *           "cancel_auth_time": null,
     *           "official_account_type": "32dfaw234yewf",
     *           "verify_type_info": null,
     *           "is_enabled": 1
     *       }
     *      }
     */

    function officialAccountByAppid(Request $request)
    {

        $appid = $request->has('appid') ? $request->input('appid') : '';
        \Log::info('==========================进入officialAccountByAppid方法'.$appid);

        if(empty($appid)) {
            return response()->error("PARAM_EMPTY");
        }
        $officialAccount['appid'] = $appid;
        $officialAccountService = OfficialAccountService::officialAccountByAppid($officialAccount);
        return response()->item(new OfficialAccountTransformer(), $officialAccountService);
    }




    /**
     * @apiVersion 1.0.0
     * @api {GET} OfficialAccount/canUseOfficialAccountByChannelId 获取可分配的公众号
     * @apiGroup OfficialAccount
     * @apiName canUseOfficialAccountByChannelId
     * @apiParam   {String}  distribution_channel_id 分销渠道id.
     * @apiSuccess {Number}  distribution_channel_id 分销渠道id.
     * @apiSuccess {String}  name 公众号原始名称.
     * @apiSuccess {String}  nickname 公众号名称.
     * @apiSuccess {String}  alias 唯一ID.
     * @apiSuccess {String}  qrcode_url 二维码地址.
     * @apiSuccess {String}  principal_name 公司名称.
     * @apiSuccess {String}  func_info 功能信息.
     * @apiSuccess {String}  head_img 头像地址.
     * @apiSuccess {String}  appid 微信appID.
     * @apiSuccess {String}  appsecret 微信appsecret.
     * @apiSuccess {String}  verify_txt 验证文件.
     * @apiSuccess {String}  verify_type_info 授权方认证类型.
     * @apiSuccess {String}  authorizer_refresh_token 授权的刷新token.
     * @apiSuccess {String}  cancel_auth_time 取消授权时间.
     * @apiSuccess {String}  official_account_type 第三方平台关注公众号.
     * @apiSuccess {Number}  is_auth 是否授权.
     * @apiSuccess {String}  service_type_info 服务号类型.
     * @apiSuccess {Number}  subscribe_top_num 强制关注总额.
     * @apiSuccess {Number}  subscribe_day_maximum 强制关注日限额.
     * @apiSuccess {Number}  is_enabled 是否可用.
     * @apiSuccessExample {json} Success-Response:
     *
     *     {
     *       "code": 0,
     *       "msg": "",
     *       "data": {
     *           "name": "gh_0fdfe1e4f56c",
     *           "nickname": "丸子书屋",
     *           "alias": "wzsw166",
     *           "head_img": "http://wx.qlogo.cn/mmopen/BDDBmFtJlKECdQ3ZeFKiaBMjU0ovndaib5tQQ1e7eXIIUCuKHGgnfwnDMdXecbpPmlstnnOicuHsiapvG71JbicBR52bapunZUvuu/0",
     *           "appid": "wx6916de1267c67d50",
     *           "appsecret": "wx6916de1267c67d501212",
     *           "verify_txt": "",
     *           "is_auth": "1",
     *           "service_type_info": "2",
     *           "subscribe_top_num": "10000",
     *           "subscribe_day_maximum": "500",
     *           "distribution_channel_id": 2147483647,
     *           "qrcode_url": "fdhgfds435gsdfg43t",
     *           "principal_name": "dfgh435saf2332",
     *           "func_info": "ry3t342trwe",
     *           "authorizer_refresh_token": "4534dfsgdsgsdgsdg",
     *           "cancel_auth_time": null,
     *           "official_account_type": "32dfaw234yewf",
     *           "verify_type_info": null,
     *           "is_enabled": 1
     *       }
     *      }
     */

    function canUseOfficialAccountByChannelId(Request $request)
    {

        $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';

        if(empty($distribution_channel_id)) {
            return response()->error("PARAM_EMPTY");
        }

        $officialAccount['distribution_channel_id'] = $distribution_channel_id;

        $officialAccountService = OfficialAccountService::canUseOfficialAccountByChannelId($officialAccount);
      
        return response()->item(new OfficialAccountTransformer(), $officialAccountService);

    }
    





    /**
     * @apiVersion 1.0.0
     * @api {GET} OfficialAccount/officialAuthAccountBydistributionChannelId 根据分销渠道号获取所有授权的公众号
     * @apiGroup OfficialAccount
     * @apiName officialAuthAccountBydistributionChannelId
     * @apiParam   {String}  distribution_channel_id 分销渠道Id.
     * @apiSuccess {Number}  distribution_channel_id 分销渠道id.
     * @apiSuccess {String}  name 公众号原始名称.
     * @apiSuccess {String}  nickname 公众号名称.
     * @apiSuccess {String}  alias 唯一ID.
     * @apiSuccess {String}  qrcode_url 二维码地址.
     * @apiSuccess {String}  principal_name 公司名称.
     * @apiSuccess {String}  func_info 功能信息.
     * @apiSuccess {String}  head_img 头像地址.
     * @apiSuccess {String}  appid 微信appID.
     * @apiSuccess {String}  appsecret 微信appsecret.
     * @apiSuccess {String}  verify_txt 验证文件.
     * @apiSuccess {String}  verify_type_info 授权方认证类型.
     * @apiSuccess {String}  authorizer_refresh_token 授权的刷新token.
     * @apiSuccess {String}  cancel_auth_time 取消授权时间.
     * @apiSuccess {String}  official_account_type 第三方平台关注公众号.
     * @apiSuccess {Number}  is_auth 是否授权.
     * @apiSuccess {String}  service_type_info 服务号类型.
     * @apiSuccess {Number}  subscribe_top_num 强制关注总额.
     * @apiSuccess {Number}  subscribe_day_maximum 强制关注日限额.
     * @apiSuccess {Number}  is_enabled 是否可用.
     * @apiSuccessExample {json} Success-Response:
     *
     *     {
     *       "code": 0,
     *       "msg": "",
     *       "data": {
     *           "name": "gh_0fdfe1e4f56c",
     *           "nickname": "丸子书屋",
     *           "alias": "wzsw166",
     *           "head_img": "http://wx.qlogo.cn/mmopen/BDDBmFtJlKECdQ3ZeFKiaBMjU0ovndaib5tQQ1e7eXIIUCuKHGgnfwnDMdXecbpPmlstnnOicuHsiapvG71JbicBR52bapunZUvuu/0",
     *           "appid": "wx6916de1267c67d50",
     *           "appsecret": "wx6916de1267c67d501212",
     *           "verify_txt": "",
     *           "is_auth": "1",
     *           "service_type_info": "2",
     *           "subscribe_top_num": "10000",
     *           "subscribe_day_maximum": "500",
     *           "distribution_channel_id": 2147483647,
     *           "qrcode_url": "fdhgfds435gsdfg43t",
     *           "principal_name": "dfgh435saf2332",
     *           "func_info": "ry3t342trwe",
     *           "authorizer_refresh_token": "4534dfsgdsgsdgsdg",
     *           "cancel_auth_time": null,
     *           "official_account_type": "32dfaw234yewf",
     *           "verify_type_info": null,
     *           "is_enabled": 1
     *       }
     *      }
     */

    function officialAuthAccountBydistributionChannelId(Request $request)
    {

        $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';

        if(empty($distribution_channel_id)) {
            return response()->error("PARAM_EMPTY");
        }

        $officialAccount['distribution_channel_id'] = $distribution_channel_id;

        $officialAccountService = OfficialAccountService::officialAuthAccountBydistributionChannelId($officialAccount);

        return response()->collection(new OfficialAccountTransformer(), $officialAccountService);
    }




    /**
     * @apiVersion 1.0.0
     * @api {GET} OfficialAccount/allOfficialAccountBydistributionChannelId 根据分销渠道号获取服务号列表
     * @apiGroup OfficialAccount
     * @apiName allOfficialAccountBydistributionChannelId
     * @apiParam   {String}  distribution_channel_id 分销渠道Id.
     * @apiSuccess {Number}  distribution_channel_id 分销渠道id.
     * @apiSuccess {String}  name 公众号原始名称.
     * @apiSuccess {String}  nickname 公众号名称.
     * @apiSuccess {String}  alias 唯一ID.
     * @apiSuccess {String}  qrcode_url 二维码地址.
     * @apiSuccess {String}  principal_name 公司名称.
     * @apiSuccess {String}  func_info 功能信息.
     * @apiSuccess {String}  head_img 头像地址.
     * @apiSuccess {String}  appid 微信appID.
     * @apiSuccess {String}  appsecret 微信appsecret.
     * @apiSuccess {String}  verify_txt 验证文件.
     * @apiSuccess {String}  verify_type_info 授权方认证类型.
     * @apiSuccess {String}  authorizer_refresh_token 授权的刷新token.
     * @apiSuccess {String}  cancel_auth_time 取消授权时间.
     * @apiSuccess {String}  official_account_type 第三方平台关注公众号.
     * @apiSuccess {Number}  is_auth 是否授权.
     * @apiSuccess {String}  service_type_info 服务号类型.
     * @apiSuccess {Number}  subscribe_top_num 强制关注总额.
     * @apiSuccess {Number}  subscribe_day_maximum 强制关注日限额.
     * @apiSuccess {Number}  todayForceSubscribeUsers 今日关注总数.
     * @apiSuccess {Number}  allForceSubscribeUsers 关注总数.
     * @apiSuccess {Number}  is_enabled 是否可用.
     * @apiSuccessExample {json} Success-Response:
     *
     *     {
     *       "code": 0,
     *       "msg": "",
     *       "data": {
     *           {
     *              "name": "测试呵呵",
     *              "nickname": "大哥",
     *              "alias": "23534dsgdsvdx",
     *              "head_img": "www.baidu.com",
     *              "appid": "1211",
     *              "appsecret": "dsfsdf3452352",
     *              "verify_txt": null,
     *              "is_auth": 1,
     *              "service_type_info": "546dsfwr23r",
     *              "subscribe_top_num": null,
     *              "subscribe_day_maximum": null,
     *              "distribution_channel_id": 1,
     *              "qrcode_url": "fdhgfds435gsdfg43t",
     *              "principal_name": "dfgh435saf2332",
     *              "func_info": "ry3t342trwe",
     *              "authorizer_refresh_token": "4534dfsgdsgsdgsdg",
     *              "cancel_auth_time": null,
     *              "official_account_type": "32dfaw234yewf",
     *              "verify_type_info": null,
     *              "is_enabled": 1,
     *              "todayForceSubscribeUsers": 0,
     *              "allForceSubscribeUsers": 0
     *          }
     *       }
     *      }
     */

    function allOfficialAccountBydistributionChannelId(Request $request)
    {

        $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';

        if(empty($distribution_channel_id)) {
            return response()->error("PARAM_EMPTY");
        }

        $officialAccount['distribution_channel_id'] = $distribution_channel_id;

        $officialAccountService = OfficialAccountService::allOfficialAccountBydistributionChannelId($officialAccount);
        
        return response()->collection(new OfficialAccountTransformer(), $officialAccountService);
    }


    /**
     * @apiVersion 1.0.0
     * @api {POST} OfficialAccount/authOfficialAccount 授权公众号信息
     * @apiGroup OfficialAccount
     * @apiName authOfficialAccount
     * @apiParam {String}  appid 微信appID.
     * @apiParam {String}  name 公众号原始名称.
     * @apiParam {String}  nickname 公众号名称.
     * @apiParam {String}  alias 唯一ID.
     * @apiParam {String}  head_img 头像地址.
     * @apiParam {String}  appid 微信appID.
     * @apiParam {String}  appsecret 微信appsecret.
     * @apiParam {String}  is_auth 是否授权.
     * @apiParam {String}  service_type_info 服务号类型.
     * @apiParam {Number}  distribution_channel_id 分销渠道id.
     * @apiParam {String}  qrcode_url 二维码地址.
     * @apiParam {String}  principal_name 公司名称.
     * @apiParam {String}  func_info 功能信息.
     * @apiParam {String}  authorizer_refresh_token 授权的刷新token.
     * @apiParam {String}  official_account_type 第三方平台关注公众号.
     * @apiSuccessExample {json} Success-Response:
     *
     *       {
     *           "code": 0,
     *           "msg": "",
     *           "data": []
     *       }       
     */
    function authOfficialAccount(Request $request) {

        $appid = $request->has('appid') ? $request->input('appid') : '';

        // $distribution_channel_id = $this->getChannelId();
        
        $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';
        
        $appsecret = $request->has('appsecret') ? $request->input('appsecret') : '';
        
        $alias = $request->has('alias') ? $request->input('alias') : '';
        
        $name = $request->has('name') ? $request->input('name') : '';
        
        $nickname = $request->has('nickname') ? $request->input('nickname') : '';
        
        $head_img = $request->has('head_img') ? $request->input('head_img') : '';
        
        $qrcode_url = $request->has('qrcode_url') ? $request->input('qrcode_url') : '';
        
        $principal_name = $request->has('principal_name') ? $request->input('principal_name') : '';
        
        $service_type_info = $request->has('service_type_info') ? $request->input('service_type_info') : '';
        
        $func_info = $request->has('func_info') ? $request->input('func_info') : '';
        
        $authorizer_refresh_token = $request->has('authorizer_refresh_token') ? $request->input('authorizer_refresh_token') : '';
        
        $is_auth = $request->has('is_auth') ? $request->input('is_auth') : '1';
        
        $official_account_type = $request->has('official_account_type') ? $request->input('official_account_type') : '';
        
        $is_enabled = 1;

        $verify_txt = $request->has('verify_txt') ? $request->input('verify_txt') : '';

        $officialAccount['appid'] = $appid;
        $officialAccount['distribution_channel_id'] = $distribution_channel_id;
        $officialAccount['appsecret'] = $appsecret;
        $officialAccount['alias'] = $alias;
        $officialAccount['name'] = $name;
        $officialAccount['nickname'] = $nickname;
        $officialAccount['head_img'] = $head_img;
        $officialAccount['qrcode_url'] = $qrcode_url;
        $officialAccount['principal_name'] = $principal_name;
        $officialAccount['service_type_info'] = $service_type_info;
        $officialAccount['func_info'] = $func_info;
        $officialAccount['authorizer_refresh_token'] = $authorizer_refresh_token;
        $officialAccount['is_auth'] = $is_auth;
        $officialAccount['official_account_type'] = $official_account_type;
        $officialAccount['is_enabled'] = $is_enabled;
        $officialAccount['verify_txt'] = $verify_txt;

        \Log::info($appid.':auth:create:params');
        \Log::info($officialAccount);
        $resultStatus = OfficialAccountService::authOfficialAccount($officialAccount);
        if ($resultStatus == 1) {
            return response()->success();
        }elseif ($resultStatus == 2) {
            return response()->error('OFFICIAL_ACCOUNT_IS_EXIST');
        }elseif ($resultStatus == 0) {
            return response()->error('OFFICIAL_ACCOUNT_FAILED');
        }else{
            return response()->error('OFFICIAL_ACCOUNT_FAILED');
        }

    }

    /**
     * @apiVersion 1.0.0
     * @api {POST} OfficialAccount/updateOfficialAccount 修改公众号信息
     * @apiGroup OfficialAccount
     * @apiName updateOfficialAccount
     * @apiParam {String}  appid 微信appID.
     * @apiParam {String}  appsecret 微信appsecret.
     * @apiParam {String}  distribution_channel_id 分销渠道id.
     * @apiParam {String}  subscribe_top_num 总阀值.
     * @apiParam {String}  subscribe_day_maximum 日上线.
     * @apiSuccessExample {json} Success-Response:
     *
     *       {
     *           "code": 0,
     *           "msg": "",
     *           "data": []
     *       }       
     */
    function updateOfficialAccount(Request $request) {

        $appid = $request->has('appid') ? $request->input('appid') : '';
        
        $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';

        // $distribution_channel_id = $this->getChannelId();
        
        $appsecret = $request->has('appsecret') ? $request->input('appsecret') : '';
        
        $alias = $request->has('alias') ? $request->input('alias') : '';
        
        $name = $request->has('name') ? $request->input('name') : '';
        
        $nickname = $request->has('nickname') ? $request->input('nickname') : '';
        
        $head_img = $request->has('head_img') ? $request->input('head_img') : '';
        
        $qrcode_url = $request->has('qrcode_url') ? $request->input('qrcode_url') : '';
        
        $principal_name = $request->has('principal_name') ? $request->input('principal_name') : '';
        
        $service_type_info = $request->has('service_type_info') ? $request->input('service_type_info') : '';
        
        $func_info = $request->has('func_info') ? $request->input('func_info') : '';
        
        $authorizer_refresh_token = $request->has('authorizer_refresh_token') ? $request->input('authorizer_refresh_token') : '';
        
        $is_auth = $request->has('is_auth') ? $request->input('is_auth') : '1';
        
        $official_account_type = $request->has('official_account_type') ? $request->input('official_account_type') : '';
        
        $is_enabled = 1;

        $verify_txt = $request->has('verify_txt') ? $request->input('verify_txt') : '';

        $subscribe_top_num = $request->has('subscribe_top_num') ? $request->input('subscribe_top_num') : '';

        $subscribe_day_maximum = $request->has('subscribe_day_maximum') ? $request->input('subscribe_day_maximum') : '';

        $officialAccount['appid'] = $appid;
        $officialAccount['distribution_channel_id'] = $distribution_channel_id;
        $officialAccount['appsecret'] = $appsecret;
        $officialAccount['alias'] = $alias;
        $officialAccount['name'] = $name;
        $officialAccount['nickname'] = $nickname;
        $officialAccount['head_img'] = $head_img;
        $officialAccount['qrcode_url'] = $qrcode_url;
        $officialAccount['principal_name'] = $principal_name;
        $officialAccount['service_type_info'] = $service_type_info;
        $officialAccount['func_info'] = $func_info;
        $officialAccount['authorizer_refresh_token'] = $authorizer_refresh_token;
        $officialAccount['is_auth'] = $is_auth;
        $officialAccount['official_account_type'] = $official_account_type;
        $officialAccount['is_enabled'] = $is_enabled;
        $officialAccount['verify_txt'] = $verify_txt;
        $officialAccount['subscribe_top_num'] = $subscribe_top_num;
        $officialAccount['subscribe_day_maximum'] = $subscribe_day_maximum;

        $resultStatus = OfficialAccountService::updateOfficialAccount($officialAccount);
        if ($resultStatus == 1) {
            return response()->success();
        }elseif ($resultStatus == 2) {
            return response()->error('OFFICIAL_ACCOUNT_NOT_FOUND');
        }elseif ($resultStatus == 0) {
            return response()->error('UPDATE_OFFICIAL_ACCOUNT_FAILED');
        }else{
            return response()->error('UPDATE_OFFICIAL_ACCOUNT_FAILED');
        }
        
        
    }

    // public function getUserClient(){
    //     return new Client(['base_uri' => env('PUBLIC_API_BASE_URI')]);
    // }


    /**
     * @apiVersion 1.0.0
     * @api {GET} OfficialAccount/cancelAuthOfficialAccount 取消公众号授权
     * @apiGroup OfficialAccount
     * @apiName cancelAuthOfficialAccount
     * @apiParam {String}  appid 微信appID.
     * @apiSuccessExample {json} Success-Response:
     *
     *       {
     *           "code": 0,
     *           "msg": "",
     *           "data": []
     *       } 
     */
    function cancelAuthOfficialAccount(Request $request) {

        $appid = $request->has('appid') ? $request->input('appid') : '';
        if(empty($appid)) {
            return response()->error("PARAM_EMPTY");
        }
        // $distribution_channel_id = $this->getChannelId();
        $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';
        $officialAccount['appid'] = $appid;
        $officialAccount['distribution_channel_id'] = $distribution_channel_id;

        $resultStatus = OfficialAccountService::cancelAuthOfficialAccount($officialAccount);
        
        if ($resultStatus == 1) {
            return response()->success();
        }elseif ($resultStatus == 2) {
            return response()->error("CANCEL_OFFICIAL_ACCOUNT_FAILED");
        }elseif ($resultStatus == 0) {
            return response()->error("CANCEL_OFFICIAL_ACCOUNT_FAILED");
        }else{
            return response()->error("CANCEL_OFFICIAL_ACCOUNT_FAILED");
        }
    }

    /**
     * @apiVersion 1.0.0
     * @api {GET} OfficialAccount/officialAccountAuthUrl 获取服务号授权URL
     * @apiGroup OfficialAccount
     * @apiName officialAccountAuthUrl
     * @apiParam {String}  distribution_channel_id 分销渠道ID.
     * @apiSuccessExample {json} Success-Response:
     *
     *       {
     *           "code": 0,
     *           "msg": "",
     *           "data": []
     *       } 
     */
    function  officialAccountAuthUrl(Request $request) {

        // $distribution_channel_id = $this->getChannelId();
        $distribution_channel_id = $request->has('distribution_channel_id') ? $request->input('distribution_channel_id') : '';
        // if(empty($distribution_channel_id)) {
        //     return response()->error("PARAM_EMPTY");
        // }

        $officialAccount['distribution_channel_id'] = $distribution_channel_id;

        $backurl = OfficialAccountService::officialAccountAuthUrl($officialAccount);

        return response()->success($backurl);
    }

    
}