企微短剧业务系统

BatchAddCustomerController.php 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Service\BatchAddCustomerService;
  4. use Illuminate\Http\Request;
  5. use App\Http\Controllers\Controller;
  6. use Illuminate\Validation\Rule;
  7. class BatchAddCustomerController extends Controller
  8. {
  9. /**
  10. * 配置自动提醒或自动回收
  11. * */
  12. public function setAutomateConfig(Request $request)
  13. {
  14. $validator = \Validator::make($request->all(),[
  15. 'corpid' => 'required|string',
  16. 'config_list' => 'required|array'
  17. ]);
  18. if ($validator->fails()) {
  19. return self::returnValue($validator->getMessageBag(), 1102);
  20. }
  21. $corpid = $request->input('corpid');
  22. $adminId = $request->input('admin_id');
  23. $configList = $request->input('config_list');
  24. $sysGroupId = $request->input('sys_group_id');
  25. $errNo = BatchAddCustomerService::editConfig($corpid, $adminId, $configList, $sysGroupId);
  26. return self::returnValue([], $errNo);
  27. }
  28. /**
  29. * 获取企业配置信息
  30. * */
  31. public function configInfo(Request $request)
  32. {
  33. $validator = \Validator::make($request->all(),[
  34. 'corpid' => 'required|string',
  35. ]);
  36. if ($validator->fails()) {
  37. return self::returnValue($validator->getMessageBag(), 1102);
  38. }
  39. $corpid = $request->input('corpid');
  40. $sysGroupId = $request->input('sys_group_id');
  41. $adminId = $request->input('admin_id');
  42. # 获取企业配置自动提醒
  43. $configInfo = array();
  44. $errno = BatchAddCustomerService::configInfo($corpid, $sysGroupId, $adminId, $configInfo);
  45. if($errno) return self::returnValue([], $errno);
  46. return self::returnValue($configInfo);
  47. }
  48. /**
  49. * 给未完成客户添加工作的成员发送消息提醒
  50. * */
  51. public function noticeUser(Request $request)
  52. {
  53. $validator = \Validator::make($request->all(),[
  54. 'corpid' => 'required|string',
  55. 'user_ids' => 'required|string',
  56. ]);
  57. if ($validator->fails()) {
  58. return self::returnValue($validator->getMessageBag(), 1102);
  59. }
  60. $corpid = $request->input('corpid');
  61. $userIds = $request->input('user_ids');
  62. $errno = BatchAddCustomerService::noticeUser($corpid, $userIds);
  63. return self::returnValue([], $errno);
  64. }
  65. /**
  66. * 查看已分配的客户列表
  67. * */
  68. public function customerList(Request $request)
  69. {
  70. $validator = \Validator::make($request->all(),[
  71. 'corpid' => 'required|string',
  72. 'user_id' => 'required|string',
  73. 'token' => 'required|string',
  74. 'timestamp' => 'required',
  75. ]);
  76. if ($validator->fails()) {
  77. return self::returnValue($validator->getMessageBag(), 1102);
  78. }
  79. $corpid = $request->input('corpid');
  80. $userId = $request->input('user_id');
  81. $token = $request->input('token');
  82. $timestamp = $request->input('timestamp');
  83. $addStatus = $request->input('add_status');
  84. $page = $request->input('page', 1);
  85. $pageSize = $request->input('page_size', 50);
  86. $errno = 0;
  87. list($list, $count, $customerTotal) = BatchAddCustomerService::getCustomerList(
  88. $corpid, $userId, $token, $timestamp, $addStatus, $page, $pageSize, $errno
  89. );
  90. if($errno) return self::returnValue([], $errno);
  91. return self::returnPageValue(['list' => $list, 'customer_total' => $customerTotal], $count, $pageSize, $page);
  92. }
  93. /**
  94. * 客服添加客户数据上报
  95. * */
  96. public function dataReporting(Request $request)
  97. {
  98. $validator = \Validator::make($request->all(),[
  99. 'corpid' => 'required|string',
  100. 'user_id' => 'required|string',
  101. 'record_id' => 'required|int',
  102. 'phone' => 'required'
  103. ]);
  104. if ($validator->fails()) {
  105. return self::returnValue($validator->getMessageBag(), 1102);
  106. }
  107. $corpid = $request->input('corpid');
  108. $phone = $request->input('phone');
  109. $userId = $request->input('user_id');
  110. $recordId = $request->input('record_id');
  111. # 数据上报
  112. $errno = BatchAddCustomerService::dataReporting($corpid, $phone, $userId, $recordId);
  113. return self::returnValue([], $errno);
  114. }
  115. /**
  116. * 数据概览
  117. * */
  118. public function dataSummary(Request $request)
  119. {
  120. $validator = \Validator::make($request->all(),[
  121. 'corpid' => 'required|string',
  122. 'start_date' => 'required|date_format:Y-m-d',
  123. 'end_date' => 'required|date_format:Y-m-d',
  124. ]);
  125. if ($validator->fails()) {
  126. return self::returnValue($validator->getMessageBag(), 1102);
  127. }
  128. $corpid = $request->input('corpid');
  129. $sysGroupId = $request->input('sys_group_id');
  130. $startDate = $request->input('start_date');
  131. $endDate = $request->input('end_date');
  132. # 获取数据概览
  133. $data = BatchAddCustomerService::dataSummary($corpid, $startDate, $endDate, $sysGroupId);
  134. return self::returnValue($data);
  135. }
  136. /**
  137. * 好友添加统计列表
  138. * */
  139. public function statistic(Request $request)
  140. {
  141. $validator = \Validator::make($request->all(),[
  142. 'corpid' => 'required|string',
  143. 'start_date' => 'required|date_format:Y-m-d',
  144. 'end_date' => 'required|date_format:Y-m-d',
  145. ]);
  146. if ($validator->fails()) {
  147. return self::returnValue($validator->getMessageBag(), 1102);
  148. }
  149. $corpid = $request->input('corpid');
  150. $userId = $request->input('user_id');
  151. $startDate = $request->input('start_date');
  152. $endDate = $request->input('end_date');
  153. $sysGroupId = $request->input('sys_group_id');
  154. $page = $request->input('page', 1);
  155. $pageSize = $request->input('page_size', 50);
  156. list($list, $count) = BatchAddCustomerService::statistic($corpid, $userId, $startDate, $endDate, $sysGroupId, $page, $pageSize);
  157. return self::returnPageValue($list, $count, $pageSize, $page);
  158. }
  159. }