| xqd
@@ -350,15 +350,19 @@ class AlbumController extends Controller
|
|
|
public function albumGoods(Request $request)
|
|
|
{
|
|
|
$userAuth = Auth('api')->user();
|
|
|
- if(!$userAuth) return $this->error(ErrorCode::ERROR_POWER, '登陆过期!');
|
|
|
+ if (!$userAuth) {
|
|
|
+ return $this->error(ErrorCode::ERROR_POWER, '登陆过期!');
|
|
|
+ }
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'cat_id' => 'required',
|
|
|
+ 'parent_id' => 'required',
|
|
|
'store_id' => 'required',
|
|
|
'status' => 'required',
|
|
|
- ],[
|
|
|
- 'cat_id.required'=>'缺少分类参数',
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
- 'status.required'=>'缺少状态参数',
|
|
|
+ ], [
|
|
|
+ 'cat_id.required' => '缺少分类参数',
|
|
|
+ 'parent_id.required' => '缺少父分类参数',
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ 'status.required' => '缺少状态参数',
|
|
|
]);
|
|
|
if ($validator->fails()) {
|
|
|
return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
| xqd
@@ -369,84 +373,72 @@ class AlbumController extends Controller
|
|
|
$store_id = request('store_id');
|
|
|
$status = request('status');
|
|
|
$style = request('style');
|
|
|
+ $parent_id = request('parent_id');
|
|
|
|
|
|
- $select_info = ['cat_id'=>$cat_id,'style'=>$style];
|
|
|
- if($userAuth->up_agent_id!=0&&$cat_id!="undefined"&&$style!="undefined"){
|
|
|
+ $select_info = ['cat_id' => $cat_id,'parent_id' => $parent_id];
|
|
|
+ if ($userAuth->up_agent_id != 0 && $cat_id != "undefined" && $parent_id != "undefined") {
|
|
|
$add_record['agent_id'] = $userAuth->up_agent_id;
|
|
|
$add_record['open_id'] = $userAuth->open_id;
|
|
|
$add_record['action'] = 2;
|
|
|
$add_record['store_id'] = $store_id;
|
|
|
$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,2,$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, 2, $userAuth->username, $agent->g_open_id);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ \Log::info($e);
|
|
|
}
|
|
|
}
|
|
|
- if(isset($data['keywords'])&&!empty($data['keywords'])) {
|
|
|
- $keywords = '%'.$data['keywords'].'%';
|
|
|
+ if (isset($data['keywords']) && !empty($data['keywords'])) {
|
|
|
+ $keywords = '%' . $data['keywords'] . '%';
|
|
|
$goods = AlbumProductModel::where([['name','like',$keywords],['store_id',$data['store_id']],['cat_id',$cat_id],['store_id',$store_id]]);
|
|
|
} else {
|
|
|
$goods = AlbumProductModel::where([['cat_id',$cat_id],['store_id',$store_id]]);
|
|
|
}
|
|
|
- if($status == 1) {
|
|
|
- $goods->where([['hot_cake', 1]]);
|
|
|
- }
|
|
|
- if($status == 2){
|
|
|
- $goods->where('news',1);
|
|
|
- }
|
|
|
- if($status == 3){
|
|
|
- $goods->where('style',$style);
|
|
|
- }
|
|
|
|
|
|
if ($userAuth->up_agent_id != 0) {
|
|
|
-
|
|
|
-
|
|
|
- $agent_in = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
+ $agent_in = AlbumAgentModel::where('id', $userAuth->up_agent_id)->first();
|
|
|
$set_show_price = $agent_in->is_show_ma_price;
|
|
|
-
|
|
|
} else {
|
|
|
$set_show_price = 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
+ $goods = $goods->select('id', 'cover_pic', 'thumb', 'name', 'style', 'hot_cake', 'news', 'price_default', 'ma_price', 'ma_price_comment')->orderByDesc('sort')->paginate(9);
|
|
|
|
|
|
- $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){
|
|
|
- if($userAuth->up_agent_id==0){
|
|
|
+ foreach ($goods as $key => $val) {
|
|
|
+ if ($userAuth->is_dealer != 1) {
|
|
|
+ if ($userAuth->up_agent_id == 0) {
|
|
|
$goods[$key]['price'] = '';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$check = AlbumProductPriceModel::where([['agent_id',$userAuth->up_agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
|
- if($check){
|
|
|
+ if ($check) {
|
|
|
$goods[$key]['price'] = $check->price;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$goods[$key]['price'] = '';
|
|
|
}
|
|
|
}
|
|
|
- }elseif($userAuth->is_dealer == 1){
|
|
|
- $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ } elseif ($userAuth->is_dealer == 1) {
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id', $userAuth->id)->first();
|
|
|
$agent_id = $user_agent['id'];
|
|
|
$check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
|
- if($check){
|
|
|
+ if ($check) {
|
|
|
$goods[$key]['price'] = $check->price;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$goods[$key]['price'] = '';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- $data =AlbumManufacturerModel::where('store_id',$store_id)->first();
|
|
|
+ $data = AlbumManufacturerModel::where('store_id', $store_id)->first();
|
|
|
$name = $data['name'];
|
|
|
- return $this->api(compact('goods','name','set_show_price'));
|
|
|
+ return $this->api(compact('goods', 'name', 'set_show_price'));
|
|
|
}
|
|
|
|
|
|
|