123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Log;
- use App\Service\UserSopService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use Illuminate\Validation\Rule;
- class UserSopController extends Controller
- {
- /**
- * 配置个人SOP规则
- * */
- public function setRule(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'title' => 'required|string',
- 'type' => ['required', Rule::in([1, 2])],
- 'is_all' => ['required', Rule::in([0, 1])],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params = [];
- $ruleId = $request->input('rule_id');
- $params['corpid'] = $request->input('corpid');
- $params['admin_id'] = $request->input('admin_id');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['title'] = $request->input('title');
- $params['is_all'] = $request->input('is_all', 0);
- $params['user_ids'] = $request->input('user_ids');
- $params['type'] = $request->input('type'); // 规则类型 1客户添加后间隔指定时间提醒 2客户添加后在指定的时间点提醒
- $params['interval_time'] = $request->input('interval_time'); // 间隔时间。单位:分钟
- $params['notice_time'] = $request->input('notice_time'); // 提醒客服时间.示例:09:00:00
- $params['msg_data'] = $request->input('msg_data'); // 提醒消息
- $params['customer_filter'] = $request->input('customer_filter', 0); // 客户筛选 0:全部客户 1:筛选客户
- $params['gender'] = $request->input('gender');
- $params['tag_screen_type'] = $request->input('tag_screen_type');
- $params['tag_list'] = $request->input('tag_list');
- $params['exclude_tag_list'] = $request->input('exclude_tag_list');
- $params['pay_status'] = $request->input('pay_status');
- $params['pay_num_min'] = $request->input('pay_num_min'); // 最小付费次数
- $params['pay_num_max'] = $request->input('pay_num_max'); // 最大付费次数
- # 设置群活码规则
- $errno = UserSopService::setRule($params, $ruleId);
- return self::returnValue([], $errno);
- }
- /**
- * 个人SOP规则列表
- * */
- public function ruleList(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $sysGroupId = $request->input('sys_group_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- # 设置群活码规则
- list($list, $count) = UserSopService::ruleList($corpid, $sysGroupId, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- /**
- * 个人SOP配置详情
- * */
- public function ruleDetail(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'rule_id' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $sysGroupId = $request->input('sys_group_id');
- $ruleId = $request->input('rule_id');
- # 获取配置详情
- $data = UserSopService::ruleDetail($corpid, $sysGroupId, $ruleId);
- return self::returnValue($data);
- }
- /**
- * 个人SOP配置状态变更
- * */
- public function changeStatus(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'rule_id' => 'required|int',
- 'status' => ['required', Rule::in([0, 1])],
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $sysGroupId = $request->input('sys_group_id');
- $ruleId = $request->input('rule_id');
- $status = $request->input('status');
- # 变更配置状态
- $errno = UserSopService::ruleStatusChange($corpid, $sysGroupId, $ruleId, $status);
- return self::returnValue([], $errno);
- }
- /**
- * 个人SOP规则详情【H5】
- * */
- public function detail(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'rule_id' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $ruleId = $request->input('rule_id');
- # 获取规则详情及待跟进客户列表
- $errno = 0;
- $data = UserSopService::getDetail($corpid, $ruleId, $errno);
- return self::returnValue(['data' => $data], $errno);
- }
- /**
- * 待跟进客户列表
- * */
- public function customer(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'rule_id' => 'required|int',
- 'user_id' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $ruleId = $request->input('rule_id');
- $userId = $request->input('user_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 50);
- # 获取待跟进客户列表
- list($list, $count) = UserSopService::getCustomerList($corpid, $ruleId, $userId, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- /**
- * 跟进客户数据上报【H5】
- * */
- public function report(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'rule_id' => 'required|int',
- 'user_id' => 'required|string',
- 'external_userid' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $ruleId = $request->input('rule_id');
- $userId = $request->input('user_id');
- $externalUserid = $request->input('external_userid');
- $errno = UserSopService::report($corpid, $ruleId, $userId, $externalUserid);
- return self::returnValue([], $errno);
- }
- }
|