企微短剧业务系统

PeriodMassMsgController.php 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Models\PeriodMassMsg\PeriodMassMsgGroup;
  4. use App\Models\PeriodMassMsg\PeriodTempGroup;
  5. use App\Service\PeriodMassMsgService;
  6. use Illuminate\Http\Request;
  7. use App\Http\Controllers\Controller;
  8. use Illuminate\Validation\Rule;
  9. class PeriodMassMsgController extends Controller
  10. {
  11. /**
  12. * 智能群发消息规则设置
  13. * */
  14. public function setRule(Request $request)
  15. {
  16. $validator = \Validator::make($request->all(), [
  17. 'corpid' => 'required|string',
  18. 'name' => 'required|string',
  19. 'send_conf' => 'required|string',
  20. 'content' => ['required_without:attachments', 'nullable'],
  21. 'attachments' => ['required_without:content', 'nullable'],
  22. 'tag_screen_type' => ['nullable', Rule::in([0, 1, 2, 3])],
  23. 'customer_filter' => ['nullable', Rule::in([0, 1])],
  24. 'pay_status' => ['nullable', Rule::in([0, 1])],
  25. 'pay_num_min' => 'nullable|int',
  26. 'pay_num_max' => 'nullable|int',
  27. ]);
  28. if ($validator->fails()) {
  29. return self::returnValue($validator->getMessageBag(), 1102);
  30. }
  31. $params = array();
  32. $ruleId = $request->input('rule_id');
  33. $params['corpid'] = $request->input('corpid');
  34. $params['admin_id'] = $request->input('admin_id');
  35. $params['group_id'] = $request->input('group_id', 0);
  36. $params['name'] = $request->input('name');
  37. $params['send_conf'] = $request->input('send_conf'); // 发送时间配置
  38. $params['is_all'] = $request->input('is_all', 0); // 是否应用于全部员工 0否 1是
  39. $params['senders'] = $request->input('senders'); // 群发账号集合
  40. $params['content'] = $request->input('content');
  41. $params['attachments'] = $request->input('attachments');
  42. $params['gender'] = $request->input('gender', 3); // 客户性别 0未知 1男性 2女性 3全部
  43. $params['tag_screen_type'] = $request->input('tag_screen_type', 0); // 标签筛选方式 0未设置标签筛选 1所选标签满足其一 2所选标签全部满足 3无任何标签
  44. $params['tag_list'] = $request->input('tag_list');
  45. $params['exclude_tag_list'] = $request->input('exclude_tag_list');
  46. // 付费情况
  47. $params['pay_status'] = $request->input('pay_status'); // 是否付费 0:未付费 1:付费
  48. $params['pay_num_min'] = $request->input('pay_num_min'); // 最小付费次数
  49. $params['pay_num_max'] = $request->input('pay_num_max'); // 最大付费次数
  50. $params['operate_type'] = $request->input('operate_type', 1);# 运营类型 1单主体 2多主体
  51. $params['operator_group_id'] = $request->input('operator_group_id');// 运营组ID
  52. $params['multiple_senders'] = $request->input('multiple_senders');
  53. $params['is_operation'] = $request->input('is_operation');
  54. # 智能群发规则设置
  55. $errNo = PeriodMassMsgService::setRule($ruleId, $params);
  56. return self::returnValue([], $errNo);
  57. }
  58. /**
  59. * 设置智能群发模板
  60. * */
  61. public function setTemplate(Request $request)
  62. {
  63. $validator = \Validator::make($request->all(), [
  64. 'title' => 'required|string',
  65. 'send_conf' => 'required|string',
  66. 'content' => ['required_without:attachments', 'nullable'],
  67. 'attachments' => ['required_without:content', 'nullable'],
  68. ]);
  69. if ($validator->fails()) {
  70. return self::returnValue($validator->getMessageBag(), 1102);
  71. }
  72. $params = array();
  73. $templateId = $request->input('template_id');
  74. $params['admin_id'] = $request->input('admin_id');
  75. $params['group_id'] = $request->input('group_id');
  76. $params['sys_group_id'] = $request->input('sys_group_id');
  77. $params['title'] = $request->input('title');
  78. $params['send_conf'] = $request->input('send_conf'); // 发送时间配置
  79. $params['content'] = $request->input('content');
  80. $params['attachments'] = $request->input('attachments');
  81. # 智能群发模板配置
  82. $errNo = PeriodMassMsgService::setTemplate($templateId, $params);
  83. return self::returnValue([], $errNo);
  84. }
  85. /**
  86. * 智能群发规则列表
  87. * */
  88. public function ruleLists(Request $request)
  89. {
  90. $validator = \Validator::make($request->all(),[
  91. 'corpid' => 'required|string',
  92. 'create_time_start' => 'nullable|date_format:Y-m-d H:i:s',
  93. 'create_time_end' => 'nullable|date_format:Y-m-d H:i:s',
  94. ]);
  95. if ($validator->fails()) {
  96. return self::returnValue($validator->getMessageBag(), 1102);
  97. }
  98. $groupId = $request->input('group_id', 0);
  99. $keyword = $request->input('keyword');
  100. $corpid = $request->input('corpid');
  101. $creatorId = $request->input('creator_id');
  102. $createTimeStart = $request->input('create_time_start');
  103. $createTimeEnd = $request->input('create_time_end');
  104. $page = $request->input('page', 1);
  105. $pageSize = $request->input('page_size', 20);
  106. # 获取群发规则列表
  107. $errno = 0;
  108. list($list, $count) = PeriodMassMsgService::ruleList(
  109. $groupId, $keyword, $corpid, $creatorId, $createTimeStart,$createTimeEnd, $page, $pageSize, $errno
  110. );
  111. # 获取分组名称
  112. $groupName = PeriodMassMsgGroup::where('id', $groupId)->value('title');
  113. if($errno) return self::returnValue([], $errno);
  114. return self::returnPageValue($list, $count, $pageSize, $page, ['group_name' => $groupName ? $groupName : '未分组']);
  115. }
  116. /**
  117. * 智能群发模板列表
  118. * */
  119. public function templateList(Request $request)
  120. {
  121. $validator = \Validator::make($request->all(),[
  122. 'create_time_start' => 'nullable|date_format:Y-m-d H:i:s',
  123. 'create_time_end' => 'nullable|date_format:Y-m-d H:i:s',
  124. ]);
  125. if ($validator->fails()) {
  126. return self::returnValue($validator->getMessageBag(), 1102);
  127. }
  128. $adminId = $request->input('admin_id');
  129. $sysGroupId = $request->input('sys_group_id');
  130. $groupId = $request->input('group_id', 0);
  131. $title = $request->input('title');
  132. $status = $request->input('status');
  133. $createTimeStart = $request->input('create_time_start');
  134. $createTimeEnd = $request->input('create_time_end');
  135. $page = $request->input('page', 1);
  136. $pageSize = $request->input('page_size', 20);
  137. # 获取分组名称
  138. $groupName = PeriodTempGroup::where('id', $groupId)->value('title');
  139. # 获取智能群发模板列表
  140. list($list, $count) = PeriodMassMsgService::templateList(
  141. $adminId, $sysGroupId, $groupId, $title, $createTimeStart,$createTimeEnd, $status, $page, $pageSize
  142. );
  143. return self::returnPageValue($list, $count, $pageSize, $page, ['group_name' => $groupName ? $groupName : '未分组']);
  144. }
  145. /**
  146. * 智能群发规则详情
  147. * */
  148. public function ruleDetail(Request $request)
  149. {
  150. $validator = \Validator::make($request->all(),[
  151. 'corpid' => 'required|string',
  152. 'rule_id' => 'required|integer',
  153. ]);
  154. if ($validator->fails()) {
  155. return self::returnValue($validator->getMessageBag(), 1102);
  156. }
  157. $corpid = $request->input('corpid');
  158. $ruleId = $request->input('rule_id');
  159. # 获取智能群发规则详情
  160. $errno = 0;
  161. $detail = PeriodMassMsgService::ruleDetail($corpid, $ruleId, $errno);
  162. return self::returnValue($detail, $errno);
  163. }
  164. /**
  165. * 智能群发模板详情
  166. * */
  167. public function templateDetail(Request $request)
  168. {
  169. $validator = \Validator::make($request->all(),[
  170. 'template_id' => 'required|integer',
  171. ]);
  172. if ($validator->fails()) {
  173. return self::returnValue($validator->getMessageBag(), 1102);
  174. }
  175. $adminId = $request->input('admin_id');
  176. $templateId = $request->input('template_id');
  177. $sysGroupId = $request->input('sys_group_id');
  178. # 获取智能群发规则详情
  179. $errno = 0;
  180. $detail = PeriodMassMsgService::templateDetail($templateId, $sysGroupId, $adminId, $errno);
  181. return self::returnValue($detail, $errno);
  182. }
  183. /**
  184. * 智能群发规则状态变更
  185. * */
  186. public function updateStatus(Request $request)
  187. {
  188. $validator = \Validator::make($request->all(),[
  189. 'corpid' => 'required|string',
  190. 'rule_id' => 'required|integer',
  191. 'status' => ['required', Rule::in([0, 1])],
  192. ]);
  193. if ($validator->fails()) {
  194. return self::returnValue($validator->getMessageBag(), 1102);
  195. }
  196. $adminId = $request->input('admin_id');
  197. $corpid = $request->input('corpid');
  198. $status = $request->input('status');
  199. $ruleId = $request->input('rule_id');
  200. $errno = PeriodMassMsgService::updateRuleStatus($corpid, $ruleId, $status, $adminId);
  201. return self::returnValue([], $errno);
  202. }
  203. /**
  204. * 智能群发模板状态修改
  205. * */
  206. public function changeStatus(Request $request)
  207. {
  208. $validator = \Validator::make($request->all(),[
  209. 'template_id' => 'required|integer',
  210. 'status' => ['required', Rule::in([0, 1])],
  211. ]);
  212. if ($validator->fails()) {
  213. return self::returnValue($validator->getMessageBag(), 1102);
  214. }
  215. $adminId = $request->input('admin_id');
  216. $sysGroupId = $request->input('sys_group_id');
  217. $status = $request->input('status');
  218. $templateId = $request->input('template_id');
  219. $errno = PeriodMassMsgService::templateChangeStatus($templateId, $adminId, $sysGroupId, $status);
  220. return self::returnValue([], $errno);
  221. }
  222. /**
  223. * 群发消息列表
  224. * */
  225. public function recordLists(Request $request)
  226. {
  227. $validator = \Validator::make($request->all(),[
  228. 'corpid' => 'required|string',
  229. 'rule_id' => 'required|integer',
  230. 'send_time_start' => 'nullable|date_format:Y-m-d H:i:s',
  231. 'send_time_end' => 'nullable|date_format:Y-m-d H:i:s',
  232. ]);
  233. if ($validator->fails()) {
  234. return self::returnValue($validator->getMessageBag(), 1102);
  235. }
  236. $corpid = $request->input('corpid');
  237. $ruleId = $request->input('rule_id');
  238. $sendTimeStart = $request->input('send_time_start');
  239. $sendTimeEnd = $request->input('send_time_end');
  240. $page = $request->input('page', 1);
  241. $pageSize = $request->input('page_size', 20);
  242. $sortColumn = $request->input('sort_column','send_time');
  243. $sortMethod = $request->input('sort_method','desc');
  244. # 获取群发规则列表
  245. $errno = 0;
  246. list($list, $count) = PeriodMassMsgService::recordList(
  247. $corpid, $ruleId, $sendTimeStart, $sendTimeEnd, $sortColumn, $sortMethod, $page, $pageSize, $errno
  248. );
  249. if($errno) return self::returnValue([], $errno);
  250. return self::returnPageValue($list, $count, $pageSize, $page);
  251. }
  252. public function recordDetail(Request $request)
  253. {
  254. $validator = \Validator::make($request->all(),[
  255. 'corpid' => 'required|string',
  256. 'rule_id' => 'required|integer',
  257. 'send_num' => 'required|numeric',
  258. 'send_date' => 'required|date',
  259. ]);
  260. if ($validator->fails()) {
  261. return self::returnValue($validator->getMessageBag(), 1102);
  262. }
  263. $corpid = $request->input('corpid');
  264. $ruleId = $request->input('rule_id');
  265. $sendNum = $request->input('send_num');
  266. $sendDate = $request->input('send_date');
  267. # 获取群发消息详情
  268. $errno = 0;
  269. $detail = PeriodMassMsgService::recordDetail($corpid, $ruleId, $sendNum, $sendDate, $errno);
  270. return self::returnValue($detail, $errno);
  271. }
  272. /**
  273. * 群发消息数据概览
  274. * @param Request $request
  275. * @return array
  276. */
  277. public function overview(Request $request){
  278. $validator = \Validator::make($request->all(),[
  279. 'corpid' => 'required|string',
  280. 'rule_id' => 'required|integer',
  281. 'send_num' => 'required|numeric',
  282. 'send_date' => 'required|date'
  283. ]);
  284. if ($validator->fails()) {
  285. return self::returnValue($validator->getMessageBag(), 1102);
  286. }
  287. $corpid = $request->input('corpid');
  288. $ruleId = $request->input('rule_id');
  289. $sendNum = $request->input('send_num');
  290. $sendDate = $request->input('send_date');
  291. $res = PeriodMassMsgService::overview($corpid, $ruleId, $sendNum, $sendDate);
  292. return self::returnValue( $res , 0 );
  293. }
  294. /**
  295. * 群发消息发送成员名单
  296. * @param Request $request
  297. * @return array
  298. */
  299. public function senderList(Request $request){
  300. $support_type = ['all','sent','unsent','fail']; //支持的查询类型
  301. $validator = \Validator::make($request->all(),[
  302. 'corpid' => 'required|string',
  303. 'rule_id' => 'required|integer',
  304. 'send_num' => 'required|numeric',
  305. 'send_date' => 'required|date',
  306. 'type' => Rule::in($support_type)
  307. ]);
  308. if ($validator->fails()) {
  309. return self::returnValue($validator->getMessageBag(), 1102);
  310. }
  311. $corpid = $request->input('corpid');
  312. $ruleId = $request->input('rule_id');
  313. $sendNum = $request->input('send_num');
  314. $sendDate = $request->input('send_date');
  315. $type = $request->input("type",$support_type[0]);
  316. $page = $request->input("page",1);
  317. $pageSize = $request->input("page_size",20);
  318. $keyword = $request->input("keyword");
  319. list($total,$list) = PeriodMassMsgService::senderList($corpid, $ruleId, $sendNum, $sendDate, $type, $keyword, $page, $pageSize);
  320. return self::returnPageValue($list,$total,$pageSize,$page);
  321. }
  322. /**
  323. * 群发消息发送成员名单 - 导出
  324. * @param Request $request
  325. * @return array
  326. */
  327. public function senderListExport(Request $request){
  328. $support_type = ['all','sent','unsent','fail']; //支持的查询类型
  329. $validator = \Validator::make($request->all(),[
  330. 'corpid' => 'required|string',
  331. 'rule_id' => 'required|integer',
  332. 'send_num' => 'required|numeric',
  333. 'send_date' => 'required|date',
  334. 'type' => Rule::in($support_type)
  335. ]);
  336. if ($validator->fails()) {
  337. return self::returnValue($validator->getMessageBag(), 1102);
  338. }
  339. $corpid = $request->input('corpid');
  340. $ruleId = $request->input('rule_id');
  341. $sendNum = $request->input('send_num');
  342. $sendDate = $request->input('send_date');
  343. $type = $request->input("type",$support_type[0]);
  344. $keyword = $request->input("keyword");
  345. PeriodMassMsgService::senderListExport($corpid, $ruleId, $sendNum, $sendDate, $type, $keyword);
  346. }
  347. /**
  348. * 获取群发详情-客户列表
  349. * @param Request $request
  350. * @return array
  351. */
  352. public function massSendCustList(Request $request)
  353. {
  354. $validator = \Validator::make($request->all(),[
  355. 'rule_id' => 'required|int',
  356. 'send_num' => 'required|numeric',
  357. 'send_date' => 'required|date',
  358. 'sender' => 'nullable|string',
  359. 'name' => 'nullable|string',
  360. 'type' => 'nullable|int|in:0,1,2,3,4'
  361. ]);
  362. if ($validator->fails()) {
  363. return self::returnValue($validator->getMessageBag(), 1102);
  364. }
  365. $ruleId = $request->input('rule_id');
  366. $sendNum = $request->input('send_num');
  367. $sendDate = $request->input('send_date');
  368. $sender = $request->input('sender');
  369. $name = $request->input('name');
  370. $type = $request->input('type');
  371. $page = $request->input('page', 1);
  372. $pageSize = (int)$request->input('page_size', 20);
  373. list($data, $total) = PeriodMassMsgService::massSendCustList($ruleId, $sendNum, $sendDate, $sender, $name, $type, $page, $pageSize);
  374. return self::returnPageValue($data, $total, $pageSize, $page);
  375. }
  376. /**
  377. * 获取群发详情-客户列表导出
  378. * @param Request $request
  379. * @return array
  380. */
  381. public function massSendCustListExport(Request $request)
  382. {
  383. $validator = \Validator::make($request->all(),[
  384. 'rule_id' => 'required|int',
  385. 'send_num' => 'required|numeric',
  386. 'send_date' => 'required|date',
  387. 'sender' => 'nullable|string',
  388. 'name' => 'nullable|string',
  389. 'type' => 'nullable|int|in:0,1,2,3,4'
  390. ]);
  391. if ($validator->fails()) {
  392. return self::returnValue($validator->getMessageBag(), 1102);
  393. }
  394. $ruleId = $request->input('rule_id');
  395. $sendNum = $request->input('send_num');
  396. $sendDate = $request->input('send_date');
  397. $sender = $request->input('sender');
  398. $name = $request->input('name');
  399. $type = $request->input('type');
  400. PeriodMassMsgService::massSendCustListExport($ruleId, $sendNum, $sendDate, $sender, $name, $type);
  401. }
  402. /**
  403. * 删除智能群发规则
  404. * */
  405. public function deleteRule(Request $request)
  406. {
  407. $validator = \Validator::make($request->all(),[
  408. 'corpid' => 'required|string',
  409. 'rule_id' => 'required|integer',
  410. ]);
  411. if ($validator->fails()) {
  412. return self::returnValue($validator->getMessageBag(), 1102);
  413. }
  414. $corpid = $request->input('corpid');
  415. $ruleId = $request->input('rule_id');
  416. $errno = PeriodMassMsgService::deleteRule($corpid, $ruleId);
  417. return self::returnValue([], $errno);
  418. }
  419. /**
  420. * 批量删除智能群发模板
  421. * */
  422. public function delTemplate(Request $request)
  423. {
  424. $validator = \Validator::make($request->all(),[
  425. 'template_ids' => 'required|string',
  426. ]);
  427. if ($validator->fails()) {
  428. return self::returnValue($validator->getMessageBag(), 1102);
  429. }
  430. $adminId = $request->input('admin_id');
  431. $templateIds = $request->input('template_ids');
  432. $errno = PeriodMassMsgService::delTemplate($templateIds, $adminId);
  433. return self::returnValue([], $errno);
  434. }
  435. /**
  436. * 智能群发分组新建/编辑
  437. * */
  438. public function editGroup(Request $request)
  439. {
  440. $validator = \Validator::make($request->all(),[
  441. 'title' => 'required|string',
  442. ]);
  443. if ($validator->fails()) {
  444. return self::returnValue($validator->getMessageBag(), 1102);
  445. }
  446. $groupId = $request->input('group_id');
  447. $operateType = $request->input('operate_type', 1);
  448. $isOperation = $request->input('is_operation', 0);
  449. $operatorGroupId = $request->input('operator_group_id');
  450. $corpid = $request->input('corpid');
  451. $isAll = $request->input('is_all', 0);
  452. $senders = $request->input('senders');
  453. $multipleSenders = $request->input('multiple_senders');
  454. $groupName = $request->input('title');
  455. $sysGroupId = $request->input('sys_group_id');
  456. $adminId = $request->input('admin_id');
  457. # 创建/编辑 素材组
  458. list($groupId, $errno) = PeriodMassMsgService::editGroup(
  459. $groupId, $groupName, $sysGroupId, $adminId, $operateType, $isOperation, $operatorGroupId, $corpid,
  460. $isAll, $senders, $multipleSenders
  461. );
  462. return self::returnValue(['group_id' => $groupId], $errno);
  463. }
  464. /**
  465. * 智能群发分组新建/编辑
  466. * */
  467. public function editTempGroup(Request $request)
  468. {
  469. $validator = \Validator::make($request->all(),[
  470. 'title' => 'required|string',
  471. ]);
  472. if ($validator->fails()) {
  473. return self::returnValue($validator->getMessageBag(), 1102);
  474. }
  475. $groupId = $request->input('group_id');
  476. $groupName = $request->input('title');
  477. $sysGroupId = $request->input('sys_group_id');
  478. $adminId = $request->input('admin_id');
  479. # 创建/编辑 素材组
  480. list($groupId, $errno) = PeriodMassMsgService::editTempGroup($groupId, $groupName, $sysGroupId, $adminId);
  481. return self::returnValue(['group_id' => $groupId], $errno);
  482. }
  483. /**
  484. * 分组禁用/启用
  485. * */
  486. public function changeGroupStatus(Request $request)
  487. {
  488. $validator = \Validator::make($request->all(),[
  489. 'group_id' => 'required|integer',
  490. 'status' => ['required', Rule::in([0, 1])],
  491. ]);
  492. if ($validator->fails()) {
  493. return self::returnValue($validator->getMessageBag(), 1102);
  494. }
  495. $adminId = $request->input('admin_id');
  496. $sysGroupId = $request->input('sys_group_id');
  497. $status = $request->input('status');
  498. $groupId = $request->input('group_id');
  499. $errno = PeriodMassMsgService::changeGroupStatus($groupId, $adminId, $sysGroupId, $status);
  500. return self::returnValue([], $errno);
  501. }
  502. /**
  503. * 模板分组禁用/启用
  504. * */
  505. public function changeTempGroupStatus(Request $request)
  506. {
  507. $validator = \Validator::make($request->all(),[
  508. 'group_id' => 'required|integer',
  509. 'status' => ['required', Rule::in([0, 1])],
  510. ]);
  511. if ($validator->fails()) {
  512. return self::returnValue($validator->getMessageBag(), 1102);
  513. }
  514. $adminId = $request->input('admin_id');
  515. $sysGroupId = $request->input('sys_group_id');
  516. $status = $request->input('status');
  517. $groupId = $request->input('group_id');
  518. $errno = PeriodMassMsgService::changeTempGroupStatus($groupId, $adminId, $sysGroupId, $status);
  519. return self::returnValue([], $errno);
  520. }
  521. /**
  522. * 分组删除
  523. * */
  524. public function delGroup(Request $request)
  525. {
  526. $validator = \Validator::make($request->all(),[
  527. 'group_id' => 'required|integer',
  528. ]);
  529. if ($validator->fails()) {
  530. return self::returnValue($validator->getMessageBag(), 1102);
  531. }
  532. $adminId = $request->input('admin_id');
  533. $sysGroupId = $request->input('sys_group_id');
  534. $groupId = $request->input('group_id');
  535. $errno = PeriodMassMsgService::delGroup($groupId, $adminId, $sysGroupId);
  536. return self::returnValue([], $errno);
  537. }
  538. /**
  539. * 模板分组删除
  540. * */
  541. public function delTempGroup(Request $request)
  542. {
  543. $validator = \Validator::make($request->all(),[
  544. 'group_id' => 'required|integer',
  545. ]);
  546. if ($validator->fails()) {
  547. return self::returnValue($validator->getMessageBag(), 1102);
  548. }
  549. $adminId = $request->input('admin_id');
  550. $sysGroupId = $request->input('sys_group_id');
  551. $groupId = $request->input('group_id');
  552. $errno = PeriodMassMsgService::delTempGroup($groupId, $adminId, $sysGroupId);
  553. return self::returnValue([], $errno);
  554. }
  555. /**
  556. * 智能推送分组列表
  557. * */
  558. public function groupList(Request $request)
  559. {
  560. $validator = \Validator::make($request->all(),[
  561. 'create_time_start' => 'nullable|date_format:Y-m-d H:i:s',
  562. 'create_time_end' => 'nullable|date_format:Y-m-d H:i:s',
  563. ]);
  564. if ($validator->fails()) {
  565. return self::returnValue($validator->getMessageBag(), 1102);
  566. }
  567. $sysGroupId = $request->input('sys_group_id');
  568. $creatorId = $request->input('creator_id');
  569. $keyword = $request->input('keyword');
  570. $status = $request->input('status');
  571. $createTimeStart = $request->input('create_time_start');
  572. $createTimeEnd = $request->input('create_time_end');
  573. $page = $request->input('page', 1);
  574. $pageSize = $request->input('page_size', 20);
  575. # 获取群发规则列表
  576. $errno = 0;
  577. list($list, $count) = PeriodMassMsgService::groupList(
  578. $sysGroupId, $creatorId, $status, $keyword, $createTimeStart,$createTimeEnd, $page, $pageSize, $errno
  579. );
  580. if($errno) return self::returnValue([], $errno);
  581. return self::returnPageValue($list, $count, $pageSize, $page);
  582. }
  583. /**
  584. * 智能群发分组详情
  585. * */
  586. public function groupDetail(Request $request)
  587. {
  588. $validator = \Validator::make($request->all(),[
  589. 'group_id' => 'required|integer',
  590. ]);
  591. if ($validator->fails()) {
  592. return self::returnValue($validator->getMessageBag(), 1102);
  593. }
  594. $sysGroupId = $request->input('sys_group_id');
  595. $groupId = $request->input('group_id');
  596. $detail = PeriodMassMsgService::groupDetail($groupId, $sysGroupId);
  597. return self::returnValue($detail);
  598. }
  599. /**
  600. * 智能推送分组列表
  601. * */
  602. public function tempGroupList(Request $request)
  603. {
  604. $validator = \Validator::make($request->all(),[
  605. 'create_time_start' => 'nullable|date_format:Y-m-d H:i:s',
  606. 'create_time_end' => 'nullable|date_format:Y-m-d H:i:s',
  607. ]);
  608. if ($validator->fails()) {
  609. return self::returnValue($validator->getMessageBag(), 1102);
  610. }
  611. $sysGroupId = $request->input('sys_group_id');
  612. $creatorId = $request->input('creator_id');
  613. $keyword = $request->input('keyword');
  614. $status = $request->input('status');
  615. $createTimeStart = $request->input('create_time_start');
  616. $createTimeEnd = $request->input('create_time_end');
  617. $page = $request->input('page', 1);
  618. $pageSize = $request->input('page_size', 20);
  619. # 获取群发规则列表
  620. $errno = 0;
  621. list($list, $count) = PeriodMassMsgService::tempGroupList(
  622. $sysGroupId, $creatorId, $status, $keyword, $createTimeStart,$createTimeEnd, $page, $pageSize, $errno
  623. );
  624. if($errno) return self::returnValue([], $errno);
  625. return self::returnPageValue($list, $count, $pageSize, $page);
  626. }
  627. /**
  628. * 批量移动分组
  629. * */
  630. public function changeGroupBatch(Request $request)
  631. {
  632. $validator = \Validator::make($request->all(),[
  633. 'group_id' => 'required|integer',
  634. 'rule_ids' => 'required|string',
  635. ]);
  636. if ($validator->fails()) {
  637. return self::returnValue($validator->getMessageBag(), 1102);
  638. }
  639. $adminId = $request->input('admin_id');
  640. $sysGroupId = $request->input('sys_group_id');
  641. $ruleIds = $request->input('rule_ids');
  642. $groupId = $request->input('group_id');
  643. $errno = PeriodMassMsgService::changeGroupBatch($groupId, $sysGroupId, $adminId, $ruleIds);
  644. return self::returnValue([], $errno);
  645. }
  646. /**
  647. * 批量移动模板分组
  648. * */
  649. public function changeTempGroupBatch(Request $request)
  650. {
  651. $validator = \Validator::make($request->all(),[
  652. 'group_id' => 'required|integer',
  653. 'rule_ids' => 'required|string',
  654. ]);
  655. if ($validator->fails()) {
  656. return self::returnValue($validator->getMessageBag(), 1102);
  657. }
  658. $adminId = $request->input('admin_id');
  659. $sysGroupId = $request->input('sys_group_id');
  660. $ruleIds = $request->input('rule_ids');
  661. $groupId = $request->input('group_id');
  662. $errno = PeriodMassMsgService::changeTempGroupBatch($groupId, $sysGroupId, $adminId, $ruleIds);
  663. return self::returnValue([], $errno);
  664. }
  665. }