当前位置: 首页>>代码示例>>PHP>>正文


PHP compute_discount函数代码示例

本文整理汇总了PHP中compute_discount函数的典型用法代码示例。如果您正苦于以下问题:PHP compute_discount函数的具体用法?PHP compute_discount怎么用?PHP compute_discount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了compute_discount函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: order_fee

/**
 * 获得订单中的费用信息
 *
 * @access  public
 * @param   array   $order
 * @param   array   $goods
 * @param   array   $consignee
 * @param   bool    $is_gb_deposit  是否团购保证金(如果是,应付款金额只计算商品总额和支付费用,可以获得的积分取 $gift_integral)
 * @return  array
 */
function order_fee($order, $goods, $consignee)
{
    /* 初始化订单的扩展code */
    if (!isset($order['extension_code'])) {
        $order['extension_code'] = '';
    }
    if ($order['extension_code'] == 'group_buy') {
        $group_buy = group_buy_info($order['extension_id']);
    }
    $total = array('real_goods_count' => 0, 'gift_amount' => 0, 'goods_price' => 0, 'market_price' => 0, 'discount' => 0, 'pack_fee' => 0, 'card_fee' => 0, 'shipping_fee' => 0, 'shipping_insure' => 0, 'integral_money' => 0, 'bonus' => 0, 'surplus' => 0, 'cod_fee' => 0, 'pay_fee' => 0, 'tax' => 0);
    $weight = 0;
    /* 商品总价 */
    foreach ($goods as $val) {
        /* 统计实体商品的个数 */
        if ($val['is_real']) {
            $total['real_goods_count']++;
        }
        $total['goods_price'] += $val['goods_price'] * $val['goods_number'];
        $total['market_price'] += $val['market_price'] * $val['goods_number'];
    }
    $total['saving'] = $total['market_price'] - $total['goods_price'];
    $total['save_rate'] = $total['market_price'] ? round($total['saving'] * 100 / $total['market_price']) . '%' : 0;
    $total['goods_price_formated'] = price_format($total['goods_price'], false);
    $total['market_price_formated'] = price_format($total['market_price'], false);
    $total['saving_formated'] = price_format($total['saving'], false);
    /* 折扣 */
    if ($order['extension_code'] != 'group_buy') {
        $discount = compute_discount();
        $total['discount'] = $discount['discount'];
        if ($total['discount'] > $total['goods_price']) {
            $total['discount'] = $total['goods_price'];
        }
    }
    $total['discount_formated'] = price_format($total['discount'], false);
    /* 税额 */
    if (!empty($order['need_inv']) && $order['inv_type'] != '') {
        /* 查税率 */
        $rate = 0;
        foreach ($GLOBALS['_CFG']['invoice_type']['type'] as $key => $type) {
            if ($type == $order['inv_type']) {
                $rate = floatval($GLOBALS['_CFG']['invoice_type']['rate'][$key]) / 100;
                break;
            }
        }
        if ($rate > 0) {
            $total['tax'] = $rate * $total['goods_price'];
        }
    }
    $total['tax_formated'] = price_format($total['tax'], false);
    /* 包装费用 */
    if (!empty($order['pack_id'])) {
        $total['pack_fee'] = pack_fee($order['pack_id'], $total['goods_price']);
    }
    $total['pack_fee_formated'] = price_format($total['pack_fee'], false);
    /* 贺卡费用 */
    if (!empty($order['card_id'])) {
        $total['card_fee'] = card_fee($order['card_id'], $total['goods_price']);
    }
    $total['card_fee_formated'] = price_format($total['card_fee'], false);
    /* 红包 */
    if (!empty($order['bonus_id'])) {
        $bonus = bonus_info($order['bonus_id']);
        $total['bonus'] = $bonus['type_money'];
    }
    $total['bonus_formated'] = price_format($total['bonus'], false);
    /* 线下红包 */
    if (!empty($order['bonus_kill'])) {
        $bonus = bonus_info(0, $order['bonus_kill']);
        $total['bonus_kill'] = $order['bonus_kill'];
        $total['bonus_kill_formated'] = price_format($total['bonus_kill'], false);
    }
    /* 配送费用 */
    $shipping_cod_fee = NULL;
    if ($order['shipping_id'] > 0 && $total['real_goods_count'] > 0) {
        $region['country'] = $consignee['country'];
        $region['province'] = $consignee['province'];
        //$region['city']     = $consignee['city'];
        //$region['district'] = $consignee['district'];
        $shipping_info = shipping_area_info($order['shipping_id'], $region);
        if (!empty($shipping_info)) {
            if ($order['extension_code'] == 'group_buy') {
                $weight_price = cart_weight_price(CART_GROUP_BUY_GOODS);
            } else {
                $weight_price = cart_weight_price();
            }
            // 查看购物车中是否有免运费商品,若是则把运费赋为零 add by 2014-09-15 20:30*/
            //原来的是要全部商品都是免运费的才免运费:$sql = 'SELECT count(*) FROM ' . $ecs->table('cart') . " WHERE `session_id` = '" . SESS_ID. "' AND `extension_code` != 'package_buy' AND `is_shipping` = 0";
            $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE `session_id` = '" . SESS_ID . "' AND `extension_code` != 'package_buy' AND `is_shipping` = 1";
            $shipping_count = $GLOBALS['db']->getOne($sql);
            //获取运费
//.........这里部分代码省略.........
开发者ID:dlpc,项目名称:ecshop,代码行数:101,代码来源:lib_order.php

示例2: order_fee

/**
 * 获得订单中的费用信息
 *
 * @access  public
 * @param   array   $order
 * @param   array   $goods
 * @param   array   $consignee
 * @param   bool    $is_gb_deposit  是否团购保证金(如果是,应付款金额只计算商品总额和支付费用,可以获得的积分取 $gift_integral)
 * @return  array
 */
function order_fee($order, $goods, $consignee)
{
    /* 初始化订单的扩展code */
    if (!isset($order['extension_code'])) {
        $order['extension_code'] = '';
    }
    if ($order['extension_code'] == 'group_buy') {
        $group_buy = group_buy_info($order['extension_id']);
    }
    $total = array('real_goods_count' => 0, 'gift_amount' => 0, 'goods_price' => 0, 'market_price' => 0, 'discount' => 0, 'pack_fee' => 0, 'card_fee' => 0, 'shipping_fee' => 0, 'shipping_insure' => 0, 'integral_money' => 0, 'bonus' => 0, 'surplus' => 0, 'cod_fee' => 0, 'pay_fee' => 0, 'tax' => 0);
    $weight = 0;
    /* 商品总价 */
    foreach ($goods as $val) {
        /* 统计实体商品的个数 */
        if ($val['is_real']) {
            $total['real_goods_count']++;
        }
        $total['goods_price'] += $val['goods_price'] * $val['goods_number'];
        $total['market_price'] += $val['market_price'] * $val['goods_number'];
    }
    $total['saving'] = $total['market_price'] - $total['goods_price'];
    $total['save_rate'] = $total['market_price'] ? round($total['saving'] * 100 / $total['market_price']) . '%' : 0;
    $total['goods_price_formated'] = price_format($total['goods_price'], false);
    $total['market_price_formated'] = price_format($total['market_price'], false);
    $total['saving_formated'] = price_format($total['saving'], false);
    /* 折扣 */
    if ($order['extension_code'] != 'group_buy') {
        $discount = compute_discount(isset($order['supplier_id']) ? $order['supplier_id'] : -1);
        $total['discount'] = $discount['discount'];
        if ($total['discount'] > $total['goods_price']) {
            $total['discount'] = $total['goods_price'];
        }
    }
    $total['discount_formated'] = price_format($total['discount'], false);
    /* 税额 */
    if (!empty($order['need_inv']) && $order['inv_type'] != '') {
        /* 查税率 */
        $rate = 0;
        foreach ($GLOBALS['_CFG']['invoice_type']['type'] as $key => $type) {
            if ($type == $order['inv_type']) {
                $rate = floatval($GLOBALS['_CFG']['invoice_type']['rate'][$key]) / 100;
                break;
            }
        }
        if ($rate > 0) {
            $total['tax'] = $rate * $total['goods_price'];
        }
    }
    $total['tax_formated'] = price_format($total['tax'], false);
    /* 包装费用 */
    if (!empty($order['pack_id'])) {
        $total['pack_fee'] = pack_fee($order['pack_id'], $total['goods_price']);
    }
    $total['pack_fee_formated'] = price_format($total['pack_fee'], false);
    /* 贺卡费用 */
    if (!empty($order['card_id'])) {
        $total['card_fee'] = card_fee($order['card_id'], $total['goods_price']);
    }
    $total['card_fee_formated'] = price_format($total['card_fee'], false);
    /* 红包 */
    $total['bonus'] = 0;
    if (!empty($order['bonus_id'])) {
        $bonus = bonus_info($order['bonus_id']);
        $total['bonus'] = $bonus['type_money'];
    }
    /* 线下红包 */
    if (!empty($order['bonus_sn'])) {
        $bonus = bonus_info(0, $order['bonus_sn']);
        $total['bonus'] += $bonus['type_money'];
        //$total['bonus_kill'] = $order['bonus_kill'];
        //$total['bonus_kill_formated'] = price_format($total['bonus_kill'], false);
    }
    $total['bonus_formated'] = price_format($total['bonus'], false);
    /* 配送费用 */
    $shipping_cod_fee = NULL;
    $sql_where = $_SESSION['user_id'] > 0 ? "user_id='" . $_SESSION['user_id'] . "' " : "session_id = '" . SESS_ID . "' AND user_id=0 ";
    if ($order['shipping_id'] > 0 && $total['real_goods_count'] > 0) {
        $region['country'] = $consignee['country'];
        $region['province'] = $consignee['province'];
        $region['city'] = $consignee['city'];
        $region['district'] = $consignee['district'];
        $shipping_info = shipping_area_info($order['shipping_id'], $region);
        if (!empty($shipping_info)) {
            if ($order['extension_code'] == 'group_buy') {
                $weight_price = cart_weight_price(CART_GROUP_BUY_GOODS);
            } else {
                $weight_price = cart_weight_price();
            }
            // 查看购物车中是否全为免运费商品,若是则把运费赋为零
            $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE  {$sql_where} AND `extension_code` != 'package_buy' AND `is_shipping` = 0 AND rec_id in (" . $_SESSION['sel_cartgoods'] . ")";
//.........这里部分代码省略.........
开发者ID:seanguo166,项目名称:yinoos,代码行数:101,代码来源:lib_order.php

示例3: mobile_error

 if (empty($cart_goods)) {
     mobile_error('返回首页', 'index.php', '购物车里面无商品');
 } else {
     $smarty->assign('cart_goods', $cart_goods);
 }
 $consignee = get_consignee($_SESSION['user_id']);
 if ($consignee['address_id']) {
     $_SESSION['mobile_flow_consignee'] = $consignee;
     save_consignee($consignee, true);
 } else {
     $_SESSION['mobile_flow_consignee'] = null;
 }
 $smarty->assign('consignee', $consignee);
 $region = array($_SESSION['mobile_flow_consignee']['country'], $_SESSION['mobile_flow_consignee']['province'], $_SESSION['mobile_flow_consignee']['city'], $_SESSION['mobile_flow_consignee']['district']);
 if ($flow_type == 0) {
     $discount = compute_discount();
     $smarty->assign('discount', $discount['discount']);
     $favour_name = empty($discount['name']) ? '' : implode(',', $discount['name']);
     $smarty->assign('your_discount', sprintf($_LANG['your_discount'], $favour_name, price_format($discount['discount'])));
 }
 $shipping_list = available_shipping_list($region);
 $smarty->assign('shipping_list', $shipping_list);
 $payment_list = mobile_payment_list('0');
 $smarty->assign('payment_list', $payment_list);
 if (!empty($shipping_list)) {
     $default_shipping_id = $shipping_list['0']['shipping_id'];
     $smarty->assign('default_shipping_id', $default_shipping_id);
 }
 if (!empty($payment_list)) {
     $default_payment_id = $payment_list['0']['pay_id'];
     $smarty->assign('default_payment_id', $default_payment_id);
开发者ID:netroby,项目名称:ecshop,代码行数:31,代码来源:flow.php

示例4: is_have_stock

     $goods_number = is_have_stock($goodsRow['goods_id'], trim($goodsRow['goods_attr_id']));
     if ($number > $goods_number) {
         $result['error'] = '1';
         $result['content'] = '对不起,您选择的数量超出库存您最多可购买' . $goods_number . "件";
         $result['number'] = $goodsRow['goods_number'] > $goods_number ? $goods_number : ($number > $goodsRow['goods_number'] ? $goodsRow['goods_number'] : $number);
         die($json->encode($result));
     }
     //morestock_morecity _end
 }
 $sql = "UPDATE " . $GLOBALS['ecs']->table('cart') . " SET goods_number = '{$number}' WHERE rec_id = {$rec_id}";
 $GLOBALS['db']->query($sql);
 /* 取得商品列表,计算合计 */
 $cart_goods = get_cart_goods();
 //折扣活动
 $result['your_discount'] = '';
 $discount = compute_discount($result['suppid']);
 if (is_array($discount)) {
     $favour_name = empty($discount['name']) ? '' : join(',', $discount['name']);
     $result['your_discount'] = sprintf($_LANG['your_discount'], $favour_name, price_format($discount['discount']));
 }
 $subtotal = $GLOBALS['db']->getONE("select goods_price * goods_number AS subtotal from " . $GLOBALS['ecs']->table('cart') . " where rec_id = {$rec_id}");
 $result['subtotal'] = price_format($subtotal, false);
 //$result['cart_amount_desc'] = sprintf($_LANG['shopping_money'], $cart_goods['total']['goods_price']);
 $result['cart_amount_desc'] = $cart_goods['total']['goods_price'];
 $shopping_money = sprintf($_LANG['shopping_money'], $cart_goods['total']['goods_price']);
 $result['market_amount_desc'] = $shopping_money;
 if ($_CFG['show_marketprice']) {
     $market_price_desc = sprintf($_LANG['than_market_price'], $cart_goods['total']['market_price'], $cart_goods['total']['saving'], $cart_goods['total']['save_rate']);
     $result['market_amount_desc'] .= "," . $market_price_desc;
 }
 die($json->encode($result));
开发者ID:moonlight-wang,项目名称:feilun,代码行数:31,代码来源:flow.php

示例5: checkout

	public function checkout () {
		global $ecs,$db,$_CFG;
		/*------------------------------------------------------ */
	    //-- 订单确认
	    /*------------------------------------------------------ */
	
	    #取得购物类型
	    $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;
		
		/*
	    #团购标志
	    if ($flow_type == CART_GROUP_BUY_GOODS)
	    {
	        $smarty->assign('is_group_buy', 1);
	    }
	    #积分兑换商品
	    elseif ($flow_type == CART_EXCHANGE_GOODS)
	    {
	        $smarty->assign('is_exchange_goods', 1);
	    }
	    else
	    {
		*/
		#正常购物流程  清空其他购物流程情况
		$_SESSION['flow_order']['extension_code'] = '';
		/*}*/
	
	    /* 检查购物车中是否有商品 */
	    $sql = "SELECT COUNT(*) FROM " . $ecs->table('cart') ." WHERE session_id = '" . SESS_ID . "' " .
	           "AND parent_id = 0 AND is_gift = 0 AND rec_type = '$flow_type'";
	
	    if ($db->getOne($sql) == 0)
	    {
			$msg = rpcLang('flow.php', 'no_goods_in_cart');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	    /*
	     * 检查用户是否已经登录
	     * 如果用户已经登录了则检查是否有默认的收货地址
	     * 如果没有登录则跳转到登录和注册页面
	     */
	    if (empty($_SESSION['direct_shopping']) && $_SESSION['user_id'] == 0)
	    {
			$msg = rpcLang('user.php', 'nologin');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	    $consignee = get_consignee($_SESSION['user_id']);
	
	    #检查收货人信息是否完整
	    if (!check_consignee_info($consignee, $flow_type))
	    {
			$msg = rpcLang('flow.php', 'user_address_not_full');
			jsonExit("{\"status\":\"$msg\"}");
	    }
	
	    //$_SESSION['flow_consignee'] = $consignee;
	    
	    #对商品信息赋值
	    $cart_goods = cart_goods($flow_type); // 取得商品列表,计算合计
	
		/*
	    $smarty->assign('goods_list', $cart_goods);
	    #对是否允许修改购物车赋值
	    if ($flow_type != CART_GENERAL_GOODS || $_CFG['one_step_buy'] == '1')
	    {
	        $smarty->assign('allow_edit_cart', 0);
	    }
	    else
	    {
	        $smarty->assign('allow_edit_cart', 1);
	    }
	    
	    #取得购物流程设置
	    $smarty->assign('config', $_CFG);
		*/
	
	    /*
	     * 取得订单信息
	     */
	    $order = flow_order_info();
	
	    /* 计算折扣 */
	    if ($flow_type != CART_EXCHANGE_GOODS && $flow_type != CART_GROUP_BUY_GOODS)
	    {
	        $discount = compute_discount();
			
	    }
	
	    /*
	     * 计算订单的费用
	     */
	    $total = order_fee($order, $cart_goods, $consignee);
		
	    #取得配送列表
	    $region            = array($consignee['country'], $consignee['province'], $consignee['city'], $consignee['district']);
		#快递方式集合
		$shipping_list     = available_shipping_list($region);
		#购物车重量
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:mdwp,代码行数:101,代码来源:flow.action.php

示例6: get_total_price_in_cart

 public static function get_total_price_in_cart()
 {
     global $db;
     global $ecs;
     include_once 'includes/lib_order.php';
     //取得购物类型
     $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS;
     //团购标志
     if ($flow_type == CART_GROUP_BUY_GOODS) {
         //$smarty->assign('is_group_buy', 1);
     } elseif ($flow_type == CART_EXCHANGE_GOODS) {
         //$smarty->assign('is_exchange_goods', 1);
     } else {
         //正常购物流程  清空其他购物流程情况
         $_SESSION['flow_order']['extension_code'] = '';
     }
     //检查购物车中是否有商品
     $sql = "SELECT COUNT(*) FROM " . $ecs->table('cart') . " WHERE session_id = '" . SESS_ID . "' " . "AND parent_id = 0 AND is_gift = 0 AND rec_type = '{$flow_type}'";
     if ($db->getOne($sql) == 0) {
         return false;
     }
     /* 对商品信息赋值 */
     $cart_goods = cart_goods($flow_type);
     // 取得商品列表,计算合计
     $order = flow_order_info();
     $order['best_time'] = $_SESSION['flow_consignee']['best_time'];
     //计算折扣
     if ($flow_type != CART_EXCHANGE_GOODS && $flow_type != CART_GROUP_BUY_GOODS) {
         $discount = compute_discount();
         $favour_name = empty($discount['name']) ? '' : join(',', $discount['name']);
     }
     //计算订单的费用
     $total = order_fee($order, $cart_goods, $consignee);
     return $total;
     /*
     //蛋糕
     $sql = "select * from " . $ecs->table('cart') . " WHERE  session_id='" . SESS_ID . "'";
     $goods = $db->getAll($sql);
     $total = 0;
     foreach($goods as $val){
     	$total += $val['goods_price'] * $val['goods_number'];
     }
     
     //餐具
     if($_SESSION['extra_fork']==NULL){
        //$_SESSION['extra_fork'] = array();
     }else{
     	$forks = $_SESSION['extra_fork'];
     	foreach ($forks as $value){
     		$total+=($value*0.5);
     	}
     }
     
     //运费
     if($_SESSION['need_shipping_fee']){
     	$total+=$_SESSION['need_shipping_fee'];
     }
     return $total;
     */
 }
开发者ID:fromzyy2ann,项目名称:mescake,代码行数:60,代码来源:order.php

示例7: array

 // 取得商品列表,计算合计
 /*
  * 分供货商显示商品
  */
 $cart_ids = $cart_goods_new = array();
 if (count($cart_goods) > 0) {
     foreach ($cart_goods as $key => $val) {
         $cart_goods_new[$val['supplier_id']]['goodlist'][] = $val;
         $cart_ids[] = $val['rec_id'];
     }
 }
 $_SESSION['sel_cartgoods'] = isset($_SESSION['sel_cartgoods']) && !empty($_SESSION['sel_cartgoods']) ? $_SESSION['sel_cartgoods'] : implode(',', $cart_ids);
 //针对app添加
 if ($flow_type != CART_EXCHANGE_GOODS && $flow_type != CART_GROUP_BUY_GOODS) {
     foreach ($cart_goods_new as $k => $v) {
         $discount = compute_discount($k);
         if (is_array($discount)) {
             $cart_goods_new[$k]['zhekou']['discount'] = $discount['discount'];
             $favour_name = empty($discount['name']) ? '' : join(',', $discount['name']);
             $cart_goods_new[$k]['zhekou']['your_discount'] = sprintf($_LANG['your_discount'], $favour_name, price_format($discount['discount']));
         }
     }
 }
 /* 对是否允许修改购物车赋值 */
 if ($flow_type != CART_GENERAL_GOODS || $_CFG['one_step_buy'] == '1') {
     $smarty->assign('allow_edit_cart', 0);
 } else {
     $smarty->assign('allow_edit_cart', 1);
 }
 /*
  * 取得购物流程设置
开发者ID:firsteam,项目名称:falcons,代码行数:31,代码来源:flow.php

示例8: order_fee

/**
 * 获得订单中的费用信息
 *
 * @access  public
 * @param   array   $order
 * @param   array   $goods
 * @param   array   $consignee
 * @param   bool    $is_gb_deposit  是否团购保证金(如果是,应付款金额只计算商品总额和支付费用,可以获得的积分取 $gift_integral)
 * @return  array
 */
function order_fee($order, $goods, $consignee)
{
    //echo "<pre>";print_r($consignee);echo "</pre>";exit;
    $total = array('real_goods_count' => 0, 'gift_amount' => 0, 'goods_price' => 0, 'market_price' => 0, 'discount' => 0, 'pack_fee' => 0, 'card_fee' => 0, 'shipping_fee' => 0, 'shipping_insure' => 0, 'integral_money' => 0, 'bonus' => 0, 'surplus' => 0, 'cod_fee' => 0, 'pay_fee' => 0, 'tax' => 0);
    $weight = 0;
    /* 商品总价 */
    foreach ($goods as $val) {
        /* 统计实体商品的个数 */
        if ($val['is_real']) {
            $total['real_goods_count']++;
        }
        /*K金的兑礼不计入总费用 bisc*/
        if ($val['is_integral'] == 1) {
            if ($val['cat_id'] != 4) {
                $total['gifts_integral'] += $val['integral'] * $val['goods_number'];
            } else {
                $total['goods_integral'] += $val['goods_price'] * $val['goods_number'];
            }
        } else {
            $total['goods_price'] += $val['goods_price'] * $val['goods_number'];
            $total['market_price'] += $val['market_price'] * $val['goods_number'];
        }
    }
    $total['saving'] = $total['market_price'] - $total['goods_price'];
    $total['save_rate'] = $total['market_price'] ? round($total['saving'] * 100 / $total['market_price']) . '%' : 0;
    $total['goods_price_formated'] = price_format($total['goods_price'], false);
    $total['market_price_formated'] = price_format($total['market_price'], false);
    $total['saving_formated'] = price_format($total['saving'], false);
    /* 折扣$NowDiscount */
    $discount = compute_discount();
    $total['discount'] = $discount['discount'];
    $total['discount_formated'] = price_format($total['discount'], false);
    /* 红包 */
    if (!empty($order['bonus_id'])) {
        $bonus = bonus_info($order['bonus_id']);
        $total['bonus'] = $bonus['type_money'];
    }
    $total['bonus_formated'] = price_format($total['bonus'], false);
    /* 配送费用 */
    $shipping_cod_fee = NULL;
    if ($order['shipping_id'] > 0 && $total['real_goods_count'] > 0) {
        $region['country'] = $consignee['country'];
        $region['province'] = $consignee['province'];
        $region['city'] = $consignee['city'];
        $region['district'] = $consignee['district'];
        $shipping_info = shipping_area_info($order['shipping_id'], $region);
        if (!empty($shipping_info)) {
            $weight_price = cart_weight_price();
            if ($consignee['province'] == '502') {
                $sql = "select shipping_fee from ecs_shipping_fee where locate(address,'" . $consignee['address'] . "') >0 ";
                $fee = $GLOBALS['db']->getOne($sql);
                $total['shipping_fee'] = $fee ? $fee : shipping_fee($shipping_info['shipping_code'], $shipping_info['configure'], $weight_price['weight'], $total['goods_price']);
            } else {
                $total['shipping_fee'] = shipping_fee($shipping_info['shipping_code'], $shipping_info['configure'], $weight_price['weight'], $total['goods_price']);
            }
        }
    }
    $total['shipping_fee_formated'] = price_format($total['shipping_fee'], false);
    $total['shipping_insure_formated'] = price_format($total['shipping_insure'], false);
    // 红包和积分最多能支付的金额为商品总额
    $max_amount = $total['goods_price'];
    /*储值卡金额*/
    if (!empty($order['surplus'])) {
        $total['surplus'] = $order['surplus'];
    }
    $total['surplus_formated'] = price_format($total['surplus'], false);
    /* 计算订单总额 */
    if ($order['extension_code'] == 'group_buy' && $group_buy['deposit'] > 0) {
        $total['amount'] = $total['goods_price'];
    } else {
        $total['amount'] = $total['goods_price'] - $total['discount'] + $total['tax'] + $total['pack_fee'] + $total['card_fee'] + $total['shipping_fee'] + $total['shipping_insure'] + $total['cod_fee'];
        // 减去红包金额
        $use_bonus = min($total['bonus'], $max_amount);
        // 实际减去的红包金额
        $total['bonus'] = $use_bonus;
        $total['bonus_formated'] = price_format($total['bonus'], false);
        $total['amount'] -= $use_bonus;
        // 还需要支付的订单金额
        $max_amount -= $use_bonus;
        // 积分最多还能支付的金额
        //减去储值卡金额
        $total['amount'] -= $order['surplus'];
    }
    /* 积分 */
    $order['integral'] = $order['integral'] > 0 ? $order['integral'] : 0;
    if ($total['amount'] > 0 && $max_amount > 0 && $order['integral'] > 0) {
        $integral_money = value_of_integral($order['integral']);
        $use_integral = min($total['amount'], $max_amount, $integral_money);
        // 实际使用积分支付的金额
        $total['integral_money'] = $use_integral;
//.........这里部分代码省略.........
开发者ID:songtaiwu,项目名称:m-cmsold,代码行数:101,代码来源:lib_order.php


注:本文中的compute_discount函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。