| 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
@@ -154,56 +162,56 @@ class AlbumController extends Controller
|
|
|
$check = AlbumUserModel::where('wechat_union_id', $decryptedData['unionId'])->first();
|
|
|
}
|
|
|
|
|
|
- if(!$check){
|
|
|
- $add['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
|
|
|
- $add['open_id'] = $res['openid'];
|
|
|
- $add['wechat_union_id'] = isset($decryptedData['unionId'])?$decryptedData['unionId']:'';
|
|
|
- $add['avatar'] = $datas['avatar'];
|
|
|
- $add['is_agent'] = 0;
|
|
|
- $add['model'] = 1;
|
|
|
- $add['store_id'] = $datas['store_id'];
|
|
|
- $res = AlbumUserModel::create($add);
|
|
|
- // dd($res);
|
|
|
- if($res){
|
|
|
- $check = AlbumUserModel::where([['wechat_union_id',$res->wechat_union_id],['store_id',$datas['store_id']]])->first();
|
|
|
- $user = [
|
|
|
- 'user_id'=>$check['id'],
|
|
|
- //'avatar'=>$check['avatar'],
|
|
|
- // 'username'=>$check['username'],
|
|
|
- 'phone'=>$check->phone,
|
|
|
- 'is_agent'=>0,
|
|
|
- 'agent_id'=>'',
|
|
|
- ];
|
|
|
- }else{
|
|
|
- $user=[
|
|
|
- 'error'=>1
|
|
|
- ];
|
|
|
- }
|
|
|
- } else {
|
|
|
- //print_r($check);die;
|
|
|
- $save['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
|
|
|
- $save['avatar'] = $datas['avatar'];
|
|
|
- // $save['open_id'] = $res['openid'];
|
|
|
- $save['model'] = 1;
|
|
|
- AlbumUserModel::where('open_id',$res['openid'])->update($save);
|
|
|
- //echo 111;
|
|
|
- //print_r($check);die;
|
|
|
- if($check->is_dealer == 1){
|
|
|
- $user_agent = AlbumAgentModel::where([['user_id',$check->id],['status',1]])->first();
|
|
|
- $agent_id = $user_agent['id'];
|
|
|
- } else {
|
|
|
- $agent_id = '';
|
|
|
- }
|
|
|
+ if(!$check){
|
|
|
+ $add['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
|
|
|
+ $add['open_id'] = $res['openid'];
|
|
|
+ $add['wechat_union_id'] = isset($decryptedData['unionId'])?$decryptedData['unionId']:'';
|
|
|
+ $add['avatar'] = $datas['avatar'];
|
|
|
+ $add['is_agent'] = 0;
|
|
|
+ $add['model'] = 1;
|
|
|
+ $add['store_id'] = $datas['store_id'];
|
|
|
+ $res = AlbumUserModel::create($add);
|
|
|
+ // dd($res);
|
|
|
+ if($res){
|
|
|
+ $check = AlbumUserModel::where([['wechat_union_id',$res->wechat_union_id],['store_id',$datas['store_id']]])->first();
|
|
|
$user = [
|
|
|
-
|
|
|
- 'user_id'=>$check->id,
|
|
|
+ 'user_id'=>$check['id'],
|
|
|
+ //'avatar'=>$check['avatar'],
|
|
|
+ // 'username'=>$check['username'],
|
|
|
'phone'=>$check->phone,
|
|
|
- 'is_agent'=>$check->is_dealer,
|
|
|
- 'agent_id'=>$agent_id,
|
|
|
-
|
|
|
+ 'is_agent'=>0,
|
|
|
+ 'agent_id'=>'',
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ $user=[
|
|
|
+ 'error'=>1
|
|
|
];
|
|
|
}
|
|
|
- // echo 111;die;
|
|
|
+ } else {
|
|
|
+ //print_r($check);die;
|
|
|
+ $save['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
|
|
|
+ $save['avatar'] = $datas['avatar'];
|
|
|
+ // $save['open_id'] = $res['openid'];
|
|
|
+ $save['model'] = 1;
|
|
|
+ AlbumUserModel::where('open_id',$res['openid'])->update($save);
|
|
|
+ //echo 111;
|
|
|
+ //print_r($check);die;
|
|
|
+ if($check->is_dealer == 1){
|
|
|
+ $user_agent = AlbumAgentModel::where([['user_id',$check->id],['status',1]])->first();
|
|
|
+ $agent_id = $user_agent['id'];
|
|
|
+ } else {
|
|
|
+ $agent_id = '';
|
|
|
+ }
|
|
|
+ $user = [
|
|
|
+
|
|
|
+ 'user_id'=>$check->id,
|
|
|
+ 'phone'=>$check->phone,
|
|
|
+ 'is_agent'=>$check->is_dealer,
|
|
|
+ 'agent_id'=>$agent_id,
|
|
|
+
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ // echo 111;die;
|
|
|
if (Auth::loginUsingId($check->id)) {
|
|
|
$userAuth = Auth::user();
|
|
|
if($check->is_dealer ==0){
|
| xqd
@@ -216,8 +224,8 @@ class AlbumController extends Controller
|
|
|
$add_record['store_id'] = $datas['store_id'];
|
|
|
$add_record['detail'] = null;
|
|
|
AlbumWatchRecord::create($add_record);
|
|
|
- // dd($add_record);
|
|
|
- // print_r($add_record['agent_id']);die;
|
|
|
+ // dd($add_record);
|
|
|
+ // print_r($add_record['agent_id']);die;
|
|
|
$user_agent = AlbumAgentModel::where('id',$add_record['agent_id'])->first();
|
|
|
//dd($user_agent);
|
|
|
if($user_agent){
|
| xqd
@@ -385,14 +393,23 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
|
|
|
if ($userAuth->up_agent_id != 0) {
|
|
|
- $agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
- $set_show_price = $agent->is_show_ma_price;
|
|
|
+
|
|
|
+
|
|
|
+ $agent_in = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
+ $set_show_price = $agent_in->is_show_ma_price;
|
|
|
+
|
|
|
} else {
|
|
|
$set_show_price = 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
- $goods = $goods->select('id','cover_pic','thumb','name','style','hot_cake','news','price_default')->orderByDesc('sort')->paginate(9);
|
|
|
+ if ($userAuth->is_dealer == 1) {
|
|
|
+ $agent_me = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ $set_show_price = $agent_me->is_show_ma_price;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $goods = $goods->select('id','cover_pic','thumb','name','style','hot_cake','news','price_default','ma_price','ma_price_comment')->orderByDesc('sort')->paginate(9);
|
|
|
|
|
|
foreach($goods as $key =>$val){
|
|
|
if($userAuth->is_dealer != 1){
|
| xqd
@@ -478,7 +495,7 @@ class AlbumController extends Controller
|
|
|
*/
|
|
|
public function albumGoodsDetail(Request $request)
|
|
|
{
|
|
|
- // $userAuth = AlbumXyxUserModel::find(1);
|
|
|
+ // $userAuth = AlbumXyxUserModel::find(1);
|
|
|
$userAuth = Auth('api')->user();
|
|
|
if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
$validator = Validator::make($request->all(), [
|
| xqd
@@ -766,7 +783,7 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
|
|
|
$user = AlbumUserModel::where([['open_id',$val->open_id],['store_id',$val->store_id]])->select(['username','avatar','phone'])->first();
|
|
|
- // dd(111);
|
|
|
+ // dd(111);
|
|
|
$data_res[] = [
|
|
|
'time'=>$val->created_at,
|
|
|
'action'=>$action,
|
| xqd
@@ -966,23 +983,37 @@ 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');
|
|
|
+ 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);
|
|
|
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
@@ -1064,7 +1095,7 @@ class AlbumController extends Controller
|
|
|
$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());
|
|
|
- // if($userAuth->up_agent_id==0) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未选择经销商!', $validator->messages());
|
|
|
+ // 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'));
|
| xqd
@@ -1518,22 +1549,22 @@ class AlbumController extends Controller
|
|
|
$save = array();
|
|
|
$return_data = array();
|
|
|
|
|
|
- $save['price'] = $data['price'];
|
|
|
- $check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
|
|
|
- if(empty($check)){
|
|
|
- $save['agent_id'] = $agent_id;
|
|
|
- $save['store_id'] = $data['store_id'];
|
|
|
- $save['product_id'] = $data['goods_id'];
|
|
|
- $res = AlbumProductPriceModel::create($save);
|
|
|
- }else{
|
|
|
- $res = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->update($save);
|
|
|
- }
|
|
|
- if($res){
|
|
|
- $return['msg'] = 'success';
|
|
|
- $return_data['price'] = $data['price'];
|
|
|
- } else {
|
|
|
- $return['msg'] = 'error';
|
|
|
- }
|
|
|
+ $save['price'] = $data['price'];
|
|
|
+ $check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
|
|
|
+ if(empty($check)){
|
|
|
+ $save['agent_id'] = $agent_id;
|
|
|
+ $save['store_id'] = $data['store_id'];
|
|
|
+ $save['product_id'] = $data['goods_id'];
|
|
|
+ $res = AlbumProductPriceModel::create($save);
|
|
|
+ }else{
|
|
|
+ $res = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->update($save);
|
|
|
+ }
|
|
|
+ if($res){
|
|
|
+ $return['msg'] = 'success';
|
|
|
+ $return_data['price'] = $data['price'];
|
|
|
+ } else {
|
|
|
+ $return['msg'] = 'error';
|
|
|
+ }
|
|
|
|
|
|
$return['data'] = $return_data;
|
|
|
return $this->api($return);
|
| xqd
@@ -1686,7 +1717,7 @@ class AlbumController extends Controller
|
|
|
$add_record['action'] = $data['type'];
|
|
|
$add_record['store_id'] = $data['store_id'];
|
|
|
$add_record['detail'] = json_encode($select_info);
|
|
|
- // dd($add_record);
|
|
|
+ // dd($add_record);
|
|
|
$res = AlbumWatchRecord::create($add_record);
|
|
|
$user_agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
| xqd
@@ -1762,7 +1793,7 @@ class AlbumController extends Controller
|
|
|
$weChatApp = AlbumManufacturerModel::where('store_id', $storeid)->first();//\Log::info('2221');
|
|
|
|
|
|
$res_account = $this->accountMesage($g_open_id,$weChatApp,$name,$content);
|
|
|
- // \Log::info($res_account);
|
|
|
+ // \Log::info($res_account);
|
|
|
if($user && $formId && (!$weChatApp->G_app_id || !$weChatApp->G_app_secret)){
|
|
|
$config_app = [
|
|
|
'app_id' => $weChatApp->app_id,
|
| xqd
@@ -1781,7 +1812,7 @@ class AlbumController extends Controller
|
|
|
'keyword3' => date('Y-m-d H:i'),
|
|
|
],
|
|
|
]);
|
|
|
- // dd($res);
|
|
|
+ // dd($res);
|
|
|
if($res){
|
|
|
$formId->delete();
|
|
|
}
|
| xqd
@@ -1802,7 +1833,7 @@ class AlbumController extends Controller
|
|
|
*/
|
|
|
private function accountMesage($g_open_id,$weChatApp,$name,$content)
|
|
|
{
|
|
|
- // Cache::flush();
|
|
|
+ // Cache::flush();
|
|
|
$value = Cache::get($g_open_id);
|
|
|
\Log::info($value);\Log::info('2225');
|
|
|
if ($g_open_id && (!$value || ($value + 60) <= time())) {
|
| xqd
@@ -2155,7 +2186,7 @@ class AlbumController extends Controller
|
|
|
$open_id = $request->input('open_id');
|
|
|
$key = $request->input('key');
|
|
|
$value = $request->input('value');
|
|
|
- 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();
|
|
|
if ($key == 'phone') {
|
|
|
$user = AlbumUserModel::where([['store_id',$store_id],['open_id',$open_id]])->first();
|
| xqd
@@ -2165,10 +2196,10 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
$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->$key = $value;
|
|
|
+ /// $customer->$key = $value;
|
|
|
$update[$key] = $value;
|
|
|
CustomerDetailsModel::where([['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->update($update);
|
|
|
- // $customer->save();
|
|
|
+ // $customer->save();
|
|
|
}else{
|
|
|
$add['agent_id'] = $user_agent->id;
|
|
|
$add['open_id'] = $open_id;
|
| xqd
@@ -2218,18 +2249,32 @@ 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');
|
|
|
+ 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);
|
|
|
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
@@ -2285,19 +2330,33 @@ 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');
|
|
|
+ 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);
|
|
|
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
@@ -2377,7 +2436,7 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
|
|
|
$res[$key]['name'] = $goods->name;
|
|
|
- // dd($res);
|
|
|
+ // dd($res);
|
|
|
$res[$key]['count'] = AlbumFavoriteModel::whereIn('user_id',$users)->where([['store_id',$store_id],['product_id',$val['product_id']]])->count();
|
|
|
}
|
|
|
return $this->api($res,0,'success');
|
| xqd
@@ -2543,21 +2602,35 @@ 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');
|
|
|
+ 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);
|
|
|
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
@@ -2570,7 +2643,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
@@ -2578,7 +2651,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
@@ -2642,6 +2715,7 @@ class AlbumController extends Controller
|
|
|
$user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
$user_agent->is_show_ma_price = $data['is_show_ma_price'];
|
|
|
$user_agent->save();
|
|
|
+<<<<<<< HEAD
|
|
|
if ($data['point'] != 0) {
|
|
|
$product = AlbumProductModel::where('store_id',$data['store_id'])->all('id','price_default');
|
|
|
foreach ($product as $key=>$val) {
|
| xqd
@@ -2657,6 +2731,24 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+=======
|
|
|
+
|
|
|
+ $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();
|
|
|
+>>>>>>> master
|
|
|
return $this->api([],0,'success');
|
|
|
}
|
|
|
}
|