} } else { $order['surplus'] = 0; $order['integral'] = 0; } /* 检查红包是否存在 */ if ($order['bonus_id'] > 0) { $bonus = bonus_info($order['bonus_id']); if (!is_bonus_available($bonus) || $bonus['user_id'] != $user_id || $bonus['min_goods_amount'] > cart_amount(false, $flow_type)) { $order['bonus_id'] = 0; } } elseif (isset($_POST['bonus_sn'])) { $bonus_sn = trim($_POST['bonus_sn']); $bonus = bonus_info(0, $bonus_sn); $now = gmtime(); if (is_bonus_available($bonus) && $bonus['user_id'] == 0 && $bonus['min_goods_amount'] <= cart_amount(false, $flow_type)) { include_once ROOT_PATH . 'includes/lib_transaction.php'; add_bonus($user_id, $bonus_sn); $order['bonus_id'] = $bonus['bonus_id']; $order['bonus_sn'] = $bonus_sn; } } /* 订单中的商品 */ $cart_goods = cart_goods($flow_type); if (empty($cart_goods)) { show_message($_LANG['no_goods_in_cart'], $_LANG['back_home'], './', 'warning'); } /* 检查商品总额是否达到最低限购金额 */ if ($flow_type == CART_GENERAL_GOODS && cart_amount(true, CART_GENERAL_GOODS) < $_CFG['min_goods_amount']) { show_message(sprintf($_LANG['goods_amount_not_enough'], price_format($_CFG['min_goods_amount'], false))); }
$order['card_fee'] = isset($_POST['card_fee']) && floatval($_POST['card_fee']) >= 0 ? round(floatval($_POST['card_fee']), 2) : 0; $order['money_paid'] = $old_order['money_paid']; $order['surplus'] = 0; //$order['integral'] = 0; $order['integral'] = intval($_POST['integral']) >= 0 ? intval($_POST['integral']) : 0; $order['integral_money'] = 0; $order['bonus_id'] = 0; $order['bonus'] = 0; /* 计算待付款金额 */ $order['order_amount'] = $order['goods_amount'] - $order['discount'] + $order['tax'] + $order['shipping_fee'] + $order['insure_fee'] + $order['pay_fee'] + $order['pack_fee'] + $order['card_fee'] - $order['money_paid']; if ($order['order_amount'] > 0) { if ($old_order['user_id'] > 0) { /* 如果选择了红包,先使用红包支付 */ if ($_POST['bonus_id'] > 0) { $bonus = bonus_info($_POST['bonus_id']); if (is_bonus_available($bonus)) { $order['bonus_id'] = $_POST['bonus_id']; $order['bonus'] = $bonus['type_money']; $order['order_amount'] -= $order['bonus']; } } /* 使用红包之后待付款金额仍大于0 */ if ($order['order_amount'] > 0) { if ($old_order['extension_code'] != 'exchange_goods') { /* 如果设置了积分,再使用积分支付 */ if (isset($_POST['integral']) && intval($_POST['integral']) > 0) { /* 检查积分是否足够 */ $order['integral'] = intval($_POST['integral']); $order['integral_money'] = value_of_integral(intval($_POST['integral'])); if ($old_order['integral'] + $user['pay_points'] < $order['integral']) { sys_msg($_LANG['pay_points_not_enough']);