企微短剧业务系统

ChatGroupMsgController.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shensong
  5. * Date: 2022/11/14
  6. * Time: 17:05
  7. */
  8. namespace App\Http\Controllers\Api;
  9. use App\Http\Controllers\Controller;
  10. use App\Service\ChatGroup\ChatGroupMassMsgService;
  11. use Illuminate\Http\Request;
  12. class ChatGroupMsgController extends Controller
  13. {
  14. public function getMessage(Request $request)
  15. {
  16. $validator = \Validator::make($request->all(),[
  17. 'corpid' => 'required|string',
  18. 'rule_id' => 'required|integer',
  19. 'chat_id' => 'required',
  20. ]);
  21. if ($validator->fails()) {
  22. return self::returnValue($validator->getMessageBag(), 1102);
  23. }
  24. $params['corpid'] = $request->input('corpid');
  25. $params['rule_id'] = $request->input('rule_id');
  26. $params['chat_id'] = $request->input('chat_id');
  27. # 消息处理成可发送的数据结构
  28. $errno = 0;
  29. $msgInfo = ChatGroupMassMsgService::getChatMessage($params, $errno);
  30. if($errno) return self::returnValue([], $errno);
  31. return self::returnValue(['data' => $msgInfo]);
  32. }
  33. public function report(Request $request)
  34. {
  35. $validator = \Validator::make($request->all(),[
  36. 'corpid' => 'required',
  37. 'chat_id' => 'required',
  38. 'rule_id' => 'required|integer'
  39. ]);
  40. if ($validator->fails()) {
  41. return self::returnValue($validator->getMessageBag(), 1102);
  42. }
  43. $params['corpid'] = $request->input('corpid');
  44. $params['chat_id'] = $request->input('chat_id');
  45. $params['rule_id'] = $request->input('rule_id');
  46. $params['status'] = $request->input('status', 1);
  47. $type = $request->input('type', 1);
  48. $errmsg = $request->input('errmsg');
  49. $errno = 0;
  50. ChatGroupMassMsgService::report($params, $errno, $type, $errmsg);
  51. return self::returnValue([], $errno);
  52. }
  53. }