Просмотр исходного кода

Merge branch 'master' of 47.110.49.99:wangdu/wangdu_public_api

zz 4 лет назад
Родитель
Сommit
e104d86f25
27 измененных файлов с 1707 добавлено и 8 удалено
  1. 2 2
      app/Console/Commands/BusinessChannelStatTask.php
  2. 78 0
      app/Console/Commands/Temp/CheckCidError.php
  3. 72 0
      app/Console/Commands/Temp/sendOrderTime.php
  4. 1 1
      app/Console/Commands/userProperty.php
  5. 3 3
      app/Console/Kernel.php
  6. 1 1
      app/Consts/SysConsts.php
  7. 14 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/CustomMsgControllerTransformer.php
  8. 17 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/CustomMsgSwitchTransformer.php
  9. 36 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/CustomSendMsgsTransformers.php
  10. 21 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/CustomSendStatsTransformers.php
  11. 41 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/OfficialAccountTransformer.php
  12. 25 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/SmartPushMsgTransformer.php
  13. 26 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/WechatKeyWordsMsgTransformer.php
  14. 18 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/WechatPublicTemplatesTransformer.php
  15. 43 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/WechatTemplatesMsgTransformer.php
  16. 22 0
      app/Http/Controllers/Channel/OfficialAccount/Transformers/WechatTemplatesTransformer.php
  17. 16 0
      app/Http/Controllers/Manage/BaseController.php
  18. 523 0
      app/Http/Controllers/Manage/OfficialAccount/CustomMsgController.php
  19. 130 0
      app/Http/Controllers/Manage/OfficialAccount/OfficialAccountsController.php
  20. 34 0
      app/Http/Controllers/Manage/OfficialAccount/Transformers/BatchCustomSendMsgsTransformers.php
  21. 38 0
      app/Http/Controllers/Manage/OfficialAccount/Transformers/CustomSendMsgsTransformers.php
  22. 25 0
      app/Http/Controllers/Manage/OfficialAccount/Transformers/CustomTemplateSendStatTransformer.php
  23. 27 0
      app/Http/Controllers/Manage/OfficialAccount/Transformers/OfficialAccountDaySubStatTransformer.php
  24. 38 0
      app/Http/Controllers/Manage/OfficialAccount/Transformers/OfficialAccountTransformer.php
  25. 215 0
      app/Http/Controllers/Manage/OfficialAccount/WeChatToolsController.php
  26. 235 0
      app/Jobs/SendStatisticsList.php
  27. 6 1
      app/Modules/Trade/Services/OrderDayStatService.php

+ 2 - 2
app/Console/Commands/BusinessChannelStatTask.php

@@ -75,8 +75,8 @@ class BusinessChannelStatTask extends Command
                 Log::info($channel['id']."日数据未生成".date("y-m-d H:i:s"."\n"));
                 continue;
             }
-            $userRegisterNum = $channel_day_data->register_user_num;//昨日注册
-            $sendOrderDataNum = $channel_day_data->send_order_num;//昨日派单创建数
+            $userRegisterNum = isset($channel_day_data->register_user_num)?$channel_day_data->register_user_num:0;//昨日注册
+            $sendOrderDataNum = isset($channel_day_data->send_order_num)?$channel_day_data->send_order_num:0;//昨日派单创建数
 
             try{
                 $paramsA = [

+ 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();
+
+        }
+    }
+
+}

+ 72 - 0
app/Console/Commands/Temp/sendOrderTime.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace App\Console\Commands\Temp;
+
+use Log;
+use Illuminate\Console\Command;
+use DB;
+
+class sendOrderTime extends Command
+{
+    /**
+     * 执行命令   php artisan temp:cal_send_order_time
+     *
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'temp:cal_send_order_time';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '派单时间';
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $this->genSendOrdertime('mysql');
+    }
+
+    public function genSendOrdertime($connecton = ''){
+        $channel_user_ids = DB::connection($connecton)->table('channel_users')
+            ->get()
+            ->pluck('id')
+            ->toArray();
+        $distribution_channel_ids = DB::connection($connecton)->table('distribution_channels')
+            ->whereIn('channel_user_id',$channel_user_ids)
+            ->get()
+            ->pluck('id')
+            ->toArray()
+        ;
+        dump(implode(',',$distribution_channel_ids));
+        $max_id = DB::connection($connecton)->table('send_order_first_order_times')->max('send_order_id');
+        if(!$max_id) $max_id=0;
+        $sql = "SELECT * FROM (select orders.created_at otime,send_orders.id send_order_id from send_orders 
+                left join users on send_orders.id = users.send_order_id
+                left join orders on orders.uid = users.id 
+                where send_orders.distribution_channel_id in(".implode(',',$distribution_channel_ids).")
+                and orders.status='PAID'
+                and send_orders.id >{$max_id}
+                ORDER BY orders.id asc) send_orders GROUP BY send_order_id";
+        $send_orders = DB::connection($connecton)->select($sql);
+        dump(count($send_orders));
+        foreach (array_chunk($send_orders, 500) as $send_order_set){
+            //通过强关进行状态更新
+            $insert = array();
+            foreach ($send_order_set as $send_order){
+                $insert[]= [
+                    'send_order_id'=>$send_order->send_order_id,
+                    'first_order_time'=>$send_order->otime,
+                ];
+            }
+            DB::connection($connecton)->table('send_order_first_order_times')->insert($insert);
+        }
+    }
+}

+ 1 - 1
app/Console/Commands/userProperty.php

@@ -45,7 +45,7 @@ class userProperty extends Command
     private function start(){
         $date_start = date('Y-m-d',time()-4*86400 );
         $date_end = date('Y-m-d',time()-3*86400 );
-        $SQL = "SELECT id FROM users WHERE created_at >=   '%s' created_at < '%s' and AND EXISTS (
+        $SQL = "SELECT id FROM users WHERE created_at >=   '%s' and created_at < '%s' AND EXISTS (
 
 SELECT id FROM orders WHERE orders.uid = users.id AND `status` = 'PAID' LIMIT 1
 )";

+ 3 - 3
app/Console/Kernel.php

@@ -159,7 +159,7 @@ class Kernel extends ConsoleKernel
         
         // temp
         Commands\Temp\NewBookTestType::class,
-        
+        Commands\Temp\CheckCidError::class,
 
     ];
 
@@ -394,8 +394,8 @@ class Kernel extends ConsoleKernel
         //站点配置
         $schedule->command('Tool:ConfigSetting')->dailyAt('11:33');
 
-        $schedule->command('cp_agent_book_day_stat')->dailyAt('01:27');
-        $schedule->command('cp_agent_day_stat')->dailyAt('01:44');
+//         $schedule->command('cp_agent_book_day_stat')->dailyAt('01:27');
+//         $schedule->command('cp_agent_day_stat')->dailyAt('01:44');
         $schedule->command('new_user_charge_day_statistic')->dailyAt('05:44');
 
 

+ 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

+ 14 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/CustomMsgControllerTransformer.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Http\Controllers\Channel\OfficialAccount\Transformers;
+
+class CustomMsgControllerTransformer
+{
+    public function transform($customMsg){
+        return [
+            // 'id'       =>  isset($customMsg->id) ? $customMsg->id : "",
+            // 'distribution_channel_id'       =>  isset($customMsg->distribution_channel_id) ? $customMsg->distribution_channel_id : "",
+            'customer_img_url'       =>  isset($customMsg->customer_img_url) ? $customMsg->customer_img_url : "",
+        ];
+    }
+}

+ 17 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/CustomMsgSwitchTransformer.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Controllers\Channel\OfficialAccount\Transformers;
+
+class CustomMsgSwitchTransformer
+{
+    public function transform($customMsgSwitchMsgs){
+        return [
+
+            'title'       =>  isset($customMsgSwitchMsgs->customMsgSwitchs->title) ? $customMsgSwitchMsgs->customMsgSwitchs->title : "",
+            'custom_category'       =>  isset($customMsgSwitchMsgs->custom_category) ? $customMsgSwitchMsgs->custom_category : "",
+            'status'       =>  isset($customMsgSwitchMsgs->status) ? $customMsgSwitchMsgs->status : "",
+            'distribution_channel_id'       =>  isset($customMsgSwitchMsgs->distribution_channel_id) ? $customMsgSwitchMsgs->distribution_channel_id : "",
+            'id'       =>  isset($customMsgSwitchMsgs->id) ? $customMsgSwitchMsgs->id : "",
+        ];
+    }
+}

+ 36 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/CustomSendMsgsTransformers.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Http\Controllers\Channel\OfficialAccount\Transformers;
+
+class CustomSendMsgsTransformers
+{
+    public function transform($customSendMsgs){
+        return [
+            'id'       =>  $customSendMsgs->id,
+            'appid'       =>  $customSendMsgs->appid,
+            'name'       =>  $customSendMsgs->name,
+            'send_time'       =>  $customSendMsgs->send_time,
+            'content'       =>  $customSendMsgs->content,
+            'description'       =>  isset($customSendMsgs->description)?$customSendMsgs->description:'',
+            'is_activity'       =>  isset($customSendMsgs->is_activity)?$customSendMsgs->is_activity:'0',
+            '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,
+            'is_full_send'       =>  $customSendMsgs->is_full_send,
+            'user_num'       =>  $customSendMsgs->user_num,
+            'uv'       =>  isset($customSendMsgs->uv)?$customSendMsgs->uv:'',
+            'pv'       =>  isset($customSendMsgs->pv)?$customSendMsgs->pv:'',
+            'register_user_num'       =>  isset($customSendMsgs->register_user_num)?$customSendMsgs->register_user_num:'',
+            'pay_user_num'       =>  isset($customSendMsgs->pay_user_num)?$customSendMsgs->pay_user_num:'',
+            'charge_amount'       =>  isset($customSendMsgs->charge_amount)?$customSendMsgs->charge_amount:'',
+            'book_name'       =>  isset($customSendMsgs->book_name)?$customSendMsgs->book_name:'',
+            'chapter_name'       =>  isset($customSendMsgs->chapter_name)?$customSendMsgs->chapter_name:'',
+            'user_category'       =>  isset($customSendMsgs->user_category)?$customSendMsgs->user_category:'',
+        ];
+    }
+}

+ 21 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/CustomSendStatsTransformers.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Http\Controllers\Channel\OfficialAccount\Transformers;
+
+class CustomSendStatsTransformers
+{
+    public function transform($customSendStats){
+        return [
+            'id'       =>  isset($customSendStats->id) ? $customSendStats->id : "",
+            'distribution_channel_id'       =>  isset($customSendStats->distribution_channel_id) ? $customSendStats->distribution_channel_id : "",
+            'date'       =>  isset($customSendStats->date) ? $customSendStats->date : "",
+            'push_user_num'       =>  isset($customSendStats->push_user_num) ? $customSendStats->push_user_num : 0,
+            'click_num'       =>  isset($customSendStats->click_num) ? $customSendStats->click_num : 0,
+            'amount'       =>  isset($customSendStats->amount) ? $customSendStats->amount : 0,
+            'success_pay_num'       =>  isset($customSendStats->success_pay_num) ? $customSendStats->success_pay_num : 0,
+            'success_pay_rate'       =>  isset($customSendStats->success_pay_rate) ? ($customSendStats->success_pay_rate).'%' : 0,
+            'click_rate'       =>  isset($customSendStats->click_rate) ? ($customSendStats->click_rate).'%' : 0,
+            'from'       =>  isset($customSendStats->from) ? $customSendStats->from : "",
+        ];
+    }
+}

+ 41 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/OfficialAccountTransformer.php

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

+ 25 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/SmartPushMsgTransformer.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Http\Controllers\Channel\OfficialAccount\Transformers;
+
+class SmartPushMsgTransformer
+{
+    public function transform($smartPushsMsg){
+        return [
+            'id'       =>   isset($smartPushsMsg->id)?$smartPushsMsg->id:'',
+            'distribution_channel_id'       =>   isset($smartPushsMsg->distribution_channel_id)?$smartPushsMsg->distribution_channel_id:'',
+            'name'       =>   isset($smartPushsMsg->name)?$smartPushsMsg->name:'',
+            'category_type'       =>   isset($smartPushsMsg->category_type)?$smartPushsMsg->category_type:'',
+            'content'       =>   isset($smartPushsMsg->content)?$smartPushsMsg->content:'',
+            'description'       =>   isset($smartPushsMsg->description)?$smartPushsMsg->description:'',
+            'book_name'       =>   isset($smartPushsMsg->book_name)?$smartPushsMsg->book_name:'',
+            'chapter_name'       =>   isset($smartPushsMsg->chapter_name)?$smartPushsMsg->chapter_name:'',
+            'sex'       =>   isset($smartPushsMsg->sex)?$smartPushsMsg->sex:'',
+            'appid'       =>  isset($smartPushsMsg->appid)?$smartPushsMsg->appid:'',
+            'status'       =>   isset($smartPushsMsg->status)?$smartPushsMsg->status:'',
+            'user_num'       =>  isset($smartPushsMsg->user_num)?$smartPushsMsg->user_num:'',
+            'created_at'       =>  isset($smartPushsMsg->created_at)?$smartPushsMsg->created_at:'',
+            'updated_at'       =>  isset($smartPushsMsg->updated_at)?$smartPushsMsg->updated_at:'',
+        ];
+    }
+}

+ 26 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/WechatKeyWordsMsgTransformer.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Http\Controllers\Channel\OfficialAccount\Transformers;
+
+class WechatKeyWordsMsgTransformer
+{
+    public function transform($wechatKeywordsMsg){
+        return [
+            'id'       =>  $wechatKeywordsMsg->id,
+            'keyword'       =>  $wechatKeywordsMsg->keyword,
+            'distribution_channel_id'       =>  $wechatKeywordsMsg->distribution_channel_id,
+            'bid'       =>  $wechatKeywordsMsg->bid,
+            'cid'       =>  $wechatKeywordsMsg->cid,
+            'appids'       =>  $wechatKeywordsMsg->appids,
+            'status'       =>  $wechatKeywordsMsg->status,
+            'book_name'       =>  $wechatKeywordsMsg->book_name,
+            'chapter_name'       =>  $wechatKeywordsMsg->chapter_name,
+            'send_title'       =>  isset($wechatKeywordsMsg->send_title)?$wechatKeywordsMsg->send_title:'',
+            'send_cover'       =>  isset($wechatKeywordsMsg->send_cover)?$wechatKeywordsMsg->send_cover:'',
+            'click_num'       =>  isset($wechatKeywordsMsg->click_num)?$wechatKeywordsMsg->click_num:'0',
+            'uv'       =>  isset($wechatKeywordsMsg->uv)?$wechatKeywordsMsg->uv:'0',
+            'new_subscribe_num'       =>  isset($wechatKeywordsMsg->new_subscribe_num)?$wechatKeywordsMsg->new_subscribe_num:'0',
+            'charge_amount'       =>  isset($wechatKeywordsMsg->charge_amount)?$wechatKeywordsMsg->charge_amount:'0',
+        ];
+    }
+}

+ 18 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/WechatPublicTemplatesTransformer.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Http\Controllers\Channel\OfficialAccount\Transformers;
+
+class WechatPublicTemplatesTransformer
+{
+    public function transform($wechatPublicTemplates){
+        return [
+            'common_template_id'       =>  $wechatPublicTemplates->common_template_id,
+            'title'       =>  $wechatPublicTemplates->title,
+            'primary_industry'       =>  $wechatPublicTemplates->primary_industry,
+            'deputy_industry'       =>  $wechatPublicTemplates->deputy_industry,
+            'content'       =>  $wechatPublicTemplates->content,
+            'example'       =>  $wechatPublicTemplates->example,
+            
+        ];
+    }
+}

+ 43 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/WechatTemplatesMsgTransformer.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace App\Http\Controllers\Channel\OfficialAccount\Transformers;
+
+class WechatTemplatesMsgTransformer
+{
+    public function transform($wechatTemplatesMsg){
+        return [
+            'id'       =>  $wechatTemplatesMsg->id,
+            'template_id'       =>  $wechatTemplatesMsg->template_id,
+            'name'       =>  $wechatTemplatesMsg->name,
+            'send_time'       =>  $wechatTemplatesMsg->send_time,
+            'template_content'       =>  $wechatTemplatesMsg->template_content,
+            'redirect_url'       =>  $wechatTemplatesMsg->redirect_url,
+            'appid'       =>  $wechatTemplatesMsg->appid,
+            'status'       =>  $wechatTemplatesMsg->status,
+            'remark'       =>  $wechatTemplatesMsg->remark,
+            'distribution_channel_id'       =>  $wechatTemplatesMsg->distribution_channel_id,
+            'common_template_id'       => $wechatTemplatesMsg->wechatTemplates->wechatPublicTemplates->common_template_id,
+            'title'       => $wechatTemplatesMsg->wechatTemplates->wechatPublicTemplates->title,
+            'primary_industry'       => $wechatTemplatesMsg->wechatTemplates->wechatPublicTemplates->primary_industry,
+            'deputy_industry'       => $wechatTemplatesMsg->wechatTemplates->wechatPublicTemplates->deputy_industry,
+            'content'       => $wechatTemplatesMsg->wechatTemplates->wechatPublicTemplates->content,
+            'example'       => $wechatTemplatesMsg->wechatTemplates->wechatPublicTemplates->example,
+            'subscribe_time'       =>  $wechatTemplatesMsg->subscribe_time,
+            'sex'       =>  $wechatTemplatesMsg->sex,
+            'balance'       =>  $wechatTemplatesMsg->balance,
+            'order_type'       =>  $wechatTemplatesMsg->order_type,
+            'category_id'       =>  $wechatTemplatesMsg->category_id,
+            'is_full_send'       =>  $wechatTemplatesMsg->is_full_send,
+            'user_num'       =>  $wechatTemplatesMsg->user_num,
+            'is_activity'       =>  isset($wechatTemplatesMsg->is_activity)?$wechatTemplatesMsg->is_activity:'0',
+            'user_category'       =>  isset($wechatTemplatesMsg->user_category)?$wechatTemplatesMsg->user_category:'',
+            'uv'       =>  isset($wechatTemplatesMsg->uv)?$wechatTemplatesMsg->uv:'',
+            'pv'       =>  isset($wechatTemplatesMsg->pv)?$wechatTemplatesMsg->pv:'',
+            'register_user_num'       =>  isset($wechatTemplatesMsg->register_user_num)?$wechatTemplatesMsg->register_user_num:'',
+            'pay_user_num'       =>  isset($wechatTemplatesMsg->pay_user_num)?$wechatTemplatesMsg->pay_user_num:'',
+            'charge_amount'       =>  isset($wechatTemplatesMsg->charge_amount)?$wechatTemplatesMsg->charge_amount:'',
+            'book_name'       =>  isset($wechatTemplatesMsg->book_name)?$wechatTemplatesMsg->book_name:'',
+            'chapter_name'       =>  isset($wechatTemplatesMsg->chapter_name)?$wechatTemplatesMsg->chapter_name:'',
+        ];
+    }
+}

+ 22 - 0
app/Http/Controllers/Channel/OfficialAccount/Transformers/WechatTemplatesTransformer.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Http\Controllers\Channel\OfficialAccount\Transformers;
+
+class WechatTemplatesTransformer
+{
+    public function transform($wechatTemplates){
+        return [
+            'appid'       =>  $wechatTemplates->appid,
+            'common_template_id'       =>  $wechatTemplates->common_template_id,
+            'template_id'       =>  $wechatTemplates->template_id,
+            // 'name'       =>  $wechatTemplates->WechatTemplateMsg->name,
+            // 'send_time'       =>  $wechatTemplates->WechatTemplateMsg->send_time,
+            // 'template_content'       =>  $wechatTemplates->WechatTemplateMsg->template_content,
+            // 'redirect_url'       =>  $wechatTemplates->WechatTemplateMsg->redirect_url,
+            // 'send_appid'       =>  $wechatTemplates->WechatTemplateMsg->send_appid,
+            // 'status'       =>  $wechatTemplates->WechatTemplateMsg->status,
+            // 'remark'       =>  $wechatTemplates->WechatTemplateMsg->remark,
+            // 'distribution_channel_id'       =>  $wechatTemplates->WechatTemplateMsg->distribution_channel_id,
+        ];
+    }
+}

+ 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
+{
+
+}

Разница между файлами не показана из-за своего большого размера
+ 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')]);
+    }
+
+}

+ 235 - 0
app/Jobs/SendStatisticsList.php

@@ -0,0 +1,235 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
+use App\Modules\OfficialAccount\Models\OfficialAccount;
+use App\Modules\Statistic\Models\SendOrderBreadevenStat;
+use App\Modules\User\Services\UserDivisionCpcPropertyService;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class SendStatisticsList extends Job implements ShouldQueue
+{
+    use InteractsWithQueue, SerializesModels;
+    private $data;
+
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct($data)
+    {
+        $data['send_time']=date("Y-m-d H:i:s");
+        $this->data = $data;
+    }
+ 
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+
+        if($this->data['type'] == 'order_info'){
+            $this->orderInfo($this->data['data']);
+        }elseif($this->data['type'] == 'visit'){
+            $this->visit($this->data['data']['openid']);
+        }elseif($this->data['type'] == 'subscribe'){
+//            \Log::info('SendStatisticsList data is');
+//            \Log::info($this->data);
+            $this->subscribe($this->data['data']['uid']);
+        }
+        else{
+            $this->subscribe_info($this->data['data']);
+        }
+
+    }
+
+
+    private function orderInfo($order_info){
+
+        $uid = $order_info['uid'];
+        \Log::info('orderInfo_start:'.$uid);
+        $sub_info = ForceSubscribeUsers::where('uid',$uid)->select('official_account_id','appid','created_at','distribution_channel_id')->first();
+        if(is_null($sub_info)){
+            \Log::info('sub_info_is_null:'.$uid);
+            return ;
+        }
+        $official = OfficialAccount::where('appid',$sub_info->appid)->select('id','nickname')->first();
+
+        $date = date('Y-m-d',strtotime($sub_info->created_at));
+        $old = $this->getDateRes($date,$sub_info->distribution_channel_id,$official->id);
+        $pay_end = $order_info['pay_end_at'];
+        $sub_timestamp = strtotime($sub_info->created_at);
+        if($pay_end){
+            $pay_end_timestamp = strtotime($pay_end);
+        }else{
+            $pay_end_timestamp = time();
+        }
+        $del = $pay_end_timestamp-$sub_timestamp;
+        if($old){
+
+            if($del <= 86400){
+                $old->recharge_amount_in_one_day = $old->recharge_amount_in_one_day+$order_info['price'];
+                $old->recharge_amount_in_three_days = $old->recharge_amount_in_three_days+$order_info['price'];
+                $old->recharge_amount_in_one_month = $old->recharge_amount_in_one_month+$order_info['price'];
+                $old->recharge_amount_in_two_months = $old->recharge_amount_in_two_months+$order_info['price'];
+                $old->recharge_amount_in_three_months = $old->recharge_amount_in_three_months+$order_info['price'];
+            }
+            if($del > 86400 && $del<= 86400*3){
+                $old->recharge_amount_in_three_days = $old->recharge_amount_in_three_days+$order_info['price'];
+                $old->recharge_amount_in_one_month = $old->recharge_amount_in_one_month+$order_info['price'];
+                $old->recharge_amount_in_two_months = $old->recharge_amount_in_two_months+$order_info['price'];
+                $old->recharge_amount_in_three_months = $old->recharge_amount_in_three_months+$order_info['price'];
+            }
+
+            if($del > 86400*3 && $del <= 30*86400){
+                $old->recharge_amount_in_one_month = $old->recharge_amount_in_one_month+$order_info['price'];
+                $old->recharge_amount_in_two_months = $old->recharge_amount_in_two_months+$order_info['price'];
+                $old->recharge_amount_in_three_months = $old->recharge_amount_in_three_months+$order_info['price'];
+            }
+
+            if($del > 30*86400 && $del <= 60*86400){
+                $old->recharge_amount_in_two_months = $old->recharge_amount_in_two_months+$order_info['price'];
+                $old->recharge_amount_in_three_months = $old->recharge_amount_in_three_months+$order_info['price'];
+            }
+
+            if($del> 60*86400 && $del <= 90*86400){
+                $old->recharge_amount_in_three_months = $old->recharge_amount_in_three_months+$order_info['price'];
+            }
+            $old->save();
+        }else{
+
+            $nickname = '未知';
+            $official_account_id = 0;
+            if($official && isset($official->nickname)){
+                $nickname = $official->nickname;
+            }
+            if($official && isset($official->id)){
+                $official_account_id = $official->id;
+            }
+            $data = [];
+            $data['recharge_amount_in_one_day'] = 0;
+            $data['recharge_amount_in_three_days'] = 0;
+            $data['recharge_amount_in_one_month'] = 0;
+            $data['recharge_amount_in_two_months'] = 0;
+            $data['recharge_amount_in_three_months'] = 0;
+            $data['distribution_channel_id'] = $sub_info->distribution_channel_id;
+            $data['official_account_id'] = $official_account_id;
+            $data['official_account_name'] = $nickname;
+            $data['date'] = $date;
+            $data['force_user_num'] = 0;
+            $data['total_force_user_num']  = 0;
+            $data['unsubscribe_in_one_day_user_num'] =0;
+            if($del <= 86400){
+                $data['recharge_amount_in_one_day'] = $order_info['price'];
+                $data['recharge_amount_in_three_days'] = $order_info['price'];
+                $data['recharge_amount_in_one_month'] = $order_info['price'];
+                $data['recharge_amount_in_two_months'] = $order_info['price'];
+                $data['recharge_amount_in_three_months'] = $order_info['price'];
+            }
+            if($del > 86400 && $del<= 86400*3){
+                $data['recharge_amount_in_three_days'] = $order_info['price'];
+                $data['recharge_amount_in_one_month'] = $order_info['price'];
+                $data['recharge_amount_in_two_months'] = $order_info['price'];
+                $data['recharge_amount_in_three_months'] = $order_info['price'];
+            }
+
+            if($del > 86400*3 && $del <= 30*86400){
+                $data['recharge_amount_in_one_month'] = $order_info['price'];
+                $data['recharge_amount_in_two_months'] = $order_info['price'];
+                $data['recharge_amount_in_three_months'] = $order_info['price'];
+            }
+
+            if($del > 30*86400 && $del <= 60*86400){
+                $data['recharge_amount_in_two_months'] = $order_info['price'];
+                $data['recharge_amount_in_three_months'] = $order_info['price'];
+            }
+
+            if($del> 60*86400 && $del <= 90*86400){
+                $data['recharge_amount_in_three_months'] = $order_info['price'];
+            }
+
+            SendOrderBreadevenStat::create($data);
+        }
+    }
+
+    private function subscribe_info($subscribe_info){
+        $subscribe_info = (array) $subscribe_info;
+        $date = date('Y-m-d',strtotime($subscribe_info['created_at']));
+        $official = OfficialAccount::where('appid',$subscribe_info['appid'])->select('id','nickname')->first();
+        $old = $this->getDateRes($date,$subscribe_info['distribution_channel_id'],$official->id);
+
+        if($old){
+            if( (strtotime($subscribe_info['unsubscribe_time']) -  strtotime($subscribe_info['created_at']) ) < 86400){
+                $old->unsubscribe_in_one_day_user_num +=1;
+                $old->save();
+            }
+        }else{
+            $data = [];
+
+
+            $nickname = '未知';
+            $official_account_id = 0;
+            if($official && isset($official->nickname)){
+                $nickname = $official->nickname;
+            }
+            if($official && isset($official->id)){
+                $official_account_id = $official->id;
+            }
+            $data['recharge_amount_in_one_day'] = 0;
+            $data['recharge_amount_in_three_days'] = 0;
+            $data['recharge_amount_in_one_month'] = 0;
+            $data['recharge_amount_in_two_months'] = 0;
+            $data['recharge_amount_in_three_months'] = 0;
+            $data['distribution_channel_id'] = $subscribe_info['distribution_channel_id'];
+            $data['official_account_id'] = $official_account_id;
+            $data['official_account_name'] = $nickname;
+            $data['date'] = $date;
+            $data['force_user_num'] = 0;
+            $data['total_force_user_num']  = 0;
+
+            if( (strtotime($subscribe_info['unsubscribe_time']) -  strtotime($subscribe_info['created_at']) ) < 86400){
+                $data['unsubscribe_in_one_day_user_num'] =1;
+            }
+
+            SendOrderBreadevenStat::create($data);
+        }
+    }
+
+
+    private function subscribe($uid){
+        if(!is_numeric($uid)) return ;
+        //UserDivisionCpcPropertyService::afterForceSubscribe($uid);
+    }
+
+    private function visit($openid){
+        $user = UserDivisionCpcPropertyService::userLevel($openid);
+        if(!$user){
+            return ;
+        }
+        if($user->type != 'NEW'){
+            return ;
+        }
+
+        $level = UserDivisionCpcPropertyService::getUserSubscribeAndChargeInfoByOpenid($openid);
+        if(!$level) return ;
+
+        if($level['type'] == $user->type) return ;
+
+        UserDivisionCpcPropertyService::update($openid,$level['property'],$level['type']);
+    }
+
+    private function getDateRes($date,$distribution_channel_id,$official_account_id){
+        return SendOrderBreadevenStat::where('date',$date)
+            ->where('distribution_channel_id',$distribution_channel_id)
+            ->where('official_account_id',$official_account_id)
+            ->first();
+    }
+
+
+}

+ 6 - 1
app/Modules/Trade/Services/OrderDayStatService.php

@@ -101,7 +101,12 @@ class OrderDayStatService
         {
             $channel_merchant_recharge_amount = DB::select("select sum(price) amount from orders join pay_merchants on pay_merchants.id=orders.pay_merchant_id where orders.distribution_channel_id = '{$distribution_channel_id}' and orders.created_at > '{$date}' and orders.created_at <= '{$end_time}' and orders.status ='PAID' and pay_merchants.is_self_channel <> 1 and orders.pay_merchant_id not in (44,41)");//pay_merchant_id in ({$not_in_pay_merchant_ids})
         }
-        $data['channel_merchant_recharge_amount'] = (float)$channel_merchant_recharge_amount[0]->amount;
+        
+        if(isset($channel_merchant_recharge_amount[0]->amount)){
+            $data['channel_merchant_recharge_amount'] = (float)$channel_merchant_recharge_amount[0]->amount;
+        }else{
+            $data['channel_merchant_recharge_amount'] = 0;
+        }
 
         //首充数据
         $first_recharge_data = OrderService::getChannelDayFirstRechargeData($distribution_channel_id,$date);