You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.2 KiB
83 lines
2.2 KiB
<?php
|
|
defined('BASE_PATH') OR exit('No direct script access allowed');
|
|
|
|
class yto
|
|
{
|
|
/*------------------------------------------------------ */
|
|
//-- PUBLIC ATTRIBUTEs
|
|
/*------------------------------------------------------ */
|
|
|
|
/**
|
|
* 配置信息
|
|
*/
|
|
var $configure;
|
|
|
|
/*------------------------------------------------------ */
|
|
//-- PUBLIC METHODs
|
|
/*------------------------------------------------------ */
|
|
|
|
/**
|
|
* 构造函数
|
|
*
|
|
* @param: $configure[array] 配送方式的参数的数组
|
|
*
|
|
* @return null
|
|
*/
|
|
function yto($cfg = array())
|
|
{
|
|
foreach ($cfg AS $key=>$val)
|
|
{
|
|
$this->configure[$val['name']] = $val['value'];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 计算订单的配送费用的函数
|
|
*
|
|
* @param float $goods_weight 商品重量
|
|
* @param float $goods_amount 商品金额
|
|
* @param float $goods_number 商品件数
|
|
* @return decimal
|
|
*/
|
|
function calculate($goods_weight, $goods_amount, $goods_number)
|
|
{
|
|
if ($this->configure['free_money'] > 0 && $goods_amount >= $this->configure['free_money'])
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
@$fee = $this->configure['base_fee'];
|
|
$this->configure['fee_compute_mode'] = !empty($this->configure['fee_compute_mode']) ? $this->configure['fee_compute_mode'] : 'by_weight';
|
|
|
|
if ($this->configure['fee_compute_mode'] == 'by_number')
|
|
{
|
|
$fee = $goods_number * $this->configure['item_fee'];
|
|
}
|
|
else
|
|
{
|
|
if ($goods_weight > 1)
|
|
{
|
|
$fee += (ceil(($goods_weight - 1))) * $this->configure['step_fee'];
|
|
}
|
|
}
|
|
|
|
return $fee;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询发货状态
|
|
*
|
|
* @access public
|
|
* @param string $invoice_sn 发货单号
|
|
* @return string
|
|
*/
|
|
function query($invoice_sn)
|
|
{
|
|
//圆通快递查询会判断链接来源,目前的查询无法生效。
|
|
$str = '<a class="btn-submit" href="http://m.kuaidi100.com/index_all.html?type=yuantong&postid=' .$invoice_sn. '">订单跟踪</a>';
|
|
return $str;
|
|
}
|
|
}
|
|
|