|
@@ -9,9 +9,11 @@
|
|
namespace App\Http\Controllers\Api\V1;
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
|
|
use App\Models\AlbumAgentModel;
|
|
use App\Models\AlbumAgentModel;
|
|
|
|
+use App\Models\AlbumCatModel;
|
|
use App\Models\AlbumProductModel;
|
|
use App\Models\AlbumProductModel;
|
|
use App\Models\AlbumUserModel;
|
|
use App\Models\AlbumUserModel;
|
|
use App\Models\AlbumWatchRecord;
|
|
use App\Models\AlbumWatchRecord;
|
|
|
|
+use App\Models\CustomerCatRecordModel;
|
|
use App\Models\CustomerDetailsModel;
|
|
use App\Models\CustomerDetailsModel;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use Validator, Response,Auth;
|
|
use Validator, Response,Auth;
|
|
@@ -76,7 +78,7 @@ class AlbumBossController extends Controller
|
|
$store_id = $request->input('store_id');
|
|
$store_id = $request->input('store_id');
|
|
$agentData = AlbumAgentModel::where('store_id', $store_id)->orderByDesc('get_count')->paginate(20);
|
|
$agentData = AlbumAgentModel::where('store_id', $store_id)->orderByDesc('get_count')->paginate(20);
|
|
foreach ($agentData as $value) {
|
|
foreach ($agentData as $value) {
|
|
- $user = AlbumUserModel::where([['id', $value->user_id], ['store_id', $store_id]])->get(['avatar']);
|
|
|
|
|
|
+ $user = AlbumUserModel::where([['id', $value->user_id], ['store_id', $store_id]])->first(['avatar']);
|
|
$value->avatar = $user->avatar;
|
|
$value->avatar = $user->avatar;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -91,6 +93,7 @@ class AlbumBossController extends Controller
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiParam {int} [store_id] 商户id
|
|
* @apiParam {int} [store_id] 商户id
|
|
* @apiParam {int} [agent_id] 经销商id
|
|
* @apiParam {int} [agent_id] 经销商id
|
|
|
|
+ * @apiParam {int} [pageNum] 分页
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
* {
|
|
* {
|
|
@@ -161,20 +164,31 @@ class AlbumBossController extends Controller
|
|
])->groupBy('open_id')->get();
|
|
])->groupBy('open_id')->get();
|
|
$i = 0;
|
|
$i = 0;
|
|
foreach ($userCount as $value) {
|
|
foreach ($userCount as $value) {
|
|
- if ($i >= (($data['pageNum'] + 1) * 20)) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if ($i >= ($data['pageNum'] * 20) && $i < (($data['pageNum'] + 1) * 20)) {
|
|
|
|
|
|
+ if ($i >= (($data['pageNum'] - 1) * 20) && $i < ($data['pageNum'] * 20)) {
|
|
$user = AlbumUserModel::where('open_id', $value->open_id)->first(['avatar', 'username', 'address']);
|
|
$user = AlbumUserModel::where('open_id', $value->open_id)->first(['avatar', 'username', 'address']);
|
|
$userComment = CustomerDetailsModel::where('open_id', $value->open_id)->first(['comment']);
|
|
$userComment = CustomerDetailsModel::where('open_id', $value->open_id)->first(['comment']);
|
|
- $customer[] = [
|
|
|
|
- 'name' => $userComment->comment,
|
|
|
|
- 'avatar' => $user->avatar,
|
|
|
|
- 'username' => $user->username,
|
|
|
|
- 'address' => $user->address
|
|
|
|
- ];
|
|
|
|
- $i++;
|
|
|
|
|
|
+ if (empty($user->phone)) {
|
|
|
|
+ $phone = '暂无';
|
|
|
|
+ } else {
|
|
|
|
+ $phone = $user->phone;
|
|
|
|
+ }
|
|
|
|
+ if (!$userComment) {
|
|
|
|
+ $customer[] = [
|
|
|
|
+ 'name' => '暂无',
|
|
|
|
+ 'avatar' => $user->avatar,
|
|
|
|
+ 'username' => $user->username,
|
|
|
|
+ 'phone' => $phone
|
|
|
|
+ ];
|
|
|
|
+ } else {
|
|
|
|
+ $customer[] = [
|
|
|
|
+ 'name' => $userComment->comment,
|
|
|
|
+ 'avatar' => $user->avatar,
|
|
|
|
+ 'username' => $user->username,
|
|
|
|
+ 'phone' => $phone
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ $i++;
|
|
}
|
|
}
|
|
|
|
|
|
return $this->api(compact('agent', 'customer'), 0, 'success');
|
|
return $this->api(compact('agent', 'customer'), 0, 'success');
|
|
@@ -282,19 +296,96 @@ class AlbumBossController extends Controller
|
|
['updated_at','<=',$end]
|
|
['updated_at','<=',$end]
|
|
])->orderByDesc('id')->count();
|
|
])->orderByDesc('id')->count();
|
|
|
|
|
|
- $totalCustomerCount = AlbumWatchRecord::where([
|
|
|
|
|
|
+ $totalCustomer = AlbumWatchRecord::where([
|
|
['agent_id', $data['agent_id']],
|
|
['agent_id', $data['agent_id']],
|
|
['store_id', $data['store_id']],
|
|
['store_id', $data['store_id']],
|
|
['updated_at','>=',$start],
|
|
['updated_at','>=',$start],
|
|
['updated_at','<=',$end]
|
|
['updated_at','<=',$end]
|
|
- ])->orderByDesc('id')->groupBy('open_id')->count();
|
|
|
|
|
|
+ ])->orderByDesc('id')->groupBy('open_id')->get();
|
|
|
|
+ $totalCustomerCount = count($totalCustomer);
|
|
|
|
|
|
return $this->api(compact('shareCount', 'totalCustomerCount', 'newCustomerCount', 'downloadCount', 'favoriteCount'));
|
|
return $this->api(compact('shareCount', 'totalCustomerCount', 'newCustomerCount', 'downloadCount', 'favoriteCount'));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @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
|
|
|
|
+ * @apiParam {int} [store_id] 商户id
|
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
|
+ * {
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "activeCustomers": [
|
|
|
|
+ * {
|
|
|
|
+ * "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
|
|
* @apiGroup Boss
|
|
* @apiPermission none
|
|
* @apiPermission none
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
@@ -313,18 +404,249 @@ class AlbumBossController extends Controller
|
|
* "shareCount":11,
|
|
* "shareCount":11,
|
|
* "newCustomerCount":11,
|
|
* "newCustomerCount":11,
|
|
* "totalCustomerCount":11,
|
|
* "totalCustomerCount":11,
|
|
- * "activeCustomers": [
|
|
|
|
- * {
|
|
|
|
- * "day" : 03/25,
|
|
|
|
- * "num" : 111
|
|
|
|
- * }
|
|
|
|
- * ],
|
|
|
|
- * "newCustomers": [
|
|
|
|
|
|
+ * }
|
|
|
|
+ * }
|
|
|
|
+ * @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],
|
|
|
|
+ ['updated_at','>=',$start],
|
|
|
|
+ ['updated_at','<=',$end]
|
|
|
|
+ ])->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();
|
|
|
|
+
|
|
|
|
+ $totalCustomer = AlbumWatchRecord::where([
|
|
|
|
+ ['store_id', $store_id],
|
|
|
|
+ ['updated_at','>=',$start],
|
|
|
|
+ ['updated_at','<=',$end]
|
|
|
|
+ ])->orderByDesc('id')->groupBy('open_id')->get()->toArray();
|
|
|
|
+ $totalCustomerCount = count($totalCustomer);
|
|
|
|
+ return $this->api(compact('totalCustomerCount', 'newCustomerCount', 'shareCount', 'downloadCount', 'customerFollow'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @api {post} /api/album_boss/agent_overview_funnel 经销商总览漏斗(agent_overview_funnel)
|
|
|
|
+ * @apiDescription 经销商总览漏斗(agent_overview_funnel)
|
|
|
|
+ * @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": {
|
|
|
|
+ * "customerFollow":11,
|
|
|
|
+ * "shareCount":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 albumOverviewFunnel(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');
|
|
|
|
+
|
|
|
|
+ $customerFollow = CustomerDetailsModel::where('store_id', $store_id)->count();
|
|
|
|
+ $shareCount = AlbumWatchRecord::where([
|
|
|
|
+ ['store_id', $store_id],
|
|
|
|
+ ['action', 8],
|
|
|
|
+ ])->orderByDesc('id')->count();
|
|
|
|
+
|
|
|
|
+ $totalCustomer = AlbumWatchRecord::where([
|
|
|
|
+ ['store_id', $store_id],
|
|
|
|
+ ])->orderByDesc('id')->groupBy('open_id')->get()->toArray();
|
|
|
|
+ $totalCustomerCount = count($totalCustomer);
|
|
|
|
+ return $this->api(compact('totalCustomerCount', 'shareCount', 'customerFollow'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @api {post} /api/album_boss/agent_overview_call 经销商总览咨询(agent_overview_call)
|
|
|
|
+ * @apiDescription 经销商总览咨询(agent_overview_call)
|
|
|
|
+ * @apiGroup Boss
|
|
|
|
+ * @apiPermission none
|
|
|
|
+ * @apiVersion 0.1.0
|
|
|
|
+ * @apiParam {int} [store_id] 商户id
|
|
|
|
+ * @apiParam {int} [day] 天数
|
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
|
+ * {
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "callCustomers": [
|
|
* {
|
|
* {
|
|
* "day" : 03/25,
|
|
* "day" : 03/25,
|
|
* "num" : 111
|
|
* "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 albumOverviewCall(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');
|
|
|
|
+ $day = $request->input('day');
|
|
|
|
+ $callCustomers = array();
|
|
|
|
+ for ($d = 0; $d < $day; $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);
|
|
|
|
+ $callCustomer = AlbumWatchRecord::where([
|
|
|
|
+ ['store_id', $store_id],
|
|
|
|
+ ['action', 7],
|
|
|
|
+ ['updated_at','>=',$Start],
|
|
|
|
+ ['updated_at','<=',$End]
|
|
|
|
+ ])->orderByDesc('id')->count();
|
|
|
|
+ $callCustomers[] = [
|
|
|
|
+ 'day' => date('m', $StartO) . '-' . date('d', $EndO),
|
|
|
|
+ 'num' => $callCustomer
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return $this->api($callCustomers);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @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} [parent_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": [
|
|
* "arrFavorite": [
|
|
* {
|
|
* {
|
|
* 'name':'asdawd',
|
|
* 'name':'asdawd',
|
|
@@ -345,7 +667,7 @@ class AlbumBossController extends Controller
|
|
* 可能出现的错误代码:
|
|
* 可能出现的错误代码:
|
|
* 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
* 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
*/
|
|
*/
|
|
- public function albumOverview(Request $request)
|
|
|
|
|
|
+ public function albumOverviewFavorite(Request $request)
|
|
{
|
|
{
|
|
|
|
|
|
$userAuth = Auth('api')->user();
|
|
$userAuth = Auth('api')->user();
|
|
@@ -377,82 +699,231 @@ class AlbumBossController extends Controller
|
|
}
|
|
}
|
|
$end = date('Y-m-d H:i:s', $end);
|
|
$end = date('Y-m-d H:i:s', $end);
|
|
$start = date('Y-m-d H:i:s', $start);
|
|
$start = date('Y-m-d H:i:s', $start);
|
|
- $resGoods = AlbumWatchRecord::where([
|
|
|
|
- ['store_id',$store_id],['action',3],['updated_at','>=',$start],
|
|
|
|
- ['updated_at','<=',$end]
|
|
|
|
- ])->get();
|
|
|
|
- $arrFavorite = array();
|
|
|
|
|
|
+ $parent_id = $request->input('parent_id');
|
|
|
|
+ $cat = AlbumCatModel::where([['store_id',$store_id],['parent_id', $parent_id]])->get(['name','id'])->toArray();
|
|
$total = 0;
|
|
$total = 0;
|
|
-
|
|
|
|
- foreach ($resGoods as $key => $val) {
|
|
|
|
- $goods_data = json_decode($val->detail, true);
|
|
|
|
- $goods_id = $goods_data['goods_id'];
|
|
|
|
- $goods = AlbumProductModel::find($goods_id);
|
|
|
|
- if (!$goods) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (isset($arr[$goods->id])) {
|
|
|
|
- $arrFavorite[$goods->id]['num']++;
|
|
|
|
|
|
+ foreach ($cat as $key => $val) {
|
|
|
|
+ $count = CustomerCatRecordModel::where([
|
|
|
|
+ ['store_id',$store_id],
|
|
|
|
+ ['cat_id',$val['id']],
|
|
|
|
+ ['updated_at','>=',$start],
|
|
|
|
+ ['updated_at','<=',$end]
|
|
|
|
+ ])->count();
|
|
|
|
+ $total += $count;
|
|
|
|
+ $cat[$key]['num'] = $count;
|
|
|
|
+ }
|
|
|
|
+ foreach ($cat as $key => $val) {
|
|
|
|
+ if ($val['num'] == 0 || $total == 0) {
|
|
|
|
+ $cat[$key]['point'] = 0;
|
|
} else {
|
|
} else {
|
|
- $arrFavorite[$goods->id]['num'] = 1;
|
|
|
|
- $arrFavorite[$goods->id]['name'] = $goods->name;
|
|
|
|
|
|
+ $cat[$key]['point'] = ($val['num'] / $total * 100) . '%';
|
|
}
|
|
}
|
|
- $total++;
|
|
|
|
}
|
|
}
|
|
- $activeCustomers = array();
|
|
|
|
|
|
+
|
|
|
|
+ return $this->api($cat);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @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} [day] 天数
|
|
|
|
+ * @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');
|
|
|
|
+ $day = $request->input('day');
|
|
$newCustomers = array();
|
|
$newCustomers = array();
|
|
- for ($d = 0; $d < 15; $d++) {
|
|
|
|
- $Start = mktime(0, 0, 0, date('m'), date('d'), date('y')) + 86400 * $d;
|
|
|
|
- $End = $Start + 86400;
|
|
|
|
- $End = date('Y-m-d H:i:s', $End);
|
|
|
|
- $Start = date('Y-m-d H:i:s', $Start);
|
|
|
|
- $customerNum = AlbumWatchRecord::where([
|
|
|
|
- ['store_id', $store_id],
|
|
|
|
- ['updated_at','>=',$Start],
|
|
|
|
- ['updated_at','<=',$End]
|
|
|
|
- ])->orderByDesc('id')->groupBy('open_id')->count();
|
|
|
|
|
|
+ for ($d = 0; $d < $day; $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);
|
|
$newCustomer = AlbumWatchRecord::where([
|
|
$newCustomer = AlbumWatchRecord::where([
|
|
['store_id', $store_id],
|
|
['store_id', $store_id],
|
|
['is_new', 1],
|
|
['is_new', 1],
|
|
['updated_at','>=',$Start],
|
|
['updated_at','>=',$Start],
|
|
['updated_at','<=',$End]
|
|
['updated_at','<=',$End]
|
|
])->orderByDesc('id')->count();
|
|
])->orderByDesc('id')->count();
|
|
- $activeCustomers[] = [
|
|
|
|
- 'day' => date('m', $Start) . '-' . date('d', $End),
|
|
|
|
- 'num' => $customerNum
|
|
|
|
- ];
|
|
|
|
$newCustomers[] = [
|
|
$newCustomers[] = [
|
|
- 'day' => date('m', $Start) . '-' . date('d', $End),
|
|
|
|
|
|
+ 'day' => date('m', $StartO) . '-' . date('d', $EndO),
|
|
'num' => $newCustomer
|
|
'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();
|
|
|
|
|
|
+ return $this->api($newCustomers);
|
|
|
|
+ }
|
|
|
|
|
|
- $newCustomerCount = AlbumWatchRecord::where([
|
|
|
|
- ['store_id', $store_id],
|
|
|
|
- ['is_new', 1],
|
|
|
|
- ['updated_at','>=',$start],
|
|
|
|
- ['updated_at','<=',$end]
|
|
|
|
- ])->orderByDesc('id')->count();
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @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');
|
|
|
|
|
|
- $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'));
|
|
|
|
|
|
+ $agent = AlbumAgentModel::where('store_id', $store_id)->orderByDesc('newCount')->paginate(12);
|
|
|
|
+ foreach ($agent as $value) {
|
|
|
|
+ $user = AlbumUserModel::where([['id', $value->user_id], ['store_id', $store_id]])->first(['avatar']);
|
|
|
|
+ $value->avatar = $user->avatar;
|
|
|
|
+ }
|
|
|
|
+ return $this->api($agent);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @api {get} /api/album_boss/boss_interactive 经销商互动排名(boss_interactive)
|
|
|
|
+ * @apiDescription 经销商互动排名(boss_interactive)
|
|
|
|
+ * @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" : 释迦摩尼,
|
|
|
|
+ * "interactive" : 111
|
|
|
|
+ * "avatar" : 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 BossInteractive(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('interactive')->paginate(20);
|
|
|
|
+ foreach ($agent as $value) {
|
|
|
|
+ $user = AlbumUserModel::where([['id', $value->user_id], ['store_id', $store_id]])->first(['avatar']);
|
|
|
|
+ $value->avatar = $user->avatar;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return $this->api($agent);
|
|
}
|
|
}
|
|
}
|
|
}
|