|
@@ -113,30 +113,30 @@ class AlbumController extends Controller
|
|
public function albumXyxLogin(Request $request)
|
|
public function albumXyxLogin(Request $request)
|
|
{
|
|
{
|
|
$datas = $request->input();
|
|
$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()) {
|
|
if ($validator->fails()) {
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
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 = [
|
|
$config = [
|
|
'app_id' => $this->wechat_app->xyx_id,
|
|
'app_id' => $this->wechat_app->xyx_id,
|
|
'secret' => $this->wechat_app->xyx_secret,
|
|
'secret' => $this->wechat_app->xyx_secret,
|
|
@@ -162,60 +162,50 @@ class AlbumController extends Controller
|
|
$check = AlbumUserModel::where([['wechat_union_id', $decryptedData['unionId']],['store_id',$datas['store_id']]])->first();
|
|
$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['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
|
|
$add['open_id'] = $res['openid'];
|
|
$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['avatar'] = $datas['avatar'];
|
|
- $add['is_agent'] = 0;
|
|
|
|
|
|
+ $add['is_dealer'] = 0;
|
|
$add['model'] = 1;
|
|
$add['model'] = 1;
|
|
$add['store_id'] = $datas['store_id'];
|
|
$add['store_id'] = $datas['store_id'];
|
|
$res = AlbumUserModel::create($add);
|
|
$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 = [
|
|
- '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 {
|
|
} else {
|
|
- //print_r($check);die;
|
|
|
|
$save['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
|
|
$save['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
|
|
$save['avatar'] = $datas['avatar'];
|
|
$save['avatar'] = $datas['avatar'];
|
|
- // $save['open_id'] = $res['openid'];
|
|
|
|
$save['model'] = 1;
|
|
$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();
|
|
$user_agent = AlbumAgentModel::where([['user_id',$check->id],['status',1]])->first();
|
|
$agent_id = $user_agent['id'];
|
|
$agent_id = $user_agent['id'];
|
|
} else {
|
|
} else {
|
|
$agent_id = '';
|
|
$agent_id = '';
|
|
}
|
|
}
|
|
$user = [
|
|
$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)) {
|
|
if (Auth::loginUsingId($check->id)) {
|
|
$userAuth = Auth::user();
|
|
$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');
|
|
$userAuth->up_agent_id = $request->input('agent_id');
|
|
}
|
|
}
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
@@ -223,45 +213,57 @@ class AlbumController extends Controller
|
|
$add_record['action'] = 4;
|
|
$add_record['action'] = 4;
|
|
$add_record['store_id'] = $datas['store_id'];
|
|
$add_record['store_id'] = $datas['store_id'];
|
|
$add_record['detail'] = null;
|
|
$add_record['detail'] = null;
|
|
|
|
+ $check_new_customer = AlbumWatchRecord::where([
|
|
|
|
+ ['agent_id', $userAuth->up_agent_id],['open_id', $check->open_id],['store_id', $datas['store_id']]
|
|
|
|
+ ])->first();
|
|
|
|
+ if ($check_new_customer) {
|
|
|
|
+ $add_record['is_new'] = 0;
|
|
|
|
+ } else {
|
|
|
|
+ $add_record['is_new'] = 1;
|
|
|
|
+ }
|
|
|
|
+ $checkWatch = AlbumWatchRecord::where([['open_id',$check->open_id],['agent_id', $userAuth->up_agent_id]])->first();
|
|
AlbumWatchRecord::create($add_record);
|
|
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();
|
|
$user_agent = AlbumAgentModel::where([['id',$add_record['agent_id']],['store_id',$datas['store_id']]])->first();
|
|
//dd($user_agent);
|
|
//dd($user_agent);
|
|
if ($user_agent) {
|
|
if ($user_agent) {
|
|
- $user_agent->get_count++;
|
|
|
|
|
|
+ if (empty($checkWatch)) {
|
|
|
|
+ $user_agent->get_count++;
|
|
|
|
+ }
|
|
|
|
+ $user_agent->pointCount++;
|
|
|
|
+ $user_agent->newCount = $user_agent->pointCount + $user_agent->favoriteCount + $user_agent->callCount + $user_agent->share_times + $user_agent->get_count;
|
|
$user_agent->save();
|
|
$user_agent->save();
|
|
$agent = AlbumUserModel::where([['id',$user_agent->user_id],['store_id',$datas['store_id']]])->first();
|
|
$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);
|
|
$this->sendLogsMessage($datas['store_id'], $agent->open_id, 4, $userAuth->username, $agent->g_open_id);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$userAuth->up_agent_id = 0;
|
|
$userAuth->up_agent_id = 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$userAuth->up_agent_id = 0;
|
|
$userAuth->up_agent_id = 0;
|
|
- }//dd($userAuth);
|
|
|
|
|
|
+ }
|
|
$userAuth->save();
|
|
$userAuth->save();
|
|
$user['up_agent_id'] = $userAuth->up_agent_id;
|
|
$user['up_agent_id'] = $userAuth->up_agent_id;
|
|
|
|
+ $user['role'] = $userAuth->role;
|
|
if (!file_exists(public_path() . '/base/poster/avatar/' . $datas['store_id'])) {
|
|
if (!file_exists(public_path() . '/base/poster/avatar/' . $datas['store_id'])) {
|
|
mkdir(public_path() . '/base/poster/avatar/' . $datas['store_id'], 0755, true);
|
|
mkdir(public_path() . '/base/poster/avatar/' . $datas['store_id'], 0755, true);
|
|
}
|
|
}
|
|
$res_image = getUrlImage($userAuth->avatar, public_path() . '/base/poster/avatar/' . $datas['store_id'] . "/$userAuth->id.jpg");
|
|
$res_image = getUrlImage($userAuth->avatar, public_path() . '/base/poster/avatar/' . $datas['store_id'] . "/$userAuth->id.jpg");
|
|
imageToCircle($res_image);
|
|
imageToCircle($res_image);
|
|
$token = $userAuth->createToken($userAuth->id . '-' . $userAuth->openid)->accessToken;
|
|
$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;
|
|
$getPhone = $conf->getPhone;
|
|
$getFocus = $conf->getFocus;
|
|
$getFocus = $conf->getFocus;
|
|
- return $this->api(compact('token', 'user','getPhone','getFocus'));
|
|
|
|
|
|
+ return $this->api(compact('token', 'user', 'getPhone', 'getFocus'));
|
|
} else {
|
|
} else {
|
|
return $this->error(ErrorCode::INCORRECT_USER_OR_PASS);
|
|
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();
|
|
$ch = curl_init();
|
|
@@ -275,22 +277,7 @@ class AlbumController extends Controller
|
|
return $output;
|
|
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)
|
|
* @api {get} /api/album/goods 商品列表(goods)
|
|
* @apiDescription 商品列表(goods)
|
|
* @apiDescription 商品列表(goods)
|
|
@@ -340,22 +327,24 @@ class AlbumController extends Controller
|
|
}
|
|
}
|
|
$validator = Validator::make($request->all(), [
|
|
$validator = Validator::make($request->all(), [
|
|
'cat_id' => 'required',
|
|
'cat_id' => 'required',
|
|
|
|
+ 'parent_id' => 'required',
|
|
'store_id' => 'required',
|
|
'store_id' => 'required',
|
|
], [
|
|
], [
|
|
'cat_id.required' => '缺少分类参数',
|
|
'cat_id.required' => '缺少分类参数',
|
|
|
|
+ 'parent_id.required' => '缺少父分类参数',
|
|
'store_id.required' => '缺少商户参数',
|
|
'store_id.required' => '缺少商户参数',
|
|
]);
|
|
]);
|
|
if ($validator->fails()) {
|
|
if ($validator->fails()) {
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
}
|
|
}
|
|
$data = $request->input();
|
|
$data = $request->input();
|
|
- //dd($data);
|
|
|
|
$cat_id = request('cat_id');
|
|
$cat_id = request('cat_id');
|
|
$store_id = request('store_id');
|
|
$store_id = request('store_id');
|
|
$parent_id = request('parent_id');
|
|
$parent_id = request('parent_id');
|
|
- $style = request('style_id');
|
|
|
|
|
|
|
|
- $select_info = ['cat_id' => $cat_id, 'style' => $style];
|
|
|
|
|
|
+
|
|
|
|
+ $select_info = ['cat_id' => $cat_id,'parent_id' => $parent_id];
|
|
|
|
+
|
|
if ($userAuth->up_agent_id != 0 && $cat_id != "undefined" && $parent_id != "undefined") {
|
|
if ($userAuth->up_agent_id != 0 && $cat_id != "undefined" && $parent_id != "undefined") {
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
$add_record['open_id'] = $userAuth->open_id;
|
|
$add_record['open_id'] = $userAuth->open_id;
|
|
@@ -373,8 +362,9 @@ class AlbumController extends Controller
|
|
}
|
|
}
|
|
if (isset($data['keywords']) && !empty($data['keywords'])) {
|
|
if (isset($data['keywords']) && !empty($data['keywords'])) {
|
|
$keywords = '%' . $data['keywords'] . '%';
|
|
$keywords = '%' . $data['keywords'] . '%';
|
|
- $goods = AlbumProductModel::where([
|
|
|
|
- ['name','like',$keywords],['store_id',$data['store_id']],['cat_id',$cat_id],['store_id',$store_id]]);
|
|
|
|
|
|
+
|
|
|
|
+ $goods = AlbumProductModel::where([['name','like',$keywords],['store_id',$data['store_id']],['cat_id',$cat_id],['store_id',$store_id]]);
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
$goods = AlbumProductModel::where([['cat_id',$cat_id],['store_id',$store_id]]);
|
|
$goods = AlbumProductModel::where([['cat_id',$cat_id],['store_id',$store_id]]);
|
|
}
|
|
}
|
|
@@ -386,14 +376,17 @@ class AlbumController extends Controller
|
|
$set_show_price = 0;
|
|
$set_show_price = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
if ($userAuth->is_dealer == 1) {
|
|
if ($userAuth->is_dealer == 1) {
|
|
$agent_me = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
$agent_me = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
$set_show_price = $agent_me->is_show_ma_price;
|
|
$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')
|
|
$goods = $goods->select('id', 'cover_pic', 'thumb', 'name', 'style', 'hot_cake', 'news', 'price_default', 'ma_price', 'ma_price_comment')
|
|
->orderByDesc('sort')->paginate(9);
|
|
->orderByDesc('sort')->paginate(9);
|
|
|
|
|
|
|
|
+
|
|
foreach ($goods as $key => $val) {
|
|
foreach ($goods as $key => $val) {
|
|
if ($userAuth->is_dealer != 1) {
|
|
if ($userAuth->is_dealer != 1) {
|
|
if ($userAuth->up_agent_id == 0) {
|
|
if ($userAuth->up_agent_id == 0) {
|
|
@@ -514,17 +507,16 @@ class AlbumController extends Controller
|
|
}
|
|
}
|
|
$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();
|
|
$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['agent_id'] = $userAuth->up_agent_id;
|
|
$cat_record['open_id'] = $userAuth->open_id;
|
|
$cat_record['open_id'] = $userAuth->open_id;
|
|
$cat_record['store_id'] = $store_id;
|
|
$cat_record['store_id'] = $store_id;
|
|
- $cat_record['style_id'] = $goods->style;
|
|
|
|
$cat_record['cat_id'] = $goods->cat_id;
|
|
$cat_record['cat_id'] = $goods->cat_id;
|
|
CustomerCatRecordModel::create($cat_record);
|
|
CustomerCatRecordModel::create($cat_record);
|
|
if (!empty($goods) && $userAuth->is_dealer != 1) {
|
|
if (!empty($goods) && $userAuth->is_dealer != 1) {
|
|
- $price = DB::table('album_product_price')->where([
|
|
|
|
- ['agent_id',$userAuth->up_agent_id],['store_id',$store_id],['product_id',$goods['id']]
|
|
|
|
- ])->first();
|
|
|
|
|
|
+
|
|
|
|
+ $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;
|
|
$goods->price = $price->price;
|
|
} else {
|
|
} else {
|
|
@@ -540,8 +532,10 @@ class AlbumController extends Controller
|
|
$goods->favorite_id = '';
|
|
$goods->favorite_id = '';
|
|
}
|
|
}
|
|
} elseif (!empty($goods) && $userAuth->is_dealer == 1) {
|
|
} 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();
|
|
|
|
|
|
+
|
|
|
|
+ $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)) {
|
|
if (!empty($price)) {
|
|
$goods->price = $price->price;
|
|
$goods->price = $price->price;
|
|
} else {
|
|
} else {
|
|
@@ -625,18 +619,20 @@ class AlbumController extends Controller
|
|
public function albumFavoriteList(Request $request)
|
|
public function albumFavoriteList(Request $request)
|
|
{
|
|
{
|
|
$userAuth = Auth('api')->user();
|
|
$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(), [
|
|
$validator = Validator::make($request->all(), [
|
|
'store_id' => 'required',
|
|
'store_id' => 'required',
|
|
- ],[
|
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
|
|
|
+ ], [
|
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
]);
|
|
]);
|
|
if ($validator->fails()) {
|
|
if ($validator->fails()) {
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
}
|
|
}
|
|
$data = $request->input();
|
|
$data = $request->input();
|
|
$favorite = AlbumFavoriteModel::where([['user_id',$userAuth->id],['store_id',$data['store_id']]])->get();
|
|
$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();
|
|
$favorite[$key]['goods'] = AlbumProductModel::where([['id',$val['product_id']],['store_id',$data['store_id']]])->first();
|
|
}
|
|
}
|
|
return $this->api($favorite);
|
|
return $this->api($favorite);
|
|
@@ -689,92 +685,107 @@ class AlbumController extends Controller
|
|
public function albumGetWatchRecord(Request $request)
|
|
public function albumGetWatchRecord(Request $request)
|
|
{
|
|
{
|
|
$userAuth = Auth('api')->user();
|
|
$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(), [
|
|
$validator = Validator::make($request->all(), [
|
|
'store_id' => 'required',
|
|
'store_id' => 'required',
|
|
- 'type'=>'required'
|
|
|
|
- ],[
|
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
|
- 'type.required'=>'缺少类型参数',
|
|
|
|
|
|
+ 'type' => 'required'
|
|
|
|
+ ], [
|
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
|
+ 'type.required' => '缺少类型参数',
|
|
]);
|
|
]);
|
|
if ($validator->fails()) {
|
|
if ($validator->fails()) {
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
}
|
|
}
|
|
$type = $request->input('type');
|
|
$type = $request->input('type');
|
|
$store_id = $request->input('store_id');
|
|
$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]]);
|
|
$query = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id]]);
|
|
- switch ($type){
|
|
|
|
|
|
+ switch ($type) {
|
|
case '1':
|
|
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'));
|
|
$user = AlbumUserModel::find(request('user_id'));
|
|
- $query = $query->where('open_id',$user->open_id);
|
|
|
|
|
|
+ $query = $query->where('open_id', $user->open_id);
|
|
break;
|
|
break;
|
|
case '2':
|
|
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]]);
|
|
$query = $query->where([['created_at','>=',$start_time],['created_at','<=',$end_time]]);
|
|
-
|
|
|
|
break;
|
|
break;
|
|
case '3':
|
|
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')]]);
|
|
$query = $query->where([['action',$request->input('action')]]);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
$res = $query->get();
|
|
$res = $query->get();
|
|
$action = '';
|
|
$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 = '进入我的画册';
|
|
$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_id = $goods_data['goods_id'];
|
|
$goods = AlbumProductModel::find($goods_id);
|
|
$goods = AlbumProductModel::find($goods_id);
|
|
if (!$goods) {
|
|
if (!$goods) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
$cat = AlbumCatModel::find($goods->cat_id);
|
|
$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']);
|
|
$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_id = $goods_data['goods_id'];
|
|
$goods = AlbumProductModel::find($goods_id);
|
|
$goods = AlbumProductModel::find($goods_id);
|
|
if (!$goods) {
|
|
if (!$goods) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
$cat = AlbumCatModel::find($goods->cat_id);
|
|
$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'];
|
|
|
|
- }elseif($val->action==6){
|
|
|
|
- $detail = json_decode($val->detail,true);
|
|
|
|
|
|
+ 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'];
|
|
$address = $detail['detail'];
|
|
- $action = '查看了您的地址'.$address.',并且点击了导航';
|
|
|
|
- }elseif($val->action==7){
|
|
|
|
- $detail = json_decode($val->detail,true);
|
|
|
|
|
|
+ $action = '查看了您的地址' . $address . ',并且点击了导航';
|
|
|
|
+ } elseif ($val->action == 7) {
|
|
|
|
+ $detail = json_decode($val->detail, true);
|
|
$phone = $detail['detail'];
|
|
$phone = $detail['detail'];
|
|
- $action = '查看了您的电话'.$phone.',并且点击了拨号';
|
|
|
|
|
|
+ $action = '查看了您的电话' . $phone . ',并且点击了拨号';
|
|
}
|
|
}
|
|
-
|
|
|
|
- $user = AlbumUserModel::where([['open_id',$val->open_id],['store_id',$val->store_id]])->select(['username','avatar','phone'])->first();
|
|
|
|
- // dd(111);
|
|
|
|
|
|
+ $user = AlbumUserModel::where([
|
|
|
|
+ ['open_id',$val->open_id],['store_id',$val->store_id]
|
|
|
|
+ ])->select(['username','avatar','phone'])->first();
|
|
$data_res[] = [
|
|
$data_res[] = [
|
|
- 'time'=>$val->created_at,
|
|
|
|
- 'action'=>$action,
|
|
|
|
- 'user'=>$user
|
|
|
|
|
|
+ 'time' => $val->created_at,
|
|
|
|
+ 'action' => $action,
|
|
|
|
+ 'user' => $user
|
|
];
|
|
];
|
|
}
|
|
}
|
|
return $this->api(compact('data_res'));
|
|
return $this->api(compact('data_res'));
|
|
@@ -818,40 +829,43 @@ class AlbumController extends Controller
|
|
public function albumGetDataGoods(Request $request)
|
|
public function albumGetDataGoods(Request $request)
|
|
{
|
|
{
|
|
$userAuth = Auth('api')->user();
|
|
$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(), [
|
|
$validator = Validator::make($request->all(), [
|
|
'store_id' => 'required'
|
|
'store_id' => 'required'
|
|
- ],[
|
|
|
|
- 'store_id.required'=>'缺少商户参数'
|
|
|
|
|
|
+ ], [
|
|
|
|
+ 'store_id.required' => '缺少商户参数'
|
|
]);
|
|
]);
|
|
if ($validator->fails()) {
|
|
if ($validator->fails()) {
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
}
|
|
}
|
|
$store_id = $request->input('store_id');
|
|
$store_id = $request->input('store_id');
|
|
- 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();
|
|
|
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
$res = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['action',3]])->get();
|
|
$res = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['action',3]])->get();
|
|
$arr = array();
|
|
$arr = array();
|
|
$total = 0;
|
|
$total = 0;
|
|
-
|
|
|
|
- foreach($res as $key=>$val){
|
|
|
|
- $goods_data = json_decode($val->detail,true);
|
|
|
|
|
|
+ foreach ($res as $key => $val) {
|
|
|
|
+ $goods_data = json_decode($val->detail, true);
|
|
$goods_id = $goods_data['goods_id'];
|
|
$goods_id = $goods_data['goods_id'];
|
|
$goods = AlbumProductModel::find($goods_id);
|
|
$goods = AlbumProductModel::find($goods_id);
|
|
if (!$goods) {
|
|
if (!$goods) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if(isset($arr[$goods->id])){
|
|
|
|
|
|
+ if (isset($arr[$goods->id])) {
|
|
$arr[$goods->id]['num']++;
|
|
$arr[$goods->id]['num']++;
|
|
- }else{
|
|
|
|
- $arr[$goods->id]['num']=1;
|
|
|
|
- $arr[$goods->id]['name']=$goods->name;
|
|
|
|
|
|
+ } else {
|
|
|
|
+ $arr[$goods->id]['num'] = 1;
|
|
|
|
+ $arr[$goods->id]['name'] = $goods->name;
|
|
}
|
|
}
|
|
$total++;
|
|
$total++;
|
|
}
|
|
}
|
|
- foreach($arr as $key=>$val){
|
|
|
|
- $arr[$key]['point'] = ($val['num']/$total*100).'%';
|
|
|
|
|
|
+ foreach ($arr as $key => $val) {
|
|
|
|
+ $arr[$key]['point'] = ($val['num'] / $total * 100) . '%';
|
|
}
|
|
}
|
|
return $this->api(compact('arr'));
|
|
return $this->api(compact('arr'));
|
|
}
|
|
}
|
|
@@ -864,7 +878,7 @@ class AlbumController extends Controller
|
|
* @apiPermission 需要登录
|
|
* @apiPermission 需要登录
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
- * @apiParam {int} [style_id]
|
|
|
|
|
|
+ * @apiParam {int} [parent_id]
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
* {
|
|
* {
|
|
@@ -895,34 +909,38 @@ class AlbumController extends Controller
|
|
public function albumGetDataCat(Request $request)
|
|
public function albumGetDataCat(Request $request)
|
|
{
|
|
{
|
|
$userAuth = Auth('api')->user();
|
|
$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(), [
|
|
$validator = Validator::make($request->all(), [
|
|
'store_id' => 'required',
|
|
'store_id' => 'required',
|
|
- 'style_id' => 'required'
|
|
|
|
- ],[
|
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
|
- 'style_id.required'=>'缺少风格参数',
|
|
|
|
|
|
+ 'parent_id' => 'required'
|
|
|
|
+ ], [
|
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
|
+ 'parent_id.required' => '缺少风格参数',
|
|
]);
|
|
]);
|
|
if ($validator->fails()) {
|
|
if ($validator->fails()) {
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
}
|
|
}
|
|
$store_id = $request->input('store_id');
|
|
$store_id = $request->input('store_id');
|
|
- $style_id = $request->input('style_id');
|
|
|
|
- if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
|
|
|
+ $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();
|
|
|
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
|
|
+ $cat = AlbumCatModel::where([['store_id',$store_id],['parent_id', $parent_id]])->get(['name','id'])->toArray();
|
|
$total = 0;
|
|
$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();
|
|
|
|
|
|
+ foreach ($cat as $key => $val){
|
|
|
|
+ $count = CustomerCatRecordModel::where([['agent_id',$user_agent->id],['store_id',$store_id],['cat_id',$val['id']]])->count();
|
|
$total += $count;
|
|
$total += $count;
|
|
$cat[$key]['num'] = $count;
|
|
$cat[$key]['num'] = $count;
|
|
}
|
|
}
|
|
- foreach($cat as $key=>$val){
|
|
|
|
- if($val['num']==0||$total==0){
|
|
|
|
- $cat[$key]['point']=0;
|
|
|
|
- }else{
|
|
|
|
- $cat[$key]['point'] = ($val['num']/$total*100).'%';
|
|
|
|
|
|
+ foreach ($cat as $key => $val) {
|
|
|
|
+ if ($val['num'] == 0 || $total == 0) {
|
|
|
|
+ $cat[$key]['point'] = 0;
|
|
|
|
+ } else {
|
|
|
|
+ $cat[$key]['point'] = ($val['num'] / $total * 100) . '%';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $this->api(compact('cat'));
|
|
return $this->api(compact('cat'));
|
|
@@ -937,6 +955,7 @@ class AlbumController extends Controller
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
* @apiParam {int} [open_id]
|
|
* @apiParam {int} [open_id]
|
|
|
|
+ * @apiParam {int} [parent_id]
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
* {
|
|
* {
|
|
@@ -967,16 +986,18 @@ class AlbumController extends Controller
|
|
public function albumGetDataCatSingle(Request $request)
|
|
public function albumGetDataCatSingle(Request $request)
|
|
{
|
|
{
|
|
$userAuth = Auth('api')->user();
|
|
$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(), [
|
|
$validator = Validator::make($request->all(), [
|
|
'store_id' => 'required',
|
|
'store_id' => 'required',
|
|
'open_id' => 'required',
|
|
'open_id' => 'required',
|
|
- // 'end' => 'required',
|
|
|
|
- //'start' => 'required',
|
|
|
|
- ],[
|
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
|
- 'open_id.required'=>'缺少风格参数',
|
|
|
|
- // 'end.required'=>'缺少结束时间参数',
|
|
|
|
|
|
+ 'parent_id' => 'required'
|
|
|
|
+ ], [
|
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
|
+ 'open_id.required' => '缺少风格参数',
|
|
|
|
+ 'parent_id.required' => '缺少父分类参数',
|
|
|
|
+ // 'end.required'=>'缺少结束时间参数',
|
|
//'start.required'=>'缺少开始时间参数',
|
|
//'start.required'=>'缺少开始时间参数',
|
|
]);
|
|
]);
|
|
if ($validator->fails()) {
|
|
if ($validator->fails()) {
|
|
@@ -984,6 +1005,7 @@ class AlbumController extends Controller
|
|
}
|
|
}
|
|
$store_id = $request->input('store_id');
|
|
$store_id = $request->input('store_id');
|
|
$open_id = $request->input('open_id');
|
|
$open_id = $request->input('open_id');
|
|
|
|
+ $parent_id = $request->input('parent_id');
|
|
$end = $request->input('end');
|
|
$end = $request->input('end');
|
|
$start = $request->input('start');
|
|
$start = $request->input('start');
|
|
if (!$end) {
|
|
if (!$end) {
|
|
@@ -992,23 +1014,24 @@ class AlbumController extends Controller
|
|
if (!$start) {
|
|
if (!$start) {
|
|
$start = 0;
|
|
$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();
|
|
|
|
|
|
+ $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],['parent_id',$parent_id]])->get(['name','id'])->toArray();
|
|
$total = 0;
|
|
$total = 0;
|
|
- foreach ($cat as $key=>$val){
|
|
|
|
|
|
+ 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();
|
|
$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;
|
|
$total += $count;
|
|
$cat[$key]['num'] = $count;
|
|
$cat[$key]['num'] = $count;
|
|
}
|
|
}
|
|
- foreach($cat as $key=>$val){
|
|
|
|
- if($val['num']==0||$total==0){
|
|
|
|
- $cat[$key]['point']=0;
|
|
|
|
- }else{
|
|
|
|
- $cat[$key]['point'] = ($val['num']/$total*100).'%';
|
|
|
|
|
|
+ foreach ($cat as $key => $val) {
|
|
|
|
+ if ($val['num'] == 0 || $total == 0) {
|
|
|
|
+ $cat[$key]['point'] = 0;
|
|
|
|
+ } else {
|
|
|
|
+ $cat[$key]['point'] = ($val['num'] / $total * 100) . '%';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $this->api(compact('cat'));
|
|
return $this->api(compact('cat'));
|
|
@@ -1063,15 +1086,17 @@ class AlbumController extends Controller
|
|
public function albumGetCartOfWatch(Request $request)
|
|
public function albumGetCartOfWatch(Request $request)
|
|
{
|
|
{
|
|
$userAuth = Auth('api')->user();
|
|
$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(), [
|
|
$validator = Validator::make($request->all(), [
|
|
'store_id' => 'required',
|
|
'store_id' => 'required',
|
|
'end' => 'required',
|
|
'end' => 'required',
|
|
'start' => 'required',
|
|
'start' => 'required',
|
|
- ],[
|
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
|
- 'end.required'=>'缺少结束时间参数',
|
|
|
|
- 'start.required'=>'缺少开始时间参数',
|
|
|
|
|
|
+ ], [
|
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
|
+ 'end.required' => '缺少结束时间参数',
|
|
|
|
+ 'start.required' => '缺少开始时间参数',
|
|
]);
|
|
]);
|
|
if ($validator->fails()) {
|
|
if ($validator->fails()) {
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
@@ -1347,8 +1372,12 @@ class AlbumController extends Controller
|
|
$add['favorite_times'] = 1;
|
|
$add['favorite_times'] = 1;
|
|
AlbumStatisticalModel::create($add);
|
|
AlbumStatisticalModel::create($add);
|
|
}
|
|
}
|
|
- $select_info = ['goods_id'=>$data['product_id']];
|
|
|
|
- if($userAuth->up_agent_id!=0){
|
|
|
|
|
|
+ $select_info = ['goods_id' => $data['product_id']];
|
|
|
|
+ if ($userAuth->up_agent_id != 0) {
|
|
|
|
+ $agent = AlbumAgentModel::where('id'. 'up_agent_id')->first();
|
|
|
|
+ $agent->favoriteCount++;
|
|
|
|
+ $agent->newCount = $agent->pointCount + $agent->favoriteCount + $agent->callCount + $agent->share_times + $agent->get_count;
|
|
|
|
+ $agent->save();
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
$add_record['open_id'] = $userAuth->open_id;
|
|
$add_record['open_id'] = $userAuth->open_id;
|
|
$add_record['action'] = 1;
|
|
$add_record['action'] = 1;
|
|
@@ -1532,6 +1561,7 @@ class AlbumController extends Controller
|
|
$user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
$user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
$agent_id = $user_agent['id'];
|
|
$agent_id = $user_agent['id'];
|
|
$data = $request->all();
|
|
$data = $request->all();
|
|
|
|
+ $product = AlbumProductModel::where('id', $data['goods_id'])->first();
|
|
//print_r($data);
|
|
//print_r($data);
|
|
$save = array();
|
|
$save = array();
|
|
$return_data = array();
|
|
$return_data = array();
|
|
@@ -1541,6 +1571,8 @@ class AlbumController extends Controller
|
|
if(empty($check)){
|
|
if(empty($check)){
|
|
$save['agent_id'] = $agent_id;
|
|
$save['agent_id'] = $agent_id;
|
|
$save['store_id'] = $data['store_id'];
|
|
$save['store_id'] = $data['store_id'];
|
|
|
|
+ $save['cat_id'] = $product->cat_id;
|
|
|
|
+ $save['name'] = $product->name;
|
|
$save['product_id'] = $data['goods_id'];
|
|
$save['product_id'] = $data['goods_id'];
|
|
$res = AlbumProductPriceModel::create($save);
|
|
$res = AlbumProductPriceModel::create($save);
|
|
}else{
|
|
}else{
|
|
@@ -1707,6 +1739,11 @@ class AlbumController extends Controller
|
|
// dd($add_record);
|
|
// dd($add_record);
|
|
$res = AlbumWatchRecord::create($add_record);
|
|
$res = AlbumWatchRecord::create($add_record);
|
|
$user_agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
$user_agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
|
+ if ($data['type'] == 7 || $data['type'] == 6) {
|
|
|
|
+ $user_agent->callCount++;
|
|
|
|
+ $user_agent->newCount = $user_agent->pointCount + $user_agent->favoriteCount + $user_agent->callCount + $user_agent->share_times + $user_agent->get_count;
|
|
|
|
+ $user_agent->save();
|
|
|
|
+ }
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
$agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
|
|
if($res){
|
|
if($res){
|
|
try{
|
|
try{
|
|
@@ -1904,7 +1941,7 @@ class AlbumController extends Controller
|
|
}
|
|
}
|
|
$data = $request->input();
|
|
$data = $request->input();
|
|
$url = "https://apis.map.qq.com/ws/geocoder/v1/?address=".$data['address']."&key=".env('QQMAP');
|
|
$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);
|
|
$res = json_decode($local,true);
|
|
$agent_check = AlbumAgentModel::where([['store_id',$data['store_id']],['user_id',$userAuth->id]])->first();
|
|
$agent_check = AlbumAgentModel::where([['store_id',$data['store_id']],['user_id',$userAuth->id]])->first();
|
|
if($agent_check){
|
|
if($agent_check){
|
|
@@ -2338,6 +2375,7 @@ class AlbumController extends Controller
|
|
if (!$end) {
|
|
if (!$end) {
|
|
$end = time();
|
|
$end = time();
|
|
}
|
|
}
|
|
|
|
+
|
|
if (!$start) {
|
|
if (!$start) {
|
|
$start = 0;
|
|
$start = 0;
|
|
}
|
|
}
|
|
@@ -2353,10 +2391,30 @@ class AlbumController extends Controller
|
|
$goods_id = $detail['goods_id'];
|
|
$goods_id = $detail['goods_id'];
|
|
$goods = AlbumProductModel::where([['id',$goods_id]])->first();
|
|
$goods = AlbumProductModel::where([['id',$goods_id]])->first();
|
|
if($goods){
|
|
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();
|
|
$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];
|
|
|
|
|
|
+ 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,
|
|
|
|
+ 'cat' => $cat->name,
|
|
|
|
+ 'thumb' => $goods->thumb,
|
|
|
|
+ 'time' => date('Y-m-d H:i', strtotime($val['created_at'])),
|
|
|
|
+ 'times' => 1
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ $arr[date('Y-m-d H:i', strtotime($val['created_at']))][$goods->id] = [
|
|
|
|
+ 'name' => $goods->name,
|
|
|
|
+ 'cat' => $cat->name,
|
|
|
|
+ 'thumb' => $goods->thumb,
|
|
|
|
+ 'time' => date('Y-m-d H:i', strtotime($val['created_at'])),
|
|
|
|
+ 'times' => 1
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ krsort($arr);
|
|
}
|
|
}
|
|
return $this->api($arr,0,'success');
|
|
return $this->api($arr,0,'success');
|
|
}
|
|
}
|
|
@@ -2519,10 +2577,10 @@ class AlbumController extends Controller
|
|
}
|
|
}
|
|
$store_id = $request->input('store_id');
|
|
$store_id = $request->input('store_id');
|
|
$goods_id = $request->input('goods_id');
|
|
$goods_id = $request->input('goods_id');
|
|
-
|
|
|
|
if($userAuth->up_agent_id !=0){
|
|
if($userAuth->up_agent_id !=0){
|
|
$user_agent = AlbumAgentModel::where([['id',$userAuth->up_agent_id],['status',1]])->first();
|
|
$user_agent = AlbumAgentModel::where([['id',$userAuth->up_agent_id],['status',1]])->first();
|
|
$user_agent->share_times++;
|
|
$user_agent->share_times++;
|
|
|
|
+ $user_agent->newCount = $user_agent->pointCount + $user_agent->favoriteCount + $user_agent->callCount + $user_agent->share_times + $user_agent->get_count;
|
|
$user_agent->save();
|
|
$user_agent->save();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2705,6 +2763,7 @@ class AlbumController extends Controller
|
|
$user_agent->is_show_ma_price = $data['is_show_ma_price'];
|
|
$user_agent->is_show_ma_price = $data['is_show_ma_price'];
|
|
$user_agent->save();
|
|
$user_agent->save();
|
|
|
|
|
|
|
|
+
|
|
$product = AlbumProductModel::where('store_id',$data['store_id'])->get(['id','ma_price']);
|
|
$product = AlbumProductModel::where('store_id',$data['store_id'])->get(['id','ma_price']);
|
|
foreach ($product as $key=>$val) {
|
|
foreach ($product as $key=>$val) {
|
|
$save['price'] = $val['ma_price'] * (1 + $data['point'] / 100);
|
|
$save['price'] = $val['ma_price'] * (1 + $data['point'] / 100);
|
|
@@ -2712,6 +2771,8 @@ class AlbumController extends Controller
|
|
if(empty($check)){
|
|
if(empty($check)){
|
|
$save['agent_id'] = $user_agent->id;
|
|
$save['agent_id'] = $user_agent->id;
|
|
$save['store_id'] = $data['store_id'];
|
|
$save['store_id'] = $data['store_id'];
|
|
|
|
+ $save['cat_id'] = $val['cat_id'];
|
|
|
|
+ $save['name'] = $val['name'];
|
|
$save['product_id'] = $val['id'];
|
|
$save['product_id'] = $val['id'];
|
|
AlbumProductPriceModel::create($save);
|
|
AlbumProductPriceModel::create($save);
|
|
}else{
|
|
}else{
|
|
@@ -2720,6 +2781,7 @@ class AlbumController extends Controller
|
|
}
|
|
}
|
|
$user_agent->set_price_point = $data['point'];
|
|
$user_agent->set_price_point = $data['point'];
|
|
$user_agent->save();
|
|
$user_agent->save();
|
|
|
|
+
|
|
return $this->api([],0,'success');
|
|
return $this->api([],0,'success');
|
|
}
|
|
}
|
|
}
|
|
}
|