⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 order.class.php

📁 Phpcms2008 是一款基于 PHP+Mysql 架构的网站内容管理系统
💻 PHP
字号:
<?php
class order
{
	var $db;
	var $table;
	var $table_deliver;
    var $table_log;
    var $STATUS;

	function __construct()
	{
		global $db, $_userid, $_username, $_amount;
		$this->db = &$db;
		$this->table = DB_PRE.'order';
        $this->table_log = DB_PRE.'order_log';
		$this->userid = $_userid;
		$this->username = $_username;
		$this->amount = $_amount;
		$this->STATUS = include dirname(__FILE__).'/status.inc.php';
		$this->where_userid = defined('IN_ADMIN') ? '' : "AND `userid`=$this->userid ";
	}

	function order()
	{
		$this->__construct();
	}

	function get($orderid, $fields = '*')
	{
		$orderid = intval($orderid);
		return $this->db->get_one("SELECT $fields FROM `$this->table` WHERE `orderid`=$orderid $this->where_userid");
	}

	function add($data)
	{
		if(!is_array($data)) return false;
		extract($data);
		if(!$goodsid || !$goodsname || !is_numeric($price) || $price < 0 || $number < 1 || (isset($carriage) && !empty($carriage) && !is_numeric($carriage))) return false;
		$date = date('Y-m-d', TIME);
		$price = round($price, 2);
		$number = intval($number);
		$carriage = round($carriage, 2);
		$amount = $price*$number + $carriage;
		$this->db->query("INSERT INTO `$this->table`(`goodsid`, `goodsname`, `goodsurl`, `unit`, `price`, `number`, `carriage`, `amount`, `consignee`, `areaid`, `telephone`, `mobile`, `address`, `postcode`, `note`, `userid`, `username`, `ip`, `time`, `date`, `status`) VALUES('$goodsid', '$goodsname', '$goodsurl', '$unit', '$price', '$number', '$carriage', '$amount', '$consignee', '$areaid', '$telephone', '$mobile', '$address', '$postcode', '$note', '$this->userid', '$this->username', '".IP."', '".TIME."', '$date', '0')");
		$this->orderid = $this->db->insert_id();
		$this->set_log($this->orderid, 0, 0, '涓嬪崟');
		return $this->orderid;
	}

	function edit($orderid, $data)
	{
        $r = $this->db->get_one("SELECT `status` FROM `$this->table` WHERE `orderid`=$orderid $this->where_userid");
		if(!$r) return false;
		$laststatus = $status = $r['status'];
		extract($data);
		if(!is_numeric($price) || !is_numeric($number) || !is_numeric($carriage)) return false;
		$amount = $price*$number+$carriage;
		$this->db->query("UPDATE `$this->table` SET `price`='$price', `number`='$number', `carriage`='$carriage', `amount`='$amount' WHERE `orderid`=$orderid $this->where_userid");
		$this->set_log($orderid, $laststatus, $status, "淇

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -