/** * 获取指订单的详情 * * @access public * @param int $order_id 订单ID * @param int $user_id 用户ID * * @return arr $order 订单所有信息的数组 */ function get_order_detail($order_id, $user_id = 0) { include_once ROOT_PATH . 'includes/lib_order.php'; $order_id = intval($order_id); if ($order_id <= 0) { $GLOBALS['err']->add($GLOBALS['_LANG']['invalid_order_id']); return false; } $order = order_info($order_id); //检查订单是否属于该用户 if ($user_id > 0 && $user_id != $order['user_id']) { $GLOBALS['err']->add($GLOBALS['_LANG']['no_priv']); return false; } /* 对发货号处理 */ if (!empty($order['invoice_no'])) { $shipping_code = $GLOBALS['db']->GetOne("SELECT shipping_code FROM " . $GLOBALS['ecs']->table('shipping') . " WHERE shipping_id = '{$order['shipping_id']}'"); $plugin = ROOT_PATH . 'includes/modules/shipping/' . $shipping_code . '.php'; if (file_exists($plugin)) { include_once $plugin; $shipping = new $shipping_code(); $order['invoice_no'] = $shipping->query($order['invoice_no']); } } /* 只有未确认才允许用户修改订单地址 */ if ($order['order_status'] == OS_UNCONFIRMED) { $order['allow_update_address'] = 1; //允许修改收货地址 } else { $order['allow_update_address'] = 0; } /* 获取订单中实体商品数量 */ $order['exist_real_goods'] = exist_real_goods($order_id); /* 如果是未付款状态,生成支付按钮 */ if ($order['pay_status'] == PS_UNPAYED && ($order['order_status'] == OS_UNCONFIRMED || $order['order_status'] == OS_CONFIRMED)) { /* * 在线支付按钮 */ //支付方式信息 /*修改于2014-04-02 by hg begin*/ /* $payment_info = array(); $payment_info = payment_info($order['pay_id']);*/ /*end*/ //无效支付方式 if (empty($order['pay_num'])) { $order['pay_online'] = ''; if ($order['txd_pay_token_id']) { $order['pay_online'] = '<input type="button" value="前往支付" onclick="window.location.href=' . "'flow.php?step=txd_pay&order_id={$order['order_id']}'\"" . '>'; } } else { /*修改于2014-04-02 by hg begin*/ /* //取得支付信息,生成支付代码 $payment = unserialize_config($payment_info['pay_config']); //获取需要支付的log_id $order['log_id'] = get_paylog_id($order['order_id'], $pay_type = PAY_ORDER); $order['user_name'] = $_SESSION['user_name']; $order['pay_desc'] = $payment_info['pay_desc']; /* 调用相应的支付方式文件 include_once(ROOT_PATH . 'includes/modules/payment/' . $payment_info['pay_code'] . '.php');*/ /* 取得在线支付方式的支付按钮 $pay_obj = new $payment_info['pay_code']; $order['pay_online'] = $pay_obj->get_code($order, $payment);*/ include_once ROOT_PATH . 'includes/modules/payment/payment.php'; $pay_obj = new payment(); $pay_num_static = strstr($order['pay_num'], '--'); if ($pay_num_static) { $pay_obj->order_set($order['pay_num']); $order['pay_num'] = $pay_obj->order_pay_num($order['pay_num']); $order['pay_online'] = $pay_obj->get_code($order); } /*end*/ } } else { $order['pay_online'] = ''; } /* 无配送时的处理 */ $order['shipping_id'] == -1 and $order['shipping_name'] = $GLOBALS['_LANG']['shipping_not_need']; /* 其他信息初始化 */ $order['how_oos_name'] = $order['how_oos']; $order['how_surplus_name'] = $order['how_surplus']; /* 虚拟商品付款后处理 */ if ($order['pay_status'] != PS_UNPAYED) { /* 取得已发货的虚拟商品信息 */ $virtual_goods = get_virtual_goods($order_id, true); $virtual_card = array(); foreach ($virtual_goods as $code => $goods_list) { /* 只处理虚拟卡 */ if ($code == 'virtual_card') { foreach ($goods_list as $goods) { if ($info = virtual_card_result($order['order_sn'], $goods)) { $virtual_card[] = array('goods_id' => $goods['goods_id'], 'goods_name' => $goods['goods_name'], 'info' => $info); } } } /* 处理超值礼包里面的虚拟卡 */ if ($code == 'package_buy') { foreach ($goods_list as $goods) { $sql = 'SELECT g.goods_id FROM ' . $GLOBALS['ecs']->table('package_goods') . ' AS pg, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE pg.goods_id = g.goods_id AND pg.package_id = '" . $goods['goods_id'] . "' AND extension_code = 'virtual_card'"; $vcard_arr = $GLOBALS['db']->getAll($sql); foreach ($vcard_arr as $val) { if ($info = virtual_card_result($order['order_sn'], $val)) { $virtual_card[] = array('goods_id' => $goods['goods_id'], 'goods_name' => $goods['goods_name'], 'info' => $info); } } } } } $var_card = deleteRepeat($virtual_card); $GLOBALS['smarty']->assign('virtual_card', $var_card); } /* 确认时间 支付时间 发货时间 */ if ($order['confirm_time'] > 0 && ($order['order_status'] == OS_CONFIRMED || $order['order_status'] == OS_SPLITED || $order['order_status'] == OS_SPLITING_PART)) { $order['confirm_time'] = sprintf($GLOBALS['_LANG']['confirm_time'], local_date($GLOBALS['_CFG']['time_format'], $order['confirm_time'])); } else { $order['confirm_time'] = ''; } if ($order['pay_time'] > 0 && $order['pay_status'] != PS_UNPAYED) { $order['pay_time'] = sprintf($GLOBALS['_LANG']['pay_time'], local_date($GLOBALS['_CFG']['time_format'], $order['pay_time'])); } else { $order['pay_time'] = ''; } if ($order['shipping_time'] > 0 && in_array($order['shipping_status'], array(SS_SHIPPED, SS_RECEIVED))) { $order['shipping_time'] = sprintf($GLOBALS['_LANG']['shipping_time'], local_date($GLOBALS['_CFG']['time_format'], $order['shipping_time'])); } else { $order['shipping_time'] = ''; } return $order; }
//如果支付费用改变了,也要相应的更改pay_log表的order_amount $order_amount = $db->getOne("SELECT order_amount FROM " . $ecs->table('pay_log') . " WHERE log_id = '{$order['log_id']}'"); if ($order_amount != $order['order_amount']) { $db->query("UPDATE " . $ecs->table('pay_log') . " SET order_amount = '{$order['order_amount']}' WHERE log_id = '{$order['log_id']}'"); } /*2014-04-08 by hg*/ /* /* 调用相应的支付方式文件 include_once(ROOT_PATH . 'includes/modules/payment/' . $payment_info['pay_code'] . '.php');*/ /* 取得在线支付方式的支付按钮 $pay_obj = new $payment_info['pay_code']; $payment_info['pay_button'] = $pay_obj->get_code($order, $payment); */ include_once 'includes/modules/payment/payment.php'; $pay_obj = new payment(); $order['pay_num'] = $payment_id; $pay_obj->order_set($order['pay_num']); $order['pay_num'] = $pay_obj->order_pay_num($order['pay_num']); $pay_online = $pay_obj->get_code($order); $payment_info['pay_button'] = $pay_obj->get_code($order); /*end*/ /* 模板赋值 */ $smarty->assign('payment', $payment_info); $smarty->assign('order', $order); $smarty->assign('pay_fee', price_format($payment_info['pay_fee'], false)); $smarty->assign('amount', price_format($order['surplus_amount'], false)); $smarty->assign('action', 'act_account'); $smarty->display('user_transaction.dwt'); } else { include_once ROOT_PATH . 'includes/lib_clips.php'; $smarty->assign('payment', get_online_payment_list()); $smarty->assign('order', $order); $smarty->assign('action', 'account_deposit');