123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029 |
- <?php
- /**
- * Created by PhpStorm.
- * User: shensong
- * Date: 2022/3/15
- * Time: 18:21
- */
- namespace App\Http\Controllers\Api;
- use App\Http\Controllers\Controller;
- use App\Log;
- use App\Service\AddCustomerService;
- use App\Service\CustomerService;
- use App\Service\HttpService;
- use App\Service\TokenService;
- use App\Service\wechatWorkService;
- use Illuminate\Http\Request;
- class CustomerController extends Controller
- {
- // 更新企业全部信息
- public function getCorCustomerList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- list($res, $code) = wechatWorkService::getCorCustomerList($corpid);
- return self::returnValue($res, $code);
- }
- //(废弃)
- public function transferCustomer(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'handover_userid' => 'required',
- 'takeover_userid' => 'required',
- 'external_userid_list' => 'required|array',
- 'type' => 'required|in:1,2',
- 'select_all' => 'nullable|in:0,1'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $handoverUserId = $request->input('handover_userid');
- $takeoverUserId = $request->input('takeover_userid');
- $externalUserIdList = $request->input('external_userid_list');
- $transferSuccessMsg = $request->input('transfer_success_msg');
- $type = $request->input('type');
- $selectAll = $request->input('select_all',0);
- list($data, $code) = CustomerService::addCustomerAssignment($corpid, $handoverUserId, $takeoverUserId,
- $externalUserIdList, $transferSuccessMsg, $type, $selectAll);
- return self::returnValue($data, $code);
- }
- // 客户迁移
- public function transferCustomerNew(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'takeover_userid' => 'required',
- 'external_user_list' => 'nullable|array',
- 'type' => 'required|in:1,2',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $takeoverUserId = $request->input('takeover_userid');
- $externalUserList = $request->input('external_user_list');
- $transferSuccessMsg = $request->input('transfer_success_msg');
- $type = $request->input('type');
- $portraitInheritance = $request->input('portrait_inheritance', 1);
- $selectAll = $request->input('select_all',0);
- $filterCustomerList = $request->input('filter_customer_list');
- $params['customer_name'] = $request->input('customer_name'); // 客户名关键字
- $params['user_id_list'] = $request->input('user_id_list'); // 所属客服
- $params['add_date_start'] = $request->input('add_date_start'); // 起始添加日期
- $params['add_date_end'] = $request->input('add_date_end'); // 截止添加日期
- $params['add_way'] = $request->input('add_way'); // 添加渠道
- $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'); // 最高付费次数
- $params['tag_type'] = $request->input('tag_type', 0); // 标签筛选类型 0未筛选 1满足其一 2同时满足 3无标签
- $params['tag_id_list'] = $request->input('tag_id_list'); // 标签列表
- list($data, $code) = CustomerService::addCustomerAssignmentNew($corpid, $takeoverUserId,
- $externalUserList, $transferSuccessMsg, $type, $portraitInheritance, $selectAll, $filterCustomerList, $params);
- return self::returnValue($data, $code);
- }
- // 待分配的离职成员客户列表
- public function unassignedCustomerList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'user_id_list' => 'nullable|array',
- 'add_date_start' => 'nullable|date',
- 'add_date_end' => 'nullable|date',
- 'add_way' => 'nullable|in:0,1,3,4,5,6,8,9,10,201,202',
- 'pay_status' => 'nullable|in:0,1',
- 'pay_num_min' => 'nullable|numeric|min:0',
- 'pay_num_max' => 'nullable|numeric',
- 'tag_type' => 'required|in:0,1,2,3',
- 'tag_id_list' => 'nullable|array|required_if:tag_type,1,2',
- 'page' => 'required|numeric|min:1',
- 'page_size' => 'required|numeric'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $customerName = $request->input('customer_name'); // 客户名关键字
- $userIdList = $request->input('user_id_list'); // 所属客服
- $addDateStart = $request->input('add_date_start'); // 起始添加日期
- $addDateEnd = $request->input('add_date_end'); // 截止添加日期
- $addWay = $request->input('add_way'); // 添加渠道
- $payStatus = $request->input('pay_status'); // 付费状态
- $payNumMin = $request->input('pay_num_min'); // 最小付费次数
- $payNumMax = $request->input('pay_num_max'); // 最高付费次数
- $tagType = $request->input('tag_type', 0); // 标签筛选类型 0未筛选 1满足其一 2同时满足 3无标签
- $tagIdList = $request->input('tag_id_list'); // 标签列表
- $corpid = $request->input('corpid');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- list($data, $count) = CustomerService::unassignedCustomerList($customerName, $userIdList, $addDateStart, $addDateEnd,
- $addWay, $payStatus, $payNumMin, $payNumMax, $tagType, $tagIdList, $corpid, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 客户来源检索框列表
- public function addWayList(Request $request)
- {
- $data = CustomerService::addWayList();
- return self::returnValue($data);
- }
- // 客户管理列表
- public function customerList(Request $request)
- {
- ini_set('memory_limit', '-1');
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'user_id_list' => 'nullable|array',
- 'add_date_start' => 'nullable|date',
- 'add_date_end' => 'nullable|date',
- 'last_pay_time_start' => 'nullable|date',
- 'last_pay_time_end' => 'nullable|date',
- 'pay_status' => 'nullable|in:0,1',
- 'pay_num_min' => 'nullable|numeric|min:0',
- 'pay_num_max' => 'nullable|numeric',
- 'tag_type' => 'required|in:0,1,2,3',
- 'tag_id_list' => 'nullable|array|required_if:tag_type,1,2',
- 'page' => 'required|numeric|min:1',
- 'page_size' => 'required|numeric',
- 'is_new_customer_no_loss' => 'nullable|in:0,1',
- 'can_receive' => 'nullable|in:0,1',
- 'retained_status' => 'nullable|in:0,1',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['customer_name'] = $request->input('customer_name'); // 客户名关键字
- $params['user_id_list'] = $request->input('user_id_list'); // 所属客服
- $params['add_date_start'] = $request->input('add_date_start'); // 起始添加日期
- $params['add_date_end'] = $request->input('add_date_end'); // 截止添加日期
- $params['last_pay_time_start'] = $request->input('last_pay_time_start'); // 最近一次充值时间起始
- $params['last_pay_time_end'] = $request->input('last_pay_time_end'); // 最近一次充值时间截止
- $params['add_way'] = $request->input('add_way'); // 添加渠道
- $params['gender'] = $request->input('gender'); // 客户性别
- $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'); // 最高付费次数
- $params['tag_type'] = $request->input('tag_type', 0); // 标签筛选类型 0未筛选 1满足其一 2同时满足 3无标签
- $params['tag_id_list'] = $request->input('tag_id_list'); // 标签列表
- $params['loss_status'] = $request->input('loss_status'); // 客户流失状态
- $params['corpid'] = $request->input('corpid');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $source = $request->input('source', 1);
- $params['loss_time_start'] = $request->input('loss_time_start');
- $params['loss_time_end'] = $request->input('loss_time_end');
- $params['is_new_customer_no_loss'] = $request->input('is_new_customer_no_loss');# 是否为新用户 0复粉 1新用户
- $params['can_receive'] = $request->input('can_receive'); // 是否可正常接收群发消息 0否 1是
- $params['retained_status'] = $request->input('retained_status'); // 是否在当前主体内还有留存 0否 1是
- list($data, $count, $extra) = CustomerService::customerList($params, $page, $pageSize, $source);
- return self::returnPageValue($data, $count, $pageSize, $page, $extra);
- }
- /**
- * 客服客户数统计(筛选数据项同客户列表保持一致)
- * @param Request $request
- */
- public static function customerCountStat(Request $request) {
- ini_set('memory_limit', '-1');
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'user_id_list' => 'nullable|array',
- 'add_date_start' => 'nullable|date',
- 'add_date_end' => 'nullable|date',
- 'last_pay_time_start' => 'nullable|date',
- 'last_pay_time_end' => 'nullable|date',
- 'pay_status' => 'nullable|in:0,1',
- 'pay_num_min' => 'nullable|numeric|min:0',
- 'pay_num_max' => 'nullable|numeric',
- 'tag_type' => 'required|in:0,1,2,3',
- 'tag_id_list' => 'nullable|array|required_if:tag_type,1,2',
- 'is_new_customer_no_loss' => 'nullable|in:0,1',
- 'can_receive' => 'nullable|in:0,1',
- 'retained_status' => 'nullable|in:0,1',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['customer_name'] = $request->input('customer_name'); // 客户名关键字
- $params['user_id_list'] = $request->input('user_id_list'); // 所属客服
- $params['add_date_start'] = $request->input('add_date_start'); // 起始添加日期
- $params['add_date_end'] = $request->input('add_date_end'); // 截止添加日期
- $params['last_pay_time_start'] = $request->input('last_pay_time_start'); // 最近一次充值时间起始
- $params['last_pay_time_end'] = $request->input('last_pay_time_end'); // 最近一次充值时间截止
- $params['add_way'] = $request->input('add_way'); // 添加渠道
- $params['gender'] = $request->input('gender'); // 客户性别
- $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'); // 最高付费次数
- $params['tag_type'] = $request->input('tag_type', 0); // 标签筛选类型 0未筛选 1满足其一 2同时满足 3无标签
- $params['tag_id_list'] = $request->input('tag_id_list'); // 标签列表
- $params['loss_status'] = $request->input('loss_status'); // 客户流失状态
- $params['corpid'] = $request->input('corpid');
- $params['loss_time_start'] = $request->input('loss_time_start');
- $params['loss_time_end'] = $request->input('loss_time_end');
- $params['is_new_customer_no_loss'] = $request->input('is_new_customer_no_loss');# 是否为新用户 0复粉 1新用户
- $params['can_receive'] = $request->input('can_receive'); // 是否可正常接收群发消息 0否 1是
- $params['retained_status'] = $request->input('retained_status'); // 是否在当前主体内还有留存 0否 1是
- $data = CustomerService::customerCountStat($params);
- return self::returnValue($data);
- }
- // 客户详情概览
- public function customerDetail(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'customer_id' => 'required|integer',
- 'user_id' => 'required|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $customerId = $request->input('customer_id');
- $userId = $request->input('user_id');
- list($data, $code) = CustomerService::customerDetail($corpid, $customerId, $userId);
- return self::returnValue($data, $code);
- }
- // 客户详情概览
- public function customerDetails(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'customer_id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $customerId = $request->input('customer_id');
- list($data, $code) = CustomerService::customerDetails($corpid, $customerId);
- return self::returnValue($data, $code);
- }
- // 客户订单列表
- public function customerOrderList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'customer_id' => 'required|integer'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $customerId = $request->input('customer_id');
- $page = $request->input('page');
- $pageSize = $request->input('page_size');
- list($data, $count) = CustomerService::customerOrderList($corpid, $customerId, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 客户详情编辑
- public function customerInfoUpdate(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'customer_id' => 'required|integer'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $customerId = $request->input('customer_id');
- $params['e_address'] = $request->input('e_address');
- $params['e_age'] = $request->input('e_age');
- $params['e_birthday'] = $request->input('e_birthday');
- $params['e_desc'] = $request->input('e_desc');
- $params['e_email'] = $request->input('e_email');
- $params['e_phone'] = $request->input('e_phone');
- $params['e_position'] = $request->input('e_position');
- $params['e_qq'] = $request->input('e_qq');
- $params['e_source'] = $request->input('e_source');
- $params['e_company'] = $request->input('e_company');
- $params['e_weibo'] = $request->input('e_weibo');
- list($data, $code) = CustomerService::customerInfoUpdate($corpid, $customerId, $params);
- return self::returnValue($data, $code);
- }
- // 将客户加入黑名单
- public function moveCustomerToBlackList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'customer_id' => 'required|integer',
- 'user_id' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $customerId = $request->input('customer_id');
- $userId = $request->input('user_id');
- $reason = $request->input('reason');
- list($res, $code) = CustomerService::moveCustomerToBlackList($corpid, $customerId, $userId, $reason);
- return self::returnValue($res, $code);
- }
- // 将客户移除黑名单
- public function removeCustomerFromBlackList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'customer_id' => 'required|integer',
- 'user_id' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $customerId = $request->input('customer_id');
- $userId = $request->input('user_id');
- list($res, $code) = CustomerService::removeCustomerFromBlackList($corpid, $customerId, $userId);
- return self::returnValue($res, $code);
- }
- // 黑名单列表
- public function blackList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'add_way' => 'nullable|in:0,1,3,4,5,6,8,9,10,201,202',
- 'page' => 'required|numeric|min:1',
- 'page_size' => 'required|numeric'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $customerName = $request->input('customer_name'); // 客户名关键字
- $addWay = $request->input('add_way'); // 添加渠道
- $corpid = $request->input('corpid');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $adminId = $request->input('admin_id');
- list($data, $count) = CustomerService::blackList($corpid, $addWay, $customerName, $adminId, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 黑名单列表
- public function blackListNew(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'add_way' => 'nullable|in:0,1,3,4,5,6,8,9,10,201,202',
- 'page' => 'required|numeric|min:1',
- 'page_size' => 'required|numeric'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $customerName = $request->input('customer_name'); // 客户名关键字
- $addWay = $request->input('add_way'); // 添加渠道
- $corpid = $request->input('corpid');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $adminId = $request->input('admin_id');
- list($data, $count) = CustomerService::blackListNew($corpid, $addWay, $customerName, $adminId, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 流失客户列表
- public function lossCustomerList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'user_id_list' => 'nullable|array',
- 'add_date_start' => 'nullable|date',
- 'add_date_end' => 'nullable|date',
- 'loss_date_start' => 'nullable|date',
- 'loss_date_end' => 'nullable|date',
- 'add_duration_min' => 'nullable|numeric',
- 'add_duration_max' => 'nullable|numeric',
- 'page' => 'required|numeric|min:1',
- 'page_size' => 'required|numeric'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $userIdList = $request->input('user_id_list'); // 所属客服
- $addDateStart = $request->input('add_date_start'); // 起始添加日期
- $addDateEnd = $request->input('add_date_end'); // 截止添加日期
- $lossDateStart = $request->input('loss_date_start');
- $lossDateEnd = $request->input('loss_date_end');
- $addDurationMin = $request->input('add_duration_min');
- $addDurationMax = $request->input('add_duration_max');
- $corpid = $request->input('corpid');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- list($data, $count) = CustomerService::lossCustomerList($userIdList, $addDateStart, $addDateEnd, $lossDateStart,
- $lossDateEnd, $addDurationMin, $addDurationMax, $corpid, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- public function customerAssignmentRecordList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'handover_userid' => 'nullable|string',
- 'takeover_userid' => 'nullable|string',
- 'assignment_date_start' => 'nullable|date',
- 'assignment_date_end' => 'nullable|date',
- 'assignment_status' => 'nullable|in:1,2,3,-1',
- 'type' => 'nullable|in:1,2',
- 'page' => 'required|numeric|min:1',
- 'page_size' => 'required|numeric'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $handoverUserId = $request->input('handover_userid'); // 迁出客服
- $takeoverUserId = $request->input('takeover_userid'); // 接替客服
- $assignmentDateStart = $request->input('assignment_date_start'); // 起始添加日期
- $assignmentDateEnd = $request->input('assignment_date_end'); // 截止添加日期
- $assignmentStatus = $request->input('assignment_status');
- $type = $request->input('type');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $operatorId = $request->input('operator_id');
- list($data, $count) = CustomerService::customerAssignmentRecordList($corpid, $handoverUserId, $operatorId
- , $takeoverUserId, $assignmentDateStart, $assignmentDateEnd, $assignmentStatus, $type, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 客户分配列表
- public function customerAssignmentList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'record_id' => 'required|integer',
- 'customer_name' => 'nullable|string',
- 'assignment_date_start' => 'nullable|date',
- 'assignment_date_end' => 'nullable|date',
- 'assignment_status' => 'nullable|in:1,2,3,4,5,-1',
- 'page' => 'required|numeric|min:1',
- 'page_size' => 'required|numeric'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $customerName = $request->input('customer_name');
- $recordId = $request->input('record_id'); // 所属客服
- $assignmentDateStart = $request->input('assignment_date_start'); // 起始添加日期
- $assignmentDateEnd = $request->input('assignment_date_end'); // 截止添加日期
- $assignmentStatus = $request->input('assignment_status');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- list($data, $count) = CustomerService::customerAssignmentList($corpid, $customerName, $recordId, $assignmentDateStart,
- $assignmentDateEnd, $assignmentStatus, $page, $pageSize);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 客户动态列表
- public function customerDynamicList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'customer_id' => 'required|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $customerId = $request->input('customer_id');
- $data = CustomerService::customerDynamicList($corpid, $customerId);
- return self::returnValue($data);
- }
- // 客户详情标签展示(编辑时使用)
- public function customerDetailTagList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'customer_id' => 'required|int',
- 'user_id' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $customerId = $request->input('customer_id');
- $userId = $request->input('user_id');
- $data = CustomerService::customerDetailTagList($corpid, $customerId, $userId);
- return self::returnValue($data);
- }
- // 客户详情标签编辑
- public function customerDetailTagUpdate(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'external_userid' => 'required',
- 'user_id' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $externalUserId = $request->input('external_userid');
- $userId = $request->input('user_id');
- $selectedTagIdList = $request->input('selected_tag_id_list');
- list($res, $code) = CustomerService::customerDetailTagUpdate($corpid, $externalUserId, $userId, $selectedTagIdList);
- return self::returnValue($res, $code);
- }
- // 批量添加客户导入
- public function batchAddCustomerImport(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'user_id_list' => 'required|array',
- 'customer_tag_list' => 'nullable|array',
- 'original_file_name' => 'required',
- 'ext' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $userIdList = $request->input('user_id_list');
- $customerTagList = $request->input('customer_tag_list');
- $originalFileName = $request->input('original_file_name');
- $ext = $request->input('ext');
- $newFileName = $request->input('new_file_name');
- $sysGroupId = $request->input('sys_group_id');
- $res = AddCustomerService::batchAddCustomerImport($originalFileName, $newFileName, $ext, $corpid, $userIdList,
- $customerTagList, $sysGroupId);
- return self::returnValue($res['info'], $res['code']);
- }
- // 批量添加客户导入二次确认
- public function batchAddCustomerImportConfirm(Request $request)
- {
- // 处理验证失败信息,不要直接抛异常
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'confirm' => 'required|in:1,0',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $corpid = $request->input('corpid');
- $confirm = $request->input('confirm');
- $newFileName = $request->input('new_file_name');
- $sysGroupId = $request->input('sys_group_id');
- $res = AddCustomerService::batchAddCustomerImportConfirm($corpid, $confirm, $newFileName, $sysGroupId);
- return self::returnValue($res['info'], $res['code']);
- }
- // 批量添加客户导入列表
- public function batchAddCustomerDetailsList(Request $request)
- {
- // 处理验证失败信息,不要直接抛异常
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'add_status' => 'nullable|in:1,2,3,4'
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $corpid = $request->input('corpid');
- $addStatus = $request->input('add_status');
- $keyword = $request->input('keyword');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $startTime = $request->input('start_time');
- $endTime = $request->input('end_time');
- $sysGroupId = $request->input('sys_group_id');
- list($data, $count) = AddCustomerService::batchAddCustomerDetailsList($corpid, $addStatus, $keyword, $startTime,
- $endTime, $page, $pageSize, $sysGroupId);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 批量添加客户导入记录列表
- public function batchAddCustomerRecordList(Request $request)
- {
- // 处理验证失败信息,不要直接抛异常
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $corpid = $request->input('corpid');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId = $request->input('sys_group_id');
- list($data, $count) = AddCustomerService::batchAddCustomerRecordList($corpid, $page, $pageSize, $sysGroupId);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 批量添加客户导入记录详情
- public function batchAddCustomerRecordDetail(Request $request)
- {
- // 处理验证失败信息,不要直接抛异常
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'record_id' => 'required',
- 'add_status' => 'nullable|in:1,2,3,4'
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $corpid = $request->input('corpid');
- $addStatus = $request->input('add_status');
- $keyword = $request->input('keyword');
- $recordId = $request->input('record_id');
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 20);
- $sysGroupId = $request->input('sys_group_id');
- list($data, $count) = AddCustomerService::batchAddCustomerRecordDetail($corpid, $addStatus, $keyword, $recordId,
- $page, $pageSize, $sysGroupId);
- return self::returnPageValue($data, $count, $pageSize, $page);
- }
- // 批量分配客户
- public function batchDistributionCustomer(Request $request)
- {
- // 处理验证失败信息,不要直接抛异常
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'add_status' => 'nullable|in:1,2,3,4',
- 'select_all' => 'nullable|in:0,1',
- 'select_id_list' => 'nullable|array',
- 'exclude_id_list' => 'nullable|array',
- 'user_id_list' => 'required|array',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $corpid = $request->input('corpid');
- $addStatus = $request->input('add_status');
- $keyword = $request->input('keyword');
- $startTime = $request->input('start_time');
- $endTime = $request->input('end_time');
- $selectAll = $request->input('select_all', 0);
- $selectIdList = $request->input('select_id_list');
- $excludeIdList = $request->input('exclude_id_list');
- $userIdList = $request->input('user_id_list');
- $sysGroupId = $request->input('sys_group_id');
- list($res, $code) = AddCustomerService::batchDistributionCustomer($corpid, $addStatus, $keyword, $startTime, $endTime,
- $selectAll, $selectIdList, $excludeIdList, $userIdList, $sysGroupId);
- return self::returnValue($res, $code);
- }
- // 删除导入记录(单个删除)
- public function deleteRecord(Request $request)
- {
- // 处理验证失败信息,不要直接抛异常
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'record_id' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $corpid = $request->input('corpid');
- $recordId = $request->input('record_id');
- $sysGroupId = $request->input('sys_group_id');
- list($res, $code) = AddCustomerService::deleteRecord($corpid, $recordId, $sysGroupId);
- return self::returnValue($res, $code);
- }
- // 删除导入客户
- public function deleteDetail(Request $request)
- {
- // 处理验证失败信息,不要直接抛异常
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'add_status' => 'nullable|in:1,2,3,4',
- 'select_all' => 'nullable|in:0,1',
- 'select_id_list' => 'nullable|array',
- 'exclude_id_list' => 'nullable|array',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $corpid = $request->input('corpid');
- $addStatus = $request->input('add_status');
- $keyword = $request->input('keyword');
- $startTime = $request->input('start_time');
- $endTime = $request->input('end_time');
- $selectAll = $request->input('select_all', 0);
- $selectIdList = $request->input('select_id_list');
- $excludeIdList = $request->input('exclude_id_list');
- $sysGroupId = $request->input('sys_group_id');
- list($res, $code) = AddCustomerService::deleteDetail($corpid, $addStatus, $keyword, $startTime, $endTime, $selectAll,
- $selectIdList, $excludeIdList, $sysGroupId);
- return self::returnValue($res, $code);
- }
- // 批量提醒(add_status为待添加以及待通过)
- public function batchRemind(Request $request)
- {
- // 处理验证失败信息,不要直接抛异常
- $validator = \Validator::make($request->all(), [
- 'corpid' => 'required|string',
- 'add_status' => 'required|in:1,2',
- 'select_all' => 'nullable|in:0,1',
- 'select_id_list' => 'nullable|array',
- 'exclude_id_list' => 'nullable|array',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $corpid = $request->input('corpid');
- $addStatus = $request->input('add_status');
- $keyword = $request->input('keyword');
- $startTime = $request->input('start_time');
- $endTime = $request->input('end_time');
- $selectAll = $request->input('select_all', 0);
- $selectIdList = $request->input('select_id_list');
- $excludeIdList = $request->input('exclude_id_list');
- $sysGroupId = $request->input('sys_group_id');
- list($res, $code) = AddCustomerService::batchRemind($corpid, $addStatus, $keyword, $startTime, $endTime, $selectAll,
- $selectIdList, $excludeIdList, $sysGroupId);
- return self::returnValue($res, $code);
- }
- /**
- * 安卓客户端获取待邀请入群的新用户列表
- * */
- public function waitInvite(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'device_id' => 'required|string',
- 'begin_time' => 'required|date_format:Y-m-d H:i:s',
- 'end_time' => 'required|date_format:Y-m-d H:i:s',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $deviceId = $request->input('device_id');
- $beginTime = $request->input('begin_time');
- $endTime = $request->input('end_time');
- $retry = $request->input('retry', 0);
- $requestCorpId = $request->input('corpid');
- $customerNumber = $request->input('customer_number');
- # 获取待邀请入群的新用户
- $userList = CustomerService::waitInvite($deviceId, $beginTime, $endTime, $retry, $requestCorpId, $customerNumber);
- Log::logInfo('邀请新用户入群请求日志', [
- 'device_id' => $deviceId,
- 'begin_time' => $beginTime,
- 'end_time' => $endTime,
- 'retry' => $retry,
- 'customer_number' => $customerNumber,
- 'corp_id' => $requestCorpId,
- 'response' => $userList
- ], 'WaitInvite');
- return self::returnValue(['list' => $userList]);
- }
- /**
- * 安卓客户端获取待共享的新用户列表
- * */
- public function waitShare(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'device_id' => 'required|string',
- 'begin_time' => 'required|date_format:Y-m-d H:i:s',
- 'end_time' => 'required|date_format:Y-m-d H:i:s',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $deviceId = $request->input('device_id');
- $beginTime = $request->input('begin_time');
- $endTime = $request->input('end_time');
- # 获取待邀请入群的新用户
- $userList = CustomerService::waitShare($deviceId, $beginTime, $endTime);
- Log::logInfo('新用户共享请求日志', [
- 'device_id' => $deviceId,
- 'begin_time' => $beginTime,
- 'end_time' => $endTime,
- 'response' => $userList
- ], 'waitShare');
- return self::returnValue(['list' => $userList]);
- }
- /**
- * 安卓客户端获取待补充邀请入群的用户列表-按群模板随机补拉
- * @param Request $request
- */
- public function waitSupplementaryInvite(Request $request) {
- $validator = \Validator::make($request->all(), [
- 'device_id' => 'required|string',
- 'begin_time' => 'required|date_format:Y-m-d H:i:s',
- 'end_time' => 'required|date_format:Y-m-d H:i:s',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $deviceId = $request->input('device_id');
- $beginTime = $request->input('begin_time');
- $endTime = $request->input('end_time');
- # 获取待邀请入群的新用户
- $userList = CustomerService::waitSupplementaryInvite($deviceId, $beginTime, $endTime);
- Log::logInfo('退群用户补充邀请入群请求日志', [
- 'device_id' => $deviceId,
- 'begin_time' => $beginTime,
- 'end_time' => $endTime,
- 'response' => $userList
- ], 'waitSupplementaryInvite');
- return self::returnValue(['list' => $userList]);
- }
- /**
- * 安卓客户端获取待补充邀请入群的用户列表-将用户拉回指定群
- */
- public function waitInviteTargetGroup(Request $request) {
- $validator = \Validator::make($request->all(), [
- 'device_id' => 'required|string',
- 'begin_time' => 'required|date_format:Y-m-d H:i:s',
- 'end_time' => 'required|date_format:Y-m-d H:i:s',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $deviceId = $request->input('device_id');
- $beginTime = $request->input('begin_time');
- $endTime = $request->input('end_time');
- # 获取待邀请入群的新用户
- $userList = CustomerService::waitInviteTargetGroup($deviceId, $beginTime, $endTime);
- Log::logInfo('退群用户补充邀请入群请求日志', [
- 'device_id' => $deviceId,
- 'begin_time' => $beginTime,
- 'end_time' => $endTime,
- 'response' => $userList
- ], 'waitInviteTargetGroup');
- return self::returnValue(['list' => $userList]);
- }
- public function inviteNewUser(Request $request)
- {
- $validator = \Validator::make($request->all(), [
- 'device_id' => 'required|string',
- 'begin_time' => 'required|date_format:Y-m-d H:i:s',
- 'end_time' => 'required|date_format:Y-m-d H:i:s',
- ]);
- if ($validator->fails()) {
- return self::returnValue(['error' => $validator->errors()], 1102);
- }
- $deviceId = $request->input('device_id');
- $beginTime = $request->input('begin_time');
- $endTime = $request->input('end_time');
- # 获取待邀请入群的新用户
- $userList = CustomerService::inviteNewUser($deviceId, $beginTime, $endTime);
- Log::logInfo('退群用户补充邀请入群请求日志', [
- 'device_id' => $deviceId,
- 'begin_time' => $beginTime,
- 'end_time' => $endTime,
- 'response' => $userList
- ], 'waitInviteTargetGroup');
- return self::returnValue(['list' => $userList]);
- }
- }
|