From 16dbdca9b25163a042d4e988e50bf85cf959115d Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Wed, 14 Dec 2022 17:05:45 +0800 Subject: [PATCH] add-sylive-item_limit --- home/controllers/h5/market/sylive2/Item.php | 15 ++- home/controllers/h5/market/sylive2/Stic.php | 105 ++++++++++++++++++- home/views/h5/market/sylive2/item/detail.php | 15 ++- home/views/h5/market/sylive2/stic/index.php | 93 +++++++++++++++- 4 files changed, 217 insertions(+), 11 deletions(-) diff --git a/home/controllers/h5/market/sylive2/Item.php b/home/controllers/h5/market/sylive2/Item.php index 5f6cfdcd..7cf70114 100644 --- a/home/controllers/h5/market/sylive2/Item.php +++ b/home/controllers/h5/market/sylive2/Item.php @@ -20,6 +20,7 @@ class Item extends Wx{ $param = $this->myencryption->base64url_decode($skey); $a_id = intval($param['a_id']);//活动id $itemId = intval($param['itemId']);//商品id + $itemId = $this->input->get('item_id'); $row = $this->market_sylive_items_model->get(['itemId'=>$itemId,'activityId'=>$a_id]); $act = $this->market_sylive_activity_model->get(['activityId'=>$a_id]); if(!$row){ @@ -87,7 +88,8 @@ class Item extends Wx{ 'live_url' => $live_url, 'a_id' => $a_id, 'ifAddress' => $row['ifAddress'], - 'protocolTitle' => $act['protocolTitle'] + 'protocolTitle' => $act['protocolTitle'], + 'item_status' => $row['status'] ]; $this->data['province_arr'] = $province_arr; $this->data['city_arr'] = $city_arr; @@ -119,6 +121,9 @@ class Item extends Wx{ if(!$row){ $this->show_json('',400,'参数错误'); } + if($row['status']){ + $this->show_json('',400,'商品已下架'); + } if(time()< strtotime($row['timeStart'])){ $this->show_json('',400,'尚未开始'); } @@ -237,10 +242,12 @@ class Item extends Wx{ if(!mobile_valid($mobile)){ $this->show_json('',400,'请输入正确的手机号码'); } - if($item_id==8){ //特殊处理需要先购买权益商品 - $where = ['itemId'=>10,'userId'=>$this->uid]; + $item_row = $this->market_sylive_items_model->get(['itemId'=>$item_id,'activityId'=>$a_id]); + if($item_row['needItemId']){ //特殊处理需要先购买权益商品 + $where = ['itemId'=>$item_row['needItemId'],'userId'=>$this->uid]; if(!$this->market_sylive_order_model->count($where)){ - $this->show_json('',400,'请先购买权益'); + $need_item_row = $this->market_sylive_items_model->get(['itemId'=>$item_row['needItemId']],'title'); + $this->show_json('',400,"购买{$need_item_row['title']}方可获得秒杀资格"); } } $act = $this->market_sylive_activity_model->get(['activityId'=>$a_id]); diff --git a/home/controllers/h5/market/sylive2/Stic.php b/home/controllers/h5/market/sylive2/Stic.php index 86064207..daa2bb13 100644 --- a/home/controllers/h5/market/sylive2/Stic.php +++ b/home/controllers/h5/market/sylive2/Stic.php @@ -35,13 +35,16 @@ class Stic extends Admin{ $info['headimg'] = $user['headimg']; $group_user = $this->groups_user_model->get(['activityId'=>$this->a_id,'userId'=>$this->uid,'status'=>0]); $info['group_name'] = ''; + $info['is_biz'] = $group_user['bizId'] ? 1 : 0; + $info['biz_id'] = $group_user['biz_id'] ? $group_user['biz_id'] : 0; if($groupsId){ $group_lists = $this->sylive2_entity->get_group_lists($groupsId,$this->a_id); unset($group_lists[0]); $info['group_name'] = implode(' ',array_column($group_lists,'groupsName')); + $groups = $this->groups_model->get(['groupsId'=>$groupsId]); + $info['biz_id'] = $groups['ifBiz'] ? $groups['groupsId'] : 0; } $info['groupsId'] = $groupsId ? $groupsId : $group_user['groupsId']; - $info['is_biz'] = $group_user['bizId'] ? 1 : 0; $info['tab'] = time()>=strtotime($row['timeStart']) ? 2 : 1; $this->data['info'] = $info; //微信分享 @@ -607,4 +610,104 @@ class Stic extends Admin{ $this->data['share'] = $wx_info['share']; $this->show_view('h5/market/sylive2/stic/rank'); } + + public function ajax_line(){ + $type = $this->input->get('type'); + $biz_id = $this->input->get('biz_id'); + $row = $this->market_sylive_activity_model->get(['activityId'=>$this->a_id],'activityStart,timeStart,timeEnd'); + $xAxisData = []; + if($type==2){ + $activityStart = strtotime($row['timeStart']); + $end_time = strtotime($row['timeEnd']); + $diff_seconds = $end_time - $activityStart; + $diff_hour = ceil($diff_seconds/3600); +// $where = [ +// 'activityId' => $this->a_id, +// 'bizId' => $biz_id, +// 'kpi' => 'watch', +// 'createTime>=' => $activityStart, +// 'createTime<=' => $end_time, +// ]; +// $watch_kpi_rows = $this->mdSytActivityKpiData->select_groupby('ctime',$where,'',0,0,'from_unixtime(createTime,"%H") as ctime,count(id) as total'); +// $where['kpi'] = 'order'; +// $order_kpi_rows = $this->mdSytActivityKpiData->select_groupby('ctime',$where,'',0,0,'from_unixtime(createTime,"%H") as ctime,count(id) as total'); +// $temp_s_data = $temp_b_data = []; + for($i=0;$i<$diff_hour;$i++){ + $xAxisData[] = date('H:00',$activityStart + $i*60*60).'-'.date('H:00',$activityStart + ($i+1)*60*60); + $watch_data[] = 0; + $order_data[] = 0; + } + $title = '直播走势图'; + $legendData = ['观看数', '订单数']; + $seriesData = [ + [ + 'name' => '观看数', + 'type' => 'line', + 'data' => $watch_data + ], + [ + 'name' => '订单数', + 'type' => 'line', + 'data' => $order_data + ], + ]; +// $xAxisData = ['9:00-10:00', '10:00-11:00', '11:00-12:00', '12:00-13:00']; + }else{ + $activityStart = strtotime($row['activityStart'])>0 ? strtotime($row['activityStart']) : strtotime($row['timeStart'])-7*24*60*60; + $end_time = time()< strtotime($row['timeStart']) ? time() : strtotime($row['timeStart']); + $diff_seconds = $end_time - $activityStart; + $diff_days = ceil($diff_seconds/86400); + $where = [ + 'activityId' => $this->a_id, + 'bizId' => $biz_id, + 'kpi' => 'browse', + 'createTime>=' => $activityStart, + 'createTime<=' => $end_time, + ]; + $browse_kpi_rows = $this->mdSytActivityKpiData->select_groupby('day',$where,'',0,0,'day,count(id) as total'); + $where['kpi'] = 'subscribe'; + $subscribe_rows = $this->mdSytActivityKpiData->select_groupby('day',$where,'',0,0,'day,count(id) as total'); + $temp_s_data = $temp_b_data = []; + if($browse_kpi_rows){ + foreach ($browse_kpi_rows as $item) { + $temp_b_data[$item['day']] = $item['total']; + } + } + if($temp_s_data){ + foreach ($subscribe_rows as $item) { + $temp_s_data[$item['day']] = $item['total']; + } + } + $browse_data = $subscribe_data = []; + for($i=0;$i<$diff_days;$i++){ + $xAxisData[] = date('m.d',$activityStart + $i*24*60*60); + $day = date('Y-m-d',$activityStart + $i*24*60*60); + $browse_data[] = $temp_b_data[$day] ? $temp_b_data[$day] : 0; + $subscribe_data[] = $temp_s_data[$day] ? $temp_s_data[$day] : 0; + } + $title = '预热走势图'; + $legendData = ['访问数', '订阅数']; + $seriesData = [ + [ + 'name' => '访问数', + 'type' => 'line', + 'data' => $browse_data + ], + [ + 'name' => '订阅数', + 'type' => 'line', + 'data' => $subscribe_data + ], + ]; + + } + + $data = [ + 'title' => $title, + 'legendData' => $legendData, + 'xAxisData' => $xAxisData, + 'seriesData' => $seriesData + ]; + $this->show_json($data,200); + } } \ No newline at end of file diff --git a/home/views/h5/market/sylive2/item/detail.php b/home/views/h5/market/sylive2/item/detail.php index d0416935..7dbeab19 100644 --- a/home/views/h5/market/sylive2/item/detail.php +++ b/home/views/h5/market/sylive2/item/detail.php @@ -45,11 +45,16 @@
活动已结束
diff --git a/home/views/h5/market/sylive2/stic/index.php b/home/views/h5/market/sylive2/stic/index.php index fc2b7871..193012ad 100644 --- a/home/views/h5/market/sylive2/stic/index.php +++ b/home/views/h5/market/sylive2/stic/index.php @@ -1,3 +1,4 @@ +
@@ -34,7 +35,7 @@
@@ -83,6 +91,12 @@
+
+
+ +
+
+
@@ -184,6 +198,23 @@ title:'', list:[], }, + lineChart:{ + // title:'', + // legendData:['观看数', '订单数'], + // xAxisData:['9:00-10:00', '10:00-11:00', '11:00-12:00', '12:00-13:00'], + // seriesData:[ + // { + // name: '观看数', + // type: 'line', + // data: [120, 90, 230, 210] + // }, + // { + // name: '订单数', + // type: 'line', + // data: [220, 18, 191, 234] + // }, + // ] + } }, created(){ @@ -249,6 +280,8 @@ let mainoffsetTop = document.querySelector('#main').offsetTop $('html,body').animate({scrollTop: mainoffsetTop+5},500); } + $('#liveChart').hide() + $('#beginChart').hide() this.tabid = id this.tabIndex = index this.isNoData = false @@ -278,6 +311,7 @@ that.h_lists = result.data.h_lists that.sub_lists = result.data.sub_lists },'json') + this.lineData() }, //拉取数据 @@ -298,6 +332,7 @@ that.h_lists = result.data.h_lists that.sub_lists = result.data.sub_lists },'json') + // this.lineData() }, //获取大区列表 @@ -358,6 +393,62 @@ } }, 'json') }, + lineData(){ + if(!this.biz_id){ + return ''; + } + var that = this + $.get('/h5/market/sylive2/stic/ajax_line',{'type':that.tabid,'biz_id':that.biz_id}, function (response) { + console.dir(response) + that.lineChart = response.data + var dom; + setTimeout(function () { + if(that.tabid==2){ + $('#liveChart').show() + dom = document.getElementById('liveChart'); + }else{ + $('#beginChart').show() + dom = document.getElementById('beginChart'); + } + let myChart = echarts.init(dom, null, { + renderer: 'canvas', + useDirtyRect: false + }); + let option; + option = { + tooltip: { + trigger: 'axis' + }, + legend: { + top: 'bottom', + data: that.lineChart.legendData, + }, + grid: { + top: '4%', + left: '2%', + right: '2%', + bottom: '11%', + containLabel: true + }, + xAxis: { + type: 'category', + boundaryGap: false, + data: that.lineChart.xAxisData, + }, + yAxis: { + type: 'value' + }, + series: that.lineChart.seriesData, + }; + if (option && typeof option === 'object') { + myChart.setOption(option); + } + window.addEventListener('resize', myChart.resize); + }, 100); + },'json') + + } + }, })