| xqd
@@ -113,30 +113,30 @@ class AlbumController extends Controller
|
|
|
public function albumXyxLogin(Request $request)
|
|
|
{
|
|
|
$datas = $request->input();
|
|
|
- $validator = Validator::make($request->all(),
|
|
|
- [
|
|
|
- 'code' => 'required',
|
|
|
- 'agent_id' => 'required',
|
|
|
- 'nickName' => 'required',
|
|
|
- 'iv' => 'required',
|
|
|
- 'encryptData' => 'required',
|
|
|
- 'avatar' => 'required',
|
|
|
- 'store_id' => 'required'
|
|
|
- ],[
|
|
|
- 'code.required' => 'code不能为空!',
|
|
|
- 'agent_id.required' => 'agent_id不能为空!',
|
|
|
- 'nickName.required' => '昵称不能为空!',
|
|
|
- 'iv.required' => '偏移量不能为空!',
|
|
|
- 'encryptData.required' => '加密数据不能为空!',
|
|
|
- 'avatar.required' => '头像不能为空!',
|
|
|
- 'store_id.required' => '站点ID不能为空!'
|
|
|
- ]
|
|
|
- );
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'code' => 'required',
|
|
|
+ 'agent_id' => 'required',
|
|
|
+ 'nickName' => 'required',
|
|
|
+ 'iv' => 'required',
|
|
|
+ 'encryptData' => 'required',
|
|
|
+ 'avatar' => 'required',
|
|
|
+ 'store_id' => 'required'
|
|
|
+ ], [
|
|
|
+ 'code.required' => 'code不能为空!',
|
|
|
+ 'agent_id.required' => 'agent_id不能为空!',
|
|
|
+ 'nickName.required' => '昵称不能为空!',
|
|
|
+ 'iv.required' => '偏移量不能为空!',
|
|
|
+ 'encryptData.required' => '加密数据不能为空!',
|
|
|
+ 'avatar.required' => '头像不能为空!',
|
|
|
+ 'store_id.required' => '站点ID不能为空!'
|
|
|
+ ]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
- $this->wechat_app = AlbumManufacturerModel::where('store_id',$datas['store_id'])->first();
|
|
|
- if(!$this->wechat_app) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '厂家参数未初始化!', $validator->messages());
|
|
|
+ $this->wechat_app = AlbumManufacturerModel::where('store_id', $datas['store_id'])->first();
|
|
|
+ if (!$this->wechat_app) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '厂家参数未初始化!', $validator->messages());
|
|
|
+ }
|
|
|
$config = [
|
|
|
'app_id' => $this->wechat_app->xyx_id,
|
|
|
'secret' => $this->wechat_app->xyx_secret,
|
| xqd
@@ -162,60 +162,50 @@ class AlbumController extends Controller
|
|
|
$check = AlbumUserModel::where([['wechat_union_id', $decryptedData['unionId']],['store_id',$datas['store_id']]])->first();
|
|
|
}
|
|
|
|
|
|
- if(!$check){
|
|
|
+ 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['wechat_union_id'] = isset($decryptedData['unionId']) ? $decryptedData['unionId'] : '';
|
|
|
$add['avatar'] = $datas['avatar'];
|
|
|
- $add['is_agent'] = 0;
|
|
|
+ $add['is_dealer'] = 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();
|
|
|
+ if ($res) {
|
|
|
+ $check = $res;
|
|
|
$user = [
|
|
|
- 'user_id'=>$check['id'],
|
|
|
- //'avatar'=>$check['avatar'],
|
|
|
- // 'username'=>$check['username'],
|
|
|
- 'phone'=>$check->phone,
|
|
|
- 'is_agent'=>0,
|
|
|
- 'agent_id'=>'',
|
|
|
+ 'user_id' => $check->id,
|
|
|
+ 'phone' => '',
|
|
|
+ 'is_agent' => 0,
|
|
|
+ 'agent_id' => '',
|
|
|
];
|
|
|
- }else{
|
|
|
- $user=[
|
|
|
- 'error'=>1
|
|
|
+ } 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){
|
|
|
+ AlbumUserModel::where('open_id', $res['openid'])->update($save);
|
|
|
+ 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,
|
|
|
-
|
|
|
+ '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){
|
|
|
- if($request->input('agent_id')!=0){
|
|
|
+ if ($check->is_dealer == 0) {
|
|
|
+ if ($request->input('agent_id') != 0) {
|
|
|
$userAuth->up_agent_id = $request->input('agent_id');
|
|
|
}
|
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
| xqd
@@ -233,8 +223,6 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
$checkWatch = AlbumWatchRecord::where([['open_id',$check->open_id],['agent_id', $userAuth->up_agent_id]])->first();
|
|
|
AlbumWatchRecord::create($add_record);
|
|
|
- // dd($add_record);
|
|
|
- // print_r($add_record['agent_id']);die;
|
|
|
$user_agent = AlbumAgentModel::where([['id',$add_record['agent_id']],['store_id',$datas['store_id']]])->first();
|
|
|
//dd($user_agent);
|
|
|
if ($user_agent) {
|
| xqd
@@ -246,13 +234,12 @@ class AlbumController extends Controller
|
|
|
$user_agent->save();
|
|
|
$agent = AlbumUserModel::where([['id',$user_agent->user_id],['store_id',$datas['store_id']]])->first();
|
|
|
$this->sendLogsMessage($datas['store_id'], $agent->open_id, 4, $userAuth->username, $agent->g_open_id);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$userAuth->up_agent_id = 0;
|
|
|
}
|
|
|
-
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$userAuth->up_agent_id = 0;
|
|
|
- }//dd($userAuth);
|
|
|
+ }
|
|
|
$userAuth->save();
|
|
|
$user['up_agent_id'] = $userAuth->up_agent_id;
|
|
|
$user['role'] = $userAuth->role;
|
| xqd
@@ -262,20 +249,21 @@ class AlbumController extends Controller
|
|
|
$res_image = getUrlImage($userAuth->avatar, public_path() . '/base/poster/avatar/' . $datas['store_id'] . "/$userAuth->id.jpg");
|
|
|
imageToCircle($res_image);
|
|
|
$token = $userAuth->createToken($userAuth->id . '-' . $userAuth->openid)->accessToken;
|
|
|
- $conf = AlbumManufacturerModel::where('store_id',$datas['store_id'])->first();
|
|
|
+ $conf = AlbumManufacturerModel::where('store_id', $datas['store_id'])->first();
|
|
|
$getPhone = $conf->getPhone;
|
|
|
$getFocus = $conf->getFocus;
|
|
|
- return $this->api(compact('token', 'user','getPhone','getFocus'));
|
|
|
+ return $this->api(compact('token', 'user', 'getPhone', 'getFocus'));
|
|
|
} else {
|
|
|
return $this->error(ErrorCode::INCORRECT_USER_OR_PASS);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- /*
|
|
|
- * curl get请求
|
|
|
- */
|
|
|
- public function curl_get($url)
|
|
|
+ /**
|
|
|
+ * @param $url
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function curlGet($url)
|
|
|
{
|
|
|
//初始化
|
|
|
$ch = curl_init();
|
| xqd
@@ -289,22 +277,7 @@ class AlbumController extends Controller
|
|
|
return $output;
|
|
|
}
|
|
|
|
|
|
- private function getOpenid($code)
|
|
|
- {
|
|
|
- $api = "https://api.weixin.qq.com/sns/jscode2session?appid={$this->wechat_app->app_id}&secret={$this->wechat_app->app_secret}&js_code={$code}&grant_type=authorization_code";
|
|
|
- $res = $this->curl_get($api);
|
|
|
- $res = json_decode($res, true);
|
|
|
- return $res;
|
|
|
- }
|
|
|
|
|
|
- private function getOpenidxyx($code)
|
|
|
- {
|
|
|
- //$api = "https://api.weixin.qq.com/sns/jscode2session?appid={$this->wechat_app->xyx_id}&secret={$this->wechat_app->xyx_secret}&js_code={$code}&grant_type=authorization_code";
|
|
|
- $api = "https://api.weixin.qq.com/sns/jscode2session?appid={$this->wechat_app->xyx_id}&secret={$this->wechat_app->xyx_secret}&js_code={$code}&grant_type=authorization_code";
|
|
|
- $res = $this->curl_get($api);
|
|
|
- $res = json_decode($res, true);
|
|
|
- return $res;
|
|
|
- }
|
|
|
/**
|
|
|
* @api {get} /api/album/goods 商品列表(goods)
|
|
|
* @apiDescription 商品列表(goods)
|
| xqd
@@ -368,11 +341,8 @@ class AlbumController extends Controller
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$data = $request->input();
|
|
|
- //dd($data);
|
|
|
$cat_id = request('cat_id');
|
|
|
$store_id = request('store_id');
|
|
|
- $status = request('status');
|
|
|
- $style = request('style');
|
|
|
$parent_id = request('parent_id');
|
|
|
|
|
|
$select_info = ['cat_id' => $cat_id,'parent_id' => $parent_id];
|
| xqd
@@ -499,21 +469,23 @@ class AlbumController extends Controller
|
|
|
{
|
|
|
// $userAuth = AlbumXyxUserModel::find(1);
|
|
|
$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(), [
|
|
|
'goods_id' => 'required',
|
|
|
'store_id' => 'required',
|
|
|
- ],[
|
|
|
- 'goods_id.required'=>'缺少商品参数',
|
|
|
- 'store_id_id.required'=>'缺少STORE参数',
|
|
|
+ ], [
|
|
|
+ 'goods_id.required' => '缺少商品参数',
|
|
|
+ 'store_id_id.required' => '缺少STORE参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$goods_id = request('goods_id');
|
|
|
$store_id = request('store_id');
|
|
|
- $select_info = ['goods_id'=>$goods_id];
|
|
|
- if($userAuth->up_agent_id!=0){
|
|
|
+ $select_info = ['goods_id' => $goods_id];
|
|
|
+ if ($userAuth->up_agent_id != 0) {
|
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
|
$add_record['open_id'] = $userAuth->open_id;
|
|
|
$add_record['action'] = 3;
|
| xqd
@@ -521,59 +493,58 @@ class AlbumController extends Controller
|
|
|
$add_record['detail'] = json_encode($select_info);
|
|
|
AlbumWatchRecord::create($add_record);
|
|
|
|
|
|
- $user_agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
- $agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
|
- try{
|
|
|
- $this->sendLogsMessage($store_id,$agent->open_id,3,$userAuth->username,$agent->g_open_id);
|
|
|
- }catch (\Exception $e){
|
|
|
-
|
|
|
+ $user_agent = AlbumAgentModel::where('id', $userAuth->up_agent_id)->first();
|
|
|
+ $agent = AlbumUserModel::where('id', $user_agent->user_id)->first();
|
|
|
+ try {
|
|
|
+ $this->sendLogsMessage($store_id, $agent->open_id, 3, $userAuth->username, $agent->g_open_id);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ \Log::info($e);
|
|
|
}
|
|
|
}
|
|
|
- $ma = AlbumManufacturerModel::where('store_id',$store_id)->first();
|
|
|
+ $ma = AlbumManufacturerModel::where('store_id', $store_id)->first();
|
|
|
$goods = AlbumProductModel::where([['id',$goods_id],['store_id',$store_id]])->first();
|
|
|
- $address = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
$cat_record['agent_id'] = $userAuth->up_agent_id;
|
|
|
$cat_record['open_id'] = $userAuth->open_id;
|
|
|
$cat_record['store_id'] = $store_id;
|
|
|
- $cat_record['style_id'] = $goods->style;
|
|
|
$cat_record['cat_id'] = $goods->cat_id;
|
|
|
CustomerCatRecordModel::create($cat_record);
|
|
|
- if(!empty($goods) && $userAuth->is_dealer != 1){
|
|
|
+ if (!empty($goods) && $userAuth->is_dealer != 1) {
|
|
|
+ $address = AlbumAgentModel::where('id', $userAuth->up_agent_id)->first();
|
|
|
$price = DB::table('album_product_price')->where([['agent_id',$userAuth->up_agent_id],['store_id',$store_id],['product_id',$goods['id']]])->first();
|
|
|
- if(!empty($price)){
|
|
|
+ if (!empty($price)) {
|
|
|
$goods->price = $price->price;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$goods->price = '';
|
|
|
}
|
|
|
$check_favorite = AlbumFavoriteModel::where([['user_id',$userAuth->id],['store_id',$store_id],['product_id',$goods['id']]])->first();
|
|
|
//dd($check_favorite);
|
|
|
- if($check_favorite){
|
|
|
+ if ($check_favorite) {
|
|
|
$goods->is_favorite = 1;
|
|
|
$goods->favorite_id = $check_favorite->id;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$goods->is_favorite = 0;
|
|
|
$goods->favorite_id = '';
|
|
|
}
|
|
|
- }elseif(!empty($goods) && $userAuth->is_dealer == 1){
|
|
|
- $agent_id = $address['id'];
|
|
|
- $price = DB::table('album_product_price')->where([['agent_id',$agent_id],['store_id',$store_id],['product_id',$goods['id']]])->first();
|
|
|
- if(!empty($price)){
|
|
|
+ } elseif (!empty($goods) && $userAuth->is_dealer == 1) {
|
|
|
+ $address = AlbumAgentModel::where([['store_id', $store_id],['user_id', $userAuth->id]])->first();
|
|
|
+ $price = DB::table('album_product_price')->where([['agent_id',$address->id],['store_id',$store_id],['product_id',$goods['id']]])->first();
|
|
|
+ if (!empty($price)) {
|
|
|
$goods->price = $price->price;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$goods->price = '';
|
|
|
}
|
|
|
|
|
|
$goods->is_favorite = 0;
|
|
|
$goods->favorite_id = '';
|
|
|
}
|
|
|
- if($userAuth->up_agent_id == 0 || !$address){
|
|
|
+ if ($userAuth->up_agent_id == 0 || !$address) {
|
|
|
$goods->price = '';
|
|
|
$goods->mobile = $ma->phone;
|
|
|
$goods->address = $ma->address;
|
|
|
$goods->realname = $ma->name;
|
|
|
$goods->avatar = $ma->avatar;
|
|
|
- }else{
|
|
|
- $agent = AlbumUserModel::where('id',$address->user_id)->first();
|
|
|
+ } else {
|
|
|
+ $agent = AlbumUserModel::where('id', $address->user_id)->first();
|
|
|
$goods->mobile = $address->phone;
|
|
|
$goods->address = $address->address;
|
|
|
$goods->realname = $address->name;
|
| xqd
@@ -640,18 +611,20 @@ class AlbumController extends Controller
|
|
|
public function albumFavoriteList(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());
|
|
|
}
|
|
|
$data = $request->input();
|
|
|
$favorite = AlbumFavoriteModel::where([['user_id',$userAuth->id],['store_id',$data['store_id']]])->get();
|
|
|
- foreach ($favorite as $key=>$val) {
|
|
|
+ foreach ($favorite as $key => $val) {
|
|
|
$favorite[$key]['goods'] = AlbumProductModel::where([['id',$val['product_id']],['store_id',$data['store_id']]])->first();
|
|
|
}
|
|
|
return $this->api($favorite);
|
| xqd
@@ -704,76 +677,89 @@ class AlbumController extends Controller
|
|
|
public function albumGetWatchRecord(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',
|
|
|
- 'type'=>'required'
|
|
|
- ],[
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
- 'type.required'=>'缺少类型参数',
|
|
|
+ 'type' => 'required'
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ 'type.required' => '缺少类型参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$type = $request->input('type');
|
|
|
$store_id = $request->input('store_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 ($userAuth->is_dealer != 1) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ }
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
|
$query = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id]]);
|
|
|
- switch ($type){
|
|
|
+ switch ($type) {
|
|
|
case '1':
|
|
|
- if(!$request->input('user_id')) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!');
|
|
|
+ if (!$request->input('user_id')) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!');
|
|
|
+ }
|
|
|
$user = AlbumUserModel::find(request('user_id'));
|
|
|
- $query = $query->where('open_id',$user->open_id);
|
|
|
+ $query = $query->where('open_id', $user->open_id);
|
|
|
break;
|
|
|
case '2':
|
|
|
- if(!$request->input('start_time')||!$request->input('end_time')) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!');
|
|
|
- $start_time = date('Y-m-d H:i:s',$request->input('start_time'));
|
|
|
- $end_time = date('Y-m-d H:i:s',$request->input('end_time'));//dd($start_time.';'.$end_time);
|
|
|
+ if (!$request->input('start_time') || !$request->input('end_time')) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!');
|
|
|
+ }
|
|
|
+ $start_time = date('Y-m-d H:i:s', $request->input('start_time'));
|
|
|
+ $end_time = date('Y-m-d H:i:s', $request->input('end_time'));
|
|
|
$query = $query->where([['created_at','>=',$start_time],['created_at','<=',$end_time]]);
|
|
|
-
|
|
|
break;
|
|
|
case '3':
|
|
|
- if(!$request->input('action')) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!');
|
|
|
+ if (!$request->input('action')) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!');
|
|
|
+ }
|
|
|
$query = $query->where([['action',$request->input('action')]]);
|
|
|
break;
|
|
|
}
|
|
|
$res = $query->get();
|
|
|
$action = '';
|
|
|
|
|
|
- foreach($res as $key=>$val){
|
|
|
- \Log::info('action:'.$val->action.',id:'.$val->id.';end');
|
|
|
- if($val->action==4){
|
|
|
+ foreach ($res as $key => $val) {
|
|
|
+ \Log::info('action:' . $val->action . ',id:' . $val->id . ';end');
|
|
|
+ if ($val->action == 4) {
|
|
|
$action = '进入我的画册';
|
|
|
- }elseif($val->action == 1||$val->action ==3){
|
|
|
- $goods_data = json_decode($val->detail,true);
|
|
|
+ } elseif ($val->action == 1 || $val->action == 3) {
|
|
|
+ $goods_data = json_decode($val->detail, true);
|
|
|
$goods_id = $goods_data['goods_id'];
|
|
|
$goods = AlbumProductModel::find($goods_id);
|
|
|
if (!$goods) {
|
|
|
continue;
|
|
|
}
|
|
|
$cat = AlbumCatModel::find($goods->cat_id);
|
|
|
- $style = AlbumProductStyleModel::find($goods->style);
|
|
|
- $val->action == 1? $act = '收藏':$act = '查看';if(empty($style)||empty($cat)) continue;
|
|
|
- $action = $act.'了您的'.$cat->name.'分类下的'.$style->name.'风格的商品 '.$goods->name;
|
|
|
- }elseif($val->action == 2){
|
|
|
- //dd(111);
|
|
|
- $cat_data = json_decode($val->detail,true);
|
|
|
- if($cat_data['cat_id']=="undefined"||$cat_data['style']=="undefined"||!$cat_data['style']||!$cat_data['cat_id']) continue;
|
|
|
+ $val->action == 1 ? $act = '收藏' : $act = '查看';
|
|
|
+ if (empty($cat)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $action = $act . '了您的' . $cat->name . '分类下的商品 ' . $goods->name;
|
|
|
+ } elseif ($val->action == 2) {
|
|
|
+ $cat_data = json_decode($val->detail, true);
|
|
|
+ if ($cat_data['cat_id'] == "undefined" || !$cat_data['cat_id']) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
$cat = AlbumCatModel::find($cat_data['cat_id']);
|
|
|
- $style = AlbumProductStyleModel::find($cat_data['style']);
|
|
|
- if(empty($style)||empty($cat)) continue;
|
|
|
- $action = '浏览了您的 '.$cat->name.'分类下的 '.$style->name.'风格的商品列表';
|
|
|
- }elseif($val->action==5){
|
|
|
- $goods_data = json_decode($val->detail,true);
|
|
|
+ if (empty($cat)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $action = '浏览了您的 ' . $cat->name . '分类下的商品列表';
|
|
|
+ } elseif ($val->action == 5) {
|
|
|
+ $goods_data = json_decode($val->detail, true);
|
|
|
$goods_id = $goods_data['goods_id'];
|
|
|
$goods = AlbumProductModel::find($goods_id);
|
|
|
if (!$goods) {
|
|
|
continue;
|
|
|
}
|
|
|
$cat = AlbumCatModel::find($goods->cat_id);
|
|
|
- $style = AlbumProductStyleModel::find($goods->style);if(empty($style)||empty($cat)) continue;
|
|
|
- $action = '点击了您的'.$cat->name.'分类下的'.$style->name.'风格的商品 '.$goods->name.'的'.$goods_data['detail'];
|
|
|
+ if(empty($cat)) continue;
|
|
|
+ $action = '点击了您的'.$cat->name.'分类下的商品 '.$goods->name.'的'.$goods_data['detail'];
|
|
|
}elseif($val->action==6){
|
|
|
$detail = json_decode($val->detail,true);
|
|
|
$address = $detail['detail'];
|
| xqd
@@ -879,7 +865,7 @@ class AlbumController extends Controller
|
|
|
* @apiPermission 需要登录
|
|
|
* @apiVersion 0.1.0
|
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
|
- * @apiParam {int} [style_id]
|
|
|
+ * @apiParam {int} [parent_id]
|
|
|
* @apiSuccessExample {json} Success-Response:
|
|
|
* HTTP/1.1 200 OK
|
|
|
* {
|
| xqd
@@ -913,23 +899,23 @@ class AlbumController extends Controller
|
|
|
if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
- 'style_id' => 'required'
|
|
|
+ 'parent_id' => 'required'
|
|
|
],[
|
|
|
'store_id.required'=>'缺少商户参数',
|
|
|
- 'style_id.required'=>'缺少风格参数',
|
|
|
+ 'parent_id.required'=>'缺少风格参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
}
|
|
|
$store_id = $request->input('store_id');
|
|
|
- $style_id = $request->input('style_id');
|
|
|
+ $parent_id = $request->input('parent_id');
|
|
|
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();
|
|
|
+ $cat = AlbumCatModel::where([['store_id',$store_id],['parent_id', $parent_id]])->get(['name','id'])->toArray();
|
|
|
$total = 0;
|
|
|
foreach ($cat as $key=>$val){
|
|
|
- $count = CustomerCatRecordModel::where([['agent_id',$user_agent->id],['store_id',$store_id],['style_id',$style_id],['cat_id',$val['id']]])->count();
|
|
|
+ $count = CustomerCatRecordModel::where([['agent_id',$user_agent->id],['store_id',$store_id],['cat_id',$val['id']]])->count();
|
|
|
$total += $count;
|
|
|
$cat[$key]['num'] = $count;
|
|
|
}
|
| xqd
@@ -952,6 +938,7 @@ class AlbumController extends Controller
|
|
|
* @apiVersion 0.1.0
|
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
|
* @apiParam {int} [open_id]
|
|
|
+ * @apiParam {int} [parent_id]
|
|
|
* @apiSuccessExample {json} Success-Response:
|
|
|
* HTTP/1.1 200 OK
|
|
|
* {
|
| xqd
@@ -986,11 +973,13 @@ class AlbumController extends Controller
|
|
|
$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'=>'缺少父分类参数',
|
|
|
// 'end.required'=>'缺少结束时间参数',
|
|
|
//'start.required'=>'缺少开始时间参数',
|
|
|
]);
|
| xqd
@@ -999,6 +988,7 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
$store_id = $request->input('store_id');
|
|
|
$open_id = $request->input('open_id');
|
|
|
+ $parent_id = $request->input('parent_id');
|
|
|
$end = $request->input('end');
|
|
|
$start = $request->input('start');
|
|
|
if (!$end) {
|
| xqd
@@ -1012,7 +1002,7 @@ class AlbumController extends Controller
|
|
|
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();
|
|
|
+ $cat = AlbumCatModel::where([['store_id',$store_id],['parent_id',$parent_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']],['updated_at','>=',$start],['updated_at','<=',$end]])->count();
|
| xqd
@@ -1931,7 +1921,7 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
$data = $request->input();
|
|
|
$url = "https://apis.map.qq.com/ws/geocoder/v1/?address=".$data['address']."&key=".env('QQMAP');
|
|
|
- $local = $this->curl_get($url);
|
|
|
+ $local = $this->curlGet($url);
|
|
|
$res = json_decode($local,true);
|
|
|
$agent_check = AlbumAgentModel::where([['store_id',$data['store_id']],['user_id',$userAuth->id]])->first();
|
|
|
if($agent_check){
|
| xqd
@@ -2381,16 +2371,13 @@ class AlbumController extends Controller
|
|
|
$goods_id = $detail['goods_id'];
|
|
|
$goods = AlbumProductModel::where([['id',$goods_id]])->first();
|
|
|
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:i',strtotime($val['created_at'])), 'style'=>$style->name, 'cat'=>$cat->name, 'thumb'=>$goods->thumb];
|
|
|
if (isset($arr[date('Y-m-d H:i', strtotime($val['created_at']))])) {
|
|
|
if (isset($arr[date('Y-m-d H:i', strtotime($val['created_at']))][$goods->id])) {
|
|
|
$arr[date('Y-m-d H:i', strtotime($val['created_at']))][$goods->id]['times']++;
|
|
|
} else {
|
|
|
$arr[date('Y-m-d H:i', strtotime($val['created_at']))][$goods->id] = [
|
|
|
'name' => $goods->name,
|
|
|
- 'style' => $style->name,
|
|
|
'cat' => $cat->name,
|
|
|
'thumb' => $goods->thumb,
|
|
|
'time' => date('Y-m-d H:i', strtotime($val['created_at'])),
|
| xqd
@@ -2400,7 +2387,6 @@ class AlbumController extends Controller
|
|
|
} else {
|
|
|
$arr[date('Y-m-d H:i', strtotime($val['created_at']))][$goods->id] = [
|
|
|
'name' => $goods->name,
|
|
|
- 'style' => $style->name,
|
|
|
'cat' => $cat->name,
|
|
|
'thumb' => $goods->thumb,
|
|
|
'time' => date('Y-m-d H:i', strtotime($val['created_at'])),
|