123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Service\BatchAddCustomerService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use Illuminate\Validation\Rule;
- class BatchAddCustomerController extends Controller
- {
- /**
- * 配置自动提醒或自动回收
- * */
- public function setAutomateConfig(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'config_list' => 'required|array'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $adminId = $request->input('admin_id');
- $configList = $request->input('config_list');
- $sysGroupId = $request->input('sys_group_id');
- $errNo = BatchAddCustomerService::editConfig($corpid, $adminId, $configList, $sysGroupId);
- return self::returnValue([], $errNo);
- }
- /**
- * 获取企业配置信息
- * */
- public function configInfo(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');
- $adminId = $request->input('admin_id');
- # 获取企业配置自动提醒
- $configInfo = array();
- $errno = BatchAddCustomerService::configInfo($corpid, $sysGroupId, $adminId, $configInfo);
- if($errno) return self::returnValue([], $errno);
- return self::returnValue($configInfo);
- }
- /**
- * 给未完成客户添加工作的成员发送消息提醒
- * */
- public function noticeUser(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'user_ids' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $userIds = $request->input('user_ids');
- $errno = BatchAddCustomerService::noticeUser($corpid, $userIds);
- return self::returnValue([], $errno);
- }
- /**
- * 查看已分配的客户列表
- * */
- public function customerList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'user_id' => 'required|string',
- 'token' => 'required|string',
- 'timestamp' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $userId = $request->input('user_id');
- $token = $request->input('token');
- $timestamp = $request->input('timestamp');
- $addStatus = $request->input('add_status');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 50);
- $errno = 0;
- list($list, $count, $customerTotal) = BatchAddCustomerService::getCustomerList(
- $corpid, $userId, $token, $timestamp, $addStatus, $page, $pageSize, $errno
- );
- if($errno) return self::returnValue([], $errno);
- return self::returnPageValue(['list' => $list, 'customer_total' => $customerTotal], $count, $pageSize, $page);
- }
- /**
- * 客服添加客户数据上报
- * */
- public function dataReporting(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'user_id' => 'required|string',
- 'record_id' => 'required|int',
- 'phone' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $phone = $request->input('phone');
- $userId = $request->input('user_id');
- $recordId = $request->input('record_id');
- # 数据上报
- $errno = BatchAddCustomerService::dataReporting($corpid, $phone, $userId, $recordId);
- return self::returnValue([], $errno);
- }
- /**
- * 数据概览
- * */
- public function dataSummary(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'start_date' => 'required|date_format:Y-m-d',
- 'end_date' => 'required|date_format:Y-m-d',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $sysGroupId = $request->input('sys_group_id');
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- # 获取数据概览
- $data = BatchAddCustomerService::dataSummary($corpid, $startDate, $endDate, $sysGroupId);
- return self::returnValue($data);
- }
- /**
- * 好友添加统计列表
- * */
- public function statistic(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'start_date' => 'required|date_format:Y-m-d',
- 'end_date' => 'required|date_format:Y-m-d',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $userId = $request->input('user_id');
- $startDate = $request->input('start_date');
- $endDate = $request->input('end_date');
- $sysGroupId = $request->input('sys_group_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 50);
- list($list, $count) = BatchAddCustomerService::statistic($corpid, $userId, $startDate, $endDate, $sysGroupId, $page, $pageSize);
- return self::returnPageValue($list, $count, $pageSize, $page);
- }
- }
|