切换导航条
此项目
正在载入...
登录
朱振飞
/
wake
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
xwp
5 years ago
提交
19eddb506cd238e6e7a3411f939158c8a798650b
1 个父辈
158d1ece
1 个管道 的构建
通过
耗费 1 秒
最新逻辑
变更
3
构建
1
显示空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
77 行增加
和
10 行删除
application/api/controller/Course.php
application/api/controller/Store.php
public/api.html
application/api/controller/Course.php
查看文件 @
19eddb5
...
...
@@ -3,7 +3,9 @@
namespace
app\api\controller
;
use
app\common\controller\Api
;
use
fast\Tree
;
use
think\Config
;
use
think\Db
;
use
WeMini\Template
;
/**
...
...
@@ -30,10 +32,38 @@ class Course extends Api
$category
=
new
\app\common\model\Category
();
$category
=
$category
->
where
([])
->
select
();
$tree
=
Tree
::
instance
();
$tree
->
init
(
$category
,
'pid'
);
$category
=
$tree
->
getTreeArray
(
0
);
$this
->
success
(
'请求成功'
,
$category
);
}
/**
* 获得区域
*
* @ApiTitle (获得区域)
* @ApiSummary (获得区域)
* @ApiMethod (POST)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", sample="{'prepay_id':'123','options':{},'order':{}}", description="扩展数据返回")
* @ApiReturn ({'code':'1','msg':'返回成功'})
*/
public
function
get_area
()
{
$parentId
=
$this
->
request
->
request
(
'parentId'
);
$area
=
DB
::
table
(
'fa_area'
)
->
where
([])
->
field
([
'id'
,
'parentId'
,
'areaName'
])
->
select
();
$tree
=
Tree
::
instance
();
$tree
->
init
(
$area
,
'parentId'
);
$area
=
$tree
->
getTreeArray
(
$parentId
);
$this
->
success
(
'请求成功'
,
$area
);
}
/**
* 获得课程等级
*
* @ApiTitle (获得课程等级)
...
...
application/api/controller/Store.php
查看文件 @
19eddb5
...
...
@@ -20,7 +20,8 @@ class Store extends Api
* @ApiMethod (POST)
* @ApiParams (name="lng", type="string", required=true, description="lng")
* @ApiParams (name="lat", type="string", required=true, description="lat")
* @ApiParams (name="distance", type="string", required=true, description="距离")
* @ApiParams (name="value", type="string", required=true, description="地区值")
* @ApiParams (name="type", type="string", required=true, description="地区类型")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", sample="{'prepay_id':'123','options':{},'order':{}}", description="扩展数据返回")
...
...
@@ -30,17 +31,12 @@ class Store extends Api
{
$lng
=
$this
->
request
->
request
(
'lng'
);
$lat
=
$this
->
request
->
request
(
'lat'
);
$distance
=
$this
->
request
->
request
(
'distance'
);
$value
=
$this
->
request
->
request
(
'value'
);
$type
=
$this
->
request
->
request
(
'type'
);
if
(
empty
(
$distance
)){
$distance
=
10
;
}
$where
=
[];
if
(
!
empty
(
$lng
)
&&!
empty
(
$lat
)){
$four_point
=
$this
->
returnSquarePoint
(
$lng
,
$lat
,
$distance
);
$this
->
success
(
'请求成功'
,
$four_point
);
$where
[
'lng'
]
=
[
'between'
,[
$four_point
[
'left-top'
][
'lng'
],
$four_point
[
'right-top'
][
'lng'
]]];
$where
[
'lat'
]
=
[
'between'
,[
$four_point
[
'left-bottom'
][
'lat'
],
$four_point
[
'left-top'
][
'lat'
]]];
if
(
!
empty
(
$value
)
&&!
empty
(
$type
)){
$where
[
$type
]
=
$value
;
}
$store
=
new
\app\admin\model\Store
();
...
...
@@ -53,12 +49,53 @@ class Store extends Api
}
$k
[
'banner'
]
=
$banner
;
$k
[
'cover'
]
=
cdnurl
(
$k
[
'cover'
],
true
);
$k
[
'distance'
]
=
$this
->
GetDistance
(
$lat
,
$lng
,
$k
[
'lat'
],
$k
[
'lng'
]);
}
if
(
!
empty
(
$store
)){
//排序
foreach
(
$store
as
$key
=>
$row
)
{
$distance
[
$key
]
=
$row
[
'distance'
];
}
array_multisort
(
$distance
,
SORT_ASC
,
$store
);
}
$this
->
success
(
'请求成功'
,
$store
);
}
/**
* 计算两组经纬度坐标 之间的距离
* $lat1 纬度1; lng1 经度1; lat2 纬度2; lng2 经度2; len_type (1:m or 2:km);
*
* @param $lat1
* @param $lng1
* @param $lat2
* @param $lng2
* @param int $len_type
* @param int $decimal
* @return false|float
*/
private
function
GetDistance
(
$lat1
,
$lng1
,
$lat2
,
$lng2
,
$len_type
=
2
,
$decimal
=
2
)
{
$EARTH_RADIUS
=
6378.137
;
//地球半径
$PI
=
3.1415926
;
$radLat1
=
$lat1
*
$PI
/
180.0
;
$radLat2
=
$lat2
*
$PI
/
180.0
;
$a
=
$radLat1
-
$radLat2
;
$b
=
(
$lng1
*
$PI
/
180.0
)
-
(
$lng2
*
$PI
/
180.0
);
$s
=
2
*
asin
(
sqrt
(
pow
(
sin
(
$a
/
2
),
2
)
+
cos
(
$radLat1
)
*
cos
(
$radLat2
)
*
pow
(
sin
(
$b
/
2
),
2
)));
$s
=
$s
*
$EARTH_RADIUS
;
$s
=
round
(
$s
*
1000
);
if
(
$len_type
>
1
)
{
$s
/=
1000
;
}
return
round
(
$s
,
$decimal
);
}
/**
* 获得门店
*
* @ApiTitle (获得门店)
...
...
public/api.html
查看文件 @
19eddb5
此 diff 太大无法显示。
请
注册
或
登录
后发表评论