正在显示
5 个修改的文件
包含
50 行增加
和
14 行删除
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | return [ | 3 | return [ |
4 | - 'First' => '首公里', | ||
5 | - 'First_fee' => '运费(元)', | ||
6 | - 'Additional' => '续公里', | ||
7 | - 'Max_distance' => '最大距离', | ||
8 | - 'Additional_fee' => '运费(元)', | ||
9 | - 'Goods_total_price' => '商品起送金额(元)' | 4 | + 'First' => '首公里', |
5 | + 'First_fee' => '收用户运费(元)', | ||
6 | + 'First_rider_fee' => '给骑手运费(元)', | ||
7 | + 'Additional' => '续公里', | ||
8 | + 'Additional_fee' => '收用户运费(元)', | ||
9 | + 'Additional_rider_fee' => '给骑手运费(元)', | ||
10 | + 'Max_distance' => '最大距离', | ||
11 | + 'Delivery_threshold' => '商品起送金额(元)' | ||
10 | ]; | 12 | ]; |
@@ -13,6 +13,12 @@ | @@ -13,6 +13,12 @@ | ||
13 | </div> | 13 | </div> |
14 | </div> | 14 | </div> |
15 | <div class="form-group"> | 15 | <div class="form-group"> |
16 | + <label class="control-label col-xs-12 col-sm-2">{:__('First_rider_fee')}:</label> | ||
17 | + <div class="col-xs-12 col-sm-8"> | ||
18 | + <input id="c-first_rider_fee" data-rule="required" min="0" class="form-control" step="0.01" name="row[first_rider_fee]" type="number" value="{$row.first_rider_fee|htmlentities}"> | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + <div class="form-group"> | ||
16 | <label class="control-label col-xs-12 col-sm-2">{:__('Additional')}:</label> | 22 | <label class="control-label col-xs-12 col-sm-2">{:__('Additional')}:</label> |
17 | <div class="col-xs-12 col-sm-8"> | 23 | <div class="col-xs-12 col-sm-8"> |
18 | <input id="c-additional" data-rule="required" min="0" class="form-control" name="row[additional]" type="number" value="{$row.additional|htmlentities}"> | 24 | <input id="c-additional" data-rule="required" min="0" class="form-control" name="row[additional]" type="number" value="{$row.additional|htmlentities}"> |
@@ -25,15 +31,21 @@ | @@ -25,15 +31,21 @@ | ||
25 | </div> | 31 | </div> |
26 | </div> | 32 | </div> |
27 | <div class="form-group"> | 33 | <div class="form-group"> |
34 | + <label class="control-label col-xs-12 col-sm-2">{:__('Additional_rider_fee')}:</label> | ||
35 | + <div class="col-xs-12 col-sm-8"> | ||
36 | + <input id="c-additional_rider_fee" data-rule="required" min="0" class="form-control" step="0.01" name="row[additional_rider_fee]" type="number" value="{$row.additional_rider_fee|htmlentities}"> | ||
37 | + </div> | ||
38 | + </div> | ||
39 | + <div class="form-group"> | ||
28 | <label class="control-label col-xs-12 col-sm-2">{:__('Max_distance')}:</label> | 40 | <label class="control-label col-xs-12 col-sm-2">{:__('Max_distance')}:</label> |
29 | <div class="col-xs-12 col-sm-8"> | 41 | <div class="col-xs-12 col-sm-8"> |
30 | <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}"> | 42 | <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}"> |
31 | </div> | 43 | </div> |
32 | </div> | 44 | </div> |
33 | <div class="form-group"> | 45 | <div class="form-group"> |
34 | - <label class="control-label col-xs-12 col-sm-2">{:__('Goods_total_price')}:</label> | 46 | + <label class="control-label col-xs-12 col-sm-2">{:__('Delivery_threshold')}:</label> |
35 | <div class="col-xs-12 col-sm-8"> | 47 | <div class="col-xs-12 col-sm-8"> |
36 | - <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}"> | 48 | + <input id="c-delivery_threshold" data-rule="required" min="0" class="form-control" step="1" name="row[delivery_threshold]" type="number" value="{$row.delivery_threshold|htmlentities}"> |
37 | </div> | 49 | </div> |
38 | </div> | 50 | </div> |
39 | <div class="form-group layer-footer"> | 51 | <div class="form-group layer-footer"> |
@@ -323,7 +323,8 @@ class Order extends Api | @@ -323,7 +323,8 @@ class Order extends Api | ||
323 | 'code':'1', | 323 | 'code':'1', |
324 | 'msg':'计算运费' | 324 | 'msg':'计算运费' |
325 | 'data': | 325 | 'data': |
326 | - "price": "37574.00" 总价 | 326 | + "price": "37574.00", 总价 |
327 | + "delivery_threshold": "20.00", 起送价 | ||
327 | }) | 328 | }) |
328 | */ | 329 | */ |
329 | public function freightCalculation() | 330 | public function freightCalculation() |
@@ -342,7 +343,11 @@ class Order extends Api | @@ -342,7 +343,11 @@ class Order extends Api | ||
342 | $lng2 = $admin_address['lng']; | 343 | $lng2 = $admin_address['lng']; |
343 | $sum_price = $this->distancePrice($lat1,$lng1,$lat2,$lng2,$goods_total_price); | 344 | $sum_price = $this->distancePrice($lat1,$lng1,$lat2,$lng2,$goods_total_price); |
344 | if ($sum_price === false) $this->error('地址超出配送距离'); | 345 | if ($sum_price === false) $this->error('地址超出配送距离'); |
345 | - $this->success('计算运费',['price'=>$sum_price]); | 346 | + $delivery_threshold = Db::name('litestore_rider_rule')->value('delivery_threshold'); |
347 | + $this->success('计算运费',[ | ||
348 | + 'price' => $sum_price, | ||
349 | + 'delivery_threshold' => $delivery_threshold | ||
350 | + ]); | ||
346 | } | 351 | } |
347 | 352 | ||
348 | /** | 353 | /** |
@@ -504,6 +509,20 @@ class Order extends Api | @@ -504,6 +509,20 @@ class Order extends Api | ||
504 | $sum_price += $distance_price; // 订单总价 | 509 | $sum_price += $distance_price; // 订单总价 |
505 | $order_no = 'LQ-'.time().mt_rand(1000,9999); // 订单号 | 510 | $order_no = 'LQ-'.time().mt_rand(1000,9999); // 订单号 |
506 | $couponprice = isset($coupon['price'])?$coupon['price']:0; // 优惠价格 | 511 | $couponprice = isset($coupon['price'])?$coupon['price']:0; // 优惠价格 |
512 | + | ||
513 | + // 给骑手佣金 | ||
514 | + $config = Db::name('litestore_rider_rule')->find(); | ||
515 | + $distance = ceil(getDistance($lat1,$lng1,$lat2,$lng2)); | ||
516 | + if ($distance > $config['first']){ | ||
517 | + $first_rider_fee = $config['first_rider_fee']; | ||
518 | + $subdistance = $distance-$config['first']; | ||
519 | + $count = ceil(bcdiv($subdistance,$config['additional'],1)); | ||
520 | + $second_rider_price = bcmul($count,$config['additional_rider_fee'],2); | ||
521 | + $rider_price = bcadd($first_rider_fee,$second_rider_price,2); | ||
522 | + }else{ | ||
523 | + $rider_price = $config['first_rider_fee']; | ||
524 | + } | ||
525 | + | ||
507 | // 订单信息 | 526 | // 订单信息 |
508 | $order = [ | 527 | $order = [ |
509 | 'order_no' => $order_no, | 528 | 'order_no' => $order_no, |
@@ -512,7 +531,8 @@ class Order extends Api | @@ -512,7 +531,8 @@ class Order extends Api | ||
512 | 'pay_price' => bcsub($sum_price,$couponprice,2), // 支付总价 | 531 | 'pay_price' => bcsub($sum_price,$couponprice,2), // 支付总价 |
513 | 'express_price' => $distance_price, // 骑手费用 | 532 | 'express_price' => $distance_price, // 骑手费用 |
514 | 'user_id' => $user_id, | 533 | 'user_id' => $user_id, |
515 | - 'user_coupon_id' => $coupon_id > 0 ? $coupon_id : 0 | 534 | + 'user_coupon_id' => $coupon_id > 0 ? $coupon_id : 0, |
535 | + 'rider_price' => $rider_price | ||
516 | ]; | 536 | ]; |
517 | 537 | ||
518 | // 添加订单 | 538 | // 添加订单 |
@@ -633,7 +653,7 @@ class Order extends Api | @@ -633,7 +653,7 @@ class Order extends Api | ||
633 | $rider_order->sendtime = time(); //送达时间 | 653 | $rider_order->sendtime = time(); //送达时间 |
634 | $rider_order->save(); | 654 | $rider_order->save(); |
635 | // 发放订单运费 | 655 | // 发放订单运费 |
636 | - \app\common\model\User::money($order->express_price,$order->rider_user_id,'订单运费'); | 656 | + \app\common\model\User::money($order->rider_price,$order->rider_user_id,'订单运费'); |
637 | 657 | ||
638 | $this->success('收货成功'); | 658 | $this->success('收货成功'); |
639 | } | 659 | } |
@@ -339,7 +339,7 @@ class Rider extends Api | @@ -339,7 +339,7 @@ class Rider extends Api | ||
339 | $rider_order->sendtime = time(); //送达时间 | 339 | $rider_order->sendtime = time(); //送达时间 |
340 | $rider_order->save(); | 340 | $rider_order->save(); |
341 | // 发放订单运费 | 341 | // 发放订单运费 |
342 | - User::money($order->express_price,$order->rider_user_id,'订单运费'); | 342 | + User::money($order->rider_price,$order->rider_user_id,'订单运费'); |
343 | 343 | ||
344 | $this->success('送达成功',$order); | 344 | $this->success('送达成功',$order); |
345 | } | 345 | } |
@@ -31,10 +31,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -31,10 +31,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
31 | {field: 'id', title: __('Id')}, | 31 | {field: 'id', title: __('Id')}, |
32 | {field: 'first', title: __('First'), operate:'BETWEEN'}, | 32 | {field: 'first', title: __('First'), operate:'BETWEEN'}, |
33 | {field: 'first_fee', title: __('First_fee'), operate:'BETWEEN'}, | 33 | {field: 'first_fee', title: __('First_fee'), operate:'BETWEEN'}, |
34 | + {field: 'first_rider_fee', title: __('First_rider_fee'), operate:'BETWEEN'}, | ||
34 | {field: 'additional', title: __('Additional'), operate:'BETWEEN'}, | 35 | {field: 'additional', title: __('Additional'), operate:'BETWEEN'}, |
35 | {field: 'additional_fee', title: __('Additional_fee'), operate:'BETWEEN'}, | 36 | {field: 'additional_fee', title: __('Additional_fee'), operate:'BETWEEN'}, |
37 | + {field: 'additional_rider_fee', title: __('Additional_rider_fee'), operate:'BETWEEN'}, | ||
36 | {field: 'max_distance', title: __('Max_distance'), operate:'BETWEEN'}, | 38 | {field: 'max_distance', title: __('Max_distance'), operate:'BETWEEN'}, |
37 | - {field: 'goods_total_price', title: __('Goods_total_price'), operate:'BETWEEN'}, | 39 | + {field: 'delivery_threshold', title: __('Delivery_threshold'), operate:'BETWEEN'}, |
38 | // {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | 40 | // {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, |
39 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 41 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
40 | ] | 42 | ] |
-
请 注册 或 登录 后发表评论