12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace app\common\model;
- /**
- * 医院信息表
- * Class StoreModel
- * @package app\common\model
- */
- class StoreModel extends BaseModel
- {
- protected $table = 'store';
- /**
- * 获取附近门店
- * @param array $condition
- * @param $lng
- * @param $lat
- * @return int|mixed
- */
- public function getVicinityStore($condition = [], $lng = '121.48', $lat = '31.22')
- {
- $this->alias('store')
- ->field("store.*,getDistance('$lng','$lat',lng,lat) distance");
- if ($condition) {
- $this->where($condition);
- }
- return $this->order('distance asc')->find();
- }
- /**
- * 获取附近门店列表
- * @param array $condition
- * @param $lng
- * @param $lat
- * @return false|\PDOStatement|string|\think\Collection
- */
- public function getVicinityStoreList($condition = [], $lng = '121.48', $lat = '31.22')
- {
- $this->alias('store')
- ->field("store.*,getDistance('$lng','$lat',lng,lat) distance");
- if ($condition){
- $this->where($condition);
- }
- return $this->order('distance asc')->select();
- }
- }
|