| xqd
@@ -50,19 +50,27 @@ class AlbumController extends Controller
|
|
|
$store_id = $request->store_id;
|
|
|
//小程序設置
|
|
|
|
|
|
- $setting = AlbumManufacturerModel::where('store_id',$store_id)->first();
|
|
|
+ $setting = AlbumManufacturerModel::where('store_id', $store_id)->first();
|
|
|
//轮播图
|
|
|
- $banner = AlbumBannerModel::where('store_id',$store_id)->orderByDesc('sort')->get();
|
|
|
+ $banner = AlbumBannerModel::where('store_id', $store_id)->orderByDesc('sort')->get();
|
|
|
|
|
|
//底部导航栏
|
|
|
- $navbar = AlbumNavModel::where([['store_id',$store_id],['state',0]])->orderByDesc('sort')->get();
|
|
|
+ $navbar = AlbumNavModel::where([['store_id', $store_id],['state',0]])->orderByDesc('sort')->get();
|
|
|
|
|
|
//顶部菜单栏
|
|
|
- $menus = AlbumNavModel::where([['store_id',$store_id],['state',1]])->orderByDesc('sort')->get();
|
|
|
+ $menus = AlbumNavModel::where([['store_id', $store_id],['state',1]])->orderByDesc('sort')->get();
|
|
|
|
|
|
- $news = AlbumNewsModel::where([['store_id',$store_id]])->orderByDesc('sort')->paginate(5);
|
|
|
+ $news = AlbumNewsModel::where([['store_id', $store_id]])->orderByDesc('sort')->paginate(5);
|
|
|
|
|
|
- return $this->api(compact('setting','banner','news','navbar','menus'));
|
|
|
+ $userAuth = Auth('api')->user();
|
|
|
+ $agent_set = array();
|
|
|
+ if ($userAuth && $userAuth->is_dealer == 1) {
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
|
+ $agent_set['set_price_point'] = $user_agent->set_price_point;
|
|
|
+ $agent_set['is_show_ma_price'] = $user_agent->is_show_ma_price;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->api(compact('setting', 'banner', 'news', 'navbar', 'menus', 'agent_set'));
|
|
|
}
|
|
|
|
|
|
|
| xqd
@@ -970,23 +978,31 @@ class AlbumController extends Controller
|
|
|
if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
- 'open_id' => 'required'
|
|
|
+ 'open_id' => 'required',
|
|
|
+ 'end' => 'required',
|
|
|
+ 'start' => 'required',
|
|
|
],[
|
|
|
'store_id.required'=>'缺少商户参数',
|
|
|
'open_id.required'=>'缺少风格参数',
|
|
|
+ 'end.required'=>'缺少结束时间参数',
|
|
|
+ 'start.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');
|
|
|
+ $end = $request->input('end');
|
|
|
+ $start = $request->input('start');
|
|
|
+ $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)->get(['name','id'])->toArray();
|
|
|
$total = 0;
|
|
|
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']]])->count();
|
|
|
+ $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;
|
|
|
}
|
| xqd
@@ -2222,18 +2238,26 @@ class AlbumController extends Controller
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
'open_id' => 'required',
|
|
|
+ 'end' => 'required',
|
|
|
+ 'start' => 'required',
|
|
|
],[
|
|
|
'store_id.required'=>'缺少商户参数',
|
|
|
'open_id.required'=>'缺少用户参数',
|
|
|
+ 'end.required'=>'缺少结束时间参数',
|
|
|
+ 'start.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');
|
|
|
+ $end = $request->input('end');
|
|
|
+ $start = $request->input('start');
|
|
|
+ $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();
|
|
|
- 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']);
|
|
|
+ if($user_agent) $res= AlbumWatchRecord::where([['action',3],['store_id',$store_id],['agent_id',$user_agent->id],['open_id',$open_id],['updated_at','>=',$start],['updated_at','<=',$end]])->groupBy('detail')->get(['detail']);
|
|
|
$arr = array();
|
|
|
foreach ($res as $key=>$val){
|
|
|
$detail = json_decode($val['detail'],true);
|
| xqd
@@ -2289,19 +2313,27 @@ class AlbumController extends Controller
|
|
|
if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
- 'open_id'=>'required'
|
|
|
+ 'open_id'=>'required',
|
|
|
+ 'end' => 'required',
|
|
|
+ 'start' => 'required',
|
|
|
],[
|
|
|
'store_id.required'=>'缺少商户参数',
|
|
|
'open_id.required'=>'缺少用户参数',
|
|
|
+ 'end.required'=>'缺少结束时间参数',
|
|
|
+ 'start.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');
|
|
|
+ $end = $request->input('end');
|
|
|
+ $start = $request->input('start');
|
|
|
+ $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();
|
|
|
- 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();
|
|
|
+ if($user_agent) $res= AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id],['updated_at','>=',$start],['updated_at','<=',$end]])->orderByDesc('id')->get(['detail','created_at'])->toArray();
|
|
|
$arr = array();
|
|
|
foreach ($res as $key=>$val){
|
|
|
$detail = json_decode($val['detail'],true);
|
| xqd
@@ -2547,21 +2579,29 @@ class AlbumController extends Controller
|
|
|
'store_id' => 'required',
|
|
|
'open_id' => 'required',
|
|
|
'type' => 'required',
|
|
|
+ 'end' => 'required',
|
|
|
+ 'start' => 'required',
|
|
|
],[
|
|
|
'store_id.required'=>'缺少商户参数',
|
|
|
'open_id.required'=>'缺少用户参数',
|
|
|
'type.required'=>'缺少类型参数',
|
|
|
+ 'end.required'=>'缺少结束时间参数',
|
|
|
+ 'start.required'=>'缺少开始时间参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$data = $request->input();
|
|
|
$res = array();
|
|
|
+ $end = $request->input('end');
|
|
|
+ $start = $request->input('start');
|
|
|
+ $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();
|
|
|
$user = AlbumUserModel::where([['open_id',$data['open_id']],['store_id',$data['store_id']]])->first();
|
|
|
if ($data['type'] == 1) { //尺寸统计
|
|
|
- $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['detail','like','%'.'u5c3a'.'%'],['action',5],['store_id',$data['store_id']]])->get();
|
|
|
+ $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['detail','like','%'.'u5c3a'.'%'],['action',5],['store_id',$data['store_id']],['updated_at','>=',$start],['updated_at','<=',$end]])->get();
|
|
|
foreach ($record as $key=>$val){
|
|
|
$detail = json_decode($val['detail'],true);
|
|
|
$goods = AlbumProductModel::where([['store_id',$data['store_id']],['id',$detail['goods_id']]])->first();
|
| xqd
@@ -2574,7 +2614,7 @@ class AlbumController extends Controller
|
|
|
];
|
|
|
}
|
|
|
} elseif ($data['type'] == 2) { //拨打电话
|
|
|
- $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['action',7],['store_id',$data['store_id']]])->get();
|
|
|
+ $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['action',7],['store_id',$data['store_id']],['updated_at','>=',$start],['updated_at','<=',$end]])->get();
|
|
|
foreach ($record as $key=>$val){
|
|
|
$res[] = [
|
|
|
'content' => $user->username . '拨打了经销商电话',
|
| xqd
@@ -2582,7 +2622,7 @@ class AlbumController extends Controller
|
|
|
];
|
|
|
}
|
|
|
} else {
|
|
|
- $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['action',8],['store_id',$data['store_id']]])->get();
|
|
|
+ $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['action',8],['store_id',$data['store_id']],['updated_at','>=',$start],['updated_at','<=',$end]])->get();
|
|
|
foreach ($record as $key=>$val){
|
|
|
$goods = AlbumProductModel::where([['store_id',$data['store_id']],['id',$val['detail']]])->first();
|
|
|
$style = AlbumProductStyleModel::where([['store_id',$data['store_id']],['id',$goods->style]])->first();
|
| xqd
@@ -2647,20 +2687,21 @@ class AlbumController extends Controller
|
|
|
$user_agent->is_show_ma_price = $data['is_show_ma_price'];
|
|
|
$user_agent->save();
|
|
|
|
|
|
- $product = AlbumProductModel::where('store_id',$data['store_id'])->get(['id','ma_price']);
|
|
|
- foreach ($product as $key=>$val) {
|
|
|
- $save['price'] = $val['ma_price'] * (1 + $data['point'] / 100);
|
|
|
- $check = AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
|
- if(empty($check)){
|
|
|
- $save['agent_id'] = $user_agent->id;
|
|
|
- $save['store_id'] = $data['store_id'];
|
|
|
- $save['product_id'] = $val['id'];
|
|
|
- AlbumProductPriceModel::create($save);
|
|
|
- }else{
|
|
|
- AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
|
|
|
- }
|
|
|
+ $product = AlbumProductModel::where('store_id',$data['store_id'])->get(['id','ma_price']);
|
|
|
+ foreach ($product as $key=>$val) {
|
|
|
+ $save['price'] = $val['ma_price'] * (1 + $data['point'] / 100);
|
|
|
+ $check = AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
|
+ if(empty($check)){
|
|
|
+ $save['agent_id'] = $user_agent->id;
|
|
|
+ $save['store_id'] = $data['store_id'];
|
|
|
+ $save['product_id'] = $val['id'];
|
|
|
+ AlbumProductPriceModel::create($save);
|
|
|
+ }else{
|
|
|
+ AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+ $user_agent->set_price_point = $data['point'];
|
|
|
+ $user_agent->save();
|
|
|
return $this->api([],0,'success');
|
|
|
}
|
|
|
}
|