From 4c45bfd64da02296be0165ea8e6c413d5a1f5ad9 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Fri, 16 Dec 2022 14:46:11 +0800 Subject: [PATCH] edit-sylive-kpi_order --- api/controllers/plan/Syt.php | 50 +++++++++++++++++++ .../libraries/market/Sylive2_data_entity.php | 2 +- common/libraries/market/Sylive2_entity.php | 2 +- home/controllers/h5/market/sylive2/Notify.php | 5 +- home/controllers/h5/market/sylive2/Stic.php | 10 ++-- 5 files changed, 61 insertions(+), 8 deletions(-) diff --git a/api/controllers/plan/Syt.php b/api/controllers/plan/Syt.php index fd660a30..73f2c6bf 100644 --- a/api/controllers/plan/Syt.php +++ b/api/controllers/plan/Syt.php @@ -466,4 +466,54 @@ class Syt extends CI_Controller echo '执行结束'; } } + + public function up_order_kpi(){ + $this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData'); + $this->load->library('market/sylive2_entity'); + $page = $this->input->get('page'); + $size = $this->input->get('size'); + !$page && $page = 1; + !$size && $size = 20; + $activityId = 6; + $time_start = strtotime('2022-12-16 00:00:00'); + $where = [ + 'activityId' => $activityId, + 'kpi' => 'order', + 'createTime<' => $time_start + ]; + $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,$size,'id,activityId,cfUserId'); + if($rows){ + foreach ($rows as $key => $val) { + $this->mdSytActivityKpiData->update(['kpi'=>'beforeOrder'],['id'=>$val['id']]); + $val['cfUserId'] && $this->sylive2_entity->kpi_count($activityId,'beforeOrder',$val['cfUserId']); + echo "执行成功:{$val['id']}\n"; + } + }else{ + echo '执行结束'; + } + } + + public function up_kpi_count(){ + $this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData'); + $this->load->library('market/sylive2_entity'); + $page = $this->input->get('page'); + $size = $this->input->get('size'); + !$page && $page = 1; + !$size && $size = 20; + $activityId = 6; + $where = [ + 'activityId' => $activityId, + 'kpi' => 'order', + 'id<=' => 237801 + ]; + $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,$size,'id,activityId,cfUserId'); + if($rows){ + foreach ($rows as $key => $val) { + $val['cfUserId'] && $this->sylive2_entity->kpi_count($activityId,'order',$val['cfUserId']); + echo "执行成功:{$val['id']}\n"; + } + }else{ + echo '执行结束'; + } + } } diff --git a/common/libraries/market/Sylive2_data_entity.php b/common/libraries/market/Sylive2_data_entity.php index b8f9a06f..5abbd3a9 100644 --- a/common/libraries/market/Sylive2_data_entity.php +++ b/common/libraries/market/Sylive2_data_entity.php @@ -8,7 +8,7 @@ class Sylive2_data_entity{ private $ci; private $map_kpi_biz = [ - 'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch' + 'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch','beforeOrder' => 'beforeOrderTotal' ]; public function __construct(){ diff --git a/common/libraries/market/Sylive2_entity.php b/common/libraries/market/Sylive2_entity.php index e1040faf..683b812f 100644 --- a/common/libraries/market/Sylive2_entity.php +++ b/common/libraries/market/Sylive2_entity.php @@ -6,7 +6,7 @@ class Sylive2_entity{ private $ci; private $map_kpi_biz = [ - 'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch' + 'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch','beforeOrder' => 'beforeOrderTotal' ]; public function __construct(){ diff --git a/home/controllers/h5/market/sylive2/Notify.php b/home/controllers/h5/market/sylive2/Notify.php index ab68a83b..57829daa 100644 --- a/home/controllers/h5/market/sylive2/Notify.php +++ b/home/controllers/h5/market/sylive2/Notify.php @@ -58,13 +58,16 @@ class Notify extends CI_Controller { throw new Exception("支付失败,sid={$sid}"); }else{ //支付成功 $res = $this->order_model->update(['status'=>1,'payTime'=>date('Y-m-d H:i:s')],['id'=>$order['id']]); + $act = $this->market_sylive_activity_model->get(['activityId'=>$order['activityId']]); + $kpi = time() > strtotime($act['timeStart']) ? 'order' : 'beforeOrder'; if($res){ $act_user = $this->act_user_model->get(['userId'=>$order['userId'],'activityId'=>$order['activityId']]); + $params = [ 'a_id' => $order['activityId'], 'uid' => $order['userId'], 'cf_uid' => $act_user['channelId'], - 'kpi' => 'order', + 'kpi' => $kpi, 'tagId' => $order['id'], 'jsondata'=> ['order_id'=>$order['id'],'sid'=>$sid,'mch_id'=>$this->mch_id], 'itemId' => $order['itemId'] diff --git a/home/controllers/h5/market/sylive2/Stic.php b/home/controllers/h5/market/sylive2/Stic.php index db12336b..2abe958a 100644 --- a/home/controllers/h5/market/sylive2/Stic.php +++ b/home/controllers/h5/market/sylive2/Stic.php @@ -169,7 +169,7 @@ class Stic extends Admin{ $owner_subscribe_count = $this->mdSytActivityKpiData->count($where); //订阅数据 $mine = [ ['title'=>'观看用户','num'=>"{$owner_browse_count}人",'url'=>'/h5/market/sylive2/stic/users?type=owner&kpi=watch'], - ['title'=>'下单数','num'=>"{$owner_subscribe_count}人",'url'=>'/h5/market/sylive2/stic/users?type=owner&kpi=order'], + ['title'=>'下单数','num'=>"{$owner_subscribe_count}单",'url'=>'/h5/market/sylive2/stic/users?type=owner&kpi=order'], ['title'=>'转化率','num'=>$owner_browse_count ? round($owner_subscribe_count/$owner_browse_count*100,2)."%" : 0], ]; $sub_lists = [ @@ -200,7 +200,7 @@ class Stic extends Admin{ $biz_subscribe_count = $this->mdSytActivityKpiData->count($where); //下单数据 $biz = [ ['title'=>'观看用户','num'=>"{$biz_browse_count}人",'url' => "/h5/market/sylive2/stic/users?type=biz&type_id={$biz_id}&kpi=watch"], - ['title'=>'下单数','num'=>"{$biz_subscribe_count}人",'url' => "/h5/market/sylive2/stic/users?type=biz&type_id={$biz_id}&kpi=order"], + ['title'=>'下单数','num'=>"{$biz_subscribe_count}单",'url' => "/h5/market/sylive2/stic/users?type=biz&type_id={$biz_id}&kpi=order"], ['title'=>'转化率','num'=>$biz_browse_count ? round($biz_subscribe_count/$biz_browse_count*100,2)."%" : 0], ]; $sub_lists[] = ['title'=>'本店','lists'=>$biz]; @@ -209,7 +209,7 @@ class Stic extends Admin{ $disk = $this->sylive2_entity->level_disk($this->a_id); if(!$group_row['groupsLevel'] && !$group_row['ifBiz']){//顶级 $browse_count = $this->mdSytActivityKpiData->count(['activityId' => $this->a_id, 'kpi' => 'watch']); //观看数据 - $subscribe_count = $this->market_sylive_order_model->count(['activityId' => $this->a_id, 'status' => 1]); //下单数据 + $subscribe_count = $this->market_sylive_order_model->count(['activityId' => $this->a_id, 'status' => 1,'createTime>='=>$row['timeStart']]); //下单数据 }else{ $browse_count = $group_row['watch'];//观看数据 $subscribe_count = $group_row['orderTotal'];//下单数据 @@ -221,7 +221,7 @@ class Stic extends Admin{ } $biz = [ ['title'=>'观看用户','num'=>"{$browse_count}人",'url'=>$b_url], - ['title'=>'下单数','num'=>"{$subscribe_count}人",'url'=>$sub_url], + ['title'=>'下单数','num'=>"{$subscribe_count}单",'url'=>$sub_url], ['title'=>'转化率','num'=>$browse_count ? round($subscribe_count/$browse_count*100,2)."%" : 0], ]; $title = $disk[$group_row['groupsLevel']+1]? '所有'.$disk[$group_row['groupsLevel']+1] : '所有门店'; @@ -500,7 +500,7 @@ class Stic extends Admin{ public function ajax_rank(){ $map_kpi_biz = [ - 'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch' + 'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch','beforeOrder' => 'beforeOrderTotal' ]; $params = $this->input->get(); $title = '';