| xqd
@@ -821,40 +821,43 @@ class AlbumController extends Controller
|
|
|
public function albumGetDataGoods(Request $request)
|
|
|
{
|
|
|
$userAuth = Auth('api')->user();
|
|
|
- if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ if (!$userAuth) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ }
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required'
|
|
|
- ],[
|
|
|
- 'store_id.required'=>'缺少商户参数'
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '缺少商户参数'
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$store_id = $request->input('store_id');
|
|
|
- if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ if ($userAuth->is_dealer != 1) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ }
|
|
|
|
|
|
- $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
|
$res = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['action',3]])->get();
|
|
|
$arr = array();
|
|
|
$total = 0;
|
|
|
-
|
|
|
- foreach($res as $key=>$val){
|
|
|
- $goods_data = json_decode($val->detail,true);
|
|
|
+ foreach ($res 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])){
|
|
|
+ if (isset($arr[$goods->id])) {
|
|
|
$arr[$goods->id]['num']++;
|
|
|
- }else{
|
|
|
- $arr[$goods->id]['num']=1;
|
|
|
- $arr[$goods->id]['name']=$goods->name;
|
|
|
+ } else {
|
|
|
+ $arr[$goods->id]['num'] = 1;
|
|
|
+ $arr[$goods->id]['name'] = $goods->name;
|
|
|
}
|
|
|
$total++;
|
|
|
}
|
|
|
- foreach($arr as $key=>$val){
|
|
|
- $arr[$key]['point'] = ($val['num']/$total*100).'%';
|
|
|
+ foreach ($arr as $key => $val) {
|
|
|
+ $arr[$key]['point'] = ($val['num'] / $total * 100) . '%';
|
|
|
}
|
|
|
return $this->api(compact('arr'));
|
|
|
}
|
| xqd
@@ -904,30 +907,32 @@ class AlbumController extends Controller
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
'parent_id' => 'required'
|
|
|
- ],[
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
- 'parent_id.required'=>'缺少风格参数',
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ 'parent_id.required' => '缺少风格参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$store_id = $request->input('store_id');
|
|
|
$parent_id = $request->input('parent_id');
|
|
|
- if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ if ($userAuth->is_dealer != 1) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ }
|
|
|
|
|
|
- $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
|
$cat = AlbumCatModel::where([['store_id',$store_id],['parent_id', $parent_id]])->get(['name','id'])->toArray();
|
|
|
$total = 0;
|
|
|
- foreach ($cat as $key=>$val){
|
|
|
+ foreach ($cat as $key => $val){
|
|
|
$count = CustomerCatRecordModel::where([['agent_id',$user_agent->id],['store_id',$store_id],['cat_id',$val['id']]])->count();
|
|
|
$total += $count;
|
|
|
$cat[$key]['num'] = $count;
|
|
|
}
|
|
|
- foreach($cat as $key=>$val){
|
|
|
- if($val['num']==0||$total==0){
|
|
|
- $cat[$key]['point']=0;
|
|
|
- }else{
|
|
|
- $cat[$key]['point'] = ($val['num']/$total*100).'%';
|
|
|
+ foreach ($cat as $key => $val) {
|
|
|
+ if ($val['num'] == 0 || $total == 0) {
|
|
|
+ $cat[$key]['point'] = 0;
|
|
|
+ } else {
|
|
|
+ $cat[$key]['point'] = ($val['num'] / $total * 100) . '%';
|
|
|
}
|
|
|
}
|
|
|
return $this->api(compact('cat'));
|
| xqd
@@ -973,17 +978,17 @@ class AlbumController extends Controller
|
|
|
public function albumGetDataCatSingle(Request $request)
|
|
|
{
|
|
|
$userAuth = Auth('api')->user();
|
|
|
- if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ if (!$userAuth) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ }
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
'open_id' => 'required',
|
|
|
'parent_id' => 'required'
|
|
|
- // 'end' => 'required',
|
|
|
- //'start' => 'required',
|
|
|
- ],[
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
- 'open_id.required'=>'缺少风格参数',
|
|
|
- 'parent_id.required'=>'缺少父分类参数',
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ 'open_id.required' => '缺少风格参数',
|
|
|
+ 'parent_id.required' => '缺少父分类参数',
|
|
|
// 'end.required'=>'缺少结束时间参数',
|
|
|
//'start.required'=>'缺少开始时间参数',
|
|
|
]);
|
| xqd
@@ -1001,23 +1006,24 @@ class AlbumController extends Controller
|
|
|
if (!$start) {
|
|
|
$start = 0;
|
|
|
}
|
|
|
- $end= date('Y-m-d H:i:s',$end);
|
|
|
- $start= date('Y-m-d H:i:s',$start);
|
|
|
- if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
-
|
|
|
- $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ $end = date('Y-m-d H:i:s', $end);
|
|
|
+ $start = date('Y-m-d H:i:s', $start);
|
|
|
+ if ($userAuth->is_dealer != 1) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ }
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
|
$cat = AlbumCatModel::where([['store_id',$store_id],['parent_id',$parent_id]])->get(['name','id'])->toArray();
|
|
|
$total = 0;
|
|
|
- foreach ($cat as $key=>$val){
|
|
|
+ foreach ($cat as $key => $val) {
|
|
|
$count = CustomerCatRecordModel::where([['agent_id',$user_agent->id],['store_id',$store_id],['open_id',$open_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{
|
|
|
- $cat[$key]['point'] = ($val['num']/$total*100).'%';
|
|
|
+ foreach ($cat as $key => $val) {
|
|
|
+ if ($val['num'] == 0 || $total == 0) {
|
|
|
+ $cat[$key]['point'] = 0;
|
|
|
+ } else {
|
|
|
+ $cat[$key]['point'] = ($val['num'] / $total * 100) . '%';
|
|
|
}
|
|
|
}
|
|
|
return $this->api(compact('cat'));
|
| xqd
@@ -1072,15 +1078,17 @@ class AlbumController extends Controller
|
|
|
public function albumGetCartOfWatch(Request $request)
|
|
|
{
|
|
|
$userAuth = Auth('api')->user();
|
|
|
- if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ if (!$userAuth) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ }
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
'end' => 'required',
|
|
|
'start' => 'required',
|
|
|
- ],[
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
- 'end.required'=>'缺少结束时间参数',
|
|
|
- 'start.required'=>'缺少开始时间参数',
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ 'end.required' => '缺少结束时间参数',
|
|
|
+ 'start.required' => '缺少开始时间参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|