repository = $repository; $this->userInfo =$this->request->isLogin() ? $this->request->userInfo():null; $this->source = $this->request->header('source'); $this->merId = $this->request->header('merId'); } /** * @Author:Qinii * @Date: 2020/5/27 * @return mixed */ public function lst() { [$page, $limit] = $this->getPage(); $where = $this->request->params(['keyword','order','category_id']); return json_encode($where); return app('json')->success($this->repository->getList($where, $page,$limit,$this->userInfo)); } /** * @Author:Qinii * @Date: 2020/5/29 * @param $id * @return mixed */ public function detail($id) { if(!$this->repository->apiGetOne($id)) return app('json')->fail('店铺不存在'); $lat=$this->request->param('lat',''); $lng=$this->request->param('lng',''); return app('json')->success($this->repository->detail($id,$this->userInfo,$lat, $lng)); } /** * @Author:Qinii * @Date: 2020/5/29 * @param $id * @return mixed */ public function productList($id) { [$page, $limit] = $this->getPage(); $where = $this->request->params(['keyword','order','mer_cate_id','price_on', 'price_off','brand_id']); $where['is_gift_bag'] = 0; $where['is_used'] = 1; $where['product_type'] = 0; $where['is_hide'] = 0; if($id==324){ $where['mer_type']=1; } if($this->source=='yhc' && $this->merId==496){ return app('json')->success($this->repository->productList_yhc($id,$where, $page, $limit,$this->userInfo)); } return app('json')->success($this->repository->productList($id,$where, $page, $limit,$this->userInfo)); } public function productTypeList() { $params= $this->request->params(['type','mer_cate_id','pageNum','pageSize','mer_id']); $name=$params['type']; $domain = $this->request->domain(); $id=0; $type439=true; $is_commercetrade = 0; if($name=='dingsheng'){ $id=486; }else if($name=='jingpin'){ $id=439; $type439=false; }else if($name=='jifen'){ $id=148; }else if($name=='gongchang'){ if(strpos($domain, 'test.hebeiyhc.com') !== false) { // 域名中包含 "test.hebeiyhc.com'" 字符串 $id=486;//测试环境工厂直供 }else{ $id=497;//生产环境工厂直供 } }else if($name=='fugou'){ $id=491; }// 商贸区 else if($name=='commercetrade'){ if (empty($params['mer_id'])) return app('json')->fail('店铺不存在'); $id=$this->merId = $params['mer_id']; $is_commercetrade = 1; } [$page, $limit] = $this->getPage(); if($params['pageNum']!=''){ $page=$params['pageNum']; } if($params['pageSize']!=''){ $limit=$params['pageSize']; } $where = $this->request->params(['keyword','order','mer_cate_id', 'cate_id','price_on', 'price_off','brand_id']); $where['is_gift_bag'] = 0; $where['is_used'] = 1; $where['product_type'] = 0; $where['is_hide'] = 0; log::info("====={$params['mer_cate_id']}==="); if($params['mer_cate_id']){ $where['cate_id'] = $params['mer_cate_id']; } return app('json')->success($this->repository->productList($id,$where, $page, $limit,$this->userInfo,$type439,$is_commercetrade)); } /** * 商贸区店铺商品列表 * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function commerceProductList() { $params= $this->request->params(['pageNum','pageSize','category_id']); $mer_id_unset = [496,486,439,148,491]; $domain = $this->request->domain(); if(strpos($domain, 'test.hebeiyhc.com') !== false) { // 域名中包含 "test.hebeiyhc.com'" 字符串 array_push($mer_id_unset, 486); }else{ array_push($mer_id_unset, 497); } $is_commercetrade = 1; [$page, $limit] = $this->getPage(); if($params['pageNum']!=''){ $page=$params['pageNum']; } if($params['pageSize']!=''){ $limit=$params['pageSize']; } $category_id = $params['category_id']?:0; $where['is_del'] = 0; $where['status'] = 1; $category_id && $where['category_id'] = $category_id; $mer_list = Db::name('merchant')->where($where)->page($page)->limit(100)->select(); $where['is_gift_bag'] = 0; $where['is_used'] = 1; $where['product_type'] = 0; $where['is_hide'] = 0; $return_list = []; if($mer_list) { $mer_list = $mer_list->toArray(); foreach ($mer_list as $mer) { if(in_array($mer['mer_id'],$mer_id_unset)) continue; $goods = $this->repository->productList($mer['mer_id'],$where, 1, 3,$this->userInfo,false,$is_commercetrade); if(empty($goods['list'])) continue; $mer['goods_list'] = $goods['list']; if (mb_strlen($mer['mer_name']) > 8) { $mer['mer_name'] = mb_substr($mer['mer_name'], 0, 8) . '...'; } $return_list[] = $mer; } } return app('json')->success(['list'=>$return_list]); } /** * 查询代理人商品 * @param $type * @return mixed */ public function areaProductList() { [$page, $limit] = $this->getPage(); $where = $this->request->params(['keyword','order','mer_cate_id','price_on', 'price_off','brand_id']); $where['is_gift_bag'] = 0; $where['is_used'] = 1; $where['product_type'] = 0; $where['is_hide'] = 0; $type = $this->request->param('type'); Log::info('查询代理人商品请求参数,type:'.$type); $type = $type == 'district' ? 13 : ($type == 'town' ? 12 : ($type == 'village' ? 11 : -1)); // $where['web_type'] = $type; $id = 324; $data = $this->repository->productList($id,$where, $page, $limit,$this->userInfo); Log::info('查询代理人商品返回'.json_encode($data,true)); return app('json')->success($data); } /** * @Author:Qinii * @Date: 2020/5/29 * @param int $id * @return mixed */ public function categoryList($id) { if(!$this->repository->merExists($id)) return app('json')->fail('店铺不存在'); return app('json')->success($this->repository->categoryList($id)); } public function qrcode($id) { $mer = \app\common\model\system\merchant\Merchant::getInstance()->where('mer_id', $id)->find(); if(!$mer) return app('json')->fail('店铺不存在'); $type = $this->request->param('type'); $is_payment = $this->request->param('is_payment', 0); switch ($type) { case 'routine': if ($is_payment) { $url = $this->repository->routineQrcode(intval($id), '/h5payment/index.html','_store_routine_payment.jpg'); } else { $url = $this->repository->routineQrcode(intval($id)); } break; default: if ($is_payment) { $url = $this->repository->wxQrcode(intval($id), '/h5payment/index.html', '_store_wap_payment.jpg', $mer->mer_avatar); } else { $url = $this->repository->wxQrcode(intval($id)); } } return app('json')->success(compact('url')); } public function payQrCode($id){ $mer = \app\common\model\system\merchant\Merchant::getInstance()->where('mer_id', $id)->find(); if(!$mer) return app('json')->fail('店铺不存在'); $res = $this -> repository -> getQrCode($mer); return app('json') -> success($res); } /** * @Date: 2020/10/10 * 店铺列表 :首页 最多十个 * @return mixed */ public function listindex() { // [$page, $limit] = $this->getPage(); $page=input("page/d",1); $limit=input("limit/d",10); $keyword=input("keyword",""); $order=input("order",0); $type=input("type",2); $lat=input("lat",1); $lng=input("lng",1); $data=[ "lat"=>$lat, "lng"=>$lng, "keyword"=>$keyword, "order"=>$order ]; return app('json')->success($this->repository->getLists($data,$page,$limit,$type)); } /** * @Date: 2020/10/10 * 店铺列表: * @param $keyword //搜索 * @param $order //排序 * @param $category_id //分类id * @return mixed */ public function list() { $category_id=input("category_id",0); $page=input("page/d",1); $limit=input("limit/d",10); $keyword=input("keyword",""); $order=input("order",0); $type=input("type",0); $lat=input("lat",'113.643636'); $lng=input("lng",'34.73841'); $city_name=input("city_name",''); if ($type==2){ $data=[ "lat"=>empty($lat)?"113.643636":$lat, "lng"=>empty($lng)?"34.73841":$lng, "keyword"=>$keyword, "order"=>$order ]; return app('json')->success($this->repository->getLists($data,$page,$limit,$type)); } $where=[]; if ($category_id){ $where["category_id"]=$category_id; } $data=[ "lat"=>empty($lat)?"34.73841":$lat, "lng"=>empty($lng)?"113.643636":$lng, ]; if ($city_name){ $data["city_name"]=$city_name; } return app('json')->success($this->repository->getLists($data,1,10,1,$where)); // return app('json')->success(['count'=>0,'list'=>[],'where'=>[]]); } /** * @Date: 2020/10/10 * 店铺分类 */ public function merchantcategory() { [$page, $limit] = $this->getPage(); return app('json')->success($this->repository->merchantcategory()); } /** * 附近页面商家分类 * @day 2020/10/30 */ public function mercat() { [$page, $limit] = $this->getPage(); return app('json')->success($this->repository->mercat($page, $limit)); } /* *分类下的商家列表 * @author cabbage * @day 2020/10/30 * */ public function mercatStore(){ [$page, $limit] = $this->getPage(); $data = $this->request->params([ 'order', //人气 'distance', //距离 'lat', //经度 'lng', //纬度 'user_id' ]); $where = $this->request->params([ 'category_id', //商铺分类id 'keyword', //商铺名称 ]); return app('json')->success($this->repository->getLst($data,$page,$limit,$where)); // return app('json')->success([]); } /** * @param $id * @return mixed * @throws \think\db\exception\DbException * 店铺置顶 */ public function shop_topping($id) { if($id!=0){ $res=Db::name('user')->where('uid',$this->request->uid())->update(['mer_topping'=>$id]); if($res!==false) $message='置顶成功'; else $message='置顶失败'; return app('json')->success($message); }else{ $res=Db::name('user')->where('uid',$this->request->uid())->update(['mer_topping'=>0]); if($res!==false) $message='取消置顶成功'; else $message='取消置顶失败'; return app('json')->success($message); } } /** * @param $id * @return mixed * @throws \think\db\exception\DbException * 店铺点赞 or 店铺取消点赞 */ public function shop_fabulous($id) { $uid=$this->request->uid(); $user_like=Db::name('store_fabulous')->where('uid',$uid)->where('mer_id',$id)->value('status'); if($user_like=='0'){ $res=Db::name('store_fabulous')->where('uid',$uid)->where('mer_id',$id)->update(['status'=>1]); if($res!==false) $message='点赞成功'; else $message='点赞失败'; }elseif ($user_like=='1'){ $res=Db::name('store_fabulous')->where('uid',$uid)->where('mer_id',$id)->update(['status'=>0]); if($res!==false) $message='取消点赞成功'; else $message='取消点赞失败'; }else{ $inser_data=[ 'uid'=>$uid, 'mer_id'=>$id, 'ctime'=>time(), 'status'=>1 ]; $res=Db::name('store_fabulous')->insert($inser_data); if($res!==false) $message='点赞成功'; else $message='点赞失败'; } return app('json')->success($message); } }