diff --git a/hyhproject/common/model/Shopping.php b/hyhproject/common/model/Shopping.php index 62fffbe..1d90e83 100755 --- a/hyhproject/common/model/Shopping.php +++ b/hyhproject/common/model/Shopping.php @@ -45,6 +45,42 @@ class Shopping extends Base{ } return WSTReturn('',1,$rs); } + public function getHelpSaleShops(){ + $page = (int)input('page',1); + $rs = cache('QLG_HELP_SALE_SHOPS_'.$page); + if(!$rs){ + $pageSize = input("post.pageSize/d",10); + $goodsSize = input("post.goodsSize/d",3); + $lat = input("post.lat",0); + $lng = input("post.lng",0); + $where['s.dataFlag'] = 1; + $where['s.shopStatus'] = 1; + $where['s.status'] = 1; + $field = 's.shopId,s.shopImg,s.shopName,s.shopLevel,ROUND(12756.276*ASIN(SQRT(POW(SIN(('.$lat.'*0.0174532925-lat*0.0174532925)/2),2)+ + COS('.$lat.'*0.0174532925)*COS(lat*0.0174532925)*POW(SIN(('.$lng.'*0.0174532925-lng*0.0174532925)/2),2)))*1000) AS distance'; + $order = 's.shopLevel ASC'; + $rs = Db::name('shops s') + ->where($where) + ->field($field) + ->order($order) + //->cache(true,86400) + ->paginate($pageSize) + ->toArray(); + //dump($this->getLastSql()); + if(count($rs['Rows']) == 0){ + return WSTReturn('',1,$rs); + } + $goods_field = 'g.goodsImg,g.shopPrice,g.goodsId,g.saleTime,g.discountRate'; + foreach ($rs['Rows'] as &$v) { + $v['goods'] = $this->getShopGoods($v['shopId'],$goodsSize,$goods_field,3); + foreach ($v['goods'] as &$val) { + $val['goodsImg'] = WSTImg($val['goodsImg'],3); + } + } + cache('QLG_HELP_SALE_SHOPS_'.$page,$rs,60); + } + return WSTReturn('',1,$rs); + } /** * 获取列表 */