企微短剧业务系统

PitcherController.php 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Service\PitcherService;
  4. use Illuminate\Http\Request;
  5. use App\Http\Controllers\Controller;
  6. class PitcherController extends Controller
  7. {
  8. /**
  9. * mp投放账号列表
  10. * @return array
  11. */
  12. public function wxAccountList(Request $request)
  13. {
  14. $validator = \Validator::make($request->all(),[
  15. 'keyword' => 'nullable|string',
  16. 'is_select' => 'nullable|integer' // 是否下拉列表
  17. ]);
  18. if ($validator->fails()) {
  19. return self::returnValue($validator->getMessageBag(), 3001);
  20. }
  21. $keyword = $request->input('keyword');
  22. $isSelect = $request->input('is_select', 0);
  23. $page = $request->input('page', 1);
  24. $pageSize = $request->input('page_size', 20);
  25. $sysGroupId = $request->input('sys_group_id');
  26. $adminId = $request->input('admin_id');
  27. $isSystemAdmin = $request->input('is_system_admin');
  28. if (!$isSelect) {
  29. list($list, $total) = PitcherService::wxAccountList(
  30. $keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin
  31. );
  32. return self::returnPageValue($list, $total, $pageSize, $page);
  33. } else {
  34. $res = PitcherService::wxAccountList($keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin);
  35. return self::returnValue($res);
  36. }
  37. }
  38. /**
  39. * 公众号列表
  40. * @param Request $request
  41. * @return array
  42. */
  43. public function officialAccountsList(Request $request)
  44. {
  45. $validator = \Validator::make($request->all(),[
  46. 'keyword' => 'nullable|string',
  47. 'is_select' => 'nullable|integer' // 是否下拉列表
  48. ]);
  49. if ($validator->fails()) {
  50. return self::returnValue($validator->getMessageBag(), 3001);
  51. }
  52. $keyword = $request->input('keyword');
  53. $isSelect = $request->input('is_select', 0);
  54. $page = $request->input('page', 1);
  55. $pageSize = $request->input('page_size', 20);
  56. $sysGroupId = $request->input('sys_group_id');
  57. $adminId = $request->input('admin_id');
  58. $isSystemAdmin = $request->input('is_system_admin');
  59. if (!$isSelect) {
  60. list($list, $total) = PitcherService::officialAccountsList(
  61. $keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin
  62. );
  63. return self::returnPageValue($list, $total, $pageSize, $page);
  64. } else {
  65. $res = PitcherService::officialAccountsList($keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin);
  66. return self::returnValue($res);
  67. }
  68. }
  69. /**
  70. * 短剧列表
  71. * @return array
  72. */
  73. public function dramaList(Request $request)
  74. {
  75. $validator = \Validator::make($request->all(),[
  76. 'keyword' => 'nullable|string',
  77. 'is_select' => 'nullable|integer' // 是否下拉列表
  78. ]);
  79. if ($validator->fails()) {
  80. return self::returnValue($validator->getMessageBag(), 3001);
  81. }
  82. $keyword = $request->input('keyword');
  83. $isSelect = $request->input('is_select', 1);
  84. $page = $request->input('page', 1);
  85. $pageSize = $request->input('page_size', 20);
  86. $sysGroupId = $request->input('sys_group_id');
  87. if (!$isSelect) {
  88. list($list, $total) = PitcherService::dramaList($keyword, $isSelect, $page, $pageSize, $sysGroupId);
  89. return self::returnPageValue($list, $total, $pageSize, $page);
  90. } else {
  91. $res = PitcherService::dramaList($keyword, $isSelect, $page, $pageSize, $sysGroupId);
  92. return self::returnValue($res);
  93. }
  94. }
  95. /**
  96. * 投手列表
  97. * @param Request $request
  98. * @return array
  99. */
  100. public function pitcherList(Request $request)
  101. {
  102. $validator = \Validator::make($request->all(),[
  103. // 'corp_id' => 'nullable|string',
  104. ]);
  105. if ($validator->fails()) {
  106. return self::returnValue($validator->getMessageBag(), 3001);
  107. }
  108. // $corpId = $request->input('corp_id');
  109. $sysGroupId = $request->input('sys_group_id');
  110. $res = PitcherService::pitcherList($sysGroupId);
  111. return self::returnValue($res);
  112. }
  113. /**
  114. * 绑定投手
  115. * @param Request $request
  116. * @return array
  117. */
  118. public function bind(Request $request)
  119. {
  120. $validator = \Validator::make($request->all(),[
  121. 'app_id' => 'required|string',
  122. 'drama_id' => 'required|integer',
  123. 'user_id' => 'required|integer',
  124. 'start_date' => 'required|date',
  125. 'end_date' => 'required|date',
  126. ]);
  127. if ($validator->fails()) {
  128. return self::returnValue($validator->getMessageBag(), 3001);
  129. }
  130. $appId = $request->input('app_id');
  131. $dramaId = $request->input('drama_id');
  132. $userId = $request->input('user_id');
  133. $startDate = $request->input('start_date');
  134. $endDate = $request->input('end_date');
  135. $sysGroupId= $request->input('sys_group_id');
  136. list($res, $code) = PitcherService::bind($appId, $dramaId, $userId, $startDate, $endDate, $sysGroupId);
  137. return self::returnValue($res, $code);
  138. }
  139. /**
  140. * 投手绑定数据
  141. * @param Request $request
  142. * @return array
  143. */
  144. public function index(Request $request)
  145. {
  146. $validator = \Validator::make($request->all(),[
  147. 'app_id' => 'required|string',
  148. ]);
  149. if ($validator->fails()) {
  150. return self::returnValue($validator->getMessageBag(), 3001);
  151. }
  152. $appId = $request->input('app_id');
  153. $page = $request->input('page', 1);
  154. $pageSize = $request->input('page_size', 20);
  155. $sysGroupId = $request->input('sys_group_id');
  156. list($list, $total) = PitcherService::index($appId, $page, $pageSize, $sysGroupId);
  157. return self::returnPageValue($list, $total, $pageSize, $page);
  158. }
  159. /**
  160. * 绑定关系数据编辑
  161. * @param Request $request
  162. * @return array
  163. */
  164. public function relaEdit(Request $request)
  165. {
  166. $validator = \Validator::make($request->all(),[
  167. 'rela_id' => 'required|integer',
  168. 'drama_id' => 'required|integer',
  169. 'user_id' => 'required|integer',
  170. 'start_date' => 'required|date',
  171. 'end_date' => 'required|date',
  172. 'enable' => 'required|integer'
  173. ]);
  174. if ($validator->fails()) {
  175. return self::returnValue($validator->getMessageBag(), 3001);
  176. }
  177. $relaId = $request->input('rela_id');
  178. $dramaId = $request->input('drama_id');
  179. $userId = $request->input('user_id');
  180. $startDate = $request->input('start_date');
  181. $endDate = $request->input('end_date');
  182. $enable = $request->input('enable');
  183. list($res, $code) = PitcherService::relaEdit($relaId, $dramaId, $userId, $startDate, $endDate, $enable);
  184. return self::returnValue($res, $code);
  185. }
  186. /**
  187. * 剧集添加
  188. * @return array
  189. */
  190. public function dramaAdd(Request $request)
  191. {
  192. $validator = \Validator::make($request->all(),[
  193. 'drama_name' => 'required|string'
  194. ]);
  195. if ($validator->fails()) {
  196. return self::returnValue($validator->getMessageBag(), 3001);
  197. }
  198. $dramaName = $request->input('drama_name');
  199. $sysGroupId = $request->input('sys_group_id');
  200. $errno = 0;
  201. $res = PitcherService::dramaAdd($dramaName, $sysGroupId, $errno);
  202. return self::returnValue($res, $errno);
  203. }
  204. /**
  205. * 剧集编辑
  206. * @return array
  207. */
  208. public function dramaEdit(Request $request)
  209. {
  210. $validator = \Validator::make($request->all(),[
  211. 'drama_id' => 'required|integer',
  212. 'drama_name' => 'required|string',
  213. 'enable' => 'required|integer'
  214. ]);
  215. if ($validator->fails()) {
  216. return self::returnValue($validator->getMessageBag(), 3001);
  217. }
  218. $dramaId = $request->input('drama_id');
  219. $dramaName = $request->input('drama_name');
  220. $enable = $request->input('enable');
  221. list($res, $code) = PitcherService::dramaEdit($dramaId, $dramaName, $enable);
  222. return self::returnValue($res, $code);
  223. }
  224. /**
  225. * 公众号设置回传方式
  226. */
  227. public function setReportRule(Request $request)
  228. {
  229. $validator = \Validator::make($request->all(),[
  230. 'app_ids' => 'required|array',
  231. 'report_type' => 'required|integer',
  232. 'enable' => 'required|in:0,1',
  233. 'if_all' => 'nullable|in:0,1',
  234. 'purchase_enable' => 'required|in:0,1',
  235. 'miss_enable' => 'required|in:0,1',
  236. 'miss_setvale' => 'required|integer',
  237. ]);
  238. if ($validator->fails()) {
  239. return self::returnValue($validator->getMessageBag(), 3001);
  240. }
  241. $app_ids = $request->input('app_ids');
  242. $report_type = $request->input('report_type');
  243. $enable = $request->input('enable');
  244. $if_all = $request->input('if_all');
  245. $purchase_enable = $request->input('purchase_enable');
  246. $miss_enable = $request->input('miss_enable');
  247. $miss_setvale = $request->input('miss_setvale');
  248. list($res, $code) = PitcherService::setReportRule($app_ids, $report_type, $enable, $purchase_enable, $miss_enable, $miss_setvale, $if_all);
  249. return self::returnValue($res, $code);
  250. }
  251. /**
  252. * 回传规则列表
  253. */
  254. public function reportRuleList(Request $request)
  255. {
  256. $res = PitcherService::reportRuleList();
  257. return self::returnValue($res);
  258. }
  259. /**
  260. * 公众号绑定数据源和企微
  261. */
  262. public function setAccountReportConf(Request $request)
  263. {
  264. $validator = \Validator::make($request->all(),[
  265. 'app_id' => 'required|string',
  266. 'user_action_set_id' => 'required',
  267. 'corpid' => 'required',
  268. ]);
  269. if ($validator->fails()) {
  270. return self::returnValue($validator->getMessageBag(), 3001);
  271. }
  272. $app_id = $request->input('app_id');
  273. $user_action_set_id = $request->input('user_action_set_id');
  274. $corp_id = $request->input('corpid');
  275. $channel = $request->input('channel');
  276. $isProvisionalStat = $request->input('is_provisional_stat', 0);
  277. $sysGroupId = $request->input('sys_group_id');
  278. $res = PitcherService::setAccountReportConf($app_id, $user_action_set_id, $corp_id, $channel, $isProvisionalStat, $sysGroupId);
  279. return self::returnValue($res);
  280. }
  281. /**
  282. * 企微下拉列表
  283. */
  284. public function getCorpIdList(Request $request)
  285. {
  286. $res = PitcherService::getCorpIdList();
  287. return self::returnValue($res);
  288. }
  289. public function adqAccountList(Request $request)
  290. {
  291. $validator = \Validator::make($request->all(),[
  292. 'keyword' => 'nullable|string',
  293. 'is_select' => 'nullable|integer' // 是否下拉列表
  294. ]);
  295. if ($validator->fails()) {
  296. return self::returnValue($validator->getMessageBag(), 3001);
  297. }
  298. $keyword = $request->input('keyword');
  299. $isSelect = $request->input('is_select', 0);
  300. $page = $request->input('page', 1);
  301. $pageSize = $request->input('page_size', 20);
  302. $sysGroupId = $request->input('sys_group_id');
  303. $adminId = $request->input('admin_id');
  304. $isSystemAdmin = $request->input('is_system_admin');
  305. if(!$isSelect) {
  306. list($list, $total) = PitcherService::adqAccountList(
  307. $keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin
  308. );
  309. return self::returnPageValue($list, $total, $pageSize, $page);
  310. } else {
  311. $res = PitcherService::adqAccountList($keyword, $isSelect, $page, $pageSize, $sysGroupId, $adminId, $isSystemAdmin);
  312. return self::returnValue($res);
  313. }
  314. }
  315. /**
  316. * 投手绑定数据
  317. * @param Request $request
  318. * @return array
  319. */
  320. public function adqPitcherIndex(Request $request)
  321. {
  322. $validator = \Validator::make($request->all(),[
  323. 'account_id' => 'required|string',
  324. ]);
  325. if ($validator->fails()) {
  326. return self::returnValue($validator->getMessageBag(), 3001);
  327. }
  328. $accountId= $request->input('account_id');
  329. $page = $request->input('page', 1);
  330. $pageSize = $request->input('page_size', 20);
  331. $sysGroupId=$request->input('sys_group_id');
  332. list($list, $total) = PitcherService::adqPitcherIndex($accountId, $page, $pageSize, $sysGroupId);
  333. return self::returnPageValue($list, $total, $pageSize, $page);
  334. }
  335. /**
  336. * 绑定投手
  337. * @param Request $request
  338. * @return array
  339. */
  340. public function adqBindPitcher(Request $request)
  341. {
  342. $validator = \Validator::make($request->all(),[
  343. 'account_id' => 'required|string',
  344. 'drama_id' => 'required|integer',
  345. 'user_id' => 'required|integer',
  346. 'start_date' => 'required|date',
  347. 'end_date' => 'required|date',
  348. ]);
  349. if ($validator->fails()) {
  350. return self::returnValue($validator->getMessageBag(), 3001);
  351. }
  352. $accountId = $request->input('account_id');
  353. $dramaId = $request->input('drama_id');
  354. $userId = $request->input('user_id');
  355. $startDate = $request->input('start_date');
  356. $endDate = $request->input('end_date');
  357. $sysGroupId= $request->input('sys_group_id');
  358. list($res, $code) = PitcherService::adqBindPitcher($accountId, $dramaId, $userId, $startDate, $endDate, $sysGroupId);
  359. return self::returnValue($res, $code);
  360. }
  361. /**
  362. * 绑定关系数据编辑
  363. * @param Request $request
  364. * @return array
  365. */
  366. public function adqEditPitcher(Request $request)
  367. {
  368. $validator = \Validator::make($request->all(),[
  369. 'rela_id' => 'required|integer',
  370. 'drama_id' => 'required|integer',
  371. 'user_id' => 'required|integer',
  372. 'start_date' => 'required|date',
  373. 'end_date' => 'required|date',
  374. 'enable' => 'required|integer'
  375. ]);
  376. if ($validator->fails()) {
  377. return self::returnValue($validator->getMessageBag(), 3001);
  378. }
  379. $relaId = $request->input('rela_id');
  380. $dramaId = $request->input('drama_id');
  381. $userId = $request->input('user_id');
  382. $startDate = $request->input('start_date');
  383. $endDate = $request->input('end_date');
  384. $enable = $request->input('enable');
  385. $sysGroupId= $request->input('sys_group_id');
  386. list($res, $code) = PitcherService::adqEditPitcher($relaId, $dramaId, $userId, $startDate, $endDate, $enable, $sysGroupId);
  387. return self::returnValue($res, $code);
  388. }
  389. /**
  390. * 公众号绑定数据源和企微
  391. */
  392. public function adqBindUserActionSetId(Request $request)
  393. {
  394. $validator = \Validator::make($request->all(),[
  395. 'account_id' => 'required|string',
  396. 'user_action_set_id' => 'required',
  397. // 'corpid' => 'required',
  398. ]);
  399. if ($validator->fails()) {
  400. return self::returnValue($validator->getMessageBag(), 3001);
  401. }
  402. $accountId = $request->input('account_id');
  403. $userActionSetId = $request->input('user_action_set_id');
  404. $corpId = $request->input('corpid');
  405. $sysGroupId = $request->input('sys_group_id');
  406. $isProvisionalStat = $request->input('is_provisional_stat', 0);
  407. $res = PitcherService::adqBindUserActionSetId($accountId, $userActionSetId, $corpId, $sysGroupId, $isProvisionalStat);
  408. return self::returnValue($res);
  409. }
  410. /*
  411. * adq投放账号设置回传方式
  412. */
  413. public function setAdqAccountReportRule(Request $request)
  414. {
  415. $validator = \Validator::make($request->all(),[
  416. 'account_ids' => 'required|array',
  417. 'report_type' => 'required|integer',
  418. 'enable' => 'required|in:0,1',
  419. 'if_all' => 'nullable|in:0,1',
  420. 'purchase_enable' => 'required|in:0,1',
  421. 'amount_enable' => 'required|in:0,1',
  422. 'amount_setvale' => 'array|required_if:amount_enable,1',
  423. 'reset_enable' => 'required|in:0,1',
  424. 'reset_setvale' => 'nullable|date_format:H:i|required_if:reset_enable,1',
  425. ]);
  426. if ($validator->fails()) {
  427. return self::returnValue($validator->getMessageBag(), 3001);
  428. }
  429. $accountIds = $request->input('account_ids');
  430. $reportType = $request->input('report_type');
  431. $enable = $request->input('enable');
  432. $ifAll = $request->input('if_all', 0);
  433. $purchaseEnable = $request->input('purchase_enable');
  434. $missEnable = 0;
  435. $missSetvale = $request->input('miss_setvale');
  436. $missValue = $request->input('miss_value', 1);
  437. $sysGroupId = $request->input('sys_group_id');
  438. $amountEnable = $request->input('amount_enable');
  439. $amountSetvale = $request->input('amount_setvale');
  440. $resetEnable = $request->input('reset_enable');
  441. $resetSetvale = $request->input('reset_setvale');
  442. $adminId = $request->input('admin_id');
  443. list($res, $code) = PitcherService::setAdqAccountReportRule($accountIds, $reportType, $enable, $purchaseEnable
  444. , $missEnable, $missSetvale, $sysGroupId, $missValue, $ifAll, $amountEnable, $amountSetvale, $resetEnable,
  445. $resetSetvale, $adminId);
  446. return self::returnValue($res, $code);
  447. }
  448. /**
  449. * 所有投放账号列表
  450. * @return array
  451. */
  452. public function adAccountList(Request $request)
  453. {
  454. $keyword = $request->input('keyword');
  455. $sysGroupId = $request->input('sys_group_id');
  456. $adminId = $request->input('admin_id');
  457. $isSystemAdmin = $request->input('is_system_admin');
  458. $res = PitcherService::adAccountList($keyword, $sysGroupId, $adminId, $isSystemAdmin);
  459. return self::returnValue($res);
  460. }
  461. public function adqAccountBindUserAction(Request $request)
  462. {
  463. $validator = \Validator::make($request->all(),[
  464. 'account_id' => 'required',
  465. 'user_list' => 'array',
  466. 'confirm' => 'required|in:0,1',
  467. ]);
  468. if ($validator->fails()) {
  469. return self::returnValue($validator->getMessageBag(), 3001);
  470. }
  471. $accountId = $request->input('account_id');
  472. $userList = $request->input('user_list');
  473. $confirm = $request->input('confirm', 0);
  474. $sysGroupId = $request->input('sys_group_id');
  475. list($res, $code) = PitcherService::adqAccountBindUserAction($accountId, $userList, $confirm, $sysGroupId);
  476. return self::returnValue($res, $code);
  477. }
  478. public function adqAccountBindUserList(Request $request) {
  479. $validator = \Validator::make($request->all(),[
  480. 'account_id' => 'required',
  481. ]);
  482. if ($validator->fails()) {
  483. return self::returnValue($validator->getMessageBag(), 3001);
  484. }
  485. $accountId = $request->input('account_id');
  486. $list = PitcherService::adqAccountBindUserList($accountId);
  487. return self::returnValue($list);
  488. }
  489. public function adqAccountBindUserDelete(Request $request) {
  490. $validator = \Validator::make($request->all(),[
  491. 'data_id' => 'required',
  492. ]);
  493. if ($validator->fails()) {
  494. return self::returnValue($validator->getMessageBag(), 3001);
  495. }
  496. $dataId = $request->input('data_id');
  497. $res = PitcherService::adqAccountBindUserDelete($dataId);
  498. return self::returnValue($res);
  499. }
  500. public function adqAccountBindAppId(Request $request)
  501. {
  502. $validator = \Validator::make($request->all(),[
  503. 'data_id_list' => 'required|array',
  504. 'app_id' => 'nullable|string',
  505. ]);
  506. if ($validator->fails()) {
  507. return self::returnValue($validator->getMessageBag(), 3001);
  508. }
  509. $dataIdList = $request->input('data_id_list');
  510. $appId = $request->input('app_id');
  511. $errcode = 0;
  512. PitcherService::adqAccountBindAppId($dataIdList, $appId, $errcode);
  513. return self::returnValue('', $errcode);
  514. }
  515. }