123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Service\PitcherService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- class PitcherController extends Controller
- {
- /**
- * mp投放账号列表
- * @return array
- */
- public function wxAccountList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'keyword' => 'nullable|string',
- 'is_select' => 'nullable|integer' // 是否下拉列表
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $keyword = $request->input('keyword');
- $isSelect = $request->input('is_select', 0);
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId = $request->input('sys_group_id');
- $adminId = $request->input('admin_id');
- $isSystemAdmin = $request->input('is_system_admin');
- if (!$isSelect) {
- list($list, $total) = PitcherService::wxAccountList(
- $keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin
- );
- return self::returnPageValue($list, $total, $pageSize, $page);
- } else {
- $res = PitcherService::wxAccountList($keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin);
- return self::returnValue($res);
- }
- }
- /**
- * 公众号列表
- * @param Request $request
- * @return array
- */
- public function officialAccountsList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'keyword' => 'nullable|string',
- 'is_select' => 'nullable|integer' // 是否下拉列表
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $keyword = $request->input('keyword');
- $isSelect = $request->input('is_select', 0);
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId = $request->input('sys_group_id');
- $adminId = $request->input('admin_id');
- $isSystemAdmin = $request->input('is_system_admin');
- if (!$isSelect) {
- list($list, $total) = PitcherService::officialAccountsList(
- $keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin
- );
- return self::returnPageValue($list, $total, $pageSize, $page);
- } else {
- $res = PitcherService::officialAccountsList($keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin);
- return self::returnValue($res);
- }
- }
- /**
- * 短剧列表
- * @return array
- */
- public function dramaList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'keyword' => 'nullable|string',
- 'is_select' => 'nullable|integer' // 是否下拉列表
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $keyword = $request->input('keyword');
- $isSelect = $request->input('is_select', 1);
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId = $request->input('sys_group_id');
- if (!$isSelect) {
- list($list, $total) = PitcherService::dramaList($keyword, $isSelect, $page, $pageSize, $sysGroupId);
- return self::returnPageValue($list, $total, $pageSize, $page);
- } else {
- $res = PitcherService::dramaList($keyword, $isSelect, $page, $pageSize, $sysGroupId);
- return self::returnValue($res);
- }
- }
- /**
- * 投手列表
- * @param Request $request
- * @return array
- */
- public function pitcherList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- // 'corp_id' => 'nullable|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- // $corpId = $request->input('corp_id');
- $sysGroupId = $request->input('sys_group_id');
- $res = PitcherService::pitcherList($sysGroupId);
- return self::returnValue($res);
- }
- /**
- * 绑定投手
- * @param Request $request
- * @return array
- */
- public function bind(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'app_id' => 'required|string',
- 'drama_id' => 'required|integer',
- 'user_id' => 'required|integer',
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $appId = $request->input('app_id');
- $dramaId = $request->input('drama_id');
- $userId = $request->input('user_id');
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $sysGroupId= $request->input('sys_group_id');
- list($res, $code) = PitcherService::bind($appId, $dramaId, $userId, $startDate, $endDate, $sysGroupId);
- return self::returnValue($res, $code);
- }
- /**
- * 投手绑定数据
- * @param Request $request
- * @return array
- */
- public function index(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'app_id' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $appId = $request->input('app_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId = $request->input('sys_group_id');
- list($list, $total) = PitcherService::index($appId, $page, $pageSize, $sysGroupId);
- return self::returnPageValue($list, $total, $pageSize, $page);
- }
- /**
- * 绑定关系数据编辑
- * @param Request $request
- * @return array
- */
- public function relaEdit(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'rela_id' => 'required|integer',
- 'drama_id' => 'required|integer',
- 'user_id' => 'required|integer',
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- 'enable' => 'required|integer'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $relaId = $request->input('rela_id');
- $dramaId = $request->input('drama_id');
- $userId = $request->input('user_id');
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $enable = $request->input('enable');
- list($res, $code) = PitcherService::relaEdit($relaId, $dramaId, $userId, $startDate, $endDate, $enable);
- return self::returnValue($res, $code);
- }
- /**
- * 剧集添加
- * @return array
- */
- public function dramaAdd(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'drama_name' => 'required|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $dramaName = $request->input('drama_name');
- $sysGroupId = $request->input('sys_group_id');
- $errno = 0;
- $res = PitcherService::dramaAdd($dramaName, $sysGroupId, $errno);
- return self::returnValue($res, $errno);
- }
- /**
- * 剧集编辑
- * @return array
- */
- public function dramaEdit(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'drama_id' => 'required|integer',
- 'drama_name' => 'required|string',
- 'enable' => 'required|integer'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $dramaId = $request->input('drama_id');
- $dramaName = $request->input('drama_name');
- $enable = $request->input('enable');
- list($res, $code) = PitcherService::dramaEdit($dramaId, $dramaName, $enable);
- return self::returnValue($res, $code);
- }
- /**
- * 公众号设置回传方式
- */
- public function setReportRule(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'app_ids' => 'required|array',
- 'report_type' => 'required|integer',
- 'enable' => 'required|in:0,1',
- 'if_all' => 'nullable|in:0,1',
- 'purchase_enable' => 'required|in:0,1',
- 'miss_enable' => 'required|in:0,1',
- 'miss_setvale' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $app_ids = $request->input('app_ids');
- $report_type = $request->input('report_type');
- $enable = $request->input('enable');
- $if_all = $request->input('if_all');
- $purchase_enable = $request->input('purchase_enable');
- $miss_enable = $request->input('miss_enable');
- $miss_setvale = $request->input('miss_setvale');
- list($res, $code) = PitcherService::setReportRule($app_ids, $report_type, $enable, $purchase_enable, $miss_enable, $miss_setvale, $if_all);
- return self::returnValue($res, $code);
- }
- /**
- * 回传规则列表
- */
- public function reportRuleList(Request $request)
- {
- $res = PitcherService::reportRuleList();
- return self::returnValue($res);
- }
- /**
- * 公众号绑定数据源和企微
- */
- public function setAccountReportConf(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'app_id' => 'required|string',
- 'user_action_set_id' => 'required',
- 'corpid' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $app_id = $request->input('app_id');
- $user_action_set_id = $request->input('user_action_set_id');
- $corp_id = $request->input('corpid');
- $channel = $request->input('channel');
- $isProvisionalStat = $request->input('is_provisional_stat', 0);
- $sysGroupId = $request->input('sys_group_id');
- $res = PitcherService::setAccountReportConf($app_id, $user_action_set_id, $corp_id, $channel, $isProvisionalStat, $sysGroupId);
- return self::returnValue($res);
- }
- /**
- * 企微下拉列表
- */
- public function getCorpIdList(Request $request)
- {
- $res = PitcherService::getCorpIdList();
- return self::returnValue($res);
- }
- public function adqAccountList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'keyword' => 'nullable|string',
- 'is_select' => 'nullable|integer' // 是否下拉列表
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $keyword = $request->input('keyword');
- $isSelect = $request->input('is_select', 0);
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId = $request->input('sys_group_id');
- $adminId = $request->input('admin_id');
- $isSystemAdmin = $request->input('is_system_admin');
- if(!$isSelect) {
- list($list, $total) = PitcherService::adqAccountList(
- $keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin
- );
- return self::returnPageValue($list, $total, $pageSize, $page);
- } else {
- $res = PitcherService::adqAccountList($keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin);
- return self::returnValue($res);
- }
- }
- /**
- * 投手绑定数据
- * @param Request $request
- * @return array
- */
- public function adqPitcherIndex(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'account_id' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $accountId= $request->input('account_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId=$request->input('sys_group_id');
- list($list, $total) = PitcherService::adqPitcherIndex($accountId, $page, $pageSize, $sysGroupId);
- return self::returnPageValue($list, $total, $pageSize, $page);
- }
- /**
- * 绑定投手
- * @param Request $request
- * @return array
- */
- public function adqBindPitcher(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'account_id' => 'required|string',
- 'drama_id' => 'required|integer',
- 'user_id' => 'required|integer',
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $accountId = $request->input('account_id');
- $dramaId = $request->input('drama_id');
- $userId = $request->input('user_id');
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $sysGroupId= $request->input('sys_group_id');
- list($res, $code) = PitcherService::adqBindPitcher($accountId, $dramaId, $userId, $startDate, $endDate, $sysGroupId);
- return self::returnValue($res, $code);
- }
- /**
- * 绑定关系数据编辑
- * @param Request $request
- * @return array
- */
- public function adqEditPitcher(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'rela_id' => 'required|integer',
- 'drama_id' => 'required|integer',
- 'user_id' => 'required|integer',
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- 'enable' => 'required|integer'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $relaId = $request->input('rela_id');
- $dramaId = $request->input('drama_id');
- $userId = $request->input('user_id');
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $enable = $request->input('enable');
- $sysGroupId= $request->input('sys_group_id');
- list($res, $code) = PitcherService::adqEditPitcher($relaId, $dramaId, $userId, $startDate, $endDate, $enable, $sysGroupId);
- return self::returnValue($res, $code);
- }
- /**
- * 公众号绑定数据源和企微
- */
- public function adqBindUserActionSetId(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'account_id' => 'required|string',
- 'user_action_set_id' => 'required',
- // 'corpid' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $accountId = $request->input('account_id');
- $userActionSetId = $request->input('user_action_set_id');
- $corpId = $request->input('corpid');
- $sysGroupId = $request->input('sys_group_id');
- $isProvisionalStat = $request->input('is_provisional_stat', 0);
- $res = PitcherService::adqBindUserActionSetId($accountId, $userActionSetId, $corpId, $sysGroupId, $isProvisionalStat);
- return self::returnValue($res);
- }
- /*
- * adq投放账号设置回传方式
- */
- public function setAdqAccountReportRule(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'account_ids' => 'required|array',
- 'report_type' => 'required|integer',
- 'enable' => 'required|in:0,1',
- 'if_all' => 'nullable|in:0,1',
- 'purchase_enable' => 'required|in:0,1',
- 'amount_enable' => 'required|in:0,1',
- 'amount_setvale' => 'array|required_if:amount_enable,1',
- 'reset_enable' => 'required|in:0,1',
- 'reset_setvale' => 'nullable|date_format:H:i|required_if:reset_enable,1',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $accountIds = $request->input('account_ids');
- $reportType = $request->input('report_type');
- $enable = $request->input('enable');
- $ifAll = $request->input('if_all', 0);
- $purchaseEnable = $request->input('purchase_enable');
- $missEnable = 0;
- $missSetvale = $request->input('miss_setvale');
- $missValue = $request->input('miss_value', 1);
- $sysGroupId = $request->input('sys_group_id');
- $amountEnable = $request->input('amount_enable');
- $amountSetvale = $request->input('amount_setvale');
- $resetEnable = $request->input('reset_enable');
- $resetSetvale = $request->input('reset_setvale');
- $adminId = $request->input('admin_id');
- list($res, $code) = PitcherService::setAdqAccountReportRule($accountIds, $reportType, $enable, $purchaseEnable
- , $missEnable, $missSetvale, $sysGroupId, $missValue, $ifAll, $amountEnable, $amountSetvale, $resetEnable,
- $resetSetvale, $adminId);
- return self::returnValue($res, $code);
- }
- /**
- * 所有投放账号列表
- * @return array
- */
- public function adAccountList(Request $request)
- {
- $keyword = $request->input('keyword');
- $sysGroupId = $request->input('sys_group_id');
- $adminId = $request->input('admin_id');
- $isSystemAdmin = $request->input('is_system_admin');
- $res = PitcherService::adAccountList($keyword, $sysGroupId, $adminId, $isSystemAdmin);
- return self::returnValue($res);
- }
- public function adqAccountBindUserAction(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'account_id' => 'required',
- 'user_list' => 'array',
- 'confirm' => 'required|in:0,1',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $accountId = $request->input('account_id');
- $userList = $request->input('user_list');
- $confirm = $request->input('confirm', 0);
- $sysGroupId = $request->input('sys_group_id');
- list($res, $code) = PitcherService::adqAccountBindUserAction($accountId, $userList, $confirm, $sysGroupId);
- return self::returnValue($res, $code);
- }
- public function adqAccountBindUserList(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'account_id' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $accountId = $request->input('account_id');
- $list = PitcherService::adqAccountBindUserList($accountId);
- return self::returnValue($list);
- }
- public function adqAccountBindUserDelete(Request $request) {
- $validator = \Validator::make($request->all(),[
- 'data_id' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $dataId = $request->input('data_id');
- $res = PitcherService::adqAccountBindUserDelete($dataId);
- return self::returnValue($res);
- }
- public function adqAccountBindAppId(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'data_id_list' => 'required|array',
- 'app_id' => 'nullable|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 3001);
- }
- $dataIdList = $request->input('data_id_list');
- $appId = $request->input('app_id');
- $errcode = 0;
- PitcherService::adqAccountBindAppId($dataIdList, $appId, $errcode);
- return self::returnValue('', $errcode);
- }
- }
|