...
|
...
|
@@ -323,7 +323,8 @@ class Order extends Api |
|
|
'code':'1',
|
|
|
'msg':'计算运费'
|
|
|
'data':
|
|
|
"price": "37574.00" 总价
|
|
|
"price": "37574.00", 总价
|
|
|
"delivery_threshold": "20.00", 起送价
|
|
|
})
|
|
|
*/
|
|
|
public function freightCalculation()
|
...
|
...
|
@@ -342,7 +343,11 @@ class Order extends Api |
|
|
$lng2 = $admin_address['lng'];
|
|
|
$sum_price = $this->distancePrice($lat1,$lng1,$lat2,$lng2,$goods_total_price);
|
|
|
if ($sum_price === false) $this->error('地址超出配送距离');
|
|
|
$this->success('计算运费',['price'=>$sum_price]);
|
|
|
$delivery_threshold = Db::name('litestore_rider_rule')->value('delivery_threshold');
|
|
|
$this->success('计算运费',[
|
|
|
'price' => $sum_price,
|
|
|
'delivery_threshold' => $delivery_threshold
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -504,6 +509,20 @@ class Order extends Api |
|
|
$sum_price += $distance_price; // 订单总价
|
|
|
$order_no = 'LQ-'.time().mt_rand(1000,9999); // 订单号
|
|
|
$couponprice = isset($coupon['price'])?$coupon['price']:0; // 优惠价格
|
|
|
|
|
|
// 给骑手佣金
|
|
|
$config = Db::name('litestore_rider_rule')->find();
|
|
|
$distance = ceil(getDistance($lat1,$lng1,$lat2,$lng2));
|
|
|
if ($distance > $config['first']){
|
|
|
$first_rider_fee = $config['first_rider_fee'];
|
|
|
$subdistance = $distance-$config['first'];
|
|
|
$count = ceil(bcdiv($subdistance,$config['additional'],1));
|
|
|
$second_rider_price = bcmul($count,$config['additional_rider_fee'],2);
|
|
|
$rider_price = bcadd($first_rider_fee,$second_rider_price,2);
|
|
|
}else{
|
|
|
$rider_price = $config['first_rider_fee'];
|
|
|
}
|
|
|
|
|
|
// 订单信息
|
|
|
$order = [
|
|
|
'order_no' => $order_no,
|
...
|
...
|
@@ -512,7 +531,8 @@ class Order extends Api |
|
|
'pay_price' => bcsub($sum_price,$couponprice,2), // 支付总价
|
|
|
'express_price' => $distance_price, // 骑手费用
|
|
|
'user_id' => $user_id,
|
|
|
'user_coupon_id' => $coupon_id > 0 ? $coupon_id : 0
|
|
|
'user_coupon_id' => $coupon_id > 0 ? $coupon_id : 0,
|
|
|
'rider_price' => $rider_price
|
|
|
];
|
|
|
|
|
|
// 添加订单
|
...
|
...
|
@@ -633,7 +653,7 @@ class Order extends Api |
|
|
$rider_order->sendtime = time(); //送达时间
|
|
|
$rider_order->save();
|
|
|
// 发放订单运费
|
|
|
\app\common\model\User::money($order->express_price,$order->rider_user_id,'订单运费');
|
|
|
\app\common\model\User::money($order->rider_price,$order->rider_user_id,'订单运费');
|
|
|
|
|
|
$this->success('收货成功');
|
|
|
}
|
...
|
...
|
|