123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Service\ChatGroupTransferService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use Illuminate\Validation\Rule;
- use phpDocumentor\Reflection\Types\Self_;
- class ChatGroupTransferController extends Controller
- {
- /**
- * 新建/编辑客户群分配配置
- * */
- public function editConfig(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'title' => 'required|string',
- 'type' => ['required', Rule::in([1, 2])],
- 'filter_type' => ['required', Rule::in([1, 2])],
- 'new_owner' => 'required|string',
- 'condition' => 'required',
- 'transfer_type' => ['required', Rule::in([1, 2])],
- 'transfer_at' => 'required|date_format:Y-m-d H:i:s',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $configId = $request->input('config_id');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['admin_id'] = $request->input('admin_id');
- $params['corpid'] = $request->input('corpid');
- $params['title'] = $request->input('title');
- $params['type'] = $request->input('type'); // 转移类型 1在职迁移 2离职迁移
- $params['filter_type'] = $request->input('filter_type'); // 筛选方式 1按群聊 2按群主
- $params['condition'] = $request->input('condition'); // 筛选条件
- $params['new_owner'] = $request->input('new_owner'); // 新群主id
- $params['transfer_type'] = $request->input('transfer_type'); // 分配方式 1立即分配 2定时分配
- $params['transfer_at'] = $request->input('transfer_at'); // 执行分配时间
- # 创建/编辑 客户群分配规则
- $errno = ChatGroupTransferService::editConfig($configId, $params);
- return self::returnValue([], $errno);
- }
- /**
- * 客户群分配配置列表
- * */
- public function configList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'status' => ['nullable', Rule::in([0, 1, 2, 3])],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $corpid = $request->input('corpid');
- $keyword = $request->input('keyword');
- $newOwner = $request->input('new_owner');
- $status = $request->input('status');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- list($list, $count) = ChatGroupTransferService::configList($sysGroupId, $corpid, $keyword, $newOwner, $status, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- /**
- * 客户群分配配置详情
- * */
- public function configDetail(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'config_id' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $corpid = $request->input('corpid');
- $configId = $request->input('config_id');
- # 获取配置详情
- $errno = 0;
- $detail = ChatGroupTransferService::getConfigDetail($sysGroupId, $corpid, $configId, $errno);
- return self::returnValue($detail, $errno);
- }
- /**
- * 修改配置状态
- * */
- public function changeStatus(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'config_id' => 'required|int',
- 'status' => ['required', Rule::in([0, 1])],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sysGroupId = $request->input('sys_group_id');
- $corpid = $request->input('corpid');
- $status = $request->input('status');
- $configId = $request->input('config_id');
- # 变更配置状态
- $errno = ChatGroupTransferService::changeConfigStatus($sysGroupId, $corpid, $status, $configId);
- return self::returnValue([], $errno);
- }
- /**
- * 客户群分配记录
- * */
- public function record(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'config_id' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $configId = $request->input('config_id');
- $page = $request->input('page', 1);
- # 获取分配记录
- list($list, $count) = ChatGroupTransferService::getTransferRecord($corpid, $configId, $page);
- return self::returnPageValue($list, $count, 100, $page);
- }
- }
|