Esempio n. 1
0
 /**
  * 得到并计算物流费用
  *
  * @param 	string $expresion    公式
  * @param 	float  $total        订单价格
  * @param 	int    $weight       订单重量
  * @return 	Float  $price
  */
 private function do_carrier_price($expression, $total, $weight = 0)
 {
     if (!$expression) {
         return 0;
     }
     $price = delivery::cal_fee($expression, $weight, $total);
     return $price;
 }
Esempio n. 2
0
 /**
  * 计算物流价格
  * 
  * @param array $condition
  * @return float $price
  * 
  * $condition = array(
  *   'delivery_id'          => '77',        //物流ID
  *   'country_id'           => '539',       //物流递送国家
  *   'weight'               => '500',       //订单重量
  *   'total_price'          => '300.99',    //订单总价
  * );
  * 如果返回值是-1表示当前物流不支持到收货地址的配送
  */
 public static function get_delivery_price_by_condition($condition)
 {
     $delivery_id = $condition['delivery_id'];
     $country_id = $condition['country_id'];
     $weight = $condition['weight'];
     $total_price = $condition['total_price'];
     $dlv_instance = DeliveryService::get_instance();
     $delivery = $dlv_instance->get_delivery_by_id($delivery_id);
     if (empty($delivery)) {
         return 0;
     }
     $flag = 0;
     if ($delivery['type'] == 0) {
         $flag = 1;
     } else {
         $delivery_country = Delivery_countryService::get_instance()->get_delivery_country($delivery_id, $country_id);
         if (empty($delivery_country)) {
             if ($delivery['is_default'] == 1) {
                 $flag = 1;
             } else {
                 return 0;
             }
         } else {
             $flag = 1;
             $delivery['expression'] = $delivery_country['expression'];
         }
     }
     if ($flag = 0) {
         return 0;
     }
     $price = delivery::cal_fee($delivery['expression'], $weight, $total_price);
     //计算物流费用
     return $price;
 }