企微短剧业务系统

PlatformController.php 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Log;
  4. use App\Service\PlatformService;
  5. use Illuminate\Http\Request;
  6. use App\Http\Controllers\Controller;
  7. use Illuminate\Validation\Rule;
  8. class PlatformController extends Controller
  9. {
  10. /**
  11. * 短剧列表
  12. * */
  13. public function playletList(Request $request)
  14. {
  15. $platformId = $request->input('platform_id');
  16. $keyword = $request->input('keyword');
  17. $accountId = $request->input('account_id');
  18. $sysGroupId = $request->input('sys_group_id');
  19. $page = $request->input('page', 1);
  20. $pageSize = $request->input('page_size', 20);
  21. # 获取群列表
  22. list($list, $count) = PlatformService::playletList($platformId, $sysGroupId, $keyword, $accountId, $page, $pageSize);
  23. return self::returnPageValue($list, $count, $pageSize, $page);
  24. }
  25. /**
  26. * 创建推广链接
  27. * */
  28. public function createLink(Request $request)
  29. {
  30. $validator = \Validator::make($request->all(),[
  31. 'corpid' => 'required|string',
  32. 'mini_app_id' => 'nullable|string',
  33. 'platform_id' => 'required|int',
  34. 'account_id' => 'required|int',
  35. 'app_id' => 'required|string',
  36. 'name' => 'required|string',
  37. 'playlet_id' => 'required|string',
  38. 'episode_num' => 'required|int',
  39. 'link_type' => 'required|in:0,1'
  40. ]);
  41. if ($validator->fails()) {
  42. return self::returnValue($validator->getMessageBag(), 1102);
  43. }
  44. $platformId = $request->input('platform_id');
  45. $accountId = $request->input('account_id');
  46. $sysGroupId = $request->input('sys_group_id');
  47. $adminId = $request->input('admin_id');
  48. $params['corpid'] = $request->input('corpid'); // 企微Id
  49. $params['app_id'] = $request->input('app_id'); // 公众号appId
  50. $params['mini_app_id'] = $request->input('mini_app_id'); // 小程序appId
  51. $params['name'] = $request->input('name'); // 推广链接名称
  52. $params['playlet_id'] = $request->input('playlet_id'); // 短剧id
  53. $params['episode_num'] = $request->input('episode_num'); // 剧集集数
  54. $params['force_subscribe'] = $request->input('episode_num', 0); // 是否强关: 0不强关,1强关
  55. $params['force_subscribe_sectionId'] = $request->input('force_subscribe_sectionId', 0); // 强关集数
  56. $params['type'] = $request->input('type', 0); // 剧集集数
  57. $params['link_type'] = $request->input('link_type'); // 链接类型
  58. $errno = 0;
  59. $data = PlatformService::createLink($params, $platformId, $accountId, $sysGroupId, $adminId, $errno);
  60. if($errno) return self::returnValue($data, $errno);
  61. return self::returnValue($data);
  62. }
  63. public function setPlayletGroup(Request $request)
  64. {
  65. $validator = \Validator::make($request->all(),[
  66. 'sys_group_id' => 'required',
  67. 'name' => 'required|string',
  68. 'playlet_list' => 'required'
  69. ]);
  70. if ($validator->fails()) {
  71. return self::returnValue($validator->getMessageBag(), 1102);
  72. }
  73. $sysGroupId = $request->input('sys_group_id');// 系统权限组ID
  74. $name = $request->input('name'); // 短剧组名称
  75. $playletList = $request->input('playlet_list');// 短剧信息
  76. $adminId = $request->input('admin_id'); // 操作人ID
  77. $corpid = $request->input('corpid'); // 企微ID
  78. $groupId = $request->input('group_id'); // 短剧组ID
  79. $errno = 0;
  80. PlatformService::setPlayletGroup($sysGroupId, $corpid, $adminId, $groupId, $name, $playletList, $errno);
  81. return self::returnValue([], $errno);
  82. }
  83. public function playletGroupList(Request $request)
  84. {
  85. $sysGroupId = $request->input('sys_group_id');
  86. $page = $request->input('page', 1);
  87. $pageSize = $request->input('page_size', 20);
  88. list($data, $total) = PlatformService::playletGroupList($sysGroupId, $page, $pageSize);
  89. return self::returnPageValue($data, $total, $pageSize, $page);
  90. }
  91. public function addPlayletToGroup(Request $request)
  92. {
  93. $validator = \Validator::make($request->all(),[
  94. 'corpid' => 'required|string',
  95. 'mini_app_id' => 'nullable|string',
  96. 'platform_id' => 'required|int',
  97. 'account_id' => 'required|int',
  98. 'app_id' => 'required|string',
  99. 'playlet_id' => 'required|string',
  100. 'episode_num' => 'required|int',
  101. 'link_type' => 'required|in:0,1'
  102. ]);
  103. if ($validator->fails()) {
  104. return self::returnValue($validator->getMessageBag(), 1102);
  105. }
  106. $params['platform_id'] = $request->input('platform_id');
  107. $params['account_id'] = $request->input('account_id');
  108. $params['group_id'] = $request->input('group_id');
  109. $params['corpid'] = $request->input('corpid'); // 企微Id
  110. $params['app_id'] = $request->input('app_id'); // 公众号appId
  111. $params['mini_app_id'] = $request->input('mini_app_id'); // 小程序appId
  112. $params['name'] = $request->input('name'); // 推广链接名称
  113. $params['playlet_id'] = $request->input('playlet_id'); // 短剧id
  114. $params['episode_num'] = $request->input('episode_num'); // 剧集集数
  115. $params['force_subscribe'] = $request->input('episode_num', 0); // 是否强关: 0不强关,1强关
  116. $params['force_subscribe_sectionId'] = $request->input('force_subscribe_sectionId', 0); // 强关集数
  117. $params['type'] = $request->input('type', 0); // 剧集集数
  118. $params['link_type'] = $request->input('link_type'); // 链接类型
  119. $errno = 0;
  120. PlatformService::addPlayletToGroup($params, $errno);
  121. return self::returnValue([], $errno);
  122. }
  123. public function playletGroupDetail(Request $request)
  124. {
  125. $validator = \Validator::make($request->all(),[
  126. 'group_id' => 'required|integer'
  127. ]);
  128. if ($validator->fails()) {
  129. return self::returnValue($validator->getMessageBag(), 1102);
  130. }
  131. $groupId = $request->input('group_id');
  132. list($data, $errno) = PlatformService::playletGroupDetail($groupId);
  133. return self::returnValue($data, $errno);
  134. }
  135. public function createPlayletGroupLink(Request $request)
  136. {
  137. $validator = \Validator::make($request->all(),[
  138. 'group_id' => 'required|integer'
  139. ]);
  140. if ($validator->fails()) {
  141. return self::returnValue($validator->getMessageBag(), 1102);
  142. }
  143. $groupId = $request->input('group_id');
  144. $corpid = $request->input('corpid');
  145. if('test' == env('ENVIRONMENT')){
  146. $url = 'http://duanju.wenxingshuju.com';
  147. } else {
  148. $url = 'http://dj.wenxingshuju.com';
  149. }
  150. $url .= '/playlet/qwh5/dist/index.html#/playletGroupH5?corpid='.$corpid.'&group_id='.$groupId.'&send_type=6';
  151. return self::returnValue($url);
  152. }
  153. public function playletGroupH5Detail(Request $request)
  154. {
  155. $validator = \Validator::make($request->all(),[
  156. 'group_id' => 'required|integer',
  157. 'sender' => 'required|string',
  158. 'rule_id' => 'required|integer',
  159. 'msg_type' => 'required'
  160. ]);
  161. if ($validator->fails()) {
  162. return self::returnValue($validator->getMessageBag(), 1102);
  163. }
  164. $groupId = $request->input('group_id');
  165. $sender = $request->input('sender');
  166. $ruleId = $request->input('rule_id');
  167. $msgType = $request->input('msg_type');
  168. $data = PlatformService::playletGroupH5Detail($groupId, $sender, $ruleId, $msgType);
  169. return self::returnValue($data);
  170. }
  171. public function paramsValidate(Request $request)
  172. {
  173. $validator = \Validator::make($request->all(),[
  174. 'corpid' => 'required|string',
  175. 'mini_app_id' => 'nullable|string',
  176. 'platform_id' => 'required|int',
  177. 'account_id' => 'required|int',
  178. 'app_id' => 'required|string',
  179. 'name' => 'required|string',
  180. 'playlet_id' => 'required|string',
  181. 'episode_num' => 'required|int',
  182. 'link_type' => 'required|in:0,1'
  183. ]);
  184. if ($validator->fails()) {
  185. return self::returnValue($validator->getMessageBag(), 1102);
  186. }
  187. $platformId = $request->input('platform_id');
  188. $accountId = $request->input('account_id');
  189. $sysGroupId = $request->input('sys_group_id');
  190. $adminId = $request->input('admin_id');
  191. $params['corpid'] = $request->input('corpid'); // 企微Id
  192. $params['app_id'] = $request->input('app_id'); // 公众号appId
  193. $params['mini_app_id'] = $request->input('mini_app_id'); // 小程序appId
  194. $params['name'] = $request->input('name'); // 推广链接名称
  195. $params['playlet_id'] = $request->input('playlet_id'); // 短剧id
  196. $params['episode_num'] = $request->input('episode_num'); // 剧集集数
  197. $params['force_subscribe'] = $request->input('episode_num', 0); // 是否强关: 0不强关,1强关
  198. $params['force_subscribe_sectionId'] = $request->input('force_subscribe_sectionId', 0); // 强关集数
  199. $params['type'] = $request->input('type', 0); // 剧集集数
  200. $params['link_type'] = $request->input('link_type'); // 链接类型
  201. $errno = 0;
  202. $data = PlatformService::paramsValidate($params, $platformId, $accountId, $sysGroupId, $adminId, $errno);
  203. if($errno) return self::returnValue($data, $errno);
  204. return self::returnValue($data);
  205. }
  206. public function batchCreateLink(Request $request)
  207. {
  208. $validator = \Validator::make($request->all(),[
  209. 'sys_group_id' => 'required',
  210. 'playlet_list' => 'required'
  211. ]);
  212. if ($validator->fails()) {
  213. return self::returnValue($validator->getMessageBag(), 1102);
  214. }
  215. $sysGroupId = $request->input('sys_group_id');// 系统权限组ID
  216. $playletList = $request->input('playlet_list');// 短剧信息
  217. $adminId = $request->input('admin_id'); // 操作人ID
  218. $corpid = $request->input('corpid'); // 企微ID
  219. list($errMsg, $errNo) = PlatformService::batchCreateLink($sysGroupId, $corpid, $adminId, $playletList);
  220. return self::returnValue($errMsg, $errNo);
  221. }
  222. }