dyjh 6 年之前
父节点
当前提交
9eb0b0b5b4
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      app/Http/Controllers/Api/V1/AlbumController.php

+ 6 - 3
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd
@@ -1052,7 +1052,7 @@ class AlbumController extends Controller
         $checkAllstart = date('Y-m-d H:i:s',$checkAllstart);
         $checkAllend = date('Y-m-d H:i:s',$checkAllend);
         $count_today = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['updated_at','>=',$checkAllstart],['updated_at','<=',$checkAllend]])->groupBy('open_id')->count();
-        $count_all = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id]])->groupBy('open_id')->count();
+        $count_all = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id]])->groupBy('open_id')->get();dd($count_all);
         $count_share = $user_agent->share_times;
         $users = Array();
         if($count_user){
@@ -2147,16 +2147,19 @@ class AlbumController extends Controller
         if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
         $validator = Validator::make($request->all(), [
             'store_id' => 'required',
+            'open_id' => 'required',
         ],[
             'store_id.required'=>'缺少商户参数',
+            'open_id.required'=>'缺少用户参数',
         ]);
         if ($validator->fails()) {
             return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
         }
         $store_id = $request->input('store_id');
+        $open_id = $request->input('open_id');
         if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
-        if($user_agent) $res=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['agent_id',$user_agent->id]])->groupBy('detail')->get(['detail']);
+        if($user_agent) $res=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['agent_id',$user_agent->id],['open_id',$open_id]])->groupBy('detail')->get(['detail']);
         $arr = array();
         foreach ($res as $key=>$val){
             $detail = json_decode($val['detail'],true);
@@ -2164,7 +2167,7 @@ class AlbumController extends Controller
             $goods_id = $detail['goods_id'];
             $goods = AlbumProductModel::where([['id',$goods_id]])->first();
             if($goods){
-                $count=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['detail',$val['detail']],['agent_id',$user_agent->id]])->count();
+                $count=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['detail',$val['detail']],['agent_id',$user_agent->id],['open_id',$open_id]])->count();
 
                 $arr[] = ['name'=>$goods->name,'count'=>$count];
             }