Browse Source

error fix

zhoulj 4 năm trước cách đây
mục cha
commit
db38e92bd5

+ 78 - 0
app/Console/Commands/Temp/CheckCidError.php

@@ -0,0 +1,78 @@
+<?php
+
+namespace App\Console\Commands\Temp;
+use Illuminate\Console\Command;
+use App\Modules\Message\MessageNotify;
+use DB;
+
+class CheckCidError extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'check_cid_error';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '检查cid';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+
+    private $emails = ['lisy@zw88.net','songdb@iqiyoo.com','zhoulj@iqiyoo.com','zhaoy@zw88.net'];
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle(){
+        \Log::info('check_cid_error_start'.date('Y-m-d'));
+        $this->Check();
+        \Log::info('check_cid_error_end'.date('Y-m-d'));
+
+    }
+    public function Check()
+    {
+        $msg = '['.env('PROJECT_NAME').']';
+        $wrong_next_cid = DB::select('select bid,next_cid,count(1) as num
+from chapters c
+where next_cid =0 and bid > 0
+group by c.bid 
+having num > 1');
+        $msg .=  !empty($wrong_next_cid) ? 'wrong_next_cid: '.\GuzzleHttp\json_encode($wrong_next_cid) : '';
+        $wrong_prev_cid =  DB::select('select bid,prev_cid,count(1) as num
+from chapters c
+where prev_cid =0 and bid > 0
+group by c.bid 
+having num > 1;');
+        $msg .=  !empty($wrong_prev_cid) ? 'wrong_prev_cid: '.\GuzzleHttp\json_encode($wrong_prev_cid) : '';
+
+        \Log::info('check_cid_error'.date('Y-m-d').$msg);
+        if($msg){
+            $notify = MessageNotify::mail([
+                'to_emails' => implode(",", $this->emails),
+                'subject' => $msg,
+                'body' =>$msg,
+                'delay_times' => 0,
+            ]);
+            $notify->notify();
+            exit();
+
+        }
+    }
+
+}

+ 1 - 1
app/Consts/SysConsts.php

@@ -15,7 +15,7 @@ class SysConsts
     /**
      * 消息通知地址
      */
-    const MESSAGE_NOTIFY_BASE_URI = '';
+    const MESSAGE_NOTIFY_BASE_URI = 'http://47.110.49.99:8099/';
 
     /**
      * 网读云public api

+ 16 - 0
app/Http/Controllers/Manage/BaseController.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: tandunzhao
+ * Date: 2017/12/22
+ * Time: 下午1:41
+ */
+
+namespace App\Http\Controllers\Manage;
+
+use App\Http\Controllers\Controller;
+
+class BaseController extends Controller
+{
+
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 523 - 0
app/Http/Controllers/Manage/OfficialAccount/CustomMsgController.php


+ 130 - 0
app/Http/Controllers/Manage/OfficialAccount/OfficialAccountsController.php

@@ -0,0 +1,130 @@
+<?php
+
+namespace App\Http\Controllers\Manage\OfficialAccount;
+
+use App\Http\Controllers\Channel\BaseController;
+use App\Modules\OfficialAccount\Services\OfficialAccountService;
+use App\Http\Controllers\Manage\OfficialAccount\Transformers\OfficialAccountTransformer;
+use Illuminate\Http\Request;
+use GuzzleHttp\Client;
+use App\Libs\OSS;
+
+class OfficialAccountsController extends BaseController
+{
+
+
+    /**
+     * @apiVersion 1.0.0
+     * @api {GET} OfficialAccount/allOfficialAccountBydistributionChannelId 根据分销渠道号获取服务号列表
+     * @apiGroup OfficialAccount
+     * @apiName allOfficialAccountBydistributionChannelId
+     * @apiParam   {String}  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");
+        }
+
+        \Log::info('-------------------获取当前渠道下的所有服务号-----------------------------------');
+        \Log::info($distribution_channel_id);
+
+        $officialAccount['distribution_channel_id'] = $distribution_channel_id;
+
+        $officialAccountService = OfficialAccountService::allOfficialAccountBydistributionChannelId($officialAccount);
+        
+        return response()->collection(new OfficialAccountTransformer(), $officialAccountService);
+    }
+
+
+    /**
+     * @apiVersion 1.0.0
+     * @api {GET} OfficialAccount/officialAccountCountByChannelId 通过渠道Id获取公众号数量
+     * @apiGroup OfficialAccount
+     * @apiName officialAccountCountByChannelId
+     * @apiParam   {String}  distribution_channel_id 分销渠道id. 
+     * @apiSuccess {Number}  official_num 公众号数量.
+     * @apiSuccessExample {json} Success-Response:
+     *
+     *     {
+     *       "code": 0,
+     *       "msg": "",
+     *       "data": {
+     *           "official_num": 2,
+     *       }
+     *      }
+     */
+
+    function officialAccountCountByChannelId(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::officialAccountCountByChannelId($officialAccount);
+        return response()->success(['official_num'=>$officialAccountService]);
+    }
+
+    
+}

+ 34 - 0
app/Http/Controllers/Manage/OfficialAccount/Transformers/BatchCustomSendMsgsTransformers.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Http\Controllers\Manage\OfficialAccount\Transformers;
+
+class BatchCustomSendMsgsTransformers
+{
+    public function transform($batchCustomSendMsgs){
+        return [
+            'id'       =>  isset($batchCustomSendMsgs->id)?$batchCustomSendMsgs->id:'',
+            'name'       =>  isset($batchCustomSendMsgs->name)?$batchCustomSendMsgs->name:'',
+            'create_time'       =>  isset($batchCustomSendMsgs->create_time)?$batchCustomSendMsgs->create_time:'',
+            'send_time'       =>  isset($batchCustomSendMsgs->send_time)?$batchCustomSendMsgs->send_time:'',
+            'content'       =>  isset($batchCustomSendMsgs->content)?$batchCustomSendMsgs->content:'',
+            'redirect_url'       =>  isset($batchCustomSendMsgs->redirect_url)?$batchCustomSendMsgs->redirect_url:'',
+            'status'       =>  isset($batchCustomSendMsgs->status)?$batchCustomSendMsgs->status:'',
+            'subscribe_time'       =>  isset($batchCustomSendMsgs->subscribe_time)?$batchCustomSendMsgs->subscribe_time:'',
+            'sex'       =>  isset($batchCustomSendMsgs->sex)?$batchCustomSendMsgs->sex:'',
+            'balance'       =>  isset($batchCustomSendMsgs->balance)?$batchCustomSendMsgs->balance:'',
+            'order_type'       => isset($batchCustomSendMsgs->order_type)?$batchCustomSendMsgs->order_type:'',
+            'category_id'       =>  isset($batchCustomSendMsgs->category_id)?$batchCustomSendMsgs->category_id:'',
+            'user_num'       =>  isset($batchCustomSendMsgs->user_num)?$batchCustomSendMsgs->user_num:'',
+            'is_full_send'       =>  isset($batchCustomSendMsgs->is_full_send)?$batchCustomSendMsgs->is_full_send:'',
+            'book_names'       =>   isset($batchCustomSendMsgs->book_names)?$batchCustomSendMsgs->book_names:'',
+            'bids'       =>   isset($batchCustomSendMsgs->bids)?$batchCustomSendMsgs->bids:'',
+            'pv'       =>  isset($batchCustomSendMsgs->pv)?$batchCustomSendMsgs->pv:'',
+            'uv'       =>  isset($batchCustomSendMsgs->uv)?$batchCustomSendMsgs->uv:'',
+            'pay_user_num'       =>  isset($batchCustomSendMsgs->pay_user_num)?$batchCustomSendMsgs->pay_user_num:'',
+            'total_order_num'       =>  isset($batchCustomSendMsgs->total_order_num)?$batchCustomSendMsgs->total_order_num:'',
+            'suc_order_num'       =>  isset($batchCustomSendMsgs->suc_order_num)?$batchCustomSendMsgs->suc_order_num:'',
+            'success_order_sum'       =>  isset($batchCustomSendMsgs->success_order_sum)?$batchCustomSendMsgs->success_order_sum:'',
+
+        ];
+    }
+}

+ 38 - 0
app/Http/Controllers/Manage/OfficialAccount/Transformers/CustomSendMsgsTransformers.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Http\Controllers\Manage\OfficialAccount\Transformers;
+
+class CustomSendMsgsTransformers
+{
+    public function transform($customSendMsgs){
+        return [
+            'id'       =>  $customSendMsgs->id,
+            'appid'       =>  $customSendMsgs->appid,
+            'official_account_name'       =>  isset($customSendMsgs->official_account_name)?$customSendMsgs->official_account_name:'',
+            'name'       =>  $customSendMsgs->name,
+            'send_time'       =>  $customSendMsgs->send_time,
+            'content'       =>  $customSendMsgs->content,
+            'redirect_url'       =>  $customSendMsgs->redirect_url,
+            'status'       =>  $customSendMsgs->status,
+            'distribution_channel_id'       =>  $customSendMsgs->distribution_channel_id,
+            'subscribe_time'       =>  $customSendMsgs->subscribe_time,
+            'sex'       =>  $customSendMsgs->sex,
+            'balance'       =>  $customSendMsgs->balance,
+            'order_type'       =>  $customSendMsgs->order_type,
+            'category_id'       =>  $customSendMsgs->category_id,
+            'user_num'       =>  $customSendMsgs->user_num,
+            'is_full_send'       =>  $customSendMsgs->is_full_send,
+            'trusteeship'       =>  $customSendMsgs->trusteeship,
+            'batch_no'       =>   isset($customSendMsgs->batch_no)?$customSendMsgs->batch_no:'',
+            'position'       =>   isset($customSendMsgs->position)?$customSendMsgs->position:'',
+            'book_names'       =>   isset($customSendMsgs->book_names)?$customSendMsgs->book_names:'',
+            'bids'       =>   isset($customSendMsgs->bids)?$customSendMsgs->bids:'',
+            'suc_order_num'       =>   isset($customSendMsgs->suc_order_num)?$customSendMsgs->suc_order_num:'',
+            'total_order_num'       =>   isset($customSendMsgs->total_order_num)?$customSendMsgs->total_order_num:'',
+            'order_suc_rate'       =>   isset($customSendMsgs->order_suc_rate)?$customSendMsgs->order_suc_rate:'',
+            'success_order_sum'       =>   isset($customSendMsgs->success_order_sum)?$customSendMsgs->success_order_sum:'',
+            'pv'       =>  isset($customSendMsgs->pv)?$customSendMsgs->pv:'0',
+            'uv'       =>  isset($customSendMsgs->uv)?$customSendMsgs->uv:'0',
+        ];
+    }
+}

+ 25 - 0
app/Http/Controllers/Manage/OfficialAccount/Transformers/CustomTemplateSendStatTransformer.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Http\Controllers\Manage\OfficialAccount\Transformers;
+
+class CustomTemplateSendStatTransformer
+{
+    public function transform($CustomTemplateSendStat){
+        return [
+            'id'       =>  isset($CustomTemplateSendStat->id) ? $CustomTemplateSendStat->id : "",
+            'created_date'       =>  isset($CustomTemplateSendStat->created_date) ? $CustomTemplateSendStat->created_date : "",
+            'template_name'       =>  isset($CustomTemplateSendStat->template_name) ? $CustomTemplateSendStat->template_name : "",
+            'task_name'       =>  isset($CustomTemplateSendStat->task_name) ? $CustomTemplateSendStat->task_name : "",
+            'site_id'       =>  isset($CustomTemplateSendStat->site_id) ? $CustomTemplateSendStat->site_id : "",
+            'official_account_name'       =>  isset($CustomTemplateSendStat->official_account_name) ? $CustomTemplateSendStat->official_account_name : "",
+            'tag'       =>  isset($CustomTemplateSendStat->tag) ? $CustomTemplateSendStat->tag : "",
+            'send_time'       =>  isset($CustomTemplateSendStat->send_time) ? $CustomTemplateSendStat->send_time : "",
+            'suc_send_num'       =>  isset($CustomTemplateSendStat->suc_send_num) ? $CustomTemplateSendStat->suc_send_num : "",
+            'uv'       =>  isset($CustomTemplateSendStat->uv) ? $CustomTemplateSendStat->uv : "",
+            'total_order_num'       =>  isset($CustomTemplateSendStat->total_order_num) ? $CustomTemplateSendStat->total_order_num : "",
+            'suc_order_num'       =>  isset($CustomTemplateSendStat->suc_order_num) ? $CustomTemplateSendStat->suc_order_num : "",
+            'charge_amount'       =>  isset($CustomTemplateSendStat->charge_amount) ? $CustomTemplateSendStat->charge_amount : "",
+            'not_first_charge_user_num'       =>  isset($CustomTemplateSendStat->not_first_charge_user_num) ? $CustomTemplateSendStat->not_first_charge_user_num : "",
+        ];
+    }
+}

+ 27 - 0
app/Http/Controllers/Manage/OfficialAccount/Transformers/OfficialAccountDaySubStatTransformer.php

@@ -0,0 +1,27 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: tandunzhao
+ * Date: 2018/6/20
+ * Time: 下午5:05
+ */
+
+namespace App\Http\Controllers\Manage\OfficialAccount\Transformers;
+
+
+class OfficialAccountDaySubStatTransformer
+{
+
+    public function transform($obj){
+        return [
+            'appid'       =>  isset($obj->appid) ? $obj->appid : "",
+            'official_account_name'       =>  isset($obj->official_account_name) ? $obj->official_account_name : "",
+            'month'       =>  isset($obj->month) ? $obj->month : "",
+            'date'       =>  isset($obj->date) ? $obj->date : "",
+            'reward_balance'       =>  (int)isset($obj->reward_balance) ? $obj->reward_balance : 0,
+            'charge_balance'       =>  (int)isset($obj->charge_balance) ? $obj->charge_balance : 0,
+            'fee'       =>  (int)isset($obj->fee) ? $obj->fee : 0,
+        ];
+    }
+
+}

+ 38 - 0
app/Http/Controllers/Manage/OfficialAccount/Transformers/OfficialAccountTransformer.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Http\Controllers\Manage\OfficialAccount\Transformers;
+
+class OfficialAccountTransformer
+{
+    public function transform($officialAccount){
+        return [
+            'id'       =>  isset($officialAccount->id) ? $officialAccount->id : "",
+            'name'       =>  isset($officialAccount->name) ? $officialAccount->name : "",
+            'nickname'       =>  isset($officialAccount->nickname) ? $officialAccount->nickname : "",
+            'alias'       =>  isset($officialAccount->alias) ? $officialAccount->alias : "",
+            'head_img'       =>  isset($officialAccount->head_img) ? $officialAccount->head_img : "",
+            'appid'   =>  isset($officialAccount->appid) ? $officialAccount->appid : "",
+            'appsecret'   => isset($officialAccount->appsecret) ? $officialAccount->appsecret : "",
+            'verify_txt' => isset($officialAccount->verify_txt) ? $officialAccount->verify_txt : "",
+            'is_auth' => isset($officialAccount->is_auth) ? $officialAccount->is_auth : "",
+            'service_type_info' => isset($officialAccount->service_type_info) ? $officialAccount->service_type_info : "",
+            'subscribe_top_num' => isset($officialAccount->subscribe_top_num) ? $officialAccount->subscribe_top_num : "",
+            'subscribe_day_maximum' => isset($officialAccount->subscribe_day_maximum) ? $officialAccount->subscribe_day_maximum : "",
+            'distribution_channel_id' => isset($officialAccount->distribution_channel_id) ? $officialAccount->distribution_channel_id : "",
+            'qrcode_url' => isset($officialAccount->qrcode_url) ? $officialAccount->qrcode_url : "",
+            'principal_name' => isset($officialAccount->principal_name) ? $officialAccount->principal_name : "",
+            'func_info' => isset($officialAccount->func_info) ? $officialAccount->func_info : "",
+            'authorizer_refresh_token' => isset($officialAccount->authorizer_refresh_token) ? $officialAccount->authorizer_refresh_token : "",
+            'cancel_auth_time' => isset($officialAccount->cancel_auth_time) ? $officialAccount->cancel_auth_time : "",
+            'official_account_type' => isset($officialAccount->official_account_type) ? $officialAccount->official_account_type : "",
+            'verify_type_info' => isset($officialAccount->verify_type_info) ? $officialAccount->verify_type_info : "",
+            'is_enabled' => isset($officialAccount->is_enabled) ? $officialAccount->is_enabled : "",
+            'todayForceSubscribeUsers' => isset($officialAccount->todayForceSubscribeUsers) ? $officialAccount->todayForceSubscribeUsers : "",
+            'allForceSubscribeUsers' => isset($officialAccount->allForceSubscribeUsers) ? $officialAccount->allForceSubscribeUsers : "",
+            'subscribe_top_num' => isset($officialAccount->subscribe_top_num) ? $officialAccount->subscribe_top_num : "",
+            'subscribe_day_maximum' => isset($officialAccount->subscribe_day_maximum) ? $officialAccount->subscribe_day_maximum : "",
+            'sort_no' => isset($officialAccount->sort_no) ? $officialAccount->sort_no : "0",
+            
+        ];
+    }
+}

+ 215 - 0
app/Http/Controllers/Manage/OfficialAccount/WeChatToolsController.php

@@ -0,0 +1,215 @@
+<?php
+
+namespace App\Http\Controllers\Manage\OfficialAccount;
+
+use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
+
+use App\Modules\OfficialAccount\Models\OfficialAccount;
+use App\Modules\OfficialAccount\Models\UntieOfficialAccount;
+
+use App\Http\Controllers\Channel\BaseController;
+use App\Modules\OfficialAccount\Services\OfficialAccountService;
+use App\Http\Controllers\Manage\OfficialAccount\Transformers\OfficialAccountTransformer;
+use Illuminate\Http\Request;
+use GuzzleHttp\Client;
+use Redis;
+
+/**
+ * 微信工具修改类
+ * @author zhoulingjie
+ *
+ */
+class WeChatToolsController extends BaseController
+{
+
+
+    /**
+     * @apiVersion 1.0.0
+     * @api {GET} OfficialAccount/add_public_templates 根据公共模板id添加模板
+     * @apiGroup OfficialAccount
+     * @apiName add_public_templates
+     * @apiParam   {String}  common_template_id 公共模板id. 
+     */
+    function add_public_templates(Request $request){
+
+       $common_template_id = $request->has('common_template_id') ? $request->input('common_template_id') : '';
+       $test_appid = $request->has('test_appid') ? $request->input('test_appid') : '';
+        
+       \Log::info('add_public_templates:'.$common_template_id);
+
+       if(empty($common_template_id)) {
+           return response()->error("PARAM_EMPTY");
+       }
+
+        $officail_accounts = OfficialAccountService::officialAuthAccounts(1,1);
+//         \Log::info($officail_accounts);
+        foreach ($officail_accounts as $officail_account){
+        	try {
+//         		if($officail_account->appid != 'wxdbc486f1b4f6a8c3') {
+//         			\Log::info('not_in:'.$officail_account->appid);
+//         			continue;
+//         		}
+        		$timestamp = time();
+        		$params = array("common_template_id"=>$common_template_id,'gzh_app_id'=>$officail_account->appid,"timestamp"=>$timestamp);
+        		$sign = get_sign($params);
+        		
+        		\Log::info('add_public_template_start,appid:'.$officail_account->appid);
+        		
+        		$mediaCustomerJson = $this->getUserClient()->request("GET","add_public_template",
+        				['query'=>['common_template_id'=>$common_template_id,'gzh_app_id'=>$officail_account->appid,'timestamp'=>$timestamp,'sign'=>$sign],'connect_timeout' => 10]
+        		)->getBody()->getContents();
+        		//\Log::info($mediaCustomerJson);
+        		\Log::info('add_public_template_end,appid:'.$officail_account->appid.' res:'.json_encode($mediaCustomerJson));
+        	
+        	} catch (\Exception $e) {
+        		\Log::info($e->getMessage());
+        	}
+        }
+
+        return response()->success(['status'=>'1']);
+
+    }
+    
+    /**
+     * @apiVersion 1.0.0
+     * @api {GET} OfficialAccount/add_public_templates 根据公共模板id添加模板
+     * @apiGroup OfficialAccount
+     * @apiName add_public_templates
+     * @apiParam   {String}  common_template_id 公共模板id.
+     */
+    public function check_official_account_templates(){
+    
+    	$officail_accounts = OfficialAccountService::officialAuthAccounts(1,1);
+    	foreach ($officail_accounts as $officail_account){
+    		try {
+//     			        		if($officail_account->appid != 'wxdbc486f1b4f6a8c3') {
+//     			        			\Log::info('not_in:'.$officail_account->appid);
+//     			        			continue;
+//     			        		}
+    			$timestamp = time();
+    			$params = array("gzh_app_id"=>$officail_account->appid,"timestamp"=>$timestamp);
+    			$sign = get_sign($params);
+    
+    			\Log::info('check_official_account_templates_start,appid:'.$officail_account->appid);
+
+    			$dataJson = $this->getUserClient()->request("GET","check_official_account_templates",
+    					['query'=>['gzh_app_id'=>$officail_account->appid,'timestamp'=>$timestamp,'sign'=>$sign],'connect_timeout' => 10]
+    			)->getBody()->getContents();
+    			//\Log::info($dataJson);
+    			\Log::info('check_official_account_templates_end,appid:'.$officail_account->appid.' res:'.json_encode($dataJson));
+
+    		}
+	        catch( \Exception $e){
+	            \Log::info($e->getMessage());
+	        }
+
+    	}
+    
+    	return response()->success(['status'=>'1']);
+    
+    }
+    
+    /**
+     * @apiVersion 1.0.0
+     * @api {GET} OfficialAccount/update_encrypt_menus 更新所有菜单->改为加密
+     * @apiGroup OfficialAccount
+     * @apiName update_encrypt_menus
+     */
+    public function update_encrypt_menus(){
+    
+    	$officail_accounts = OfficialAccountService::officialAuthSubscribeAccounts(1,1);
+    	foreach ($officail_accounts as $officail_account){
+    		try {
+//     			if($officail_account->appid != 'wxdbc486f1b4f6a8c3') {
+//     			   \Log::info('not_in:'.$officail_account->appid);
+//     			   continue;
+//     			}
+    			$timestamp = time();
+    			$params = array("set_type"=>"menu","authorizer_appid"=>$officail_account->appid,"timestamp"=>$timestamp);
+    			$sign = get_sign($params);
+//     			http://zydy/oauth/auto_set_menu_and_template_test?set_type=menu&authorizer_appid=wxdbc486f1b4f6a8c3&timestamp=1511509543&sign=98dccc7b29e3c05e4b4367f488ff1966
+    			    
+    			\Log::info('update_encrypt_menus_start,appid:'.$officail_account->appid);
+    
+    			$dataJson = $this->getAuthClient()->request("GET","auto_set_menu_and_template_test",
+    					['query'=>["set_type"=>"menu",'authorizer_appid'=>$officail_account->appid,'timestamp'=>$timestamp,'sign'=>$sign],'connect_timeout' => 10]
+    			)->getBody()->getContents();
+    			//\Log::info($dataJson);
+    			\Log::info('update_encrypt_menus_end,appid:'.$officail_account->appid.' res:'.json_encode($dataJson));
+    
+    		}
+    		catch( \Exception $e){
+    			\Log::info($e->getMessage());
+    		}
+    
+    	}
+    
+    	return response()->success(['status'=>'1']);
+    
+    }
+    
+    /**
+     * @apiVersion 1.0.0
+     * @api {GET} OfficialAccount/untie_distribution_official_account 解绑公众号
+     * @apiGroup OfficialAccount
+     * @apiName untie_distribution_official_account
+     * @apiParam   {String}  appid 渠道id.
+     */
+    public function untie_distribution_official_account(Request $request){
+    	$appid = $request->has('appid') ? $request->input('appid') : '';
+    	$force_untie = $request->has('force_untie') ? $request->input('force_untie') : '0';
+    	
+    	\Log::info('untie_distribution_official_account_start:'.$appid);
+    	
+    	if(empty($appid)) {
+    		return response()->error("PARAM_EMPTY");
+    	}
+    	
+    	// 找到公众号 
+    	$official_account = OfficialAccount::officialAccountArrByAppid($appid);
+    	if(empty($official_account)) {
+    		return response()->error("NOT_FOUND_OFFICIAL_ACCOUNT");
+    	}
+    	
+    	// 判断公众号的注册用户数,大于10个默认是老号不给删除,否则用户数据会异常
+    	$force_subscribe_count = ForceSubscribeUsers::forceSubscribeUsersCountByAppid($appid);
+    	\Log::info('untie_distribution_official_account_appid:'.$appid.' force_subscribe_count:'.$force_subscribe_count.' $force_untie:'.$force_untie);
+    	if($force_untie){
+    		// 强制解绑的话,大号也不行
+    		if($force_subscribe_count >=10000){
+    			return response()->error("OLD_APP_NOT_ALLOW_DELETE");
+    		}
+    	}else{
+    		// 小权限限制下500人
+    		if($force_subscribe_count >=500){
+    			return response()->error("OLD_APP_NOT_ALLOW_DELETE");
+    		}
+    	}
+    	
+    	// 备份
+    	$untie_offcial_account = object_to_array($official_account);
+    	UntieOfficialAccount::firstOrCreate($untie_offcial_account);
+    	
+    	// 删除OfficialAccount
+    	\Log::info('del_official_account:'.json_encode($official_account));
+    	OfficialAccount::deleteOfficialAccount($official_account['id']);
+    	
+    	// 删除redis中OfficialAccount缓存
+    	\Log::info('del_redis:'.'official_account_info:app_id:'.$appid);
+    	Redis::del('official_account_info:app_id:'.$appid);
+    	
+    	\Log::info('untie_distribution_official_account_end:'.$appid);
+    
+    	return response()->success(['status'=>'1']);
+    
+    }
+    
+    public function getUserClient(){
+    	return new Client(['base_uri' => env('MEDIA_API_BASE_URI')]);
+    }
+    
+    public function getAuthClient(){
+    	return new Client(['base_uri' => env('AUTH_API_BASE_URI')]);
+    }
+
+}