|
| xqd
@@ -988,6 +988,9 @@ class AlbumController extends Controller
|
|
|
* "status_code": 0,
|
|
|
* "message": "",
|
|
|
* "data": [
|
|
|
+ * "count_today":0,
|
|
|
+ * "count_all":0,
|
|
|
+ * "count_share":0,
|
|
|
* "user": {
|
|
|
* "username":"王小贱",
|
|
|
* "avatar":"awdawdawdawdawdawd",头像
|
|
| xqd
@@ -1042,7 +1045,13 @@ class AlbumController extends Controller
|
|
|
// if($userAuth->up_agent_id==0) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未选择经销商!', $validator->messages());
|
|
|
$user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
$count_user = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['updated_at','>=',$start],['updated_at','<=',$end]])->orderBy('id','DESC')->groupBy('open_id')->get();
|
|
|
-
|
|
|
+ $checkAllstart = mktime(0,0,0,date('m'),date('d'),date('Y'));
|
|
|
+ $checkAllend = $checkAllstart+86400;
|
|
|
+ $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_share = $user_agent->share_times;
|
|
|
$users = Array();
|
|
|
if($count_user){
|
|
|
foreach($count_user as $key=>$val){
|
|
| xqd
@@ -1067,7 +1076,7 @@ class AlbumController extends Controller
|
|
|
$res = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['action',$i]])->get();
|
|
|
$action['type'.$i] = count($res);
|
|
|
}
|
|
|
- return $this->api(compact('count','users','action'));
|
|
|
+ return $this->api(compact('count','users','action','count_today','count_all','count_share'));
|
|
|
}
|
|
|
/**
|
|
|
* @api {get} /api/album/checklogin 登陆应用(checklogin)
|
|
| xqd
@@ -2036,17 +2045,13 @@ class AlbumController extends Controller
|
|
|
if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
- 'purpose_level' => 'required',
|
|
|
- 'comment' => 'required',
|
|
|
- 'address' => 'required',
|
|
|
- 'tips' => 'required',
|
|
|
- 'open_id'=>'required'
|
|
|
+ 'key' => 'required',
|
|
|
+ 'value' => 'required',
|
|
|
+ 'open_id' => 'required',
|
|
|
],[
|
|
|
'store_id.required'=>'缺少商户参数',
|
|
|
- 'address.required'=>'缺少地址参数',
|
|
|
- 'purpose_level.required'=>'缺少意向等级参数',
|
|
|
- 'comment.required'=>'缺少客户备注参数',
|
|
|
- 'tips.required'=>'缺少标签参数',
|
|
|
+ 'key.required'=>'缺少键参数',
|
|
|
+ 'value.required'=>'缺少值参数',
|
|
|
'open_id.required'=>'缺少用户参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
| xqd
@@ -2054,18 +2059,19 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
$store_id = $request->input('store_id');
|
|
|
$open_id = $request->input('open_id');
|
|
|
- $add = $request->input();
|
|
|
+ $key = $request->input('key');
|
|
|
+ $value = $request->input('value');
|
|
|
if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
$user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
$customer = CustomerDetailsModel::where([['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->first(['purpose_level','comment','tips','address']);
|
|
|
if($customer){
|
|
|
- $customer->address = $add['address'];
|
|
|
- $customer->purpose_level = $add['purpose_level'];
|
|
|
- $customer->comment = $add['comment'];
|
|
|
- $customer->tips = $add['tips'];
|
|
|
+ $customer->$key = $value;
|
|
|
$customer->save();
|
|
|
}else{
|
|
|
$add['agent_id'] = $user_agent->id;
|
|
|
+ $add['open_id'] = $open_id;
|
|
|
+ $add['store_id'] = $store_id;
|
|
|
+ $add[$key] = $value;
|
|
|
$user = CustomerDetailsModel::create($add);
|
|
|
}
|
|
|
return $this->api([],0,'success');
|
|
| xqd
@@ -2126,7 +2132,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']]])->count();
|
|
|
+ $count= AlbumWatchRecord::where([['action',3],['store_id',$store_id],['detail',$val['detail'],['agent_id',$user_agent->id]]])->count();
|
|
|
$arr[] = ['name'=>$goods->name,'count'=>$count];
|
|
|
}
|
|
|
}
|
|
| xqd
@@ -2185,7 +2191,7 @@ class AlbumController extends Controller
|
|
|
$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],['open_id',$open_id],['agent_id',$user_agent->id]])->get(['detail','created_at'])->toArray();
|
|
|
+ if($user_agent) $res= AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->orderByDesc('id')->get(['detail','created_at'])->toArray();
|
|
|
$arr = array();
|
|
|
foreach ($res as $key=>$val){
|
|
|
$detail = json_decode($val['detail'],true);
|
|
| xqd
@@ -2195,7 +2201,7 @@ class AlbumController extends Controller
|
|
|
if($goods){
|
|
|
$style = AlbumProductStyleModel::where([['store_id',$store_id],['id',$goods->style]])->first();
|
|
|
$cat = AlbumCatModel::where([['store_id',$store_id],['id',$goods->cat_id]])->first();
|
|
|
- $arr[] = ['name'=>$goods->name,'time'=>date('Y-m-d-h',strtotime($val['created_at'])),'style'=>$style->name,'cat'=>$cat->name];
|
|
|
+ $arr[] = ['name'=>$goods->name,'time'=>date('Y-m-d H:i',strtotime($val['created_at'])),'style'=>$style->name,'cat'=>$cat->name];
|
|
|
}
|
|
|
}
|
|
|
return $this->api($arr,0,'success');
|
|
| xqd
@@ -2348,13 +2354,21 @@ class AlbumController extends Controller
|
|
|
{
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
+ 'agent_id' => 'required'
|
|
|
],[
|
|
|
'store_id.required'=>'缺少商户参数',
|
|
|
+ 'agent_id.required'=>'缺少经销商参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$store_id = $request->input('store_id');
|
|
|
+ $agent_id = $request->input('agent_id');
|
|
|
+ if($agent_id!=0){
|
|
|
+ $user_agent = AlbumAgentModel::where([['id',$agent_id],['status',1]])->first();
|
|
|
+ $user_agent->share_times++;
|
|
|
+ $user_agent->save();
|
|
|
+ }
|
|
|
$userAuth = Auth('api')->user();
|
|
|
if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
$time = mktime(0,0,0,date('m'),date('d'),date('y'));
|