...
|
...
|
@@ -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('优惠券不可使用');
|
...
|
...
|
|