企微短剧业务系统

SourceQrcodeController.php 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Service\SourceQrcodeService;
  4. use Illuminate\Http\Request;
  5. use App\Http\Controllers\Controller;
  6. class SourceQrcodeController extends Controller
  7. {
  8. public function addSqgroup(Request $request)
  9. {
  10. $validator = \Validator::make($request->all(),[
  11. 'corpid' => 'required',
  12. 'name' => 'required'
  13. ]);
  14. if ($validator->fails()) {
  15. return self::returnValue($validator->getMessageBag(), 1102);
  16. }
  17. $corpid = $request->input('corpid');
  18. $name = $request->input('name');
  19. $type = $request->input('type', 1); // 类型 1:渠道活码 2:群活码
  20. $errCode = SourceQrcodeService::addSqgroup($corpid, $name, $type);
  21. return self::returnValue([], $errCode);
  22. }
  23. public function editSqgroup(Request $request)
  24. {
  25. $validator = \Validator::make($request->all(),[
  26. 'id' => 'required|int',
  27. 'name' => 'required'
  28. ]);
  29. if ($validator->fails()) {
  30. return self::returnValue($validator->getMessageBag(), 1102);
  31. }
  32. $id = $request->input('id');
  33. $name = $request->input('name');
  34. $errCode = SourceQrcodeService::editSqgroup($id, $name);
  35. return self::returnValue([], $errCode);
  36. }
  37. public function editGroupSort(Request $request)
  38. {
  39. $validator = \Validator::make($request->all(),[
  40. 'ids' => 'required|array',
  41. ]);
  42. if ($validator->fails()) {
  43. return self::returnValue($validator->getMessageBag(), 1102);
  44. }
  45. $ids = $request->input('ids');
  46. $errCode = SourceQrcodeService::editGroupSort($ids);
  47. return self::returnValue([], $errCode);
  48. }
  49. public function delSqGroup(Request $request)
  50. {
  51. $validator = \Validator::make($request->all(),[
  52. 'id' => 'required|int',
  53. 'del_sqs' => 'nullable|int'
  54. ]);
  55. if ($validator->fails()) {
  56. return self::returnValue($validator->getMessageBag(), 1102);
  57. }
  58. $id = $request->input('id');
  59. $del_sqs = $request->input('del_sqs');
  60. $errCode = SourceQrcodeService::delSqGroup($id, $del_sqs);
  61. return self::returnValue([], $errCode);
  62. }
  63. public function sqGroupList(Request $request)
  64. {
  65. $validator = \Validator::make($request->all(),[
  66. 'corpid' => 'required',
  67. 'page' => 'required|int',
  68. 'page_size' => 'int',
  69. ]);
  70. if ($validator->fails()) {
  71. return self::returnValue($validator->getMessageBag(), 1102);
  72. }
  73. $corpid = $request->input('corpid');
  74. $page = $request->input('page', 1);
  75. $pagesize = $request->input('page_size', 20);
  76. $type = $request->input('type', 1);
  77. list($data, $total) = SourceQrcodeService::sqGroupList($corpid, $type, $page, $pagesize);
  78. return self::returnPageValue($data, $total, $pagesize, $page);
  79. }
  80. public function addSourceQrcode(Request $request)
  81. {
  82. $validator = \Validator::make($request->all(),[
  83. 'corpid' => 'required',
  84. 'name' => 'required',
  85. 'group_id' => 'nullable',
  86. 'user_json' => 'required',
  87. 'tag_list' => 'nullable',
  88. 'customer_prefix' => 'required',
  89. 'customer_prefix_type' => 'required',
  90. 'up_toplimit' => 'nullable|int',
  91. 'warn_user' => 'nullable',
  92. 'msg_data' => 'required'
  93. ]);
  94. if ($validator->fails()) {
  95. return self::returnValue($validator->getMessageBag(), 1102);
  96. }
  97. $corpid = $request->input('corpid');
  98. $name = $request->input('name');
  99. $group_id = $request->input('group_id');
  100. $user_json = $request->input('user_json');
  101. $tag_list = $request->input('tag_list');
  102. $customer_prefix = $request->input('customer_prefix');
  103. $customer_prefix_type = $request->input('customer_prefix_type');
  104. $up_toplimit = $request->input('up_toplimit');
  105. $warn_user = $request->input('warn_user');
  106. $msg_data = $request->input('msg_data');
  107. list($code, $msg) = SourceQrcodeService::addSourceQrcode($corpid, $name, $group_id, $user_json, $tag_list, $customer_prefix, $customer_prefix_type, $up_toplimit, $warn_user, $msg_data);
  108. return self::returnValue(['msg' => $msg], $code);
  109. }
  110. public function editSourceQrcode(Request $request)
  111. {
  112. $validator = \Validator::make($request->all(),[
  113. 'id' => 'required|int',
  114. 'name' => 'required',
  115. 'group_id' => 'nullable',
  116. 'user_json' => 'required',
  117. 'tag_list' => 'required',
  118. 'customer_prefix' => 'required',
  119. 'customer_prefix_type' => 'required',
  120. 'up_toplimit' => 'nullable|int',
  121. 'warn_user' => 'nullable',
  122. 'msg_data' => 'required'
  123. ]);
  124. if ($validator->fails()) {
  125. return self::returnValue($validator->getMessageBag(), 1102);
  126. }
  127. $id = $request->input('id');
  128. $name = $request->input('name');
  129. $group_id = $request->input('group_id');
  130. $user_json = $request->input('user_json');
  131. $tag_list = $request->input('tag_list');
  132. $customer_prefix = $request->input('customer_prefix');
  133. $customer_prefix_type = $request->input('customer_prefix_type');
  134. $up_toplimit = $request->input('up_toplimit');
  135. $warn_user = $request->input('warn_user');
  136. $msg_data = $request->input('msg_data');
  137. list($code, $msg) = SourceQrcodeService::editSourceQrcode($id, $name, $group_id, $user_json, $tag_list, $customer_prefix, $customer_prefix_type, $up_toplimit, $warn_user, $msg_data);
  138. return self::returnValue(['msg' => $msg], $code);
  139. }
  140. public function sourceQrcodeList(Request $request)
  141. {
  142. $validator = \Validator::make($request->all(),[
  143. 'corpid' => 'required',
  144. 'group_id' => 'nullable|int',
  145. 'name' => 'nullable',
  146. 'user_id' => 'nullable',
  147. 'page' => 'required|int',
  148. 'page_size' => 'int',
  149. ]);
  150. if ($validator->fails()) {
  151. return self::returnValue($validator->getMessageBag(), 1102);
  152. }
  153. $corpid = $request->input('corpid');
  154. $group_id = $request->input('group_id');
  155. $name = $request->input('name');
  156. $user_ids = $request->input('user_ids');
  157. $page = $request->input('page', 1);
  158. $pagesize = $request->input('page_size', 20);
  159. list($data, $total) = SourceQrcodeService::sourceQrcodeList($corpid, $group_id, $name, $user_ids, $page, $pagesize);
  160. return self::returnPageValue($data, $total, $pagesize, $page);
  161. }
  162. public function delSourceQrcode(Request $request)
  163. {
  164. $validator = \Validator::make($request->all(),[
  165. 'id' => 'required|int'
  166. ]);
  167. if ($validator->fails()) {
  168. return self::returnValue($validator->getMessageBag(), 1102);
  169. }
  170. $id = $request->input('id');
  171. list($code, $msg) = SourceQrcodeService::delSourceQrcode($id);
  172. return self::returnValue(['msg' => $msg], $code);
  173. }
  174. public function sourceQrcodeDetail(Request $request)
  175. {
  176. $validator = \Validator::make($request->all(),[
  177. 'id' => 'required|int'
  178. ]);
  179. if ($validator->fails()) {
  180. return self::returnValue($validator->getMessageBag(), 1102);
  181. }
  182. $id = $request->input('id');
  183. $res = SourceQrcodeService::sourceQrcodeDetail($id);
  184. return self::returnValue($res);
  185. }
  186. public function customerList(Request $request)
  187. {
  188. $validator = \Validator::make($request->all(),[
  189. 'sq_id' => 'required|int',
  190. 'name' => 'nullable',
  191. ]);
  192. if ($validator->fails()) {
  193. return self::returnValue($validator->getMessageBag(), 1102);
  194. }
  195. $sq_id = $request->input('sq_id');
  196. $name = $request->input('name');
  197. $page = $request->input('page', 1);
  198. $pagesize = $request->input('page_size', 20);
  199. list($data, $total) = SourceQrcodeService::customerList($sq_id, $name, $page, $pagesize);
  200. return self::returnPageValue($data, $total, $pagesize, $page);
  201. }
  202. public function staffList(Request $request)
  203. {
  204. $validator = \Validator::make($request->all(),[
  205. 'sq_id' => 'required|int'
  206. ]);
  207. if ($validator->fails()) {
  208. return self::returnValue($validator->getMessageBag(), 1102);
  209. }
  210. $sq_id = $request->input('sq_id');
  211. $data = SourceQrcodeService::staffList($sq_id);
  212. return self::returnValue($data);
  213. }
  214. /**
  215. * 数据分析概览
  216. * @param Request $request
  217. * @return array
  218. */
  219. public function dataView(Request $request)
  220. {
  221. $validator = \Validator::make($request->all(),[
  222. 'id' => 'required|int'
  223. ]);
  224. if ($validator->fails()) {
  225. return self::returnValue($validator->getMessageBag(), 1102);
  226. }
  227. $id = $request->input('id');
  228. $res = SourceQrcodeService::dataView($id);
  229. return self::returnValue($res);
  230. }
  231. /**
  232. * 数据分析趋势
  233. * @param Request $request
  234. * @return array
  235. */
  236. public function dataTrend(Request $request)
  237. {
  238. $validator = \Validator::make($request->all(),[
  239. 'id' => 'required|int',
  240. 'st_date' => 'required|date',
  241. 'en_date' => 'required|date',
  242. ]);
  243. if ($validator->fails()) {
  244. return self::returnValue($validator->getMessageBag(), 1102);
  245. }
  246. $id = $request->input('id');
  247. $stDate = $request->input('st_date');
  248. $enDate = $request->input('en_date');
  249. $res = SourceQrcodeService::dataTrend($id, $stDate, $enDate);
  250. return self::returnValue($res);
  251. }
  252. }