企微短剧业务系统

IntelligentMassSendingController.php 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shensong
  5. * Date: 2022/9/27
  6. * Time: 11:34
  7. */
  8. namespace App\Http\Controllers\Api;
  9. use App\Http\Controllers\Controller;
  10. use Illuminate\Http\Request;
  11. use App\Service\IntelligentMassSendingService;
  12. use Illuminate\Validation\Rule;
  13. class IntelligentMassSendingController extends Controller
  14. {
  15. # 平台列表
  16. public function platformIndex()
  17. {
  18. $data = IntelligentMassSendingService::platformIndex();
  19. return self::returnValue($data);
  20. }
  21. # 添加账号
  22. public function addAccount(Request $request)
  23. {
  24. $validator = \Validator::make($request->all(),[
  25. 'platform_id' => 'required|integer',
  26. 'account' => 'required|string',
  27. 'status' => ['required', Rule::in([1, 2])],//1 启用 2禁用
  28. ]);
  29. if ($validator->fails()) {
  30. return self::returnValue($validator->getMessageBag(), 1102);
  31. }
  32. $params['platform_id'] = $request->input('platform_id');
  33. $params['account'] = $request->input('account');
  34. $params['description'] = $request->input('description');
  35. $params['status'] = $request->input('status');
  36. $params['sys_group_id'] = $request->input('sys_group_id');
  37. list($res, $code) = IntelligentMassSendingService::addAccount($params);
  38. return self::returnValue($res, $code);
  39. }
  40. # 账号列表
  41. public function accountIndex(Request $request)
  42. {
  43. $validator = \Validator::make($request->all(),[
  44. 'page' => 'required|numeric',
  45. 'page_size' => 'required|numeric',
  46. ]);
  47. if ($validator->fails()) {
  48. return self::returnValue($validator->getMessageBag(), 1102);
  49. }
  50. $page = $request->input('page', 1);
  51. $pageSize = $request->input('page_size', 20);
  52. $sysGroupId = $request->input('sys_group_id');
  53. list($list, $count) = IntelligentMassSendingService::accountIndex($page, $pageSize, $sysGroupId);
  54. return self::returnPageValue($list, $count, $pageSize, $page);
  55. }
  56. # 编辑账号
  57. public function editAccount(Request $request)
  58. {
  59. $validator = \Validator::make($request->all(),[
  60. 'account_id' => 'required|integer',
  61. 'account' => 'required|string',
  62. 'platform_id' => 'required|integer',
  63. 'status' => ['required', Rule::in([1, 2])],//1 启用 2禁用
  64. ]);
  65. if ($validator->fails()) {
  66. return self::returnValue($validator->getMessageBag(), 1102);
  67. }
  68. $accountId = $request->input('account_id');
  69. $params['account'] = $request->input('account');
  70. $params['platform_id'] = $request->input('platform_id');
  71. $params['description'] = $request->input('description');
  72. $params['status'] = $request->input('status');
  73. list($res, $code) = IntelligentMassSendingService::editAccount($accountId, $params);
  74. return self::returnValue($res, $code);
  75. }
  76. # 账号列表--下拉框
  77. public function accountList(Request $request)
  78. {
  79. $validator = \Validator::make($request->all(),[
  80. 'platform_id' => 'nullable|integer',
  81. ]);
  82. if ($validator->fails()) {
  83. return self::returnValue($validator->getMessageBag(), 1102);
  84. }
  85. $platformId = $request->input('platform_id');
  86. $sysGroupId = $request->input('sys_group_id');
  87. $list = IntelligentMassSendingService::accountList($platformId, $sysGroupId);
  88. return self::returnValue($list);
  89. }
  90. # 添加小程序
  91. public function addSmallApp(Request $request)
  92. {
  93. $validator = \Validator::make($request->all(),[
  94. 'app_name' => 'required|string',
  95. 'app_id' => 'required|string',
  96. 'platform_id' => 'required|integer',
  97. 'status' => ['required', Rule::in([1, 2])],//1 启用 2禁用
  98. ]);
  99. if ($validator->fails()) {
  100. return self::returnValue($validator->getMessageBag(), 1102);
  101. }
  102. $params['app_name'] = $request->input('app_name');
  103. $params['app_id'] = $request->input('app_id');
  104. $params['platform_id'] = $request->input('platform_id');
  105. $params['sys_group_id'] = $request->input('sys_group_id');
  106. $params['status'] = $request->input('status');
  107. list($res, $code) = IntelligentMassSendingService::addSmallApp($params);
  108. return self::returnValue($res, $code);
  109. }
  110. # 编辑小程序
  111. public function editSmallApp(Request $request)
  112. {
  113. $validator = \Validator::make($request->all(),[
  114. 'data_id' => 'required|integer',
  115. 'app_name' => 'required|string',
  116. 'app_id' => 'required|string',
  117. 'platform_id' => 'required|integer',
  118. 'status' => ['required', Rule::in([1, 2])],//1 启用 2禁用
  119. ]);
  120. if ($validator->fails()) {
  121. return self::returnValue($validator->getMessageBag(), 1102);
  122. }
  123. $dataId = $request->input('data_id');
  124. $params['app_name'] = $request->input('app_name');
  125. $params['app_id'] = $request->input('app_id');
  126. $params['platform_id'] = $request->input('platform_id');
  127. $params['sys_group_id'] = $request->input('sys_group_id');
  128. $params['status'] = $request->input('status');
  129. list($res, $code) = IntelligentMassSendingService::editSmallApp($dataId, $params);
  130. return self::returnValue($res, $code);
  131. }
  132. # 小程序列表
  133. public function smallAppIndex(Request $request)
  134. {
  135. $validator = \Validator::make($request->all(),[
  136. 'page' => 'required|numeric',
  137. 'app_name' => 'nullable|string',
  138. 'page_size' => 'required|numeric',
  139. ]);
  140. if ($validator->fails()) {
  141. return self::returnValue($validator->getMessageBag(), 1102);
  142. }
  143. $appName = $request->input('app_name');
  144. $page = $request->input('page');
  145. $pageSize = $request->input('page_size');
  146. $sysGroupId = $request->input('sys_group_id');
  147. list($list, $count) = IntelligentMassSendingService::smallAppIndex($appName, $page, $pageSize, $sysGroupId);
  148. return self::returnPageValue($list, $count, $pageSize, $page);
  149. }
  150. # 小程序下拉列表
  151. public function smallAppList(Request $request)
  152. {
  153. $validator = \Validator::make($request->all(),[
  154. 'platform_id' => 'integer',
  155. ]);
  156. if ($validator->fails()) {
  157. return self::returnValue($validator->getMessageBag(), 1102);
  158. }
  159. $sysGroupId = $request->input('sys_group_id');
  160. $platformId = $request->input('platform_id');
  161. $list = IntelligentMassSendingService::smallAppList($sysGroupId, $platformId);
  162. return self::returnValue($list);
  163. }
  164. # 公众号下拉列表
  165. public function appList(Request $request)
  166. {
  167. $validator = \Validator::make($request->all(),[
  168. 'corpid' => 'required|string',
  169. ]);
  170. if ($validator->fails()) {
  171. return self::returnValue($validator->getMessageBag(), 1102);
  172. }
  173. $corpid = $request->input('corpid');
  174. $list = IntelligentMassSendingService::appList($corpid);
  175. return self::returnValue($list);
  176. }
  177. }