From e25a08dbc1f358df714fa6098bcfca7745a7ba8d Mon Sep 17 00:00:00 2001 From: dengbw Date: Tue, 11 Oct 2022 15:39:42 +0800 Subject: [PATCH] sylive_10111 --- market/controllers/api/sylive/Activity.php | 28 +++++++++++-------- .../controllers/api/sylive/Organization.php | 19 +++++++++++++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/market/controllers/api/sylive/Activity.php b/market/controllers/api/sylive/Activity.php index 6a5ffc48..fd429b9b 100644 --- a/market/controllers/api/sylive/Activity.php +++ b/market/controllers/api/sylive/Activity.php @@ -504,19 +504,23 @@ class Activity extends BaseController } $watch_per = number_format_com($watch / $browse * 100, 1, ''); $order_per = number_format_com($order / $browse * 100, 1, ''); - if ($order > $subscribe) { - $expected_data = [['name' => "浏览人数(100%)", 'value' => 100], ['name' => "观看人数({$watch_per}%)", 'value' => 66.7], ['name' => "订单数({$order_per}%)", 'value' => 33.3]]; - $actual_data = [['name' => '浏览人数', 'value' => $browse], ['name' => '观看人数', 'value' => $watch], ['name' => '订单数', 'value' => $order]]; - } else { - $subscribe_per = number_format_com($subscribe / $browse * 100, 1, ''); - $expected_data = [['name' => "浏览人数100%", 'value' => 100], ['name' => "预约人数({$subscribe_per}%)", 'value' => $subscribe > $watch ? 75 : 50] - , ['name' => "观看人数({$watch_per}%)", 'value' => $watch > $subscribe ? 75 : 50], ['name' => "订单数({$order_per}%)", 'value' => 25]]; - $actual_data = [['name' => '浏览人数', 'value' => $browse], ['name' => '预约人数', 'value' => $subscribe] - , ['name' => '观看人数', 'value' => $watch], ['name' => '订单数', 'value' => $order]]; - } - $funnel = ['title' => '活动漏斗', 'expected_data' => $expected_data, 'actual_data' => $actual_data]; + $browse_expected_data = [['name' => "浏览人数(100%)", 'value' => 100], ['name' => "观看人数({$watch_per}%)", 'value' => 66.7], ['name' => "订单数({$order_per}%)", 'value' => 33.3]]; + $browse_actual_data = [['name' => '浏览人数', 'value' => $browse], ['name' => '观看人数', 'value' => $watch], ['name' => '订单数', 'value' => $order]]; + $funnel_browse = ['title' => '浏览转化漏斗', 'expected_data' => $browse_expected_data, 'actual_data' => $browse_actual_data]; + + $id_in = "id in(select id from lc_market_sylive_activity_kpidata where a_id = {$activityId} AND kpi = 'subscribe')"; + $watch_subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'watch', $id_in => null]); + $order_subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'order', $id_in => null]); + $subscribe_per = number_format_com($subscribe / $browse * 100, 1, ''); + $watch_subscribe_per = number_format_com($watch_subscribe / $browse * 100, 1, ''); + $order_subscribe_per = number_format_com($order_subscribe / $browse * 100, 1, ''); + $subscribe_expected_data = [['name' => "浏览人数100%", 'value' => 100], ['name' => "预约人数({$subscribe_per}%)", 'value' => 75] + , ['name' => "观看人数({$watch_subscribe_per}%)", 'value' => 50], ['name' => "订单数({$order_subscribe_per}%)", 'value' => 25]]; + $subscribe_actual_data = [['name' => '浏览人数', 'value' => $browse], ['name' => '预约人数', 'value' => $subscribe] + , ['name' => '观看人数', 'value' => $watch_subscribe], ['name' => '订单数', 'value' => $order_subscribe]]; + $funnel_subscribe = ['title' => '预约转化漏斗', 'expected_data' => $subscribe_expected_data, 'actual_data' => $subscribe_actual_data]; $data = ['activityId' => $activityId, 'title' => $title, 'activityData1' => $activityData1, 'activityData2' => $activityData2, 'areaData' => $areaData - , 'bizData' => $bizData, 'consultantData' => $consultantData, 'funnel' => $funnel]; + , 'bizData' => $bizData, 'consultantData' => $consultantData, 'funnelBrowse' => $funnel_browse, 'funnelSubscribe' => $funnel_subscribe]; $this->return_response($data); } diff --git a/market/controllers/api/sylive/Organization.php b/market/controllers/api/sylive/Organization.php index 8cc65eed..1fe82c58 100644 --- a/market/controllers/api/sylive/Organization.php +++ b/market/controllers/api/sylive/Organization.php @@ -32,6 +32,13 @@ class Organization extends BaseController $res[$k]['organizationId'] = intval($v['organizationId']); $res[$k]['parentId'] = intval($v['parentId']); $res[$k]['sortNumber'] = intval($v['sortNumber']); + $city = []; + if ($v['countyId']) { + $city[] = $v['provinceId']; + $city[] = $v['cityId']; + $city[] = $v['countyId']; + } + $res[$k]['city'] = $city; } $this->return_response_list($res); } @@ -49,6 +56,7 @@ class Organization extends BaseController $organizationType = $this->input_param('organizationType'); $sortNumber = intval($this->input_param('sortNumber')); $comments = $this->input_param('comments'); + $city = $this->input_param('city'); if (!$organizationName) { $this->return_json('请输入机构名称'); } @@ -59,6 +67,11 @@ class Organization extends BaseController $addDate = ['parentId' => $parentId, 'organizationName' => $organizationName, 'organizationFullName' => $organizationFullName , 'organizationType' => $organizationType, 'sortNumber' => $sortNumber, 'comments' => $comments , 'createTime' => date('Y-m-d H:i:s')]; + if ($city) { + $addDate['provinceId'] = intval($city[0]); + $addDate['cityId'] = intval($city[1]); + $addDate['countyId'] = intval($city[2]); + } $id = $this->mdSyliveOrganization->add($addDate); if (!$id) { $this->return_json('添加机构失败'); @@ -80,6 +93,7 @@ class Organization extends BaseController $organizationType = $this->input_param('organizationType'); $sortNumber = intval($this->input_param('sortNumber')); $comments = $this->input_param('comments'); + $city = $this->input_param('city'); !$comments && $comments = ''; if (!$organizationId) { $this->return_json('参数错误'); @@ -93,6 +107,11 @@ class Organization extends BaseController !$comments && $comments = ''; $upDate = ['parentId' => $parentId, 'organizationName' => $organizationName, 'organizationFullName' => $organizationFullName , 'organizationType' => $organizationType, 'sortNumber' => $sortNumber, 'comments' => $comments]; + if ($city) { + $upDate['provinceId'] = intval($city[0]); + $upDate['cityId'] = intval($city[1]); + $upDate['countyId'] = intval($city[2]); + } $this->mdSyliveOrganization->update($upDate, ['organizationId' => $organizationId]); $this->return_response(); }