企微短剧业务系统

CustomerLossController.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Service\CustomerLossService;
  4. use Illuminate\Http\Request;
  5. use App\Http\Controllers\Controller;
  6. class CustomerLossController extends Controller
  7. {
  8. /**
  9. * 账号客户流失数据趋势
  10. * */
  11. public function accountLossTrend(Request $request)
  12. {
  13. $validator = \Validator::make($request->all(),[
  14. 'start_date' => 'required|date',
  15. 'end_date' => 'required|date',
  16. ]);
  17. if ($validator->fails()) {
  18. return self::returnValue($validator->getMessageBag(), 1102);
  19. }
  20. $params['corpid'] = $request->input('corpid');
  21. $params['sys_group_id'] = $request->input('sys_group_id');
  22. $params['start_date'] = $request->input('start_date');
  23. $params['end_date'] = $request->input('end_date');
  24. $sortField = $request->input('sort_field', 'corpid');
  25. $sortType = $request->input('sort_type', 'desc'); // 排序方式
  26. $page = $request->input('page', 1);
  27. $pageSize = $request->input('page_size', 10);
  28. # 获取账号客户流失数据趋势
  29. list($list, $count, $retrieveColumns) = CustomerLossService::getFansLossTrend(
  30. $params, $sortField, $sortType, $page, $pageSize
  31. );
  32. return self::returnPageValue($list, $count, $pageSize, $page, $retrieveColumns);
  33. }
  34. /**
  35. * 账号客户流失总概数据
  36. * */
  37. public function accountLossSummary(Request $request)
  38. {
  39. $validator = \Validator::make($request->all(),[
  40. 'start_date' => 'required|date',
  41. 'end_date' => 'required|date',
  42. ]);
  43. if ($validator->fails()) {
  44. return self::returnValue($validator->getMessageBag(), 1102);
  45. }
  46. $params['corpid'] = $request->input('corpid');
  47. $params['sys_group_id'] = $request->input('sys_group_id');
  48. $params['start_date'] = $request->input('start_date');
  49. $params['end_date'] = $request->input('end_date');
  50. list($data, $header) = CustomerLossService::getFansLossSummary($params);
  51. return self::returnValue([
  52. 'data' => $data,
  53. 'header' => $header
  54. ]);
  55. }
  56. /**
  57. * 账号客户流失趋势曲线
  58. * */
  59. public function accountLossCurve(Request $request)
  60. {
  61. $validator = \Validator::make($request->all(),[
  62. 'start_date' => 'required|date',
  63. 'end_date' => 'required|date',
  64. ]);
  65. if ($validator->fails()) {
  66. return self::returnValue($validator->getMessageBag(), 1102);
  67. }
  68. $params['corpid'] = $request->input('corpid');
  69. $params['sys_group_id'] = $request->input('sys_group_id');
  70. $params['start_date'] = $request->input('start_date');
  71. $params['end_date'] = $request->input('end_date');
  72. $data = CustomerLossService::getFansLossCurve($params);
  73. return self::returnValue(['data' => $data]);
  74. }
  75. }