zhoulj 4 лет назад
Родитель
Сommit
67f3ed7cc4

+ 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,
+        ];
+    }
+}

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