source = request()->header('source'); $this->merId = request()->header('merId'); } //大仓列表 public function da_cang_lst() { $list=Db::name('big_warehouse')->where('status',1)->field('id,logo,warehouse_name')->select()->toArray(); return app('json')->success($list); } //大仓分类 public function classify(){ // $merid=$this->merId; $merid = $this->request->params(['mer_id']); $cate_arr=[]; $list = Db::name('store_category') -> where('is_show',1) -> when( !$this->source ,function($query) use ($merid){ $query->where('pid',564); }) -> when( $this->source =='yhc',function($q) use ($cate_arr,$merid){ $q->where(function($q1) use ($cate_arr) { $q1->where(function($query) use ($cate_arr) { $query->where('pid', 564)->whereIn('cate_name', $cate_arr); })->whereOr('mer_id', 496); }); }) -> field('store_category_id,cate_name') -> order('sort desc') -> group('cate_name') -> select(); foreach ($list as $key => $item) { $product = Db::name('store_product') ->where('is_show',1) ->where('status',1) ->where('mer_id',$merid) ->where('cate_id',$item['store_category_id']) ->limit(1) ->find(); if(!$product) unset($list[$key]); } return app('json')->success($list); } //大仓列表商品1 public function da_cang_product_lst() { [$page, $limit] = $this->getPage(); $classify = $this -> request -> params(['classify','keyword']); $where=[ 'is_used'=>1, 'mer_status'=>1, // 'type'=>5, 'is_show'=>1, 'is_hide'=>0, 'is_del' => 0 ]; $product_id=[]; $cateIds=[]; if (isset($classify['classify']) && !empty($classify['classify'])){ $where['cate_id'] = $classify['classify']; } $make2 = app()->make(Goods::class); $gongProduct439=$make2->getJoinProduct439(); $ProductRepository=app() -> make(ProductRepository::class); $product_data=Db::name('store_product')->where($where) ->when(isset($classify['keyword']) && !empty($classify['keyword']), function ($query) use ($classify) { $query->where('store_name', 'like', "%" . $classify['keyword'] . "%"); })->when(!$this->source, function ($q1) use ($gongProduct439) { $q1->where(function ($query) use ($gongProduct439) { $query->whereNotIn('spu_id', $gongProduct439)->whereOr("spu_id is null"); }); })->when(!$this->source, function ($query) { $query->where('type=5 or mer_id= 595'); // $query2->where('spu_id IS NOT NULL')->whereOr("mer_id","321"); // })->when(isset($product_id) && count($product_id), function ($query) use ($product_id) { // $query->whereIn('product_id',$product_id); // }) }) ->order('sort desc,create_time desc') ->page($page,$limit) ->select()->toArray(); // echo Db::getlastsql();die; foreach ($product_data as &$product){ $product['price']=set_price_rtrim($product['price']); $product['cost']=set_price_rtrim($product['cost']); $product['ot_price']=set_price_rtrim($product['ot_price']); $product['flag']='1'; $product['yanglao']=set_price_rtrim($ProductRepository->yanglaojin($product['product_id'],0,1));//养老金 $product['yanglao']=isset($product['yanglao']) && $product['yanglao']!=''? $product['yanglao']:0; $dacang_price=Db::name('store_product_attr_value')->where('product_id',$product['product_id'])->order('dacang_price','asc')->limit(1)->value('dacang_price'); $product['da_cang_price']=set_price_rtrim($dacang_price); $product['yanglao_price']= $product['yanglao']; if($product['spu_id']!=''){ $product['type']=5; } if(isset($product['type'])){ $product['type']=(int)$product['type']; } } return app('json')->success($product_data); } //大仓介绍 public function introduce($id) { $data=Db::name('big_warehouse')->where('id',$id)->find();//查询ID为它的数据 if($data) return app('json')->success($data); return app('json')->fail(''); } //大仓首页商品列表 public function dc_home_product($id) { [$page, $limit] = $this->getPage(); $where=[ 'is_used'=>1, 'mer_status'=>1, 'type'=>5, 'is_show'=>1, 'is_hide'=>0, 'is_del' => 0 ]; $ProductRepository=app() -> make(ProductRepository::class); $product_data=Db::name('store_product')->where('dc_id',$id)->where($where)->page($page,$limit)->select()->toArray(); foreach ($product_data as &$product){ $product['flag']='1'; $product['yanglao']=$ProductRepository->yanglaojin($product['product_id']);//养老金 $product['da_cang_price']=Db::name('store_product_attr_value')->where('product_id',$product['product_id'])->order('dacang_price','asc')->limit(1)->value('dacang_price'); } return app('json')->success($product_data); } //大仓首页商户 public function dc_home_merchant($id) { $data=Db::name('merchant')->where('dc_id',$id)->field('mer_id,mer_name,mer_avatar')->select()->toArray(); return app('json')->success($data); } }