企微短剧业务系统

CustomerController.php 42KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shensong
  5. * Date: 2022/3/15
  6. * Time: 18:21
  7. */
  8. namespace App\Http\Controllers\Api;
  9. use App\Http\Controllers\Controller;
  10. use App\Log;
  11. use App\Service\AddCustomerService;
  12. use App\Service\CustomerService;
  13. use App\Service\HttpService;
  14. use App\Service\TokenService;
  15. use App\Service\wechatWorkService;
  16. use Illuminate\Http\Request;
  17. class CustomerController extends Controller
  18. {
  19. // 更新企业全部信息
  20. public function getCorCustomerList(Request $request)
  21. {
  22. $validator = \Validator::make($request->all(),[
  23. 'corpid' => 'required',
  24. ]);
  25. if ($validator->fails()) {
  26. return self::returnValue($validator->getMessageBag(), 1102);
  27. }
  28. $corpid = $request->input('corpid');
  29. list($res, $code) = wechatWorkService::getCorCustomerList($corpid);
  30. return self::returnValue($res, $code);
  31. }
  32. //(废弃)
  33. public function transferCustomer(Request $request)
  34. {
  35. $validator = \Validator::make($request->all(),[
  36. 'corpid' => 'required',
  37. 'handover_userid' => 'required',
  38. 'takeover_userid' => 'required',
  39. 'external_userid_list' => 'required|array',
  40. 'type' => 'required|in:1,2',
  41. 'select_all' => 'nullable|in:0,1'
  42. ]);
  43. if ($validator->fails()) {
  44. return self::returnValue($validator->getMessageBag(), 1102);
  45. }
  46. $corpid = $request->input('corpid');
  47. $handoverUserId = $request->input('handover_userid');
  48. $takeoverUserId = $request->input('takeover_userid');
  49. $externalUserIdList = $request->input('external_userid_list');
  50. $transferSuccessMsg = $request->input('transfer_success_msg');
  51. $type = $request->input('type');
  52. $selectAll = $request->input('select_all',0);
  53. list($data, $code) = CustomerService::addCustomerAssignment($corpid, $handoverUserId, $takeoverUserId,
  54. $externalUserIdList, $transferSuccessMsg, $type, $selectAll);
  55. return self::returnValue($data, $code);
  56. }
  57. // 客户迁移
  58. public function transferCustomerNew(Request $request)
  59. {
  60. $validator = \Validator::make($request->all(),[
  61. 'corpid' => 'required',
  62. 'takeover_userid' => 'required',
  63. 'external_user_list' => 'nullable|array',
  64. 'type' => 'required|in:1,2',
  65. ]);
  66. if ($validator->fails()) {
  67. return self::returnValue($validator->getMessageBag(), 1102);
  68. }
  69. $corpid = $request->input('corpid');
  70. $takeoverUserId = $request->input('takeover_userid');
  71. $externalUserList = $request->input('external_user_list');
  72. $transferSuccessMsg = $request->input('transfer_success_msg');
  73. $type = $request->input('type');
  74. $portraitInheritance = $request->input('portrait_inheritance', 1);
  75. $selectAll = $request->input('select_all',0);
  76. $filterCustomerList = $request->input('filter_customer_list');
  77. $params['customer_name'] = $request->input('customer_name'); // 客户名关键字
  78. $params['user_id_list'] = $request->input('user_id_list'); // 所属客服
  79. $params['add_date_start'] = $request->input('add_date_start'); // 起始添加日期
  80. $params['add_date_end'] = $request->input('add_date_end'); // 截止添加日期
  81. $params['add_way'] = $request->input('add_way'); // 添加渠道
  82. $params['pay_status'] = $request->input('pay_status'); // 付费状态
  83. $params['pay_num_min'] = $request->input('pay_num_min'); // 最小付费次数
  84. $params['pay_num_max'] = $request->input('pay_num_max'); // 最高付费次数
  85. $params['tag_type'] = $request->input('tag_type', 0); // 标签筛选类型 0未筛选 1满足其一 2同时满足 3无标签
  86. $params['tag_id_list'] = $request->input('tag_id_list'); // 标签列表
  87. list($data, $code) = CustomerService::addCustomerAssignmentNew($corpid, $takeoverUserId,
  88. $externalUserList, $transferSuccessMsg, $type, $portraitInheritance, $selectAll, $filterCustomerList, $params);
  89. return self::returnValue($data, $code);
  90. }
  91. // 待分配的离职成员客户列表
  92. public function unassignedCustomerList(Request $request)
  93. {
  94. $validator = \Validator::make($request->all(),[
  95. 'corpid' => 'required',
  96. 'user_id_list' => 'nullable|array',
  97. 'add_date_start' => 'nullable|date',
  98. 'add_date_end' => 'nullable|date',
  99. 'add_way' => 'nullable|in:0,1,3,4,5,6,8,9,10,201,202',
  100. 'pay_status' => 'nullable|in:0,1',
  101. 'pay_num_min' => 'nullable|numeric|min:0',
  102. 'pay_num_max' => 'nullable|numeric',
  103. 'tag_type' => 'required|in:0,1,2,3',
  104. 'tag_id_list' => 'nullable|array|required_if:tag_type,1,2',
  105. 'page' => 'required|numeric|min:1',
  106. 'page_size' => 'required|numeric'
  107. ]);
  108. if ($validator->fails()) {
  109. return self::returnValue($validator->getMessageBag(), 1102);
  110. }
  111. $customerName = $request->input('customer_name'); // 客户名关键字
  112. $userIdList = $request->input('user_id_list'); // 所属客服
  113. $addDateStart = $request->input('add_date_start'); // 起始添加日期
  114. $addDateEnd = $request->input('add_date_end'); // 截止添加日期
  115. $addWay = $request->input('add_way'); // 添加渠道
  116. $payStatus = $request->input('pay_status'); // 付费状态
  117. $payNumMin = $request->input('pay_num_min'); // 最小付费次数
  118. $payNumMax = $request->input('pay_num_max'); // 最高付费次数
  119. $tagType = $request->input('tag_type', 0); // 标签筛选类型 0未筛选 1满足其一 2同时满足 3无标签
  120. $tagIdList = $request->input('tag_id_list'); // 标签列表
  121. $corpid = $request->input('corpid');
  122. $page = $request->input('page', 1);
  123. $pageSize = $request->input('page_size', 20);
  124. list($data, $count) = CustomerService::unassignedCustomerList($customerName, $userIdList, $addDateStart, $addDateEnd,
  125. $addWay, $payStatus, $payNumMin, $payNumMax, $tagType, $tagIdList, $corpid, $page, $pageSize);
  126. return self::returnPageValue($data, $count, $pageSize, $page);
  127. }
  128. // 客户来源检索框列表
  129. public function addWayList(Request $request)
  130. {
  131. $data = CustomerService::addWayList();
  132. return self::returnValue($data);
  133. }
  134. // 客户管理列表
  135. public function customerList(Request $request)
  136. {
  137. ini_set('memory_limit', '-1');
  138. $validator = \Validator::make($request->all(),[
  139. 'corpid' => 'required',
  140. 'user_id_list' => 'nullable|array',
  141. 'add_date_start' => 'nullable|date',
  142. 'add_date_end' => 'nullable|date',
  143. 'last_pay_time_start' => 'nullable|date',
  144. 'last_pay_time_end' => 'nullable|date',
  145. 'pay_status' => 'nullable|in:0,1',
  146. 'pay_num_min' => 'nullable|numeric|min:0',
  147. 'pay_num_max' => 'nullable|numeric',
  148. 'tag_type' => 'required|in:0,1,2,3',
  149. 'tag_id_list' => 'nullable|array|required_if:tag_type,1,2',
  150. 'page' => 'required|numeric|min:1',
  151. 'page_size' => 'required|numeric',
  152. 'is_new_customer_no_loss' => 'nullable|in:0,1',
  153. 'can_receive' => 'nullable|in:0,1',
  154. 'retained_status' => 'nullable|in:0,1',
  155. ]);
  156. if ($validator->fails()) {
  157. return self::returnValue($validator->getMessageBag(), 1102);
  158. }
  159. $params['customer_name'] = $request->input('customer_name'); // 客户名关键字
  160. $params['user_id_list'] = $request->input('user_id_list'); // 所属客服
  161. $params['add_date_start'] = $request->input('add_date_start'); // 起始添加日期
  162. $params['add_date_end'] = $request->input('add_date_end'); // 截止添加日期
  163. $params['last_pay_time_start'] = $request->input('last_pay_time_start'); // 最近一次充值时间起始
  164. $params['last_pay_time_end'] = $request->input('last_pay_time_end'); // 最近一次充值时间截止
  165. $params['add_way'] = $request->input('add_way'); // 添加渠道
  166. $params['gender'] = $request->input('gender'); // 客户性别
  167. $params['pay_status'] = $request->input('pay_status'); // 付费状态
  168. $params['pay_num_min'] = $request->input('pay_num_min'); // 最小付费次数
  169. $params['pay_num_max'] = $request->input('pay_num_max'); // 最高付费次数
  170. $params['tag_type'] = $request->input('tag_type', 0); // 标签筛选类型 0未筛选 1满足其一 2同时满足 3无标签
  171. $params['tag_id_list'] = $request->input('tag_id_list'); // 标签列表
  172. $params['loss_status'] = $request->input('loss_status'); // 客户流失状态
  173. $params['corpid'] = $request->input('corpid');
  174. $page = $request->input('page', 1);
  175. $pageSize = $request->input('page_size', 20);
  176. $source = $request->input('source', 1);
  177. $params['loss_time_start'] = $request->input('loss_time_start');
  178. $params['loss_time_end'] = $request->input('loss_time_end');
  179. $params['is_new_customer_no_loss'] = $request->input('is_new_customer_no_loss');# 是否为新用户 0复粉 1新用户
  180. $params['can_receive'] = $request->input('can_receive'); // 是否可正常接收群发消息 0否 1是
  181. $params['retained_status'] = $request->input('retained_status'); // 是否在当前主体内还有留存 0否 1是
  182. list($data, $count, $extra) = CustomerService::customerList($params, $page, $pageSize, $source);
  183. return self::returnPageValue($data, $count, $pageSize, $page, $extra);
  184. }
  185. /**
  186. * 客服客户数统计(筛选数据项同客户列表保持一致)
  187. * @param Request $request
  188. */
  189. public static function customerCountStat(Request $request) {
  190. ini_set('memory_limit', '-1');
  191. $validator = \Validator::make($request->all(),[
  192. 'corpid' => 'required',
  193. 'user_id_list' => 'nullable|array',
  194. 'add_date_start' => 'nullable|date',
  195. 'add_date_end' => 'nullable|date',
  196. 'last_pay_time_start' => 'nullable|date',
  197. 'last_pay_time_end' => 'nullable|date',
  198. 'pay_status' => 'nullable|in:0,1',
  199. 'pay_num_min' => 'nullable|numeric|min:0',
  200. 'pay_num_max' => 'nullable|numeric',
  201. 'tag_type' => 'required|in:0,1,2,3',
  202. 'tag_id_list' => 'nullable|array|required_if:tag_type,1,2',
  203. 'is_new_customer_no_loss' => 'nullable|in:0,1',
  204. 'can_receive' => 'nullable|in:0,1',
  205. 'retained_status' => 'nullable|in:0,1',
  206. ]);
  207. if ($validator->fails()) {
  208. return self::returnValue($validator->getMessageBag(), 1102);
  209. }
  210. $params['customer_name'] = $request->input('customer_name'); // 客户名关键字
  211. $params['user_id_list'] = $request->input('user_id_list'); // 所属客服
  212. $params['add_date_start'] = $request->input('add_date_start'); // 起始添加日期
  213. $params['add_date_end'] = $request->input('add_date_end'); // 截止添加日期
  214. $params['last_pay_time_start'] = $request->input('last_pay_time_start'); // 最近一次充值时间起始
  215. $params['last_pay_time_end'] = $request->input('last_pay_time_end'); // 最近一次充值时间截止
  216. $params['add_way'] = $request->input('add_way'); // 添加渠道
  217. $params['gender'] = $request->input('gender'); // 客户性别
  218. $params['pay_status'] = $request->input('pay_status'); // 付费状态
  219. $params['pay_num_min'] = $request->input('pay_num_min'); // 最小付费次数
  220. $params['pay_num_max'] = $request->input('pay_num_max'); // 最高付费次数
  221. $params['tag_type'] = $request->input('tag_type', 0); // 标签筛选类型 0未筛选 1满足其一 2同时满足 3无标签
  222. $params['tag_id_list'] = $request->input('tag_id_list'); // 标签列表
  223. $params['loss_status'] = $request->input('loss_status'); // 客户流失状态
  224. $params['corpid'] = $request->input('corpid');
  225. $params['loss_time_start'] = $request->input('loss_time_start');
  226. $params['loss_time_end'] = $request->input('loss_time_end');
  227. $params['is_new_customer_no_loss'] = $request->input('is_new_customer_no_loss');# 是否为新用户 0复粉 1新用户
  228. $params['can_receive'] = $request->input('can_receive'); // 是否可正常接收群发消息 0否 1是
  229. $params['retained_status'] = $request->input('retained_status'); // 是否在当前主体内还有留存 0否 1是
  230. $data = CustomerService::customerCountStat($params);
  231. return self::returnValue($data);
  232. }
  233. // 客户详情概览
  234. public function customerDetail(Request $request)
  235. {
  236. $validator = \Validator::make($request->all(),[
  237. 'corpid' => 'required',
  238. 'customer_id' => 'required|integer',
  239. 'user_id' => 'required|string'
  240. ]);
  241. if ($validator->fails()) {
  242. return self::returnValue($validator->getMessageBag(), 1102);
  243. }
  244. $corpid = $request->input('corpid');
  245. $customerId = $request->input('customer_id');
  246. $userId = $request->input('user_id');
  247. list($data, $code) = CustomerService::customerDetail($corpid, $customerId, $userId);
  248. return self::returnValue($data, $code);
  249. }
  250. // 客户详情概览
  251. public function customerDetails(Request $request)
  252. {
  253. $validator = \Validator::make($request->all(),[
  254. 'corpid' => 'required',
  255. 'customer_id' => 'required|integer',
  256. ]);
  257. if ($validator->fails()) {
  258. return self::returnValue($validator->getMessageBag(), 1102);
  259. }
  260. $corpid = $request->input('corpid');
  261. $customerId = $request->input('customer_id');
  262. list($data, $code) = CustomerService::customerDetails($corpid, $customerId);
  263. return self::returnValue($data, $code);
  264. }
  265. // 客户订单列表
  266. public function customerOrderList(Request $request)
  267. {
  268. $validator = \Validator::make($request->all(),[
  269. 'corpid' => 'required',
  270. 'customer_id' => 'required|integer'
  271. ]);
  272. if ($validator->fails()) {
  273. return self::returnValue($validator->getMessageBag(), 1102);
  274. }
  275. $corpid = $request->input('corpid');
  276. $customerId = $request->input('customer_id');
  277. $page = $request->input('page');
  278. $pageSize = $request->input('page_size');
  279. list($data, $count) = CustomerService::customerOrderList($corpid, $customerId, $page, $pageSize);
  280. return self::returnPageValue($data, $count, $pageSize, $page);
  281. }
  282. // 客户详情编辑
  283. public function customerInfoUpdate(Request $request)
  284. {
  285. $validator = \Validator::make($request->all(),[
  286. 'corpid' => 'required',
  287. 'customer_id' => 'required|integer'
  288. ]);
  289. if ($validator->fails()) {
  290. return self::returnValue($validator->getMessageBag(), 1102);
  291. }
  292. $corpid = $request->input('corpid');
  293. $customerId = $request->input('customer_id');
  294. $params['e_address'] = $request->input('e_address');
  295. $params['e_age'] = $request->input('e_age');
  296. $params['e_birthday'] = $request->input('e_birthday');
  297. $params['e_desc'] = $request->input('e_desc');
  298. $params['e_email'] = $request->input('e_email');
  299. $params['e_phone'] = $request->input('e_phone');
  300. $params['e_position'] = $request->input('e_position');
  301. $params['e_qq'] = $request->input('e_qq');
  302. $params['e_source'] = $request->input('e_source');
  303. $params['e_company'] = $request->input('e_company');
  304. $params['e_weibo'] = $request->input('e_weibo');
  305. list($data, $code) = CustomerService::customerInfoUpdate($corpid, $customerId, $params);
  306. return self::returnValue($data, $code);
  307. }
  308. // 将客户加入黑名单
  309. public function moveCustomerToBlackList(Request $request)
  310. {
  311. $validator = \Validator::make($request->all(),[
  312. 'corpid' => 'required',
  313. 'customer_id' => 'required|integer',
  314. 'user_id' => 'required|string',
  315. ]);
  316. if ($validator->fails()) {
  317. return self::returnValue($validator->getMessageBag(), 1102);
  318. }
  319. $corpid = $request->input('corpid');
  320. $customerId = $request->input('customer_id');
  321. $userId = $request->input('user_id');
  322. $reason = $request->input('reason');
  323. list($res, $code) = CustomerService::moveCustomerToBlackList($corpid, $customerId, $userId, $reason);
  324. return self::returnValue($res, $code);
  325. }
  326. // 将客户移除黑名单
  327. public function removeCustomerFromBlackList(Request $request)
  328. {
  329. $validator = \Validator::make($request->all(),[
  330. 'corpid' => 'required',
  331. 'customer_id' => 'required|integer',
  332. 'user_id' => 'required|string',
  333. ]);
  334. if ($validator->fails()) {
  335. return self::returnValue($validator->getMessageBag(), 1102);
  336. }
  337. $corpid = $request->input('corpid');
  338. $customerId = $request->input('customer_id');
  339. $userId = $request->input('user_id');
  340. list($res, $code) = CustomerService::removeCustomerFromBlackList($corpid, $customerId, $userId);
  341. return self::returnValue($res, $code);
  342. }
  343. // 黑名单列表
  344. public function blackList(Request $request)
  345. {
  346. $validator = \Validator::make($request->all(),[
  347. 'corpid' => 'required',
  348. 'add_way' => 'nullable|in:0,1,3,4,5,6,8,9,10,201,202',
  349. 'page' => 'required|numeric|min:1',
  350. 'page_size' => 'required|numeric'
  351. ]);
  352. if ($validator->fails()) {
  353. return self::returnValue($validator->getMessageBag(), 1102);
  354. }
  355. $customerName = $request->input('customer_name'); // 客户名关键字
  356. $addWay = $request->input('add_way'); // 添加渠道
  357. $corpid = $request->input('corpid');
  358. $page = $request->input('page', 1);
  359. $pageSize = $request->input('page_size', 20);
  360. $adminId = $request->input('admin_id');
  361. list($data, $count) = CustomerService::blackList($corpid, $addWay, $customerName, $adminId, $page, $pageSize);
  362. return self::returnPageValue($data, $count, $pageSize, $page);
  363. }
  364. // 黑名单列表
  365. public function blackListNew(Request $request)
  366. {
  367. $validator = \Validator::make($request->all(),[
  368. 'corpid' => 'required',
  369. 'add_way' => 'nullable|in:0,1,3,4,5,6,8,9,10,201,202',
  370. 'page' => 'required|numeric|min:1',
  371. 'page_size' => 'required|numeric'
  372. ]);
  373. if ($validator->fails()) {
  374. return self::returnValue($validator->getMessageBag(), 1102);
  375. }
  376. $customerName = $request->input('customer_name'); // 客户名关键字
  377. $addWay = $request->input('add_way'); // 添加渠道
  378. $corpid = $request->input('corpid');
  379. $page = $request->input('page', 1);
  380. $pageSize = $request->input('page_size', 20);
  381. $adminId = $request->input('admin_id');
  382. list($data, $count) = CustomerService::blackListNew($corpid, $addWay, $customerName, $adminId, $page, $pageSize);
  383. return self::returnPageValue($data, $count, $pageSize, $page);
  384. }
  385. // 流失客户列表
  386. public function lossCustomerList(Request $request)
  387. {
  388. $validator = \Validator::make($request->all(),[
  389. 'corpid' => 'required',
  390. 'user_id_list' => 'nullable|array',
  391. 'add_date_start' => 'nullable|date',
  392. 'add_date_end' => 'nullable|date',
  393. 'loss_date_start' => 'nullable|date',
  394. 'loss_date_end' => 'nullable|date',
  395. 'add_duration_min' => 'nullable|numeric',
  396. 'add_duration_max' => 'nullable|numeric',
  397. 'page' => 'required|numeric|min:1',
  398. 'page_size' => 'required|numeric'
  399. ]);
  400. if ($validator->fails()) {
  401. return self::returnValue($validator->getMessageBag(), 1102);
  402. }
  403. $userIdList = $request->input('user_id_list'); // 所属客服
  404. $addDateStart = $request->input('add_date_start'); // 起始添加日期
  405. $addDateEnd = $request->input('add_date_end'); // 截止添加日期
  406. $lossDateStart = $request->input('loss_date_start');
  407. $lossDateEnd = $request->input('loss_date_end');
  408. $addDurationMin = $request->input('add_duration_min');
  409. $addDurationMax = $request->input('add_duration_max');
  410. $corpid = $request->input('corpid');
  411. $page = $request->input('page', 1);
  412. $pageSize = $request->input('page_size', 20);
  413. list($data, $count) = CustomerService::lossCustomerList($userIdList, $addDateStart, $addDateEnd, $lossDateStart,
  414. $lossDateEnd, $addDurationMin, $addDurationMax, $corpid, $page, $pageSize);
  415. return self::returnPageValue($data, $count, $pageSize, $page);
  416. }
  417. public function customerAssignmentRecordList(Request $request)
  418. {
  419. $validator = \Validator::make($request->all(),[
  420. 'corpid' => 'required',
  421. 'handover_userid' => 'nullable|string',
  422. 'takeover_userid' => 'nullable|string',
  423. 'assignment_date_start' => 'nullable|date',
  424. 'assignment_date_end' => 'nullable|date',
  425. 'assignment_status' => 'nullable|in:1,2,3,-1',
  426. 'type' => 'nullable|in:1,2',
  427. 'page' => 'required|numeric|min:1',
  428. 'page_size' => 'required|numeric'
  429. ]);
  430. if ($validator->fails()) {
  431. return self::returnValue($validator->getMessageBag(), 1102);
  432. }
  433. $corpid = $request->input('corpid');
  434. $handoverUserId = $request->input('handover_userid'); // 迁出客服
  435. $takeoverUserId = $request->input('takeover_userid'); // 接替客服
  436. $assignmentDateStart = $request->input('assignment_date_start'); // 起始添加日期
  437. $assignmentDateEnd = $request->input('assignment_date_end'); // 截止添加日期
  438. $assignmentStatus = $request->input('assignment_status');
  439. $type = $request->input('type');
  440. $page = $request->input('page', 1);
  441. $pageSize = $request->input('page_size', 20);
  442. $operatorId = $request->input('operator_id');
  443. list($data, $count) = CustomerService::customerAssignmentRecordList($corpid, $handoverUserId, $operatorId
  444. , $takeoverUserId, $assignmentDateStart, $assignmentDateEnd, $assignmentStatus, $type, $page, $pageSize);
  445. return self::returnPageValue($data, $count, $pageSize, $page);
  446. }
  447. // 客户分配列表
  448. public function customerAssignmentList(Request $request)
  449. {
  450. $validator = \Validator::make($request->all(),[
  451. 'corpid' => 'required',
  452. 'record_id' => 'required|integer',
  453. 'customer_name' => 'nullable|string',
  454. 'assignment_date_start' => 'nullable|date',
  455. 'assignment_date_end' => 'nullable|date',
  456. 'assignment_status' => 'nullable|in:1,2,3,4,5,-1',
  457. 'page' => 'required|numeric|min:1',
  458. 'page_size' => 'required|numeric'
  459. ]);
  460. if ($validator->fails()) {
  461. return self::returnValue($validator->getMessageBag(), 1102);
  462. }
  463. $corpid = $request->input('corpid');
  464. $customerName = $request->input('customer_name');
  465. $recordId = $request->input('record_id'); // 所属客服
  466. $assignmentDateStart = $request->input('assignment_date_start'); // 起始添加日期
  467. $assignmentDateEnd = $request->input('assignment_date_end'); // 截止添加日期
  468. $assignmentStatus = $request->input('assignment_status');
  469. $page = $request->input('page', 1);
  470. $pageSize = $request->input('page_size', 20);
  471. list($data, $count) = CustomerService::customerAssignmentList($corpid, $customerName, $recordId, $assignmentDateStart,
  472. $assignmentDateEnd, $assignmentStatus, $page, $pageSize);
  473. return self::returnPageValue($data, $count, $pageSize, $page);
  474. }
  475. // 客户动态列表
  476. public function customerDynamicList(Request $request)
  477. {
  478. $validator = \Validator::make($request->all(),[
  479. 'corpid' => 'required',
  480. 'customer_id' => 'required|int',
  481. ]);
  482. if ($validator->fails()) {
  483. return self::returnValue($validator->getMessageBag(), 1102);
  484. }
  485. $corpid = $request->input('corpid');
  486. $customerId = $request->input('customer_id');
  487. $data = CustomerService::customerDynamicList($corpid, $customerId);
  488. return self::returnValue($data);
  489. }
  490. // 客户详情标签展示(编辑时使用)
  491. public function customerDetailTagList(Request $request)
  492. {
  493. $validator = \Validator::make($request->all(),[
  494. 'corpid' => 'required',
  495. 'customer_id' => 'required|int',
  496. 'user_id' => 'required'
  497. ]);
  498. if ($validator->fails()) {
  499. return self::returnValue($validator->getMessageBag(), 1102);
  500. }
  501. $corpid = $request->input('corpid');
  502. $customerId = $request->input('customer_id');
  503. $userId = $request->input('user_id');
  504. $data = CustomerService::customerDetailTagList($corpid, $customerId, $userId);
  505. return self::returnValue($data);
  506. }
  507. // 客户详情标签编辑
  508. public function customerDetailTagUpdate(Request $request)
  509. {
  510. $validator = \Validator::make($request->all(),[
  511. 'corpid' => 'required',
  512. 'external_userid' => 'required',
  513. 'user_id' => 'required'
  514. ]);
  515. if ($validator->fails()) {
  516. return self::returnValue($validator->getMessageBag(), 1102);
  517. }
  518. $corpid = $request->input('corpid');
  519. $externalUserId = $request->input('external_userid');
  520. $userId = $request->input('user_id');
  521. $selectedTagIdList = $request->input('selected_tag_id_list');
  522. list($res, $code) = CustomerService::customerDetailTagUpdate($corpid, $externalUserId, $userId, $selectedTagIdList);
  523. return self::returnValue($res, $code);
  524. }
  525. // 批量添加客户导入
  526. public function batchAddCustomerImport(Request $request)
  527. {
  528. $validator = \Validator::make($request->all(),[
  529. 'corpid' => 'required|string',
  530. 'user_id_list' => 'required|array',
  531. 'customer_tag_list' => 'nullable|array',
  532. 'original_file_name' => 'required',
  533. 'ext' => 'required',
  534. ]);
  535. if ($validator->fails()) {
  536. return self::returnValue($validator->getMessageBag(), 1102);
  537. }
  538. $corpid = $request->input('corpid');
  539. $userIdList = $request->input('user_id_list');
  540. $customerTagList = $request->input('customer_tag_list');
  541. $originalFileName = $request->input('original_file_name');
  542. $ext = $request->input('ext');
  543. $newFileName = $request->input('new_file_name');
  544. $sysGroupId = $request->input('sys_group_id');
  545. $res = AddCustomerService::batchAddCustomerImport($originalFileName, $newFileName, $ext, $corpid, $userIdList,
  546. $customerTagList, $sysGroupId);
  547. return self::returnValue($res['info'], $res['code']);
  548. }
  549. // 批量添加客户导入二次确认
  550. public function batchAddCustomerImportConfirm(Request $request)
  551. {
  552. // 处理验证失败信息,不要直接抛异常
  553. $validator = \Validator::make($request->all(), [
  554. 'corpid' => 'required|string',
  555. 'confirm' => 'required|in:1,0',
  556. ]);
  557. if ($validator->fails()) {
  558. return self::returnValue(['error' => $validator->errors()], 1102);
  559. }
  560. $corpid = $request->input('corpid');
  561. $confirm = $request->input('confirm');
  562. $newFileName = $request->input('new_file_name');
  563. $sysGroupId = $request->input('sys_group_id');
  564. $res = AddCustomerService::batchAddCustomerImportConfirm($corpid, $confirm, $newFileName, $sysGroupId);
  565. return self::returnValue($res['info'], $res['code']);
  566. }
  567. // 批量添加客户导入列表
  568. public function batchAddCustomerDetailsList(Request $request)
  569. {
  570. // 处理验证失败信息,不要直接抛异常
  571. $validator = \Validator::make($request->all(), [
  572. 'corpid' => 'required|string',
  573. 'add_status' => 'nullable|in:1,2,3,4'
  574. ]);
  575. if ($validator->fails()) {
  576. return self::returnValue(['error' => $validator->errors()], 1102);
  577. }
  578. $corpid = $request->input('corpid');
  579. $addStatus = $request->input('add_status');
  580. $keyword = $request->input('keyword');
  581. $page = $request->input('page', 1);
  582. $pageSize = $request->input('page_size', 20);
  583. $startTime = $request->input('start_time');
  584. $endTime = $request->input('end_time');
  585. $sysGroupId = $request->input('sys_group_id');
  586. list($data, $count) = AddCustomerService::batchAddCustomerDetailsList($corpid, $addStatus, $keyword, $startTime,
  587. $endTime, $page, $pageSize, $sysGroupId);
  588. return self::returnPageValue($data, $count, $pageSize, $page);
  589. }
  590. // 批量添加客户导入记录列表
  591. public function batchAddCustomerRecordList(Request $request)
  592. {
  593. // 处理验证失败信息,不要直接抛异常
  594. $validator = \Validator::make($request->all(), [
  595. 'corpid' => 'required|string',
  596. ]);
  597. if ($validator->fails()) {
  598. return self::returnValue(['error' => $validator->errors()], 1102);
  599. }
  600. $corpid = $request->input('corpid');
  601. $page = $request->input('page', 1);
  602. $pageSize = $request->input('page_size', 20);
  603. $sysGroupId = $request->input('sys_group_id');
  604. list($data, $count) = AddCustomerService::batchAddCustomerRecordList($corpid, $page, $pageSize, $sysGroupId);
  605. return self::returnPageValue($data, $count, $pageSize, $page);
  606. }
  607. // 批量添加客户导入记录详情
  608. public function batchAddCustomerRecordDetail(Request $request)
  609. {
  610. // 处理验证失败信息,不要直接抛异常
  611. $validator = \Validator::make($request->all(), [
  612. 'corpid' => 'required|string',
  613. 'record_id' => 'required',
  614. 'add_status' => 'nullable|in:1,2,3,4'
  615. ]);
  616. if ($validator->fails()) {
  617. return self::returnValue(['error' => $validator->errors()], 1102);
  618. }
  619. $corpid = $request->input('corpid');
  620. $addStatus = $request->input('add_status');
  621. $keyword = $request->input('keyword');
  622. $recordId = $request->input('record_id');
  623. $page = $request->input('page', 1);
  624. $pageSize = $request->input('page_size', 20);
  625. $sysGroupId = $request->input('sys_group_id');
  626. list($data, $count) = AddCustomerService::batchAddCustomerRecordDetail($corpid, $addStatus, $keyword, $recordId,
  627. $page, $pageSize, $sysGroupId);
  628. return self::returnPageValue($data, $count, $pageSize, $page);
  629. }
  630. // 批量分配客户
  631. public function batchDistributionCustomer(Request $request)
  632. {
  633. // 处理验证失败信息,不要直接抛异常
  634. $validator = \Validator::make($request->all(), [
  635. 'corpid' => 'required|string',
  636. 'add_status' => 'nullable|in:1,2,3,4',
  637. 'select_all' => 'nullable|in:0,1',
  638. 'select_id_list' => 'nullable|array',
  639. 'exclude_id_list' => 'nullable|array',
  640. 'user_id_list' => 'required|array',
  641. ]);
  642. if ($validator->fails()) {
  643. return self::returnValue(['error' => $validator->errors()], 1102);
  644. }
  645. $corpid = $request->input('corpid');
  646. $addStatus = $request->input('add_status');
  647. $keyword = $request->input('keyword');
  648. $startTime = $request->input('start_time');
  649. $endTime = $request->input('end_time');
  650. $selectAll = $request->input('select_all', 0);
  651. $selectIdList = $request->input('select_id_list');
  652. $excludeIdList = $request->input('exclude_id_list');
  653. $userIdList = $request->input('user_id_list');
  654. $sysGroupId = $request->input('sys_group_id');
  655. list($res, $code) = AddCustomerService::batchDistributionCustomer($corpid, $addStatus, $keyword, $startTime, $endTime,
  656. $selectAll, $selectIdList, $excludeIdList, $userIdList, $sysGroupId);
  657. return self::returnValue($res, $code);
  658. }
  659. // 删除导入记录(单个删除)
  660. public function deleteRecord(Request $request)
  661. {
  662. // 处理验证失败信息,不要直接抛异常
  663. $validator = \Validator::make($request->all(), [
  664. 'corpid' => 'required|string',
  665. 'record_id' => 'required',
  666. ]);
  667. if ($validator->fails()) {
  668. return self::returnValue(['error' => $validator->errors()], 1102);
  669. }
  670. $corpid = $request->input('corpid');
  671. $recordId = $request->input('record_id');
  672. $sysGroupId = $request->input('sys_group_id');
  673. list($res, $code) = AddCustomerService::deleteRecord($corpid, $recordId, $sysGroupId);
  674. return self::returnValue($res, $code);
  675. }
  676. // 删除导入客户
  677. public function deleteDetail(Request $request)
  678. {
  679. // 处理验证失败信息,不要直接抛异常
  680. $validator = \Validator::make($request->all(), [
  681. 'corpid' => 'required|string',
  682. 'add_status' => 'nullable|in:1,2,3,4',
  683. 'select_all' => 'nullable|in:0,1',
  684. 'select_id_list' => 'nullable|array',
  685. 'exclude_id_list' => 'nullable|array',
  686. ]);
  687. if ($validator->fails()) {
  688. return self::returnValue(['error' => $validator->errors()], 1102);
  689. }
  690. $corpid = $request->input('corpid');
  691. $addStatus = $request->input('add_status');
  692. $keyword = $request->input('keyword');
  693. $startTime = $request->input('start_time');
  694. $endTime = $request->input('end_time');
  695. $selectAll = $request->input('select_all', 0);
  696. $selectIdList = $request->input('select_id_list');
  697. $excludeIdList = $request->input('exclude_id_list');
  698. $sysGroupId = $request->input('sys_group_id');
  699. list($res, $code) = AddCustomerService::deleteDetail($corpid, $addStatus, $keyword, $startTime, $endTime, $selectAll,
  700. $selectIdList, $excludeIdList, $sysGroupId);
  701. return self::returnValue($res, $code);
  702. }
  703. // 批量提醒(add_status为待添加以及待通过)
  704. public function batchRemind(Request $request)
  705. {
  706. // 处理验证失败信息,不要直接抛异常
  707. $validator = \Validator::make($request->all(), [
  708. 'corpid' => 'required|string',
  709. 'add_status' => 'required|in:1,2',
  710. 'select_all' => 'nullable|in:0,1',
  711. 'select_id_list' => 'nullable|array',
  712. 'exclude_id_list' => 'nullable|array',
  713. ]);
  714. if ($validator->fails()) {
  715. return self::returnValue(['error' => $validator->errors()], 1102);
  716. }
  717. $corpid = $request->input('corpid');
  718. $addStatus = $request->input('add_status');
  719. $keyword = $request->input('keyword');
  720. $startTime = $request->input('start_time');
  721. $endTime = $request->input('end_time');
  722. $selectAll = $request->input('select_all', 0);
  723. $selectIdList = $request->input('select_id_list');
  724. $excludeIdList = $request->input('exclude_id_list');
  725. $sysGroupId = $request->input('sys_group_id');
  726. list($res, $code) = AddCustomerService::batchRemind($corpid, $addStatus, $keyword, $startTime, $endTime, $selectAll,
  727. $selectIdList, $excludeIdList, $sysGroupId);
  728. return self::returnValue($res, $code);
  729. }
  730. /**
  731. * 安卓客户端获取待邀请入群的新用户列表
  732. * */
  733. public function waitInvite(Request $request)
  734. {
  735. $validator = \Validator::make($request->all(), [
  736. 'device_id' => 'required|string',
  737. 'begin_time' => 'required|date_format:Y-m-d H:i:s',
  738. 'end_time' => 'required|date_format:Y-m-d H:i:s',
  739. ]);
  740. if ($validator->fails()) {
  741. return self::returnValue(['error' => $validator->errors()], 1102);
  742. }
  743. $deviceId = $request->input('device_id');
  744. $beginTime = $request->input('begin_time');
  745. $endTime = $request->input('end_time');
  746. $retry = $request->input('retry', 0);
  747. $requestCorpId = $request->input('corpid');
  748. $customerNumber = $request->input('customer_number');
  749. # 获取待邀请入群的新用户
  750. $userList = CustomerService::waitInvite($deviceId, $beginTime, $endTime, $retry, $requestCorpId, $customerNumber);
  751. Log::logInfo('邀请新用户入群请求日志', [
  752. 'device_id' => $deviceId,
  753. 'begin_time' => $beginTime,
  754. 'end_time' => $endTime,
  755. 'retry' => $retry,
  756. 'customer_number' => $customerNumber,
  757. 'corp_id' => $requestCorpId,
  758. 'response' => $userList
  759. ], 'WaitInvite');
  760. return self::returnValue(['list' => $userList]);
  761. }
  762. /**
  763. * 安卓客户端获取待共享的新用户列表
  764. * */
  765. public function waitShare(Request $request)
  766. {
  767. $validator = \Validator::make($request->all(), [
  768. 'device_id' => 'required|string',
  769. 'begin_time' => 'required|date_format:Y-m-d H:i:s',
  770. 'end_time' => 'required|date_format:Y-m-d H:i:s',
  771. ]);
  772. if ($validator->fails()) {
  773. return self::returnValue(['error' => $validator->errors()], 1102);
  774. }
  775. $deviceId = $request->input('device_id');
  776. $beginTime = $request->input('begin_time');
  777. $endTime = $request->input('end_time');
  778. # 获取待邀请入群的新用户
  779. $userList = CustomerService::waitShare($deviceId, $beginTime, $endTime);
  780. Log::logInfo('新用户共享请求日志', [
  781. 'device_id' => $deviceId,
  782. 'begin_time' => $beginTime,
  783. 'end_time' => $endTime,
  784. 'response' => $userList
  785. ], 'waitShare');
  786. return self::returnValue(['list' => $userList]);
  787. }
  788. /**
  789. * 安卓客户端获取待补充邀请入群的用户列表-按群模板随机补拉
  790. * @param Request $request
  791. */
  792. public function waitSupplementaryInvite(Request $request) {
  793. $validator = \Validator::make($request->all(), [
  794. 'device_id' => 'required|string',
  795. 'begin_time' => 'required|date_format:Y-m-d H:i:s',
  796. 'end_time' => 'required|date_format:Y-m-d H:i:s',
  797. ]);
  798. if ($validator->fails()) {
  799. return self::returnValue(['error' => $validator->errors()], 1102);
  800. }
  801. $deviceId = $request->input('device_id');
  802. $beginTime = $request->input('begin_time');
  803. $endTime = $request->input('end_time');
  804. # 获取待邀请入群的新用户
  805. $userList = CustomerService::waitSupplementaryInvite($deviceId, $beginTime, $endTime);
  806. Log::logInfo('退群用户补充邀请入群请求日志', [
  807. 'device_id' => $deviceId,
  808. 'begin_time' => $beginTime,
  809. 'end_time' => $endTime,
  810. 'response' => $userList
  811. ], 'waitSupplementaryInvite');
  812. return self::returnValue(['list' => $userList]);
  813. }
  814. /**
  815. * 安卓客户端获取待补充邀请入群的用户列表-将用户拉回指定群
  816. */
  817. public function waitInviteTargetGroup(Request $request) {
  818. $validator = \Validator::make($request->all(), [
  819. 'device_id' => 'required|string',
  820. 'begin_time' => 'required|date_format:Y-m-d H:i:s',
  821. 'end_time' => 'required|date_format:Y-m-d H:i:s',
  822. ]);
  823. if ($validator->fails()) {
  824. return self::returnValue(['error' => $validator->errors()], 1102);
  825. }
  826. $deviceId = $request->input('device_id');
  827. $beginTime = $request->input('begin_time');
  828. $endTime = $request->input('end_time');
  829. # 获取待邀请入群的新用户
  830. $userList = CustomerService::waitInviteTargetGroup($deviceId, $beginTime, $endTime);
  831. Log::logInfo('退群用户补充邀请入群请求日志', [
  832. 'device_id' => $deviceId,
  833. 'begin_time' => $beginTime,
  834. 'end_time' => $endTime,
  835. 'response' => $userList
  836. ], 'waitInviteTargetGroup');
  837. return self::returnValue(['list' => $userList]);
  838. }
  839. public function inviteNewUser(Request $request)
  840. {
  841. $validator = \Validator::make($request->all(), [
  842. 'device_id' => 'required|string',
  843. 'begin_time' => 'required|date_format:Y-m-d H:i:s',
  844. 'end_time' => 'required|date_format:Y-m-d H:i:s',
  845. ]);
  846. if ($validator->fails()) {
  847. return self::returnValue(['error' => $validator->errors()], 1102);
  848. }
  849. $deviceId = $request->input('device_id');
  850. $beginTime = $request->input('begin_time');
  851. $endTime = $request->input('end_time');
  852. # 获取待邀请入群的新用户
  853. $userList = CustomerService::inviteNewUser($deviceId, $beginTime, $endTime);
  854. Log::logInfo('退群用户补充邀请入群请求日志', [
  855. 'device_id' => $deviceId,
  856. 'begin_time' => $beginTime,
  857. 'end_time' => $endTime,
  858. 'response' => $userList
  859. ], 'waitInviteTargetGroup');
  860. return self::returnValue(['list' => $userList]);
  861. }
  862. }