企微短剧业务系统

ChatGroupTransferController.php 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Service\ChatGroupTransferService;
  4. use Illuminate\Http\Request;
  5. use App\Http\Controllers\Controller;
  6. use Illuminate\Validation\Rule;
  7. use phpDocumentor\Reflection\Types\Self_;
  8. class ChatGroupTransferController extends Controller
  9. {
  10. /**
  11. * 新建/编辑客户群分配配置
  12. * */
  13. public function editConfig(Request $request)
  14. {
  15. $validator = \Validator::make($request->all(),[
  16. 'corpid' => 'required|string',
  17. 'title' => 'required|string',
  18. 'type' => ['required', Rule::in([1, 2])],
  19. 'filter_type' => ['required', Rule::in([1, 2])],
  20. 'new_owner' => 'required|string',
  21. 'condition' => 'required',
  22. 'transfer_type' => ['required', Rule::in([1, 2])],
  23. 'transfer_at' => 'required|date_format:Y-m-d H:i:s',
  24. ]);
  25. if ($validator->fails()) {
  26. return self::returnValue($validator->getMessageBag(), 1102);
  27. }
  28. $configId = $request->input('config_id');
  29. $params['sys_group_id'] = $request->input('sys_group_id');
  30. $params['admin_id'] = $request->input('admin_id');
  31. $params['corpid'] = $request->input('corpid');
  32. $params['title'] = $request->input('title');
  33. $params['type'] = $request->input('type'); // 转移类型 1在职迁移 2离职迁移
  34. $params['filter_type'] = $request->input('filter_type'); // 筛选方式 1按群聊 2按群主
  35. $params['condition'] = $request->input('condition'); // 筛选条件
  36. $params['new_owner'] = $request->input('new_owner'); // 新群主id
  37. $params['transfer_type'] = $request->input('transfer_type'); // 分配方式 1立即分配 2定时分配
  38. $params['transfer_at'] = $request->input('transfer_at'); // 执行分配时间
  39. # 创建/编辑 客户群分配规则
  40. $errno = ChatGroupTransferService::editConfig($configId, $params);
  41. return self::returnValue([], $errno);
  42. }
  43. /**
  44. * 客户群分配配置列表
  45. * */
  46. public function configList(Request $request)
  47. {
  48. $validator = \Validator::make($request->all(),[
  49. 'corpid' => 'required|string',
  50. 'status' => ['nullable', Rule::in([0, 1, 2, 3])],
  51. ]);
  52. if ($validator->fails()) {
  53. return self::returnValue($validator->getMessageBag(), 1102);
  54. }
  55. $sysGroupId = $request->input('sys_group_id');
  56. $corpid = $request->input('corpid');
  57. $keyword = $request->input('keyword');
  58. $newOwner = $request->input('new_owner');
  59. $status = $request->input('status');
  60. $page = $request->input('page', 1);
  61. $pageSize = $request->input('page_size', 20);
  62. list($list, $count) = ChatGroupTransferService::configList($sysGroupId, $corpid, $keyword, $newOwner, $status, $page, $pageSize);
  63. return self::returnPageValue($list, $count, $pageSize, $page);
  64. }
  65. /**
  66. * 客户群分配配置详情
  67. * */
  68. public function configDetail(Request $request)
  69. {
  70. $validator = \Validator::make($request->all(),[
  71. 'corpid' => 'required|string',
  72. 'config_id' => 'required|int',
  73. ]);
  74. if ($validator->fails()) {
  75. return self::returnValue($validator->getMessageBag(), 1102);
  76. }
  77. $sysGroupId = $request->input('sys_group_id');
  78. $corpid = $request->input('corpid');
  79. $configId = $request->input('config_id');
  80. # 获取配置详情
  81. $errno = 0;
  82. $detail = ChatGroupTransferService::getConfigDetail($sysGroupId, $corpid, $configId, $errno);
  83. return self::returnValue($detail, $errno);
  84. }
  85. /**
  86. * 修改配置状态
  87. * */
  88. public function changeStatus(Request $request)
  89. {
  90. $validator = \Validator::make($request->all(),[
  91. 'corpid' => 'required|string',
  92. 'config_id' => 'required|int',
  93. 'status' => ['required', Rule::in([0, 1])],
  94. ]);
  95. if ($validator->fails()) {
  96. return self::returnValue($validator->getMessageBag(), 1102);
  97. }
  98. $sysGroupId = $request->input('sys_group_id');
  99. $corpid = $request->input('corpid');
  100. $status = $request->input('status');
  101. $configId = $request->input('config_id');
  102. # 变更配置状态
  103. $errno = ChatGroupTransferService::changeConfigStatus($sysGroupId, $corpid, $status, $configId);
  104. return self::returnValue([], $errno);
  105. }
  106. /**
  107. * 客户群分配记录
  108. * */
  109. public function record(Request $request)
  110. {
  111. $validator = \Validator::make($request->all(),[
  112. 'corpid' => 'required|string',
  113. 'config_id' => 'required|int',
  114. ]);
  115. if ($validator->fails()) {
  116. return self::returnValue($validator->getMessageBag(), 1102);
  117. }
  118. $corpid = $request->input('corpid');
  119. $configId = $request->input('config_id');
  120. $page = $request->input('page', 1);
  121. # 获取分配记录
  122. list($list, $count) = ChatGroupTransferService::getTransferRecord($corpid, $configId, $page);
  123. return self::returnPageValue($list, $count, 100, $page);
  124. }
  125. }