本文整理汇总了PHP中utils::cal_fee方法的典型用法代码示例。如果您正苦于以下问题:PHP utils::cal_fee方法的具体用法?PHP utils::cal_fee怎么用?PHP utils::cal_fee使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils::cal_fee方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select_delivery_method
/**
* 选择配送方式的接口
* @params object 控制器入口
* @params string 最后一级地区的id
* @params array 标准购物车数据
*/
public function select_delivery_method(&$controller, $area_id = '', $sdf_cart)
{
//$dly_types = &$controller->app->model('dlytype');
//$all_dly_types = $dly_types->get_dlytype($area_id);
$all_dly_types = $this->get_dlytype($controller, $area_id);
foreach ($all_dly_types as $rows) {
$rows['money'] = utils::cal_fee($rows['dt_expressions'], $sdf_cart['subtotal_weight'], $sdf_cart['subtotal'], $rows['firstprice']);
$shipping[] = $rows;
}
$controller->pagedata['shippings'] =& $shipping;
return $controller->fetch("site/cart/checkout_shipping.html");
}
示例2: get_special_delivery
public function get_special_delivery(&$controller, $area_id = 0, $sdf_cart, $shipping_id = 0)
{
$objdlytype = $controller->app->model('dlytype');
$dlytype = $objdlytype->getList('*', array('dt_id' => $shipping_id, 'dt_status' => '1'), 0, -1, 'ordernum ASC');
$cost_item = $sdf_cart['subtotal'];
if ($dlytype) {
$rows = $dlytype[0];
if ($rows['is_threshold']) {
if ($rows['threshold']) {
$rows['threshold'] = unserialize(stripslashes($rows['threshold']));
if (isset($rows['threshold']) && $rows['threshold']) {
foreach ($rows['threshold'] as $res) {
if ($res['area'][1] > 0) {
if ($cost_item >= $res['area'][0] && $cost_item < $res['area'][1]) {
$rows['firstprice'] = $res['first_price'];
$rows['continueprice'] = $res['continue_price'];
}
} else {
if ($cost_item >= $res['area'][0]) {
$rows['firstprice'] = $res['first_price'];
$rows['continueprice'] = $res['continue_price'];
}
}
}
}
}
}
if ($rows['area_fee_conf']) {
$area_fee_conf = unserialize($rows['area_fee_conf']);
if ($area_fee_conf && is_array($area_fee_conf) && !$rows['setting']) {
foreach ($area_fee_conf as $k => $v) {
$areas = explode(',', $v['areaGroupId']);
// 再次解析字符
foreach ($areas as &$strArea) {
if (strpos($strArea, '|') !== false) {
$strArea = substr($strArea, 0, strpos($strArea, '|'));
// 取当前area id对应的最上级的区域id
$objRegions = app::get('ectools')->model('regions');
$tmp = $objRegions->getList('*', array('region_id' => $area_id));
$arrRegion = $tmp[0];
while ($row = $objRegions->getRegionByParentId($arrRegion['p_region_id'])) {
$arrRegion = $row;
$tmp_area_id = $row['region_id'];
if ($tmp_area_id == $strArea) {
$area_id = $tmp_area_id;
break;
}
}
}
}
if (in_array($area_id, $areas)) {
//如果地区在其中,优先使用地区设置的配送费用,及公式
$rows['firstprice'] = $v['firstprice'];
$rows['continueprice'] = $v['continueprice'];
$rows['dt_expressions'] = $v['dt_expressions'];
break;
}
}
}
}
if (isset($sdf_cart['is_free_shipping']) && $sdf_cart['is_free_shipping']) {
$rows['money'] = 0;
} else {
$rows['money'] = @utils::cal_fee($rows['dt_expressions'], $sdf_cart['subtotal_weight'], $cost_item, $rows['firstprice'], $rows['continueprice'], $rows['firstprice']);
}
$shipping = $rows;
$controller->pagedata['shipping'] =& $shipping;
$str_html = $controller->fetch("site/cart/checkout_shipping_info.html");
$obj_ajax_view_help = kernel::single('b2c_view_ajax');
return $obj_ajax_view_help->get_html($str_html, 'b2c_order_dlytype', 'get_special_delivery');
}
}
示例3: payment_detail
/**
* 生成订单总计详细
* @params object 控制器
* @params object cart objects
* @params array sdf array
*/
public function payment_detail(&$controller, $cart, $sdf_order)
{
$objMath = kernel::single('ectools_math');
//$cart_info = $cart->get_objects(true);
$cart_info = $cart;
$cost_item = $cart_info['subtotal'];
//购物车里商品总费用
$cost_item = $objMath->number_minus(array($cost_item, $cart_info['discount_amount_prefilter']));
$items_weight = $cart_info['subtotal_weight'];
//购物车里商品总重量
if (isset($cart_info['is_free_shipping']) && $cart_info['is_free_shipping']) {
$items_weight = 0;
} else {
if ($cart_info['object']['goods']) {
foreach ($cart_info['object']['goods'] as $item_obj) {
if (isset($item_obj['is_free_shipping']) && $item_obj['is_free_shipping']) {
if (isset($item_obj['obj_items']['products'][0]) && $item_obj['obj_items']['products'][0]) {
$product_item = $item_obj['obj_items']['products'][0];
if ($product_item['package_use']) {
$items_weight_added = $objMath->number_multiple(array($product_item['package_unit'], $item_obj['quantity'], $product_item['weight']));
} else {
$items_weight_added = $objMath->number_multiple(array($product_item['weight'], $item_obj['quantity']));
}
$items_weight = $objMath->number_minus(array($items_weight, $items_weight_added));
}
}
}
}
}
$objCurrency = app::get('ectools')->model('currency');
$arrDefCurrency = $objCurrency->getDefault();
$strDefCurrency = $arrDefCurrency['cur_code'];
$aCur = $objCurrency->getcur($sdf_order['cur']);
if ($sdf_order['shipping_id']) {
$dlytype = $controller->app->model('dlytype');
//配送方式
$dlytype_info = $dlytype->dump($sdf_order['shipping_id'], '*');
if ($sdf_order['is_protect'] === 'true' || $sdf_order['is_protect'] === '1' || $sdf_order['is_protect'] === true) {
//配送设置了保价
//$cost_protect = ($cost_item*$dlytype_info['protect_rate']);
$cost_protect = $objMath->number_multiple(array($cost_item, $dlytype_info['protect_rate']));
$cost_protect = $cost_protect > $dlytype_info['minprice'] ? $cost_protect : $dlytype_info['minprice'];
//保价费
}
if (!$dlytype_info['setting']) {
$arrArea = explode(':', $sdf_order['area']);
$area_id = $arrArea[2];
if (isset($dlytype_info['area_fee_conf']) && $dlytype_info['area_fee_conf']) {
$area_fee_conf = unserialize($dlytype_info['area_fee_conf']);
foreach ($area_fee_conf as $k => $v) {
$areas = explode(',', $v['areaGroupId']);
// 再次解析字符
foreach ($areas as &$strArea) {
if (strpos($strArea, '|') !== false) {
$strArea = substr($strArea, 0, strpos($strArea, '|'));
}
}
// 取当前area id对应的最上级的区域id
$objRegions = app::get('ectools')->model('regions');
$arrRegion = $objRegions->dump($area_id);
while ($row = $objRegions->getRegionByParentId($arrRegion['p_region_id'])) {
$arrRegion = $row;
$area_id = $row['region_id'];
}
if (in_array($area_id, $areas)) {
//如果地区在其中,优先使用地区设置的配送费用,及公式
$dlytype_info['firstprice'] = $v['firstprice'];
$dlytype_info['continueprice'] = $v['continueprice'];
$dlytype_info['dt_expressions'] = $v['dt_expressions'];
break;
}
}
}
}
$cost_freight = utils::cal_fee($dlytype_info['dt_expressions'], $items_weight, $cost_item);
//配送费
}
if (isset($cart_info['is_free_shipping']) && $cart_info['is_free_shipping']) {
$cost_freight = 0;
$cost_protect = 0;
}
if ($sdf_order['payment'] && $sdf_order['payment'] != -1) {
$payment_info = app::get('ectools')->model('payment_cfgs')->getPaymentInfo($sdf_order['payment']);
$pay_fee = $payment_info['pay_fee'];
//支付费率
} else {
$pay_fee = 0;
}
if ($sdf_order['is_tax'] == 'true') {
$cost_tax = $objMath->number_multiple(array($controller->app->getConf("site.tax_ratio"), $cost_item));
}
$total_amount = $objMath->number_plus(array($cost_item, $cost_protect, $cost_freight));
$cost_payment = $objMath->number_multiple(array($total_amount, $pay_fee));
$total_amount = $objCurrency->amount_nocur($objMath->number_plus(array($total_amount, $cost_payment, $cost_tax)), $sdf_order['cur'], false, false);
//.........这里部分代码省略.........
示例4: payment_detail
//.........这里部分代码省略.........
if (isset($dlytype_info['area_fee_conf']) && $dlytype_info['area_fee_conf']) {
$area_fee_conf = unserialize($dlytype_info['area_fee_conf']);
foreach ($area_fee_conf as $k => $v) {
$areas = explode(',', $v['areaGroupId']);
// 再次解析字符
foreach ($areas as &$strArea) {
if (strpos($strArea, '|') !== false) {
$strArea = substr($strArea, 0, strpos($strArea, '|'));
// 取当前area id对应的最上级的区域id
$objRegions = app::get('ectools')->model('regions');
$arrRegion = $objRegions->dump($area_id);
while ($row = $objRegions->getRegionByParentId($arrRegion['p_region_id'])) {
$arrRegion = $row;
$tmp_area_id = $row['region_id'];
if ($tmp_area_id == $strArea) {
$area_id = $tmp_area_id;
break;
}
}
}
}
if (in_array($area_id, $areas)) {
//如果地区在其中,优先使用地区设置的配送费用,及公式
if ($dlytype_info['firstprice']) {
$dlytype_info['firstprice'] = $v['firstprice'];
}
$dlytype_info['continueprice'] = $v['continueprice'];
$dlytype_info['dt_expressions'] = $v['dt_expressions'];
break;
}
}
}
}
$cost_freight = @utils::cal_fee($dlytype_info['dt_expressions'], $items_weight, $cost_item, $dlytype_info['firstprice'], $dlytype_info['continueprice']);
//配送费
}
/**
* 订单免运费
*/
if (isset($cart_info['is_free_shipping']) && $cart_info['is_free_shipping']) {
$cart_info['discount_amount_order'] = $objMath->number_plus(array($cart_info['discount_amount_order'], $cost_freight, $cost_protect));
$cart_info['discount_amount'] = $objMath->number_plus(array($cart_info['discount_amount'], $cost_freight, $cost_protect));
}
/** end **/
if ($sdf_order['payment'] && $sdf_order['payment'] != -1) {
$payment_info = app::get('ectools')->model('payment_cfgs')->getPaymentInfo($sdf_order['payment']);
$pay_fee = $payment_info['pay_fee'];
//支付费率
} else {
$pay_fee = 0;
}
if ($sdf_order['is_tax'] == 'true') {
$tax_ratio = $controller->app->getConf("site." . $sdf_order['tax_type'] . "_tax_ratio");
// 税率计算埋点
foreach (kernel::servicelist('b2c.order_ratio_calulate') as $services) {
if (is_object($services)) {
if (method_exists($services, 'ratioCalculate')) {
$services->ratioCalculate($controller, $sdf_order['tax_type'], $tax_ratio);
}
}
}
$cost_tax = $objMath->number_multiple(array($tax_ratio, $objMath->number_minus(array($cost_item, $cart_info['discount_amount_prefilter']))));
}
$total_amount = $objMath->number_plus(array($cost_item, $cost_protect, $cost_freight));
$total_amount = $objMath->number_minus(array($total_amount, $cart_info['discount_amount']));
$total_amount = $objMath->number_plus(array($total_amount, $cost_tax));
示例5: generate
//.........这里部分代码省略.........
$arrArea = explode(':', $aData['ship_area']);
$area_id = $arrArea[2];
if (isset($dlytype_info['area_fee_conf']) && $dlytype_info['area_fee_conf']) {
$area_fee_conf = unserialize($dlytype_info['area_fee_conf']);
foreach ($area_fee_conf as $k => $v) {
$areas = explode(',', $v['areaGroupId']);
// 再次解析字符
foreach ($areas as &$strArea) {
if (strpos($strArea, '|') !== false) {
$strArea = substr($strArea, 0, strpos($strArea, '|'));
// 取当前area id对应的最上级的区域id
$objRegions = app::get('ectools')->model('regions');
$arrRegion = $objRegions->dump($area_id);
while ($row = $objRegions->getRegionByParentId($arrRegion['p_region_id'])) {
$arrRegion = $row;
$tmp_area_id = $row['region_id'];
if ($tmp_area_id == $strArea) {
$area_id = $tmp_area_id;
break;
}
}
}
}
if (in_array($area_id, $areas)) {
//如果地区在其中,优先使用地区设置的配送费用,及公式
$dlytype_info['firstprice'] = $v['firstprice'];
$dlytype_info['continueprice'] = $v['continueprice'];
$dlytype_info['dt_expressions'] = $v['dt_expressions'];
break;
}
}
}
}
$aData['cost_freight'] = @utils::cal_fee($dlytype_info['dt_expressions'], $item_weight, $itemsFund, $dlytype_info['firstprice'], $dlytype_info['continueprice']);
//配送费
}
if ($delMark) {
$this->execDelItems($orderid, $aProduct['edit']);
} else {
//$itemsFund = $this->getCostItems($orderid);
}
// 存储新增的订单项目
if (isset($arr_insert_objects) && $arr_insert_objects) {
foreach ($arr_insert_objects as $order_objects) {
$mdl_order_objects->save($order_objects);
}
}
$aDataTmp['cost_item'] = $itemsFund;
$aDataTmp['shipping']['cost_shipping'] = $aData['cost_freight'];
$aDataTmp['shipping']['cost_protect'] = $aData['cost_protect'];
$rate = $obj_orders->dump($orderid, 'cur_rate,discount,pmt_order,pmt_goods');
$aData['discount'] = $this->objMath->number_minus(array($aData['discount'], $rate['discount']));
$aDataTmp['total_amount'] = $this->objMath->number_plus(array($itemsFund, $aData['cost_freight'], $aData['cost_protect'], $aData['cost_payment'], $aData['cost_tax'], $rate['discount'], $aData['discount'], -$rate['pmt_order']));
if ($aDataTmp['total_amount'] < 0) {
$aDataTmp['total_amount'] = 0;
}
$aDataTmp['weight'] = $item_weight ? $item_weight : 0;
$aDataTmp['discount'] = $this->objMath->number_plus(array($rate['discount'], $aData['discount']));
$aDataTmp['cur_amount'] = $this->objMath->number_multiple(array($aDataTmp['total_amount'], $rate['cur_rate']));
$aDataTmp['order_id'] = $orderid;
if ($obj_orders->save($aDataTmp) && !$is_error) {
// 添加日志.
$orderLog = $this->app->model("order_log");
$log_text[] = array('txt_key' => '订单修改成功!', 'data' => array());
$log_text = serialize($log_text);
$sdf_order_log = array('rel_id' => $orderid, 'op_id' => $aData['user_id'], 'op_name' => $aData['account']['login_name'], 'alttime' => time(), 'bill_type' => 'order', 'behavior' => 'updates', 'result' => 'SUCCESS', 'log_text' => $log_text);
示例6: get_dlytype
/**
* 根据地区ID,获取在次购物车中配送方式和配送价格
*/
public function get_dlytype($params, &$service)
{
if (!$this->check_accesstoken($params['accesstoken'], $params['member_id'])) {
return $service->send_user_error('100001', 'accesstoken fail');
}
$mCart = app::get('b2c')->model('cart');
$aCart = $mCart->get_objects($aData);
$all_dly_types = kernel::single('b2c_order_dlytype')->get_dlytype($this, $params['area_id'], $aCart);
foreach ($all_dly_types as $i => $rows) {
if ($rows['is_threshold'] && $rows['threshold']) {
$rows['threshold'] = unserialize(stripslashes($rows['threshold']));
if (isset($rows['threshold']) && $rows['threshold']) {
foreach ($rows['threshold'] as $res) {
if ($res['area'][1] > 0) {
if ($cost_item >= $res['area'][0] && $cost_item < $res['area'][1]) {
$rows['firstprice'] = $res['first_price'];
$rows['continueprice'] = $res['continue_price'];
}
} else {
if ($cost_item >= $res['area'][0]) {
$rows['firstprice'] = $res['first_price'];
$rows['continueprice'] = $res['continue_price'];
}
}
}
}
}
$delivery[$i]['dt_id'] = $rows['dt_id'];
$delivery[$i]['has_cod'] = $rows['has_cod'];
$delivery[$i]['dt_name'] = $rows['dt_name'];
$delivery[$i]['detail'] = $rows['detail'];
$delivery[$i]['protect'] = $rows['protect'];
$delivery[$i]['protect_rate'] = $rows['protect_rate'];
$delivery[$i]['minprice'] = $rows['minprice'];
$delivery[$i]['money'] = utils::cal_fee($rows['dt_expressions'], $aCart['subtotal_weight'], $aCart['subtotal'], $rows['firstprice'], $rows['continueprice'], $rows['firstprice']);
}
return $delivery;
}
示例7: editOrder
//.........这里部分代码省略.........
$item_weight = $this->objMath->number_plus(array($item_weight, $this->objMath->number_multiple(array($aPdtinfo['weight'], $aItem['quantity']))));
$aPdtinfo['weight'] *= $aItem['quantity'];
unset($aPdtinfo['price']);
$aGoodsinfo = $mdl_goods->dump($aPdtinfo['goods_id'], 'type_id');
$aItem = array_merge($aItem, $aPdtinfo);
$aItem['type_id'] = $aGoodsinfo['type']['type_id'];
$arr_insert_objects[] = array('obj_type' => 'goods', 'obj_alias' => '商品区块', 'goods_id' => $aItem['goods_id'], 'order_id' => $aItem['order_id'], 'bn' => $aItem['bn'], 'name' => $aItem['name'], 'price' => $aItem['price'], 'quantity' => 1, 'amount' => $aItem['amount'], 'weight' => $aItem['weight'], 'score' => 0, 'order_items' => array(array('products' => array('product_id' => $productId), 'goods_id' => $aItem['goods_id'], 'order_id' => $aItem['order_id'], 'item_type' => 'product', 'bn' => $aItem['bn'], 'name' => $aItem['name'], 'type_id' => $aItem['type_id'], 'cost' => $aItem['cost'], 'quantity' => $aItem['quantity'], 'sendnum' => 0, 'amount' => $aItem['amount'], 'price' => $aItem['price'], 'weight' => $aItem['weight'], 'addon' => 0)));
$aProduct['edit'][] = array('product_id' => $productId, 'object_id' => $object_id);
}
$itemsFund = $this->objMath->number_plus(array($itemsFund, $aItem['amount']));
$freezTime = $this->app->getConf('system.goods.freez.time');
$tmpdata = array();
if ($freezTime == 1) {
$tmpdata['product_id'] = $productId;
if (isset($addStore[$productId])) {
if (floatval($addStore[$productId]) >= 0) {
// 冻结库存
$tmpdata['freez'] = $this->objMath->number_plus(array($row['freez'], floatval($addStore[$productId])));
$mdl_goods->freez($aItem['goods_id'], $productId, abs(floatval($addStore[$productId])));
} else {
$tmpdata['freez'] = $this->objMath->number_plus(array($row['freez'], floatval($addStore[$productId])));
$mdl_goods->unfreez($aItem['goods_id'], $productId, abs(floatval($addStore[$productId])));
}
}
}
}
if ($aData['shipping_id']) {
$dlytype = $this->app->model('dlytype');
//配送方式
$dlytype_info = $dlytype->dump($aData['shipping_id'], '*');
if ($aData['is_protect'] == 'true' || $aData['is_protect'] == '1') {
//配送设置了保价
//$cost_protect = ($cost_item*$dlytype_info['protect_rate']);
$cost_protect = $this->objMath->number_multiple(array($cost_item, $dlytype_info['protect_rate']));
$cost_protect = $cost_protect > $dlytype_info['minprice'] ? $cost_protect : $dlytype_info['minprice'];
//保价费
}
if (!$dlytype_info['setting']) {
$arrArea = explode(':', $aData['ship_area']);
$area_id = $arrArea[2];
if (isset($dlytype_info['area_fee_conf']) && $dlytype_info['area_fee_conf']) {
$area_fee_conf = unserialize($dlytype_info['area_fee_conf']);
foreach ($area_fee_conf as $k => $v) {
$areas = explode(',', $v['areaGroupId']);
// 再次解析字符
foreach ($areas as &$strArea) {
if (strpos($strArea, '|') !== false) {
$strArea = substr($strArea, 0, strpos($strArea, '|'));
}
}
// 取当前area id对应的最上级的区域id
$objRegions = app::get('ectools')->model('regions');
$arrRegion = $objRegions->dump($area_id);
while ($row = $objRegions->getRegionByParentId($arrRegion['p_region_id'])) {
$arrRegion = $row;
$area_id = $row['region_id'];
}
if (in_array($area_id, $areas)) {
//如果地区在其中,优先使用地区设置的配送费用,及公式
$dlytype_info['firstprice'] = $v['firstprice'];
$dlytype_info['continueprice'] = $v['continueprice'];
$dlytype_info['dt_expressions'] = $v['dt_expressions'];
break;
}
}
}
}
$aData['cost_freight'] = utils::cal_fee($dlytype_info['dt_expressions'], $item_weight, $cost_item);
//配送费
}
if ($delMark) {
$this->execDelItems($orderid, $aProduct['edit']);
} else {
//$itemsFund = $this->getCostItems($orderid);
}
// 存储新增的订单项目
if (isset($arr_insert_objects) && $arr_insert_objects) {
foreach ($arr_insert_objects as $order_objects) {
$mdl_order_objects->save($order_objects);
}
}
$aDataTmp['cost_item'] = $itemsFund;
$aDataTmp['shipping']['cost_shipping'] = $aData['cost_freight'];
$aDataTmp['total_amount'] = $this->objMath->number_minus(array($this->objMath->number_plus(array($itemsFund, $aData['cost_freight'], $aData['cost_protect'], $aData['cost_payment'], $aData['cost_tax'], $aData['discount'])), $aData['pmt_order']));
$aDataTmp['weight'] = $item_weight;
$aDataTmp['discount'] = abs($aData['discount']);
$rate = $obj_orders->dump($orderid, 'cur_rate');
$aDataTmp['cur_amount'] = $this->objMath->number_multiple(array($aDataTmp['total_amount'], $rate['cur_rate']));
$aDataTmp['order_id'] = $orderid;
if ($obj_orders->save($aDataTmp) && !$is_error) {
// 添加日志.
$orderLog = $this->app->model("order_log");
$sdf_order_log = array('rel_id' => $orderid, 'op_id' => $aData['user_id'], 'op_name' => $aData['account']['login_name'], 'alttime' => time(), 'bill_type' => 'order', 'behavior' => 'updates', 'result' => 'SUCCESS');
$orderLog->save($sdf_order_log);
return true;
} else {
return false;
}
return $aMsg;
}