<?php /** * Created by PhpStorm. * User: hssh_win8.1 * Date: 2015/10/6 * Time: 12:05 * file: goodsaddhandles.php */ require_once './common/include.php'; // 获取数据库实例 $mu = new ModelUser('bl_goods'); // 补充部分数据 $goods_sn = empty($_POST['goods_sn']) ? ToolsGoodsSn::GetGoodsSn() : $_POST['goods_sn']; // 获得唯一的货单号 $goods_weight = empty($_POST['goods_weight']) ? '0' : $_POST['goods_weight']; $goods_total = empty($_POST['goods_total']) ? 0 : $_POST['goods_total'] + 0; // 移动照片 $tempimg = ROOT . 'data/images/temp/' . $_POST['goods_img']; $img = ROOT . 'data/images/goods/' . $_POST['goods_img']; if (!is_file($tempimg) || !rename($tempimg, $img)) { echo "1"; return; } //并生成400*400中图 和1000*1000的大图 ToolsImage::ResizeImage($img, 400, 400, 'mid'); ToolsImage::ResizeImage($img, 1000, 1000, 'big'); $data = array('goods_name' => $_POST['goods_name'], 'cate_id' => $_POST['cate_id'] + 0, 'goods_time' => time(), 'goods_sn' => $goods_sn, 'goods_price' => $_POST['goods_price'], 'price_unit' => '1', 'goods_weight' => $goods_weight, 'weight_unit' => "1", 'goods_total' => $goods_total, 'is_best' => $_POST['is_best'] + 0, 'is_new' => $_POST['is_new'] + 0, 'is_hot' => $_POST['is_hot'] + 0, 'is_delete' => 0, 'on_sale' => $_POST['on_sale'] + 0, 'goods_key' => $_POST['goods_key'], 'goods_img' => $img, 'goods_desc' => $_POST['goods_desc'], 'goods_details' => $_POST['goods_details'], 'seller_note' => $_POST['seller_note']); $res = $mu->insert($data); //echo $res; if ($res != 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; } // 写入n条数据到bl_order_goods表 知道购物车为空 while (!$cart->isEmpty()) { $mog->writeAllItem($order_id, $order_sn, $user_id); } echo json_encode(array('status' => 0, 'order_sn' => $order_sn));