From 9fadfc483719e880069a70631e27ffb0bb596754 Mon Sep 17 00:00:00 2001 From: dengbw Date: Fri, 30 Sep 2022 09:52:48 +0800 Subject: [PATCH] market_930 --- market/controllers/api/Login.php | 9 +- market/controllers/api/auth/User.php | 3 +- market/controllers/api/sylive/Activity.php | 96 +++++++++++++++++++--- 3 files changed, 90 insertions(+), 18 deletions(-) diff --git a/market/controllers/api/Login.php b/market/controllers/api/Login.php index 78ba5ac5..49b0a191 100644 --- a/market/controllers/api/Login.php +++ b/market/controllers/api/Login.php @@ -58,7 +58,8 @@ class Login extends BaseController , 'loginType' => 1, 'comments' => $message]); $this->return_json($message); } - $user = ['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname'], 'avatar' => "https://cdn.eleadmin.com/20200610/avatar.jpg" + $user = ['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname'] + , 'avatar' => "https://qs.haodian.cn/web/images/project/H5-ShiYu/default-avatar.jpg" , 'sex' => $re['sex'], 'phone' => $re['phone'], 'introduction' => $re['introduction'], 'email' => $re['email'] , 'enabled' => true, 'accountNonLocked' => true, 'credentialsNonExpired' => true, 'accountNonExpired' => true]; $roles = $authorities = []; @@ -84,12 +85,6 @@ class Login extends BaseController } $user['roles'] = $roles; $user['authorities'] = $authorities; -// $user['authorities'] = [ -// ['menuId' => 1, 'parentId' => 0, 'title' => "系统管理", 'path' => '/system', 'component' => null, 'menuType' => 0, 'sortNumber' => 1, 'authority' => null, 'icon' => 'el-icon-setting', 'hide' => 0, 'meta' => ['badge' => 'New', 'badgeColor' => 'warning'], 'deleted' => 0, 'createTime' => '2020-02-26 12:51:23', 'updateTime' => '2022-03-11 16:46:28', 'children' => null, 'checked' => null], -// ['menuId' => 2, 'parentId' => 1, 'title' => "用户管理", 'path' => '/system/user', 'component' => '/system/user', 'menuType' => 0, 'sortNumber' => 1, 'authority' => null, 'icon' => 'el-icon-_user-group', 'hide' => 0, 'meta' => null, 'deleted' => 0, 'createTime' => '2020-02-26 12:51:55', 'updateTime' => '2021-05-21 17:56:28', 'children' => null, 'checked' => null], -// ['menuId' => 7, 'parentId' => 1, 'title' => "角色管理", 'path' => '/system/role', 'component' => '/system/role', 'menuType' => 0, 'sortNumber' => 2, 'authority' => null, 'icon' => 'el-icon-postcard', 'hide' => 0, 'meta' => null, 'deleted' => 0, 'createTime' => '2020-03-13 13:29:08', 'updateTime' => '2021-05-21 17:56:34', 'children' => null, 'checked' => null], -// ['menuId' => 12, 'parentId' => 1, 'title' => "菜单管理", 'path' => '/system/menu', 'component' => '/system/menu', 'menuType' => 0, 'sortNumber' => 3, 'authority' => null, 'icon' => 'el-icon-s-operation', 'hide' => 0, 'meta' => null, 'deleted' => 0, 'createTime' => '2020-03-21 01:07:13', 'updateTime' => '2021-05-21 17:56:39', 'children' => null, 'checked' => null] -// ]; $data['access_token'] = Authorization::generateToken($re['userId']); $data['user'] = $user; $this->record->loginRecord(['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname']]); diff --git a/market/controllers/api/auth/User.php b/market/controllers/api/auth/User.php index ae21b2eb..dd0ae7af 100644 --- a/market/controllers/api/auth/User.php +++ b/market/controllers/api/auth/User.php @@ -20,7 +20,8 @@ class User extends BaseController public function index_get() { $re = $_SESSION; - $user = ['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname'], 'avatar' => "https://cdn.eleadmin.com/20200610/avatar.jpg" + $user = ['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname'] + , 'avatar' => "https://qs.haodian.cn/web/images/project/H5-ShiYu/default-avatar.jpg" , 'sex' => $re['sex'], 'phone' => $re['phone'], 'introduction' => $re['introduction'], 'email' => $re['email'] , 'enabled' => true, 'accountNonLocked' => true, 'credentialsNonExpired' => true, 'accountNonExpired' => true]; $roles = $authorities = []; diff --git a/market/controllers/api/sylive/Activity.php b/market/controllers/api/sylive/Activity.php index 1717ed46..07bb8da7 100644 --- a/market/controllers/api/sylive/Activity.php +++ b/market/controllers/api/sylive/Activity.php @@ -47,7 +47,7 @@ class Activity extends BaseController $dateRange = [$v['timeStart'], $v['timeEnd']]; $status = intval($v['status']); $activityId = intval($v['activityId']); - $bgImg = $channelImg = $shareImg = $shareTitle = $bizIds = []; + $bgImg = $channelImg = $sharePhoto = $shareImg = $shareTitle = $bizIds = []; $item = ['activityId' => $activityId, 'itemImg' => [], 'title' => '', 'introduction' => '', 'price' => '', 'dateRange' => '']; $v['shareTitle'] && $shareTitle = json_decode($v['shareTitle'], true); $jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : []; @@ -71,6 +71,9 @@ class Activity extends BaseController if ($v['channelImg']) { $channelImg = [['uid' => 1, 'fileUrl' => $v['channelImg'], 'url' => build_qiniu_image_url($v['channelImg']), 'status' => 'done']]; } + if ($v['sharePhoto']) { + $sharePhoto = [['uid' => 1, 'fileUrl' => $v['sharePhoto'], 'url' => build_qiniu_image_url($v['sharePhoto']), 'status' => 'done']]; + } if ($v['shareImg']) { $getShareImg = json_decode($v['shareImg'], true); foreach ($getShareImg as $k2 => $v2) { @@ -87,7 +90,7 @@ class Activity extends BaseController $list[] = [ 'activityId' => $activityId, 'title' => $v['title'], 'channelId' => $v['channelId'], 'bizIds' => $bizIds, 'introduction' => $v['introduction'], 'shareTitle' => $shareTitle, 'dateRange' => $dateRange - , 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'shareImg' => $shareImg, 'item' => $item, 'url' => $url + , 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'sharePhoto' => $sharePhoto, 'shareImg' => $shareImg, 'item' => $item, 'url' => $url , 's_time' => $v['timeStart'], 'e_time' => $v['timeEnd'], 'status' => $status, 'createTime' => $v['createTime']]; } } @@ -110,6 +113,7 @@ class Activity extends BaseController $shareImg = $this->input_param('shareImg'); $bgImg = $this->input_param('bgImg'); $channelImg = $this->input_param('channelImg'); + $sharePhoto = $this->input_param('sharePhoto'); $bizIds = $this->input_param('bizIds'); if (!$title) { $this->return_json('请输入活动标题'); @@ -130,6 +134,7 @@ class Activity extends BaseController $this->return_json('请输入活动简介'); } $bgImg = $bgImg[0]['fileUrl']; + $sharePhoto = $sharePhoto[0]['fileUrl'] ? $sharePhoto[0]['fileUrl'] : ''; $channelImg = $channelImg[0]['fileUrl'] ? $channelImg[0]['fileUrl'] : ''; $shareTitle && $shareTitle = json_encode($shareTitle, JSON_UNESCAPED_UNICODE); $setShareImg = ''; @@ -140,8 +145,8 @@ class Activity extends BaseController $setShareImg = json_encode($setShareImg, JSON_UNESCAPED_UNICODE); } $addDate = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId - , 'introduction' => $introduction, 'shareTitle' => $shareTitle, 'shareImg' => $setShareImg, 'timeStart' => $dateRange[0] - , 'timeEnd' => $dateRange[1], 'status' => 1, 'createTime' => date('Y-m-d H:i:s')]; + , 'introduction' => $introduction, 'shareTitle' => $shareTitle, 'sharePhoto' => $sharePhoto, 'shareImg' => $setShareImg + , 'timeStart' => $dateRange[0], 'timeEnd' => $dateRange[1], 'status' => 1, 'createTime' => date('Y-m-d H:i:s')]; $activityId = $this->mdSyliveActivity->add($addDate); if (!$activityId) { $this->return_json('添加活动失败'); @@ -196,6 +201,7 @@ class Activity extends BaseController $shareImg = $this->input_param('shareImg'); $bgImg = $this->input_param('bgImg'); $channelImg = $this->input_param('channelImg'); + $sharePhoto = $this->input_param('sharePhoto'); $bizIds = $this->input_param('bizIds'); if (!$activityId) { $this->return_json('参数错误'); @@ -237,6 +243,7 @@ class Activity extends BaseController $add_biz && $this->mdSyliveActivityBiz->add_batch($add_biz); } $bgImg = $bgImg[0]['fileUrl']; + $sharePhoto = $sharePhoto[0]['fileUrl'] ? $sharePhoto[0]['fileUrl'] : ''; $channelImg = $channelImg[0]['fileUrl'] ? $channelImg[0]['fileUrl'] : ''; $shareTitle && $shareTitle = json_encode($shareTitle, JSON_UNESCAPED_UNICODE); $setShareImg = ''; @@ -247,7 +254,7 @@ class Activity extends BaseController $setShareImg = json_encode($setShareImg, JSON_UNESCAPED_UNICODE); } $upDate = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'introduction' => $introduction, - 'shareTitle' => $shareTitle, 'shareImg' => $setShareImg, 'timeStart' => $dateRange[0], 'timeEnd' => $dateRange[1]]; + 'shareTitle' => $shareTitle, 'sharePhoto' => $sharePhoto, 'shareImg' => $setShareImg, 'timeStart' => $dateRange[0], 'timeEnd' => $dateRange[1]]; $this->mdSyliveActivity->update($upDate, ['activityId' => $activityId]); $this->return_response(); } @@ -351,11 +358,13 @@ class Activity extends BaseController $this->load->model('market/Market_sylive_activity_kpidata_model', 'mdSyliveActivityKpidata'); $this->load->model('market/Market_sylive_user_model', 'mdSyliveUser'); $this->load->model('live/Live_polyv_session_model', 'mdPolyvSession'); + $this->load->model('live/Live_polyv_viewlog_model', 'mdPolyvViewlog'); $title = ''; $activityData = $areaData = $bizData = $consultantData = $areaAry = []; $re = $this->mdSyliveActivity->get(['activityId' => $activityId]); if ($re) { $title = $re['title']; + $channelId = $re['channelId']; $res_biz = $this->mdSyliveActivityBiz->select(['activityId' => $activityId, 'status' => 0], 'browse desc'); foreach ($res_biz as $k => $v) { $areaId = intval($v['areaId']); @@ -363,9 +372,28 @@ class Activity extends BaseController $re_biz = $this->mdSyliveOrganization->get(['organizationId' => $bizId]); if ($re_biz) { $consultant = $this->mdSyliveActivityKpidata->count(['biz_id' => $bizId, 'a_id' => $activityId], 'distinct(cf_uid)'); + $livePV = $watchDuration = 0; + if ($channelId) { + $res_watch = $this->mdSyliveActivityKpidata->db->select('b.unionid') + ->from('lc_market_sylive_activity_kpidata as a') + ->join('lc_market_sylive_user as b', "b.userId=a.uid", 'left') + ->where(['a.biz_id' => $bizId, 'a.a_id' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null]) + ->limit(10000, 0) + ->get()->result_array(); + if ($res_watch) { + $str_unionids = implode("','", array_column($res_watch, 'unionid')); + $where_pv = ['channelId' => $channelId, 'param3' => 'live']; + $where_pv["param1 in ('" . $str_unionids . "')"] = null; + $livePV = $this->mdPolyvViewlog->count($where_pv); + $re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv); + if ($re_sum['playDuration']) { + $watchDuration = round($re_sum['playDuration'] / $livePV); + } + } + } $bizData[] = ['areaId' => $areaId, 'bizId' => $bizId, 'bizName' => $re_biz['organizationName'], 'consultant' => $consultant, 'browse' => $v['browse'], 'subscribe' => $v['subscribe'] - , 'watch' => $v['watch'], 'order' => $v['orderTotal'], 'livePV' => 35, 'watchDuration' => 10]; + , 'watch' => $v['watch'], 'order' => $v['orderTotal'], 'livePV' => $livePV, 'watchDuration' => $watchDuration]; if (!$areaAry[$areaId]) {//大区 $areaAry[$areaId] = 1; } else { @@ -382,9 +410,28 @@ class Activity extends BaseController $subscribe = $this->mdSyliveActivityKpidata->count(['area_id' => $areaId, 'a_id' => $activityId, 'kpi' => 'subscribe']); $watch = $this->mdSyliveActivityKpidata->count(['area_id' => $areaId, 'a_id' => $activityId, 'kpi' => 'watch']); $order = $this->mdSyliveActivityKpidata->count(['area_id' => $areaId, 'a_id' => $activityId, 'kpi' => 'order']); + $livePV = $watchDuration = 0; + if ($channelId) { + $res_watch = $this->mdSyliveActivityKpidata->db->select('b.unionid') + ->from('lc_market_sylive_activity_kpidata as a') + ->join('lc_market_sylive_user as b', "b.userId=a.uid", 'left') + ->where(['a.area_id' => $areaId, 'a.a_id' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null]) + ->limit(10000, 0) + ->get()->result_array(); + if ($res_watch) { + $str_unionids = implode("','", array_column($res_watch, 'unionid')); + $where_pv = ['channelId' => $channelId, 'param3' => 'live']; + $where_pv["param1 in ('" . $str_unionids . "')"] = null; + $livePV = $this->mdPolyvViewlog->count($where_pv); + $re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv); + if ($re_sum['playDuration']) { + $watchDuration = round($re_sum['playDuration'] / $livePV); + } + } + } $areaData[] = ['areaName' => $re_area['organizationName'], 'biz' => $v, 'consultant' => $consultant , 'browse' => $browse, 'subscribe' => $subscribe, 'watch' => $watch, 'order' => $order - , 'livePV' => 35, 'watchDuration' => 10]; + , 'livePV' => $livePV, 'watchDuration' => $watchDuration]; } } $res_user = $this->mdSyliveActivityKpidata->select(['a_id' => $activityId], 'id desc', 0, 0, 'distinct(cf_uid) as userId'); @@ -397,18 +444,47 @@ class Activity extends BaseController $subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'cf_uid' => $userId, 'kpi' => 'subscribe']); $watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'cf_uid' => $userId, 'kpi' => 'watch']); $order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'cf_uid' => $userId, 'kpi' => 'order']); + $livePV = $watchDuration = 0; + if ($channelId) { + $res_watch = $this->mdSyliveActivityKpidata->db->select('b.unionid') + ->from('lc_market_sylive_activity_kpidata as a') + ->join('lc_market_sylive_user as b', "b.userId=a.uid", 'left') + ->where(['a.cf_uid' => $userId, 'a.a_id' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null]) + ->limit(10000, 0) + ->get()->result_array(); + if ($res_watch) { + $str_unionids = implode("','", array_column($res_watch, 'unionid')); + $where_pv = ['channelId' => $channelId, 'param3' => 'live']; + $where_pv["param1 in ('" . $str_unionids . "')"] = null; + $livePV = $this->mdPolyvViewlog->count($where_pv); + $re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv); + if ($re_sum['playDuration']) { + $watchDuration = round($re_sum['playDuration'] / $livePV); + } + } + } $consultantData = [['consultantName' => $consultantName, 'browse' => $browse, 'subscribe' => $subscribe, 'watch' => $watch - , 'order' => $order, 'livePV' => 35, 'watchDuration' => 10]]; + , 'order' => $order, 'livePV' => $livePV, 'watchDuration' => $watchDuration]]; } } $browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'browse']); $subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'subscribe']); $watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'watch']); $order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'order']); + $duration = $livePV = $watchDuration = 0; + if ($channelId) { + $res_live = $this->mdPolyvSession->select(['channelId' => $channelId], 'id desc', 1, 1, 'duration,livePV'); + $re_live = $res_live[0]; + if ($re_live['duration']) { + $duration = ceil($re_live['duration'] / 60); + $livePV = $re_live['livePV']; + $watchDuration = round($duration / $livePV); + } + } $activityData = [['name' => '参与区域数', 'value' => count($areaData)], ['name' => '参与门店数', 'value' => count($bizData)] , ['name' => '参与顾问数', 'value' => count($res_user)], ['name' => '浏览人数', 'value' => $browse], ['name' => '预约人数', 'value' => $subscribe] - , ['name' => '观看人数', 'value' => $watch], ['name' => '订单数', 'value' => $order], ['name' => '直播时长', 'value' => 8] - , ['name' => '观看次数', 'value' => 10], ['name' => '人均观看', 'value' => 9]]; + , ['name' => '观看人数', 'value' => $watch], ['name' => '订单数', 'value' => $order], ['name' => '直播时长', 'value' => $duration] + , ['name' => '观看次数', 'value' => $livePV], ['name' => '人均观看', 'value' => $watchDuration]]; } $data = ['activityId' => $activityId, 'title' => $title, 'activityData' => $activityData, 'areaData' => $areaData , 'bizData' => $bizData, 'consultantData' => $consultantData];