public static function GetOrderSn()
 {
     $moi = new ModelOrderInfo('bl_order_info');
     $sn = substr(str_shuffle('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 15);
     $res = $moi->select(array('order_sn'), 'order_sn="' . $sn . '"');
     if ($res) {
         return self::GetOrderSn();
     } else {
         return $sn;
     }
 }
Exemple #2
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/9
 * Time: 19:27
 * 订单提交处理
 */
require_once './common/include.php';
// 先判断是否已经登录
if (!isset($_SESSION['name'])) {
    header("location: " . 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . '/login.php');
}
$moi = new ModelOrderInfo('bl_order_info');
$mog = new ModelOrderGoods('bl_order_goods');
// 获得用户id
$user_id = $mu->getOne("select id from bl_user where username=\"" . $_SESSION['name'] . '"');
// 支付方式
$pay_type = $_POST['pay_type'] ? 1 : 0;
// 生成订单号
$order_sn = ToolsGoodsSn::GetOrderSn();
// 写一条数据到 bl_order_info
$data = array('order_sn' => $order_sn, 'reciver' => $_POST['name'], 'user_id' => $user_id, 'tel' => $_POST['tel'], 'zone' => $_POST['zone'], 'address' => $_POST['address'], 'zipcode' => $_POST['zipcode'], 'order_time' => time(), 'pay_type' => $pay_type, 'total_price' => $cart->getTotalPrice());
// 新插入订单信息
$order_id = $moi->insertOrder($data);
//插入失败
if ($order_id === false) {
    echo json_encode(array('status' => 1));
    return;
}
Exemple #3
0
<?php

/**
 * Created by PhpStorm.
 * User: hssh_win8.1
 * Date: 2015/10/9
 * Time: 20:58
 * 支付页面
 */
require_once './common/include.php';
// 先判断是否已经登录
if (!isset($_SESSION['name'])) {
    header("location: " . 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']) . '/login.php');
}
$order_sn = isset($_GET['order_sn']) ? $_GET['order_sn'] : '';
$moi = new ModelOrderInfo('bl_order_info');
$sql = "select * from bl_order_info where order_sn='" . $order_sn . "'";
$oi = $moi->getRow($sql);
if (!$oi) {
    exit('订单不存在');
}
require ROOT . 'view/front/pay.html';