切换导航条
此项目
正在载入...
登录
李忠强
/
temporaryfood
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
何书鹏
3 years ago
提交
f0a57c98a67af10263f35caf9877a1c97c8f30d4
1 个父辈
0cc1d4fc
商品起送金额
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
20 行增加
和
5 行删除
application/admin/lang/zh-cn/litestore_rider_rule.php
application/admin/view/litestore_rider_rule/edit.html
application/api/controller/Order.php
application/api/controller/User.php
application/common/controller/Api.php
public/assets/js/backend/litestore_rider_rule.js
application/admin/lang/zh-cn/litestore_rider_rule.php
查看文件 @
f0a57c9
...
...
@@ -5,5 +5,6 @@ return [
'First_fee'
=>
'运费(元)'
,
'Additional'
=>
'续公里'
,
'Max_distance'
=>
'最大距离'
,
'Additional_fee'
=>
'运费(元)'
'Additional_fee'
=>
'运费(元)'
,
'Goods_total_price'
=>
'商品起送金额(元)'
];
...
...
application/admin/view/litestore_rider_rule/edit.html
查看文件 @
f0a57c9
...
...
@@ -30,6 +30,12 @@
<input
id=
"c-max_distance"
data-rule=
"required"
min=
"0"
class=
"form-control"
step=
"1"
name=
"row[max_distance]"
type=
"number"
value=
"{$row.max_distance|htmlentities}"
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"control-label col-xs-12 col-sm-2"
>
{:__('Goods_total_price')}:
</label>
<div
class=
"col-xs-12 col-sm-8"
>
<input
id=
"c-goods_total_price"
data-rule=
"required"
min=
"0"
class=
"form-control"
step=
"1"
name=
"row[goods_total_price]"
type=
"number"
value=
"{$row.goods_total_price|htmlentities}"
>
</div>
</div>
<div
class=
"form-group layer-footer"
>
<label
class=
"control-label col-xs-12 col-sm-2"
></label>
<div
class=
"col-xs-12 col-sm-8"
>
...
...
application/api/controller/Order.php
查看文件 @
f0a57c9
...
...
@@ -226,7 +226,7 @@ class Order extends Api
$admin_address
=
Db
::
name
(
'admin_address'
)
->
find
();
$lat2
=
$admin_address
[
'lat'
];
$lng2
=
$admin_address
[
'lng'
];
$express_price
=
$this
->
distancePrice
(
$lat1
,
$lng1
,
$lat2
,
$lng2
);
$express_price
=
$this
->
distancePrice
(
$lat1
,
$lng1
,
$lat2
,
$lng2
,
$sum_price
);
if
(
$express_price
===
false
)
$express_price
=
0
;
}
else
{
$address
=
[];
...
...
@@ -315,6 +315,7 @@ class Order extends Api
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="address_id", type="integer", required=true, description="地址id")
* @ApiParams (name="goods_total_price", type="string", required=true, description="商品总价")
* @ApiReturn ({
'code':'1',
'msg':'计算运费'
...
...
@@ -325,7 +326,9 @@ class Order extends Api
public
function
freightCalculation
()
{
$address_id
=
$this
->
request
->
post
(
'address_id'
);
$goods_total_price
=
$this
->
request
->
post
(
'goods_total_price'
);
if
(
!
$address_id
)
$this
->
error
(
'请选择地址'
);
if
(
!
$goods_total_price
)
$this
->
error
(
'请计算商品总价'
);
$model
=
new
UserAddress
();
$address
=
$model
::
get
(
$address_id
);
if
(
!
$address
)
$this
->
error
(
'地址不存在'
);
...
...
@@ -334,7 +337,7 @@ class Order extends Api
$admin_address
=
Db
::
name
(
'admin_address'
)
->
find
();
$lat2
=
$admin_address
[
'lat'
];
$lng2
=
$admin_address
[
'lng'
];
$sum_price
=
$this
->
distancePrice
(
$lat1
,
$lng1
,
$lat2
,
$lng2
);
$sum_price
=
$this
->
distancePrice
(
$lat1
,
$lng1
,
$lat2
,
$lng2
,
$goods_total_price
);
if
(
$sum_price
===
false
)
$this
->
error
(
'地址超出配送距离'
);
$this
->
success
(
'计算运费'
,[
'price'
=>
$sum_price
]);
}
...
...
@@ -478,7 +481,7 @@ class Order extends Api
$admin_address
=
Db
::
name
(
'admin_address'
)
->
find
();
$lat2
=
$admin_address
[
'lat'
];
$lng2
=
$admin_address
[
'lng'
];
$distance_price
=
$this
->
distancePrice
(
$lat1
,
$lng1
,
$lat2
,
$lng2
);
$distance_price
=
$this
->
distancePrice
(
$lat1
,
$lng1
,
$lat2
,
$lng2
,
$sum_price
);
if
(
$distance_price
===
false
)
$this
->
error
(
'地址超出配送距离'
);
if
(
$coupon
!==
[]
&&
$coupon
[
'full_price'
]
>
$sum_price
)
$this
->
error
(
'优惠券不可使用'
);
...
...
application/api/controller/User.php
查看文件 @
f0a57c9
...
...
@@ -819,6 +819,7 @@ class User extends Api
/**
* 测试
* @ApiInternal
*/
public
function
notice
(){
$client
=
new
Client
();
...
...
application/common/controller/Api.php
查看文件 @
f0a57c9
...
...
@@ -388,14 +388,17 @@ class Api
* @param $lat1
* @param $lng2
* @param $lat2
* @param $goods_total_price
* @return bool|float
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
protected
function
distancePrice
(
$lat1
,
$lng1
,
$lat2
,
$lng2
)
protected
function
distancePrice
(
$lat1
,
$lng1
,
$lat2
,
$lng2
,
$goods_total_price
=
0
)
{
$config
=
Db
::
name
(
'litestore_rider_rule'
)
->
find
();
// 商品起送金额
if
(
$goods_total_price
>=
$config
[
'goods_total_price'
])
return
0
;
$distance
=
ceil
(
getDistance
(
$lat1
,
$lng1
,
$lat2
,
$lng2
));
if
(
$distance
>
$config
[
'max_distance'
])
return
false
;
if
(
$distance
>
$config
[
'first'
]){
...
...
public/assets/js/backend/litestore_rider_rule.js
查看文件 @
f0a57c9
...
...
@@ -34,6 +34,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{
field
:
'additional'
,
title
:
__
(
'Additional'
),
operate
:
'BETWEEN'
},
{
field
:
'additional_fee'
,
title
:
__
(
'Additional_fee'
),
operate
:
'BETWEEN'
},
{
field
:
'max_distance'
,
title
:
__
(
'Max_distance'
),
operate
:
'BETWEEN'
},
{
field
:
'goods_total_price'
,
title
:
__
(
'Goods_total_price'
),
operate
:
'BETWEEN'
},
// {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{
field
:
'operate'
,
title
:
__
(
'Operate'
),
table
:
table
,
events
:
Table
.
api
.
events
.
operate
,
formatter
:
Table
.
api
.
formatter
.
operate
}
]
...
...
请
注册
或
登录
后发表评论