} /* 检查积分余额是否合法 */ $user_id = $_SESSION['user_id']; if ($user_id > 0) { $user_info = user_info($user_id); $order['surplus'] = min($order['surplus'], $user_info['user_money'] + $user_info['credit_line']); if ($order['surplus'] < 0) { $order['surplus'] = 0; } // 查询用户有多少积分 $flow_points = flow_available_points(); // 该订单允许使用的积分 $user_points = $user_info['pay_points']; // 用户的积分总数 $order['integral'] = min($order['integral'], $user_points, $flow_points); if ($order['integral'] < 0) { $order['integral'] = 0; } } else { $order['surplus'] = 0; $order['integral'] = 0; } /* 检查红包是否存在 */
$order['extension_code'] = $_SESSION['extension_code']; $order['extension_id'] = $_SESSION['extension_id']; } else { $order['extension_code'] = ''; $order['extension_id'] = 0; } /* 检查积分余额是否合法 */ $user_id = $_SESSION['user_id']; if ($user_id > 0) { $user_info = user_info($user_id); $order['surplus'] = min($order['surplus'], $user_info['user_money'] + $user_info['credit_line']); if ($order['surplus'] < 0) { $order['surplus'] = 0; } // 查询用户有多少积分 $flow_points = flow_available_points(); // 该订单允许使用的积分 $user_points = $user_info['pay_points']; // 用户的积分总数 $order['integral'] = min($order['integral'], $user_points, $flow_points); if ($order['integral'] < 0) { $order['integral'] = 0; } } else { $order['surplus'] = 0; $order['integral'] = 0; } /* 订单中的商品 */ $cart_goods = cart_goods($flow_type); if (empty($cart_goods)) { $tips = '您的购物车中没有商品';
public static function checkout($card_message) { include_once 'includes/lib_order.php'; global $ecs; global $db; $res = array(); //取得购物类型 $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 json_encode(array('code' => RES_FAIL, 'msg' => $_LANG['no_goods_in_cart'])); } /* * 检查用户是否已经登录 * 如果用户已经登录了则检查是否有默认的收货地址 * 如果没有登录则跳转到登录和注册页面 */ if (empty($_SESSION['direct_shopping']) && $_SESSION['user_id'] == 0) { /* 用户没有登录且没有选定匿名购物,转向到登录页面 */ //ecs_header("Location: flow.php?step=login\n"); //exit; } $country = "北京市 "; $id = $_SESSION[flow_consignee][city]; $card_message = explode('|', $card_message); for ($i = 0; $i < count($card_message); $i++) { $card_message[$i] = $card_message[$i] == '添加一个生日牌' ? '无' : $card_message[$i]; } $numbe1 = count($card_message); $cardname = array(); foreach ($card_message as $key => $v) { if ($v == '') { $cardname[] = '无'; } else { $cardname[] = '其它'; } } $cardname = implode(";", $cardname); //$card_message=implode(";",$card_message); //生日卡 最后一步 执行done的时候会存入订单的数据库 $_SESSION['card_message'] = $card_message; //var_dump($_SESSION['card_message']); $_SESSION['card_name'] = $cardname; $city = $db->getOne("SELECT region_name FROM " . $ecs->table('region') . " WHERE region_id={$id}"); $_SESSION['flow_consignee']['addressname'] = $country . $city . $_SESSION['flow_consignee']['address']; /* 对商品信息赋值 */ $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(); //$smarty->assign('discount', $discount['discount']); $favour_name = empty($discount['name']) ? '' : join(',', $discount['name']); //$smarty->assign('your_discount', sprintf($_LANG['your_discount'], $favour_name, price_format($discount['discount']))); } //计算订单的费用 $total = order_fee($order, $cart_goods, $consignee); //取得配送列表 $region = array($consignee['country'], $consignee['province'], $consignee['city'], $consignee['district']); $insure_disabled = true; $cod_disabled = true; $user_info = user_info($_SESSION['user_id']); $order['orderman'] = $user_info['user_name']; $order['mobile'] = $user_info['mobile_phone']; $order['email'] = $user_info['email']; $my_info = array(); if ($_SESSION['user_id'] > 0 && $user_info['user_money'] >= 0) { // 能使用余额 //$smarty->assign('allow_use_surplus', 1); //$smarty->assign('your_surplus', $user_info['user_money']); $my_info['user_money'] = $user_info['user_money']; } /* 如果使用积分,取得用户可用积分及本订单最多可以使用的积分 */ if ((!isset($_CFG['use_integral']) || $_CFG['use_integral'] == '1') && $_SESSION['user_id'] > 0 && $user_info['pay_points'] > 0 && ($flow_type != CART_GROUP_BUY_GOODS && $flow_type != CART_EXCHANGE_GOODS)) { //$smarty->assign('order_max_integral', flow_available_points()); // 可用积分 //$smarty->assign('your_integral', $user_info['pay_points']); // 用户积分 $my_info['order_max_integral'] = flow_available_points(); $my_info['your_integral'] = $user_info['pay_points']; } $_SESSION['flow_order'] = $order; return json_encode(array('code' => RES_SUCCSEE, 'order' => $order, 'total' => $total, 'goods' => $cart_goods, 'my_info' => $my_info)); }