123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Service\CustomerLossService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- class CustomerLossController extends Controller
- {
- /**
- * 账号客户流失数据趋势
- * */
- public function accountLossTrend(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corpid'] = $request->input('corpid');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- $sortField = $request->input('sort_field', 'corpid');
- $sortType = $request->input('sort_type', 'desc'); // 排序方式
- $page = $request->input('page', 1);
- $pageSize = $request->input('page_size', 10);
- # 获取账号客户流失数据趋势
- list($list, $count, $retrieveColumns) = CustomerLossService::getFansLossTrend(
- $params, $sortField, $sortType, $page, $pageSize
- );
- return self::returnPageValue($list, $count, $pageSize, $page, $retrieveColumns);
- }
- /**
- * 账号客户流失总概数据
- * */
- public function accountLossSummary(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corpid'] = $request->input('corpid');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- list($data, $header) = CustomerLossService::getFansLossSummary($params);
- return self::returnValue([
- 'data' => $data,
- 'header' => $header
- ]);
- }
- /**
- * 账号客户流失趋势曲线
- * */
- public function accountLossCurve(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'start_date' => 'required|date',
- 'end_date' => 'required|date',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $params['corpid'] = $request->input('corpid');
- $params['sys_group_id'] = $request->input('sys_group_id');
- $params['start_date'] = $request->input('start_date');
- $params['end_date'] = $request->input('end_date');
- $data = CustomerLossService::getFansLossCurve($params);
- return self::returnValue(['data' => $data]);
- }
- }
|