Php 订单Id在opencart中跳转

Php 订单Id在opencart中跳转,php,Php,我有一个网站在opencart的订单id跳起来。 意思是说,如果一个人在网站上订购了一些东西,他的订单id是49,那么下一个订单的订单id应该是50,但显示为51或52。 当我检入数据库表oc_order时,它显示了丢失订单号的相同顺序 class ModelCheckoutOrder extends Model { public function addOrder($data) { $this->db->query("INSERT INTO `" . DB_PREF

我有一个网站在opencart的订单id跳起来。 意思是说,如果一个人在网站上订购了一些东西,他的订单id是49,那么下一个订单的订单id应该是50,但显示为51或52。 当我检入数据库表oc_order时,它显示了丢失订单号的相同顺序

class ModelCheckoutOrder extends Model {    
public function addOrder($data) {
    $this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET invoice_prefix = '" . $this->db->escape($data['invoice_prefix']) . "', store_id = '" . (int)$data['store_id'] . "', store_name = '" . $this->db->escape($data['store_name']) . "', store_url = '" . $this->db->escape($data['store_url']) . "', customer_id = '" . (int)$data['customer_id'] . "', customer_group_id = '" . (int)$data['customer_group_id'] . "', emp_name = '" . $this->db->escape($data['emp_name']) . "', emp_ID = '" . $this->db->escape($data['emp_ID']) . "', email = '" . $this->db->escape($data['email']) . "', mobile_no = '" . $this->db->escape($data['mobile_no']) . "', fax = '" . $this->db->escape($data['fax']) . "', payment_emp_name = '" . $this->db->escape($data['payment_emp_name']) . "', payment_emp_ID = '" . $this->db->escape($data['payment_emp_ID']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_company_id = '" . $this->db->escape($data['payment_company_id']) . "', payment_tax_id = '" . $this->db->escape($data['payment_tax_id']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', shipping_emp_name = '" . $this->db->escape($data['shipping_emp_name']) . "', shipping_emp_ID = '" . $this->db->escape($data['shipping_emp_ID']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', total = '" . (float)$data['total'] . "', affiliate_id = '" . (int)$data['affiliate_id'] . "', commission = '" . (float)$data['commission'] . "', language_id = '" . (int)$data['language_id'] . "', currency_id = '" . (int)$data['currency_id'] . "', currency_code = '" . $this->db->escape($data['currency_code']) . "', currency_value = '" . (float)$data['currency_value'] . "', ip = '" . $this->db->escape($data['ip']) . "', forwarded_ip = '" .  $this->db->escape($data['forwarded_ip']) . "', user_agent = '" . $this->db->escape($data['user_agent']) . "', accept_language = '" . $this->db->escape($data['accept_language']) . "', date_added = NOW(), date_modified = NOW()");




    $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '1', comment = '" . $this->db->escape(($comment && $notify) ? $comment : '') . "', date_added = NOW()");

        $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");

        foreach ($order_product_query->rows as $order_product) {
            $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");

            $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product['order_product_id'] . "'");

            foreach ($order_option_query->rows as $option) {
                $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' AND subtract = '1'");
            }
        }

这是因为在数据库本身中看到的内容与在订单管理页面中看到的内容之间存在差异。这种差异是由于opencart存储了一种称为“缺少订单id”的东西,例如,有人填写了所有详细信息,然后错误地重新加载了结帐页面,然后按下了确认按钮。在本例中,例如在订单管理页面中,他预订了两个订单号,您将只看到第二个订单号-ofc跳过的订单ID数与opencart本身存储的丢失订单数相同

如果您想测试此功能,请转到“签出”页面,填写所有订单,然后进行确认,在这种情况下,您不会看到任何差异,但是如果您转到“签出”页面,填写所有信息,然后重新加载页面,然后只需按“确认”,您将看到订单id将跳过一个数字


在opencart数据库中,您不会看到缺少的订单ID,因为opencart只有在确认后才会在数据库中插入订单。

显示一些关于如何保存记录的代码,我们无法猜测问题出在哪里。除非您为opencart实现了一些自定义,否则您需要询问opencart的支持,而不是StackOverflow。