| xqd
@@ -293,8 +293,8 @@ class AlbumBossController extends Controller
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @api {post} /api/album_boss/agent_overview 经销商总览(agent_overview)
|
|
|
- * @apiDescription 经销商总览(agent_overview)
|
|
|
+ * @api {post} /api/album_boss/agent_overview_active 经销商总览活跃客户(agent_overview_active)
|
|
|
+ * @apiDescription 经销商总览活跃客户(agent_overview_active)
|
|
|
* @apiGroup Boss
|
|
|
* @apiPermission none
|
|
|
* @apiVersion 0.1.0
|
| xqd
@@ -308,23 +308,181 @@ class AlbumBossController extends Controller
|
|
|
* "status_code": 0,
|
|
|
* "message": "",
|
|
|
* "data": {
|
|
|
- * "customerFollow":11,
|
|
|
- * "downloadCount":11,
|
|
|
- * "shareCount":11,
|
|
|
- * "newCustomerCount":11,
|
|
|
- * "totalCustomerCount":11,
|
|
|
* "activeCustomers": [
|
|
|
* {
|
|
|
* "day" : 03/25,
|
|
|
* "num" : 111
|
|
|
* }
|
|
|
* ],
|
|
|
- * "newCustomers": [
|
|
|
- * {
|
|
|
- * "day" : 03/25,
|
|
|
- * "num" : 111
|
|
|
- * }
|
|
|
- * ]
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function albumOverviewActive(Request $request)
|
|
|
+ {
|
|
|
+
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ if (!$userAuth) {
|
|
|
+ return $this->error(ErrorCode::ERROR_POWER, '登陆过期!');
|
|
|
+ }
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($userAuth->role != 4) {
|
|
|
+ return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
+ }
|
|
|
+
|
|
|
+ $store_id = $request->input('store_id');
|
|
|
+
|
|
|
+ $activeCustomers = array();
|
|
|
+ for ($d = 0; $d < 15; $d++) {
|
|
|
+ $StartO = mktime(0, 0, 0, date('m'), date('d'), date('y')) + 86400 * $d;
|
|
|
+ $EndO = $StartO + 86400;
|
|
|
+ $End = date('Y-m-d H:i:s', $EndO);
|
|
|
+ $Start = date('Y-m-d H:i:s', $StartO);
|
|
|
+ $customerNum = AlbumWatchRecord::where([
|
|
|
+ ['store_id', $store_id],
|
|
|
+ ['updated_at','>=',$Start],
|
|
|
+ ['updated_at','<=',$End]
|
|
|
+ ])->orderByDesc('id')->groupBy('open_id')->count();
|
|
|
+ $activeCustomers[] = [
|
|
|
+ 'day' => date('m', $StartO) . '-' . date('d', $EndO),
|
|
|
+ 'num' => $customerNum
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return $this->api($activeCustomers);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {post} /api/album_boss/agent_overview_left 经销商总览左侧(agent_overview_left)
|
|
|
+ * @apiDescription 经销商总览左侧(agent_overview_left)
|
|
|
+ * @apiGroup Boss
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} [store_id] 商户id
|
|
|
+ * @apiParam {int} [start] 开始时间
|
|
|
+ * @apiParam {int} [end] 结束时间
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": {
|
|
|
+ * "customerFollow":11,
|
|
|
+ * "downloadCount":11,
|
|
|
+ * "shareCount":11,
|
|
|
+ * "newCustomerCount":11,
|
|
|
+ * "totalCustomerCount":11,
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function albumOverviewLeft(Request $request)
|
|
|
+ {
|
|
|
+
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ if (!$userAuth) {
|
|
|
+ return $this->error(ErrorCode::ERROR_POWER, '登陆过期!');
|
|
|
+ }
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($userAuth->role != 4) {
|
|
|
+ return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
+ }
|
|
|
+
|
|
|
+ $end = $request->input('end');
|
|
|
+ $start = $request->input('start');
|
|
|
+ $store_id = $request->input('store_id');
|
|
|
+ if (!$end) {
|
|
|
+ $end = time();
|
|
|
+ }
|
|
|
+ if (!$start) {
|
|
|
+ $start = 0;
|
|
|
+ }
|
|
|
+ $end = date('Y-m-d H:i:s', $end);
|
|
|
+ $start = date('Y-m-d H:i:s', $start);
|
|
|
+
|
|
|
+ $customerFollow = CustomerDetailsModel::where('store_id', $store_id)->count();
|
|
|
+ $downloadCount = AlbumWatchRecord::where([
|
|
|
+ ['store_id', $store_id],
|
|
|
+ ['action', 9],
|
|
|
+ ['updated_at','>=',$start],
|
|
|
+ ['updated_at','<=',$end]
|
|
|
+ ])->orderByDesc('id')->count();
|
|
|
+
|
|
|
+ $shareCount = AlbumWatchRecord::where([
|
|
|
+ ['store_id', $store_id],
|
|
|
+ ['action', 8],
|
|
|
+ ['updated_at','>=',$start],
|
|
|
+ ['updated_at','<=',$end]
|
|
|
+ ])->orderByDesc('id')->count();
|
|
|
+
|
|
|
+ $newCustomerCount = AlbumWatchRecord::where([
|
|
|
+ ['store_id', $store_id],
|
|
|
+ ['is_new', 1],
|
|
|
+ ['updated_at','>=',$start],
|
|
|
+ ['updated_at','<=',$end]
|
|
|
+ ])->orderByDesc('id')->count();
|
|
|
+
|
|
|
+ $totalCustomerCount = AlbumWatchRecord::where([
|
|
|
+ ['store_id', $store_id],
|
|
|
+ ['updated_at','>=',$start],
|
|
|
+ ['updated_at','<=',$end]
|
|
|
+ ])->orderByDesc('id')->groupBy('open_id')->count();
|
|
|
+ return $this->api(compact('totalCustomerCount', 'newCustomerCount', 'shareCount', 'downloadCount', 'customerFollow'));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {post} /api/album_boss/agent_overview_favorite 经销商总览兴趣占比(agent_overview_favorite)
|
|
|
+ * @apiDescription 经销商总览兴趣占比(agent_overview_favorite)
|
|
|
+ * @apiGroup Boss
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} [store_id] 商户id
|
|
|
+ * @apiParam {int} [start] 开始时间
|
|
|
+ * @apiParam {int} [end] 结束时间
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": {
|
|
|
* "arrFavorite": [
|
|
|
* {
|
|
|
* 'name':'asdawd',
|
| xqd
@@ -345,7 +503,7 @@ class AlbumBossController extends Controller
|
|
|
* 可能出现的错误代码:
|
|
|
* 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
*/
|
|
|
- public function albumOverview(Request $request)
|
|
|
+ public function albumOverviewFavorite(Request $request)
|
|
|
{
|
|
|
|
|
|
$userAuth = Auth('api')->user();
|
| xqd
@@ -399,60 +557,146 @@ class AlbumBossController extends Controller
|
|
|
}
|
|
|
$total++;
|
|
|
}
|
|
|
- $activeCustomers = array();
|
|
|
+ foreach ($arrFavorite as $key => $val) {
|
|
|
+ $arrFavorite[$key]['point'] = ($val['num'] / $total * 100) . '%';
|
|
|
+ }
|
|
|
+ return $this->api($arrFavorite);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {post} /api/album_boss/agent_overview_new 经销商总览新增客户(agent_overview_new)
|
|
|
+ * @apiDescription 经销商总览新增客户(agent_overview_new)
|
|
|
+ * @apiGroup Boss
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} [store_id] 商户id
|
|
|
+ * @apiParam {int} [start] 开始时间
|
|
|
+ * @apiParam {int} [end] 结束时间
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": {
|
|
|
+ * "newCustomers": [
|
|
|
+ * {
|
|
|
+ * "day" : 03/25,
|
|
|
+ * "num" : 111
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function albumOverviewNew(Request $request)
|
|
|
+ {
|
|
|
+
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ if (!$userAuth) {
|
|
|
+ return $this->error(ErrorCode::ERROR_POWER, '登陆过期!');
|
|
|
+ }
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($userAuth->role != 4) {
|
|
|
+ return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
+ }
|
|
|
+
|
|
|
+ $store_id = $request->input('store_id');
|
|
|
+
|
|
|
$newCustomers = array();
|
|
|
for ($d = 0; $d < 15; $d++) {
|
|
|
$StartO = mktime(0, 0, 0, date('m'), date('d'), date('y')) + 86400 * $d;
|
|
|
$EndO = $StartO + 86400;
|
|
|
$End = date('Y-m-d H:i:s', $EndO);
|
|
|
$Start = date('Y-m-d H:i:s', $StartO);
|
|
|
- $customerNum = AlbumWatchRecord::where([
|
|
|
- ['store_id', $store_id],
|
|
|
- ['updated_at','>=',$Start],
|
|
|
- ['updated_at','<=',$End]
|
|
|
- ])->orderByDesc('id')->groupBy('open_id')->count();
|
|
|
$newCustomer = AlbumWatchRecord::where([
|
|
|
['store_id', $store_id],
|
|
|
['is_new', 1],
|
|
|
['updated_at','>=',$Start],
|
|
|
['updated_at','<=',$End]
|
|
|
])->orderByDesc('id')->count();
|
|
|
- $activeCustomers[] = [
|
|
|
- 'day' => date('m', $StartO) . '-' . date('d', $EndO),
|
|
|
- 'num' => $customerNum
|
|
|
- ];
|
|
|
$newCustomers[] = [
|
|
|
'day' => date('m', $StartO) . '-' . date('d', $EndO),
|
|
|
'num' => $newCustomer
|
|
|
];
|
|
|
}
|
|
|
- $customerFollow = CustomerDetailsModel::where('store_id', $store_id)->count();
|
|
|
- $downloadCount = AlbumWatchRecord::where([
|
|
|
- ['store_id', $store_id],
|
|
|
- ['action', 9],
|
|
|
- ['updated_at','>=',$start],
|
|
|
- ['updated_at','<=',$end]
|
|
|
- ])->orderByDesc('id')->count();
|
|
|
-
|
|
|
- $shareCount = AlbumWatchRecord::where([
|
|
|
- ['store_id', $store_id],
|
|
|
- ['action', 8],
|
|
|
- ['updated_at','>=',$start],
|
|
|
- ['updated_at','<=',$end]
|
|
|
- ])->orderByDesc('id')->count();
|
|
|
|
|
|
- $newCustomerCount = AlbumWatchRecord::where([
|
|
|
- ['store_id', $store_id],
|
|
|
- ['is_new', 1],
|
|
|
- ['updated_at','>=',$start],
|
|
|
- ['updated_at','<=',$end]
|
|
|
- ])->orderByDesc('id')->count();
|
|
|
+ return $this->api($newCustomers);
|
|
|
+ }
|
|
|
|
|
|
- $totalCustomerCount = AlbumWatchRecord::where([
|
|
|
- ['store_id', $store_id],
|
|
|
- ['updated_at','>=',$start],
|
|
|
- ['updated_at','<=',$end]
|
|
|
- ])->orderByDesc('id')->groupBy('open_id')->count();
|
|
|
- return $this->api(compact('totalCustomerCount', 'newCustomerCount', 'shareCount', 'downloadCount', 'customerFollow', 'newCustomers', 'activeCustomers', 'arrFavorite'));
|
|
|
+ /**
|
|
|
+ * @api {post} /api/album_boss/agent_analysis 经销商分析(agent_analysis)
|
|
|
+ * @apiDescription 经销商分析(agent_analysis)
|
|
|
+ * @apiGroup Boss
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} [store_id] 商户id
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": [
|
|
|
+ * {
|
|
|
+ * "realname" : 释迦摩尼,
|
|
|
+ * "pointCount" : 111
|
|
|
+ * "callCount" : 111
|
|
|
+ * "favoriteCount" : 111
|
|
|
+ * "get_count" : 111
|
|
|
+ * "share_times" : 111
|
|
|
+ * "newCount" : 111
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function agentAnalysis(Request $request)
|
|
|
+ {
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ if (!$userAuth) {
|
|
|
+ return $this->error(ErrorCode::ERROR_POWER, '登陆过期!');
|
|
|
+ }
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ ]);
|
|
|
+ if ($userAuth->role != 4) {
|
|
|
+ return $this->error(ErrorCode::NOT_BOSS, '该用户没有Boss权限');
|
|
|
+ }
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
+ }
|
|
|
+ $store_id = $request->input('store_id');
|
|
|
+ $agent = AlbumAgentModel::where('store_id', $store_id)->orderByDesc('newCount')->select('realname', 'pointCount', 'callCount', 'favoriteCount', 'get_count', 'share_times', 'newCount')->pagenate(12);
|
|
|
+ return $this->api($agent);
|
|
|
}
|
|
|
}
|