123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Models\Report\CustomerServiceData;
- use App\Service\DjUserService;
- use App\Service\NewStatisticsService;
- use App\Service\Report\PublicAccountDataService;
- use App\Service\StatisticsService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- class StatisticsController extends Controller
- {
- /**
- * 首页-客户总概
- * @param Request $request
- * @return
- */
- public function custTotal(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $res = StatisticsService::custTotal($corpid);
- return self::returnValue($res);
- }
- public function custTrends(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'start' => 'required',
- 'end' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $start = $request->input('start');
- $end = $request->input('end');
- $user_id = $request->input('user_id');
- $res = StatisticsService::custTrends($corpid, $start, $end, $user_id);
- return self::returnValue($res);
- }
- public function playletPopulariz(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'principalName' => 'nullable',
- 'start' => 'nullable',
- 'end' => 'nullable',
- 'page' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $principalName = $request->input('principalName');
- $mpAppId = $request->input('mpAppId');
- $start = $request->input('start');
- $end = $request->input('end');
- $playletId = $request->input('playletId');
- $operators = $request->input('operators');
- $page = (int)$request->input('page', 1);
- $pagesize = (int)$request->input('pagesize', 20);
- list($data, $total) = StatisticsService::playletPopulariz($principalName, $mpAppId, $start, $end, $playletId, $operators, $page, $pagesize);
- return self::returnPageValue($data, $total, $pagesize, $page);
- }
- public function momentsPopulariz(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'principalName' => 'nullable',
- 'start' => 'nullable',
- 'end' => 'nullable',
- 'page' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $principalName = $request->input('principalName');
- $mpAppId = $request->input('mpAppId');
- $start = $request->input('start');
- $end = $request->input('end');
- $playletId = $request->input('playletId');
- $operators = $request->input('operators');
- $page = (int)$request->input('page', 1);
- $pagesize = (int)$request->input('pagesize', 20);
- list($data, $total) = StatisticsService::momentsPopulariz($principalName, $mpAppId, $start, $end, $playletId, $operators, $page, $pagesize);
- return self::returnPageValue($data, $total, $pagesize, $page);
- }
- public function popularizAccounts(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'type' => 'nullable|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $type = $request->input('type');
- $res = StatisticsService::popularizAccounts($type);
- return self::returnValue($res);
- }
- public function popularizPlaylets(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'mpAppId' => 'required',
- 'type' => 'nullable|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $mpAppId = $request->input('mpAppId');
- $type = $request->input('type');
- $res = StatisticsService::popularizPlaylets($mpAppId, $type);
- return self::returnValue($res);
- }
- public function popularizCompanys(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'type' => 'nullable|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $type = $request->input('type');
- $res = StatisticsService::popularizCompanys($type);
- return self::returnValue($res);
- }
- public function operateDayRetrieve(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start' => 'nullable',
- 'end' => 'nullable',
- 'app_id' => 'nullable',
- 'page' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $app_id = $request->input('app_id');
- $start = $request->input('start');
- $end = $request->input('end');
- $drama_id = (int)$request->input('drama_id');
- $page = (int)$request->input('page', 1);
- $pagesize = (int)$request->input('pagesize', 20);
- $sysGroupId = $request->input('sys_group_id');
- $orderType = $request->input('order_type', 1);
- if(1 == $orderType) {
- $res = StatisticsService::operateDayRetrieve($app_id, $start, $end, $page, $pagesize, $drama_id, $sysGroupId);
- } else {
- $res = StatisticsService::operateDayRetrieveAdq($start, $end, $page, $pagesize, $sysGroupId);
- }
- return self::returnPageValue($res['list'], $res['total'], $pagesize, $page, $res['retrieveColumns']);
- }
- public function throwPersonData(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start' => 'required',
- 'end' => 'required',
- 'user_id' => 'nullable|int',
- 'drama_id' => 'nullable|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $user_id = $request->input('user_id');
- $drama_id = $request->input('drama_id');
- $start = $request->input('start');
- $end = $request->input('end');
- $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');
- $closingDate = $request->input('closing_date');
- $res = StatisticsService::throwPersonData($start, $end, $user_id, $drama_id, $sysGroupId, $adminId
- , $isSystemAdmin, $appId, $launchAccountId, $closingDate);
- return self::returnValue($res);
- }
- public function throwPersonList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start' => 'required|date',
- 'end' => 'required|date',
- 'user_id' => 'nullable|int',
- 'drama_id' => 'nullable|int',
- 'page' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $user_id = $request->input('user_id');
- $drama_id = $request->input('drama_id');
- $start = $request->input('start');
- $end = $request->input('end');
- $page = $request->input('page');
- $pageSize = (int)$request->input('pagesize', 10);
- $sysGroupId = $request->input('sys_group_id');
- $sortField = $request->input('sort_field', 'date');
- $adminId = $request->input('admin_id');
- $isSystemAdmin = $request->input('is_system_admin');
- $appId = $request->input('app_id'); // 公众号
- $launchAccountId = $request->input('launch_account_id');
- $closingDate = $request->input('closing_date');
- list($data, $total) = StatisticsService::throwPersonList($start, $end, $user_id, $drama_id, $page, $pageSize
- , $sysGroupId, $sortField, $adminId, $isSystemAdmin, $appId, $launchAccountId, $closingDate);
- return self::returnPageValue($data, $total, $pageSize, $page);
- }
- public function officialTrendTotal(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start' => 'required|date',
- 'end' => 'required|date',
- 'app_id' => 'nullable|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $appId = $request->input('app_id');
- $start = $request->input('start');
- $end = $request->input('end');
- $sysGroupId = $request->input('sys_group_id');
- $data = StatisticsService::officialTrendTotal($start, $end, $appId, $sysGroupId);
- return self::returnValue($data);
- }
- public function officialTrendList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start' => 'required|date',
- 'end' => 'required|date',
- 'app_id' => 'nullable|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $appId = $request->input('app_id');
- $start = $request->input('start');
- $end = $request->input('end');
- $sysGroupId = $request->input('sys_group_id');
- $page = $request->input('page', 1);
- $pagesize = (int)$request->input('pagesize', 10);
- list($data, $total, $day_columns) = StatisticsService::officialTrendList($start, $end, $appId, $page, $pagesize, $sysGroupId);
- return self::returnPageValue($data, $total, $pagesize, $page, ['day_columns' => $day_columns]);
- }
- /**
- * 投手数据
- * @param Request $request
- * @return array
- */
- public function pitcherData (Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'st_date' => 'required|date',
- 'en_date' => 'required|date',
- 'user_id' => 'nullable|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $stDate = $request->input('st_date');
- $enDate = $request->input('en_date');
- $userId = $request->input('user_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sortField = $request->input('sort_field', 'roi');
- $sysGroupId = $request->input('sys_group_id');
- $adminId = $request->input('admin_id');
- $isSystemAdmin = $request->input('is_system_admin');
- list($data, $total) = StatisticsService::pitcherData($stDate, $enDate, $userId, $page, $pageSize, $sortField
- , $sysGroupId, $adminId, $isSystemAdmin);
- return self::returnPageValue($data, $total, $pageSize, $page);
- }
- public function custTotalNew (Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'nullable',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $group_admin_id = $request->input("group_admin_id",0);
- $is_system_admin = $request->input("is_system_admin",0);
- $sys_group_id = $request->input('sys_group_id');
- $corpid = $request->input('corpid');
- $res = StatisticsService::custTotalNew($corpid, $group_admin_id, $is_system_admin, $sys_group_id);
- return self::returnValue($res);
- }
- public function custTrendsNew(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'nullable',
- 'start' => 'required|date',
- 'end' => 'required|date'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $start = $request->input('start');
- $end = $request->input('end');
- $group_admin_id = $request->input("group_admin_id",0);
- $is_system_admin = $request->input("is_system_admin",0);
- $sys_group_id = $request->input('sys_group_id');
- $res = StatisticsService::custTrendsNew($corpid, $start, $end, $group_admin_id, $is_system_admin, $sys_group_id);
- return self::returnValue($res);
- }
- public function custDataList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'nullable'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $group_admin_id = $request->input("group_admin_id",0);
- $is_system_admin = $request->input("is_system_admin",0);
- $sys_group_id = $request->input('sys_group_id');
- $res = StatisticsService::custDataList($corpid, $group_admin_id, $is_system_admin, $sys_group_id);
- return self::returnValue($res);
- }
- /**
- * 获取累计充值用户【去重】
- * */
- public function chargeUserUnique(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- 'app_id' => 'nullable|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $appId = $request->input('app_id');
- $start = $request->input('start_date');
- $end = $request->input('end_date');
- $sysGroupId = $request->input('sys_group_id');
- # 获取累计充值用户
- $count = StatisticsService::chargeUserUnique($appId, $start, $end, $sysGroupId);
- return self::returnValue(['count' => $count]);
- }
- /**
- * 获取首日充值用户【去重】
- * */
- public function firstDayChargeUserUnique(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- 'app_id' => 'nullable|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $appId = $request->input('app_id');
- $start = $request->input('start_date');
- $end = $request->input('end_date');
- $sysGroupId = $request->input('sys_group_id');
- # 获取首日充值用户
- $count = StatisticsService::firstDayChargeUserUnique($appId, $start, $end, $sysGroupId);
- return self::returnValue(['count' => $count]);
- }
- public function operateDayRetrieveByAccount(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start' => 'nullable',
- 'end' => 'nullable',
- 'app_id' => 'nullable',
- 'page' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $appId = $request->input('app_id');
- $start = $request->input('start');
- $end = $request->input('end');
- $dramaId = (int)$request->input('drama_id');
- $page = (int)$request->input('page', 1);
- $pageSize = (int)$request->input('pagesize', 20);
- $sysGroupId = $request->input('sys_group_id');
- $orderType = $request->input('order_type', 1);
- $isSystemAdmin = $request->input('is_system_admin');
- $adminId = $request->input('admin_id');
- if(1 == $orderType) {
- $res = NewStatisticsService::operateDayRetrieveByAccount($appId, $start, $end, $page, $pageSize, $dramaId
- , $sysGroupId, $adminId, $isSystemAdmin);
- } else {
- $res = NewStatisticsService::operateDayRetrieveAdqByAccount($start, $end, $page, $pageSize, $sysGroupId
- , $adminId, $isSystemAdmin);
- }
- return self::returnPageValue($res['list'], $res['total'], $pageSize, $page, $res['retrieveColumns']);
- }
- public function publicAccountDataList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- 'app_id' => 'nullable',
- 'closing_date' => 'nullable|date',
- 'page' => 'required|numeric',
- 'page_size' => 'required|numeric',
- 'operator_id' => 'nullable|integer',
- 'pitcher_id' => 'nullable|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- $params['closing_date'] = $request->input('closing_date');
- $params['cost_cover_min'] = $request->input('cost_cover_min');
- $params['cost_cover_max'] = $request->input('cost_cover_max');
- $params['admin_id'] = $request->input('admin_id');
- $params['is_system_admin'] = $request->input('is_system_admin');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['operator_id'] = $request->input('operator_id');
- $params['pitcher_id'] = $request->input('pitcher_id');
- $params['app_id'] = $request->input('app_id');
- $page = $request->input('page');
- $pageSize = $request->input('page_size');
- $sortField = $request->input('sort_field', 'expense_date');
- $sortType = $request->input('sort_type', 'desc');
- list($count, $list, $retrieveColumns) = PublicAccountDataService::publicAccountDataList($params
- , $page, $pageSize, $sortField, $sortType);
- return self::returnPageValue($list, $count, $pageSize, $page, $retrieveColumns);
- }
- public function publicAccountDataSummary(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- 'app_id' => 'nullable',
- 'closing_date' => 'nullable|date',
- 'operator_id' => 'nullable|integer',
- 'pitcher_id' => 'nullable|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- $params['closing_date'] = $request->input('closing_date');
- $params['cost_cover_min'] = $request->input('cost_cover_min');
- $params['cost_cover_max'] = $request->input('cost_cover_max');
- $params['admin_id'] = $request->input('admin_id');
- $params['is_system_admin'] = $request->input('is_system_admin');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['operator_id'] = $request->input('operator_id');
- $params['pitcher_id'] = $request->input('pitcher_id');
- $params['app_id'] = $request->input('app_id');
- list($data, $header) = PublicAccountDataService::publicAccountDataSummary($params);
- return self::returnValue([
- 'data' => $data,
- 'header' => $header
- ]);
- }
- public function cumulativeRecoveryData(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start' => 'nullable',
- 'end' => 'nullable',
- 'page' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $page = (int)$request->input('page', 1);
- $pageSize = (int)$request->input('page_size', 20);
- $isSystemAdmin = $request->input('is_system_admin');
- $adminId = $request->input('admin_id');
- $sysGroupId = $request->input('sys_group_id');
- $res = NewStatisticsService::cumulativeRecoveryData($startDate, $endDate, $page, $pageSize, $isSystemAdmin
- , $adminId, $sysGroupId);
- return self::returnPageValue($res['list'], $res['total'], $pageSize, $page, $res['retrieveColumns']);
- }
- public function customerServiceData(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'status' => 'nullable|in:1, 2, 3',
- 'active_status' => 'nullable|in:0, 1'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corp_id'] = $request->input('corp_id');
- $params['user_name'] = $request->input('user_name');
- $params['status'] = $request->input('status');
- $params['active_status'] = $request->input('active_status');
- $params['operator_uid'] = $request->input('operator_uid');
- $params['sort_field'] = $request->input('sort_field');
- $params['sort_type'] = $request->input('sort_type');
- $params['sort_field'] = empty($params['sort_field']) ? 'daily_new_contact_cnt' : $params['sort_field'];
- $params['sort_type'] = empty($params['sort_type']) ? 'desc' : $params['sort_type'];
- $page = (int)$request->input('page', 1);
- $pageSize = (int)$request->input('page_size', 20);
- $isSystemAdmin = $request->input('is_system_admin');
- $adminId = $request->input('admin_id');
- $sysGroupId = $request->input('sys_group_id');
- $res = NewStatisticsService::customerServiceData($params, $page, $pageSize, $isSystemAdmin, $adminId, $sysGroupId);
- return self::returnPageValue($res['list'], $res['total'], $pageSize, $page, $res['columns']);
- }
- public function customerServiceDataTotal(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'status' => 'nullable|in:1, 2, 3',
- 'active_status' => 'nullable|in:0, 1'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corp_id'] = $request->input('corp_id');
- $params['user_name'] = $request->input('user_name');
- $params['status'] = $request->input('status');
- $params['active_status'] = $request->input('active_status');
- $params['operator_uid'] = $request->input('operator_uid');
- $isSystemAdmin = $request->input('is_system_admin');
- $adminId = $request->input('admin_id');
- $sysGroupId = $request->input('sys_group_id');
- $res = NewStatisticsService::customerServiceDataTotal($params, $isSystemAdmin, $adminId, $sysGroupId);
- return self::returnValue($res['data'], 0, $res['columns']);
- }
- }
|