From 0205ee703e57f199d6a326821bc6dbd903335005 Mon Sep 17 00:00:00 2001 From: dengbw Date: Sat, 10 Dec 2022 14:11:34 +0800 Subject: [PATCH] market_groups_1210 --- market/controllers/api/sylive/Activity.php | 11 ++- .../api/sylive/GroupsStatistics.php | 77 ++++++++++++++++--- 2 files changed, 76 insertions(+), 12 deletions(-) diff --git a/market/controllers/api/sylive/Activity.php b/market/controllers/api/sylive/Activity.php index 267ee453..ebff8dda 100644 --- a/market/controllers/api/sylive/Activity.php +++ b/market/controllers/api/sylive/Activity.php @@ -132,9 +132,9 @@ class Activity extends BaseController } } $skey = $this->myencryption->base64url_encode("a_id=" . $activityId); - if($activityId>=6){ + if ($activityId >= 6) { $url = http_host_com('home') . "/h5/market/sylive2?skey=" . $skey;//活动连接 - }else{ + } else { $url = http_host_com('home') . "/h5/market/sylive?skey=" . $skey;//活动连接 } $serviceLink = $jsondata['serviceLink'] ? $jsondata['serviceLink'] : ''; @@ -143,12 +143,13 @@ class Activity extends BaseController $groups = 0; $re_gro = $this->mdSyliveGroups->get(['activityId' => $activityId, 'parentId' => 0, 'status>=' => 0]); $re_gro && $groups = 1; + $blacklist = intval($jsondata['blacklist']); $list[] = [ 'activityId' => $activityId, 'title' => $v['title'], 'channelId' => $v['channelId'], 'pay' => $pay, 'organizationId' => $organizationId, 'activityStart' => $activityStart, 'shareTitle' => $shareTitle, 'dateRange' => $dateRange, 'coupon' => $coupon, 'drawCode' => $v['drawCode'], 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'banner' => $banner, 'sharePhoto' => $sharePhoto, 'shareImg' => $shareImg, 'item' => $item, 'url' => $url, 'mchId' => $v['mchId'], 'protocolTitle' => $v['protocolTitle'], 'protocol' => $v['protocol'], 'serviceLink' => $serviceLink, 'bottoms' => $bottoms - , 's_time' => $v['timeStart'], 'e_time' => $v['timeEnd'], 'status' => $status, 'groups' => $groups, 'createTime' => $v['createTime']]; + , 's_time' => $v['timeStart'], 'e_time' => $v['timeEnd'], 'status' => $status, 'groups' => $groups, 'blacklist' => $blacklist, 'createTime' => $v['createTime']]; } } $date = ['list' => $list, 'count' => $count]; @@ -217,6 +218,7 @@ class Activity extends BaseController $serviceLink = $this->input_param('serviceLink'); $activityStart = $this->input_param('activityStart'); $bottoms = $this->input_param('bottoms'); + $blacklist = intval($this->input_param('blacklist')); if (!$title) { $this->return_json('请输入活动标题'); } @@ -264,6 +266,7 @@ class Activity extends BaseController $setBottoms[] = $v; } $jsondata['bottoms'] = $setBottoms; + $jsondata['blacklist'] = $blacklist; $jsondata = json_encode($jsondata, JSON_UNESCAPED_UNICODE); $createTime = date('Y-m-d H:i:s'); $addDate = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'jsondata' => $jsondata @@ -310,6 +313,7 @@ class Activity extends BaseController $organizationId = intval($this->input_param('organizationId')); $activityStart = $this->input_param('activityStart'); $bottoms = $this->input_param('bottoms'); + $blacklist = intval($this->input_param('blacklist')); if (!$activityId) { $this->return_json('参数错误'); } @@ -358,6 +362,7 @@ class Activity extends BaseController $jsondata['pay'] = $pay; $jsondata['banner'] = $banner; $jsondata['serviceLink'] = $serviceLink; + $jsondata['blacklist'] = $blacklist; $setBottoms = []; foreach ($bottoms as $v) { if ($v['urlType'] == 'link') { diff --git a/market/controllers/api/sylive/GroupsStatistics.php b/market/controllers/api/sylive/GroupsStatistics.php index 977ef78e..734cdad0 100644 --- a/market/controllers/api/sylive/GroupsStatistics.php +++ b/market/controllers/api/sylive/GroupsStatistics.php @@ -99,7 +99,7 @@ class GroupsStatistics extends BaseController $groupsLevel = intval($v['dictDataCode']); $re_gro = $this->mdSyliveGroups->get(['activityId' => $activityId, 'groupsLevel' => $groupsLevel, 'status>=' => 0]); if ($re_gro) { - $levelData[] = ['title' => $v['dictDataName'].'统计', 'value' => $groupsLevel]; + $levelData[] = ['title' => $v['dictDataName'] . '统计', 'value' => $groupsLevel]; } } } @@ -284,6 +284,9 @@ class GroupsStatistics extends BaseController } else { $sort_order = $sort . ' ' . $order; } + //一级分组 + $map_level1 = $this->mdSyliveGroups->map('groupsId', 'groupsName', ['groupsLevel' => 1, 'status>=' => 0]); + $map_biz = []; if ($day) {//按天搜索 $createTimeStart = strtotime($day . ' 00:00:00'); $createTimeEnd = strtotime($day . ' 23:59:59'); @@ -293,11 +296,21 @@ class GroupsStatistics extends BaseController } $count = $this->mdSyliveActivityKpidata->count($where, 'bizId'); if ($count) { - $res = $this->mdSyliveActivityKpidata->select_groupby('bizId', $where, "total {$order},id desc", $page, $limit, "bizId,count(id) as total"); + $res = $this->mdSyliveActivityKpidata->select_groupby('bizId', $where, "total {$order},id desc", + $page, $limit, "bizId,levelId1,count(id) as total"); + $str_biz = implode(',', array_column($res, 'bizId')); + $map_biz = $this->mdSyliveGroups->map('groupsId', 'groupsName', + ["groupsId in({$str_biz})" => null, 'activityId' => $activityId, 'status>=' => 0]); foreach ($res as $v) { $bizId = intval($v['bizId']); - $re_biz = $this->mdSyliveGroups->get(['groupsId' => $bizId, 'activityId' => $activityId, 'status>=' => 0]); - $bizName = $re_biz ? $re_biz['groupsName'] : '-'; + $levelId1 = intval($v['levelId1']); + $bizName = ''; + if ($map_level1[$levelId1]) { + $bizName = $map_level1[$levelId1]; + } + if ($map_biz[$bizId]) { + $bizName = $bizName ? $bizName . ' ' . $map_biz[$bizId] : $map_biz[$bizId]; + } $where_sort['bizId'] = $bizId; if ($sort == 'browse') { $browse = $v['total']; @@ -355,20 +368,40 @@ class GroupsStatistics extends BaseController if ($count) { if ($sort == 'order' && $itemId) {//有订单排序与商品id,区分订单搜索 $res = $this->mdSyliveActivityKpidata->select_groupby('bizId', $where, "orderTotal {$order},id desc" - , $page, $limit, "bizId,count(id) as orderTotal"); - + , $page, $limit, "bizId,levelId1,count(id) as orderTotal"); + $str_biz = implode(',', array_column($res, 'bizId')); + $map_biz = $this->mdSyliveGroups->map('groupsId', 'groupsName', + ["groupsId in({$str_biz})" => null, 'activityId' => $activityId, 'status>=' => 0]); } else { $res = $this->mdSyliveGroups->select($where, "{$sort_order},groupsId desc", $page, $limit, 'groupsId,groupsName,browse,subscribe,watch,orderTotal'); } foreach ($res as $v) { + $bizName = ''; if ($sort == 'order' && $itemId) { $bizId = intval($v['bizId']); - $re_biz = $this->mdSyliveGroups->get(['groupsId' => $bizId, 'activityId' => $activityId, 'status>=' => 0]); - $bizName = $re_biz ? $re_biz['groupsName'] : '-'; + $levelId1 = intval($v['levelId1']); + if ($map_level1[$levelId1]) { + $bizName = $map_level1[$levelId1]; + } + if ($map_biz[$bizId]) { + $bizName = $bizName ? $bizName . ' ' . $map_biz[$bizId] : $map_biz[$bizId]; + } } else { $bizId = intval($v['groupsId']); - $bizName = $v['groupsName'] ? $v['groupsName'] : '-'; + $re_use = $this->mdSyliveGroupsUser->get(["bizId" => $bizId, 'activityId' => $activityId, 'status>=' => 0]); + if ($re_use['levelId1']) {//根据用户找1级 + $levelId1 = intval($re_use['levelId1']); + if ($map_level1[$levelId1]) { + $bizName = $map_level1[$levelId1]; + } + } + if (!$bizName && $bizId) {//根据门店向上找1级 + $bizName = $this->getLevelName($bizId, 1, ''); + } + if ($v['groupsName']) { + $bizName = $bizName ? $bizName . ' ' . $v['groupsName'] : $v['groupsName']; + } } $consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'activityId' => $activityId], 'cfUserId'); $allConsultant = $this->mdSyliveGroupsUser->count(['bizId' => $bizId, 'activityId' => $activityId, 'status>=' => 0]); @@ -679,4 +712,30 @@ class GroupsStatistics extends BaseController return $biz; } + /** + * Notes:根据等级找名字 + * Created on: 2022/12/10 13:56 + * Created by: dengbw + * @param $groupsId + * @param $groupsLevel + * @param string $groupsName + * @return string + */ + private function getLevelName($groupsId, $groupsLevel, $groupsName = '') + { + $re = $this->mdSyliveGroups->get(['groupsId' => $groupsId], 'groupsName,parentId,groupsLevel'); + if (!$re) { + return $groupsName; + } else { + if ($re['groupsLevel'] == $groupsLevel) { + $groupsName = $re['groupsName']; + } + if (!$groupsName && $re['parentId']) { + return $this->getLevelName($re['parentId'], $groupsLevel, $groupsName); + } else { + return $groupsName; + } + } + } + } \ No newline at end of file