123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\fastshop\model;
- use think\Model;
- class Fare extends Model{
-
- protected $pk = 'id';
- protected $table = 'ai_fastshop_fare';
- protected $autoWriteTimestamp = true;
- protected $createTime = false;
-
- public static function realAmount($item,$member_miniapp_id){
- $fare = self::where(['member_miniapp_id' => $member_miniapp_id])->find();
- $real_amount = 0;
- $real_weight = 0;
- $real_freight = 0;
-
- foreach($item as $value){
- $real_amount += $value['amount'];
- $real_weight += $value['weight'] * $value['num'];
- }
-
- if($real_weight <= $fare['first_weight'] || 0 == $fare['second_weight']){
- $real_freight = $fare['first_price'];
- }else{
- $weight = $real_weight - $fare['second_weight'];
- $real_freight = $fare['first_price'] + ceil($weight/$fare['second_weight']) * $fare['second_price'];
- }
- $data['real_amount'] = money($real_amount);
- $data['real_freight'] = money($real_freight);
- $data['order_amount'] = money($real_freight+$real_amount);
- return $data;
- }
- }
|