123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538 |
- <?php
- /**
- * Created by PhpStorm.
- * User: shensong
- * Date: 2022/4/20
- * Time: 11:48
- */
- namespace App\Http\Controllers\Api;
- use App\Http\Controllers\Controller;
- use App\Service\DataStatisticsService;
- use App\Service\NewStatisticsService;
- use App\Service\Report\ServiceDataService;
- use Illuminate\Http\Request;
- use Illuminate\Validation\Rule;
- use Validator;
- class DataStatisticsController extends Controller
- {
- // 公众号数据(旧版,不用)
- // public function wechatAccountData(Request $request)
- // {
- // $validator = \Validator::make($request->all(),[
- // 'start_date' => 'nullable|date',
- // 'end_date' => 'nullable|date'
- // ]);
- //
- // if ($validator->fails()) {
- // return self::returnValue($validator->getMessageBag(), 1102);
- // }
- //
- // $startDate = $request->input('start_date');
- // $endDate = $request->input('end_date');
- // $accountId = $request->input('account_id');
- // $corpid = $request->input('corpid');
- // $sortField = $request->input('sort_field', 'charge_total');
- // $sysGroupId = $request->input('sys_group_id');
- //
- // $page = $request->input('page', 1);
- // $pageSize = $request->input('page_size', 10);
- //
- // list($data, $count) = DataStatisticsService::wechatAccountData($startDate, $endDate, $accountId, $corpid,
- // $sortField, $page, $pageSize, $sysGroupId);
- //
- // return self::returnPageValue($data, $count, $pageSize, $page);
- // }
- // 短剧投放趋势数据
- public function playletTrendData(Request $request)
- {
- $validator = Validator::make($request->all(),[
- 'start_date' => 'nullable|date',
- 'end_date' => 'nullable|date'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $accountId = $request->input('account_id');
- $corpid = $request->input('corpid');
- $playletId = $request->input('playlet_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 10);
- list($data, $count) = DataStatisticsService::playletTrendData($startDate, $endDate, $accountId, $corpid, $playletId,
- $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 短剧数据(老)
- public function playletData(Request $request)
- {
- $validator = Validator::make($request->all(),[
- 'start_date' => 'nullable|date',
- 'end_date' => 'nullable|date'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $accountId = $request->input('account_id');
- $corpid = $request->input('corpid');
- $playletId = $request->input('playlet_id');
- $sortField = $request->input('sort_field', 'charge_total');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 10);
- list($data, $count) = DataStatisticsService::playletData($startDate, $endDate, $accountId, $corpid, $playletId,
- $sortField, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- # 短剧数据(新)
- public function playletDataTrend(Request $request)
- {
- $validator = Validator::make($request->all(),[
- 'start_date' => 'nullable|date',
- 'end_date' => 'nullable|date'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $playletId = $request->input('playlet_id');
- $sysGroupId = $request->input('sys_group_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 10);
- list($data, $count) = DataStatisticsService::playletDataTrend($startDate, $endDate, $playletId,
- $page, $pageSize, $sysGroupId);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- /**
- * 短剧粉丝激活趋势
- * */
- public function activeFansData(Request $request)
- {
- $validator = Validator::make($request->all(),[
- 'start_date' => 'nullable|date',
- 'end_date' => 'nullable|date'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $closingDate = $request->input('closing_date');
- $accountId = $request->input('app_id');
- $minPaid = $request->input('min_paid');
- $maxPaid = $request->input('max_paid');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 10);
- $sysGroupId = $request->input('sys_group_id');
- list($data, $count) = DataStatisticsService::activeFansData(
- $startDate, $endDate, $closingDate, $accountId, $minPaid, $maxPaid, $page, $pageSize, $sysGroupId
- );
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 公众号数据(2022-07-21改版)
- public function OfficialAccountData(Request $request)
- {
- $validator = Validator::make($request->all(),[
- 'start_date' => 'nullable|date',
- 'end_date' => 'nullable|date'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $accountId = $request->input('account_id');
- $sortField = $request->input('sort_field', 'charge_total');
- $sysGroupId = $request->input('sys_group_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 10);
- list($data, $count) = DataStatisticsService::OfficialAccountData($startDate, $endDate, $accountId,
- $sortField, $page, $pageSize, $sysGroupId);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- public function playletDataUniqueUser (Request $request)
- {
- $validator = Validator::make($request->all(),[
- 'start_date' => 'required|date',
- 'end_date' => 'required|date'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $playletId = $request->input('playlet_id');
- $sysGroupId = $request->input('sys_group_id');
- $adminId = $request->input('admin_id');
- $isSystemAdmin = $request->input('is_system_admin');
- $appId = $request->input('app_id'); // 公众号
- $launchAccountId = $request->input('launch_account_id');
- $data = DataStatisticsService::statisticsDataUniqueUser($startDate, $endDate, $playletId, null, $sysGroupId
- , 3, $adminId, $isSystemAdmin, $appId, $launchAccountId);
- return self::returnValue($data);
- }
- public function pitcherDataUniqueUser (Request $request)
- {
- $validator = Validator::make($request->all(),[
- 'start_date' => 'required|date',
- 'end_date' => 'required|date'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $pitcherId = $request->input('pitcher_id');
- $sysGroupId = $request->input('sys_group_id');
- $playletId = $request->input('playlet_id', null);
- $adminId = $request->input('admin_id');
- $isSystemAdmin = $request->input('is_system_admin');
- $appId = $request->input('app_id'); // 公众号
- $launchAccountId = $request->input('launch_account_id');
- $data = DataStatisticsService::statisticsDataUniqueUser($startDate, $endDate, $playletId, $pitcherId, $sysGroupId
- , 1, $adminId, $isSystemAdmin, $appId, $launchAccountId);
- return self::returnValue($data);
- }
- /*
- * 数据循环统计
- * */
- public function dataCycleList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'begin_date' => 'required',
- 'end_date' => 'required',
- 'first_order_cost_min' => 'nullable|numeric',
- 'first_order_cost_max' => 'nullable|numeric',
- 'first_order_cost_unique_min' => 'nullable|numeric',
- 'first_order_cost_unique_max' => 'nullable|numeric',
- 'per_follow_cost_min' => 'nullable|numeric',
- 'per_follow_cost_max' => 'nullable|numeric',
- 'total_roi_min' => 'nullable|numeric',
- 'total_roi_max' => 'nullable|numeric',
- 'first_day_roi_min' => 'nullable|numeric',
- 'first_day_roi_max' => 'nullable|numeric',
- 'order_type' => 'required|in:1,2',// 1Mp 2Adq
- 'plat_order_type' => 'nullable|numeric',
- 'paid_min' => 'nullable|numeric',
- 'paid_max' => 'nullable|numeric',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $page = $request->input("page",1);
- $pageSize = $request->input("page_size",20);
- $beginDate = $request->input("begin_date", null);
- $endDate = $request->input("end_date", null);
- $sysGroupId = $request->input('sys_group_id');
- $firstOrderCostMin = $request->input('first_order_cost_min', null);
- $firstOrderCostMax = $request->input('first_order_cost_max', null);
- $firstOrderCostUniqueMin= $request->input('first_order_cost_unique_min', null);
- $firstOrderCostUniqueMax= $request->input('first_order_cost_unique_max', null);
- $perFollowCostMin = $request->input('per_follow_cost_min', null);
- $perFollowCostMax = $request->input('per_follow_cost_max', null);
- $totalRoiMin = $request->input('total_roi_min', null);
- $totalRoiMax = $request->input('total_roi_max', null);
- $firstDayRoiMin = $request->input('first_day_roi_min', null);
- $firstDayRoiMax = $request->input('first_day_roi_max', null);
- $orderType = $request->input('order_type', 1);
- $platOrderType = $request->input('plat_order_type', null);
- $closingDate = $request->input('closing_date', null);
- $paidMin = $request->input('paid_min', null);
- $paidMax = $request->input('paid_max', null);
- $sortField = $request->input('sort_field', 'date');
- $sortType = $request->input('sort_type', 'desc');
- list($total, $list, $overview) = DataStatisticsService::dataCycleList(
- $beginDate,$endDate,$page,$pageSize, $sysGroupId, $firstOrderCostMin, $firstOrderCostMax,
- $firstOrderCostUniqueMin, $firstOrderCostUniqueMax, $perFollowCostMin, $perFollowCostMax,
- $totalRoiMin, $totalRoiMax, $firstDayRoiMin, $firstDayRoiMax, $orderType, $platOrderType, $closingDate,
- $paidMin, $paidMax, $sortField, $sortType);
- return self::returnPageValue(['list'=>$list, 'overview' => $overview],$total,$pageSize,$page);
- }
- /**
- * 获取数据看板数据更新时间
- * */
- public function uptime(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'type' => ['required', Rule::in([
- 'account_data_trend_mp', 'account_data_trend_adq', 'playlet_data_trend_adq', 'data_cycle_nur',
- 'playlet_data_trend_mp', 'data_cycle_adq', 'data_cycle_mp', 'account_data_trend', 'playlet_data_trend',
- 'operate_data_trend', 'cumulative_recovery_data', 'account_funds'
- ])],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $type = $request->input('type');
- # 获取数据更新时间
- $dateTime = DataStatisticsService::getDataUptime($type);
- return self::returnValue(['uptime' => $dateTime]);
- }
- public function HuaShengDataCycleList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'begin_date' => 'required',
- 'end_date' => 'required',
- 'first_order_cost_min' => 'nullable|numeric',
- 'first_order_cost_max' => 'nullable|numeric',
- 'per_follow_cost_min' => 'nullable|numeric',
- 'per_follow_cost_max' => 'nullable|numeric',
- 'total_roi_min' => 'nullable|numeric',
- 'total_roi_max' => 'nullable|numeric',
- 'first_day_roi_min' => 'nullable|numeric',
- 'first_day_roi_max' => 'nullable|numeric',
- 'paid_min' => 'nullable|numeric',
- 'paid_max' => 'nullable|numeric',
- 'plat_order_type' => 'nullable|numeric',
- 'order_source' => 'nullable|numeric',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $page = $request->input("page",1);
- $pageSize = $request->input("page_size",20);
- $beginDate = $request->input("begin_date", null);
- $endDate = $request->input("end_date", null);
- $sysGroupId = $request->input('sys_group_id');
- $firstOrderCostMin = $request->input('first_order_cost_min', null);
- $firstOrderCostMax = $request->input('first_order_cost_max', null);
- $perFollowCostMin = $request->input('per_follow_cost_min', null);
- $perFollowCostMax = $request->input('per_follow_cost_max', null);
- $totalRoiMin = $request->input('total_roi_min', null);
- $totalRoiMax = $request->input('total_roi_max', null);
- $firstDayRoiMin = $request->input('first_day_roi_min', null);
- $firstDayRoiMax = $request->input('first_day_roi_max', null);
- $closingDate = $request->input('closing_date', null);
- $paidMin = $request->input('paid_min', null);
- $paidMax = $request->input('paid_max', null);
- $sortField = $request->input('sort_field', 'date');
- $sortType = $request->input('sort_type', 'desc');
- $appId = $request->input('app_id');
- $platOrderType = $request->input('plat_order_type', null);
- $adminId = $request->input('admin_id');
- $isSystemAdmin = $request->input('is_system_admin');
- $orderSource = $request->input('order_source', 5);
- list($total, $list, $overview) = DataStatisticsService::huaShengDataCycleList($adminId, $isSystemAdmin,
- $beginDate,$endDate,$page,$pageSize, $sysGroupId, $firstOrderCostMin, $firstOrderCostMax,
- $perFollowCostMin, $perFollowCostMax, $totalRoiMin, $totalRoiMax, $firstDayRoiMin, $firstDayRoiMax,
- $closingDate, $paidMin, $paidMax, $sortField, $sortType, $appId, $platOrderType, $orderSource);
- return self::returnPageValue(['list'=>$list, 'overview' => $overview],$total,$pageSize,$page);
- }
- public function dataCycleListByAccount(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'begin_date' => 'required',
- 'end_date' => 'required',
- 'first_order_cost_min' => 'nullable|numeric',
- 'first_order_cost_max' => 'nullable|numeric',
- 'per_follow_cost_min' => 'nullable|numeric',
- 'per_follow_cost_max' => 'nullable|numeric',
- 'total_roi_min' => 'nullable|numeric',
- 'total_roi_max' => 'nullable|numeric',
- 'first_day_roi_min' => 'nullable|numeric',
- 'first_day_roi_max' => 'nullable|numeric',
- 'order_type' => 'required|in:1,2',// 1Adq 2Mp
- 'plat_order_type' => 'nullable|numeric',
- 'paid_min' => 'nullable|numeric',
- 'paid_max' => 'nullable|numeric',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['begin_date'] = $request->input("begin_date", null);
- $params['end_date'] = $request->input("end_date", null);
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['is_system_admin'] = $request->input('is_system_admin');
- $params['admin_id'] = $request->input('admin_id');
- $params['first_order_cost_min'] = $request->input('first_order_cost_min', null);
- $params['first_order_cost_max'] = $request->input('first_order_cost_max', null);
- $params['per_follow_cost_min'] = $request->input('per_follow_cost_min', null);
- $params['per_follow_cost_max'] = $request->input('per_follow_cost_max', null);
- $params['total_roi_min'] = $request->input('total_roi_min', null);
- $params['total_roi_max'] = $request->input('total_roi_max', null);
- $params['first_day_roi_min'] = $request->input('first_day_roi_min', null);
- $params['first_day_roi_max'] = $request->input('first_day_roi_max', null);
- $params['plat_order_type'] = $request->input('plat_order_type', null);
- $params['closing_date'] = $request->input('closing_date', null);
- $params['paid_min'] = $request->input('paid_min', null);
- $params['paid_max'] = $request->input('paid_max', null);
- $orderType = $request->input('order_type', 1);
- $sortField = $request->input('sort_field', 'date');
- $sortType = $request->input('sort_type', 'desc');
- $page = $request->input("page",1);
- $pageSize = $request->input("page_size",20);
- list($total, $list, $overview) = NewStatisticsService::dataCycleListByAccount($params, $orderType, $page, $pageSize
- , $sortField, $sortType);
- return self::returnPageValue(['list'=>$list, 'overview' => $overview],$total,$pageSize,$page);
- }
- public function HuaShengDataPlatformList(Request $request)
- {
- $data = [
- ['order_source' => 99, 'desc' => '全部'],
- ['order_source' => 5, 'desc' => '花生'],
- ['order_source' => 7, 'desc' => '九州'],
- ];
- return self::returnValue($data);
- }
- # 投手ADQ数据汇总(账户数以及投放天数只统计有消耗的数据)
- public function pitcherAdqAccountData(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'start_date' => 'required',
- 'end_date' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['start_date'] = $request->input("start_date", null);
- $params['end_date'] = $request->input("end_date", null);
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['is_system_admin'] = $request->input('is_system_admin');
- $params['admin_id'] = $request->input('admin_id');
- $sortField = $request->input('sort_field', 'total_paid');
- $sortType = $request->input('sort_type', 'desc');
- $res = DataStatisticsService::pitcherAdqAccountData($params, $sortField, $sortType);
- return self::returnValue($res);
- }
- # 送达数据 - 客户群发消息
- public function massMsgServiceData(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'send_time_start' => 'nullable|date_format:Y-m-d',
- 'send_time_end' => 'nullable|date_format:Y-m-d',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $creatorId = $request->input('creator_id');
- $sendTimeStart = $request->input('send_time_start');
- $sendTimeEnd = $request->input('send_time_end');
- $keyword = $request->input('keyword');
- $sysGroupId = $request->input('sys_group_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- list($data, $count) = ServiceDataService::massMsgServiceData($creatorId, $sendTimeStart, $sendTimeEnd, $keyword
- , $sysGroupId, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- # 送达数据 - 客户群群发消息
- public function chatGroupMassMsgServiceData(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'send_time_start' => 'nullable|date_format:Y-m-d',
- 'send_time_end' => 'nullable|date_format:Y-m-d',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $creatorId = $request->input('creator_id');
- $sendTimeStart = $request->input('send_time_start');
- $sendTimeEnd = $request->input('send_time_end');
- $keyword = $request->input('keyword');
- $sysGroupId = $request->input('sys_group_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- list($data, $count) = ServiceDataService::chatGroupMassMsgServiceData($creatorId, $sendTimeStart, $sendTimeEnd
- , $keyword, $sysGroupId, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- # 送达数据 - 智能群发消息
- public function periodMassMsgServiceData(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'send_time_start' => 'nullable|date_format:Y-m-d',
- 'send_time_end' => 'nullable|date_format:Y-m-d',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $creatorId = $request->input('creator_id');
- $sendTimeStart = $request->input('send_time_start');
- $sendTimeEnd = $request->input('send_time_end');
- $keyword = $request->input('keyword');
- $sysGroupId = $request->input('sys_group_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- list($data, $count) = ServiceDataService::periodMassMsgServiceData($creatorId, $sendTimeStart, $sendTimeEnd, $keyword
- , $sysGroupId, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- }
|