企微短剧业务系统

UserSopController.php 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Log;
  4. use App\Service\UserSopService;
  5. use Illuminate\Http\Request;
  6. use App\Http\Controllers\Controller;
  7. use Illuminate\Validation\Rule;
  8. class UserSopController extends Controller
  9. {
  10. /**
  11. * 配置个人SOP规则
  12. * */
  13. public function setRule(Request $request)
  14. {
  15. $validator = \Validator::make($request->all(), [
  16. 'corpid' => 'required|string',
  17. 'title' => 'required|string',
  18. 'type' => ['required', Rule::in([1, 2])],
  19. 'is_all' => ['required', Rule::in([0, 1])],
  20. ]);
  21. if ($validator->fails()) {
  22. return self::returnValue($validator->getMessageBag(), 1102);
  23. }
  24. $params = [];
  25. $ruleId = $request->input('rule_id');
  26. $params['corpid'] = $request->input('corpid');
  27. $params['admin_id'] = $request->input('admin_id');
  28. $params['sys_group_id'] = $request->input('sys_group_id');
  29. $params['title'] = $request->input('title');
  30. $params['is_all'] = $request->input('is_all', 0);
  31. $params['user_ids'] = $request->input('user_ids');
  32. $params['type'] = $request->input('type'); // 规则类型 1客户添加后间隔指定时间提醒 2客户添加后在指定的时间点提醒
  33. $params['interval_time'] = $request->input('interval_time'); // 间隔时间。单位:分钟
  34. $params['notice_time'] = $request->input('notice_time'); // 提醒客服时间.示例:09:00:00
  35. $params['msg_data'] = $request->input('msg_data'); // 提醒消息
  36. $params['customer_filter'] = $request->input('customer_filter', 0); // 客户筛选 0:全部客户 1:筛选客户
  37. $params['gender'] = $request->input('gender');
  38. $params['tag_screen_type'] = $request->input('tag_screen_type');
  39. $params['tag_list'] = $request->input('tag_list');
  40. $params['exclude_tag_list'] = $request->input('exclude_tag_list');
  41. $params['pay_status'] = $request->input('pay_status');
  42. $params['pay_num_min'] = $request->input('pay_num_min'); // 最小付费次数
  43. $params['pay_num_max'] = $request->input('pay_num_max'); // 最大付费次数
  44. # 设置群活码规则
  45. $errno = UserSopService::setRule($params, $ruleId);
  46. return self::returnValue([], $errno);
  47. }
  48. /**
  49. * 个人SOP规则列表
  50. * */
  51. public function ruleList(Request $request)
  52. {
  53. $validator = \Validator::make($request->all(), [
  54. 'corpid' => 'required|string',
  55. ]);
  56. if ($validator->fails()) {
  57. return self::returnValue($validator->getMessageBag(), 1102);
  58. }
  59. $corpid = $request->input('corpid');
  60. $sysGroupId = $request->input('sys_group_id');
  61. $page = $request->input('page', 1);
  62. $pageSize = $request->input('page_size', 20);
  63. # 设置群活码规则
  64. list($list, $count) = UserSopService::ruleList($corpid, $sysGroupId, $page, $pageSize);
  65. return self::returnPageValue($list, $count, $pageSize, $page);
  66. }
  67. /**
  68. * 个人SOP配置详情
  69. * */
  70. public function ruleDetail(Request $request)
  71. {
  72. $validator = \Validator::make($request->all(), [
  73. 'corpid' => 'required|string',
  74. 'rule_id' => 'required|int',
  75. ]);
  76. if ($validator->fails()) {
  77. return self::returnValue($validator->getMessageBag(), 1102);
  78. }
  79. $corpid = $request->input('corpid');
  80. $sysGroupId = $request->input('sys_group_id');
  81. $ruleId = $request->input('rule_id');
  82. # 获取配置详情
  83. $data = UserSopService::ruleDetail($corpid, $sysGroupId, $ruleId);
  84. return self::returnValue($data);
  85. }
  86. /**
  87. * 个人SOP配置状态变更
  88. * */
  89. public function changeStatus(Request $request)
  90. {
  91. $validator = \Validator::make($request->all(), [
  92. 'corpid' => 'required|string',
  93. 'rule_id' => 'required|int',
  94. 'status' => ['required', Rule::in([0, 1])],
  95. ]);
  96. if ($validator->fails()) {
  97. return self::returnValue($validator->getMessageBag(), 1102);
  98. }
  99. $corpid = $request->input('corpid');
  100. $sysGroupId = $request->input('sys_group_id');
  101. $ruleId = $request->input('rule_id');
  102. $status = $request->input('status');
  103. # 变更配置状态
  104. $errno = UserSopService::ruleStatusChange($corpid, $sysGroupId, $ruleId, $status);
  105. return self::returnValue([], $errno);
  106. }
  107. /**
  108. * 个人SOP规则详情【H5】
  109. * */
  110. public function detail(Request $request)
  111. {
  112. $validator = \Validator::make($request->all(), [
  113. 'corpid' => 'required|string',
  114. 'rule_id' => 'required|int',
  115. ]);
  116. if ($validator->fails()) {
  117. return self::returnValue($validator->getMessageBag(), 1102);
  118. }
  119. $corpid = $request->input('corpid');
  120. $ruleId = $request->input('rule_id');
  121. # 获取规则详情及待跟进客户列表
  122. $errno = 0;
  123. $data = UserSopService::getDetail($corpid, $ruleId, $errno);
  124. return self::returnValue(['data' => $data], $errno);
  125. }
  126. /**
  127. * 待跟进客户列表
  128. * */
  129. public function customer(Request $request)
  130. {
  131. $validator = \Validator::make($request->all(), [
  132. 'corpid' => 'required|string',
  133. 'rule_id' => 'required|int',
  134. 'user_id' => 'required|string',
  135. ]);
  136. if ($validator->fails()) {
  137. return self::returnValue($validator->getMessageBag(), 1102);
  138. }
  139. $corpid = $request->input('corpid');
  140. $ruleId = $request->input('rule_id');
  141. $userId = $request->input('user_id');
  142. $page = $request->input('page', 1);
  143. $pageSize = $request->input('page_size', 50);
  144. # 获取待跟进客户列表
  145. list($list, $count) = UserSopService::getCustomerList($corpid, $ruleId, $userId, $page, $pageSize);
  146. return self::returnPageValue($list, $count, $pageSize, $page);
  147. }
  148. /**
  149. * 跟进客户数据上报【H5】
  150. * */
  151. public function report(Request $request)
  152. {
  153. $validator = \Validator::make($request->all(), [
  154. 'corpid' => 'required|string',
  155. 'rule_id' => 'required|int',
  156. 'user_id' => 'required|string',
  157. 'external_userid' => 'required|string',
  158. ]);
  159. if ($validator->fails()) {
  160. return self::returnValue($validator->getMessageBag(), 1102);
  161. }
  162. $corpid = $request->input('corpid');
  163. $ruleId = $request->input('rule_id');
  164. $userId = $request->input('user_id');
  165. $externalUserid = $request->input('external_userid');
  166. $errno = UserSopService::report($corpid, $ruleId, $userId, $externalUserid);
  167. return self::returnValue([], $errno);
  168. }
  169. }