...
|
...
|
@@ -494,6 +494,23 @@ class Order extends Api |
|
|
|
|
|
if ($coupon !== [] && $coupon['full_price'] > $sum_price) $this->error('优惠券不可使用');
|
|
|
|
|
|
// 给骑手佣金
|
|
|
$rider_rule = Db::name('litestore_rider_rule')->find();
|
|
|
if ($sum_price < $rider_rule['delivery_threshold']){
|
|
|
$last_price = $rider_rule['delivery_threshold'] - $sum_price;
|
|
|
$this->error('差'.$last_price.'元起送');
|
|
|
}
|
|
|
$distance = ceil(getDistance($lat1,$lng1,$lat2,$lng2));
|
|
|
if ($distance > $rider_rule['first']){
|
|
|
$first_rider_fee = $rider_rule['first_rider_fee'];
|
|
|
$subdistance = $distance-$rider_rule['first'];
|
|
|
$count = ceil(bcdiv($subdistance,$rider_rule['additional'],1));
|
|
|
$second_rider_price = bcmul($count,$rider_rule['additional_rider_fee'],2);
|
|
|
$rider_price = bcadd($first_rider_fee,$second_rider_price,2);
|
|
|
}else{
|
|
|
$rider_price = $rider_rule['first_rider_fee'];
|
|
|
}
|
|
|
|
|
|
// 订单地址
|
|
|
$order_address = [
|
|
|
'name' => $address['username'],
|
...
|
...
|
@@ -510,19 +527,6 @@ class Order extends Api |
|
|
$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,
|
...
|
...
|
|