最模板 - 外贸网站建设,外贸网站模板

最模板

当前位置: 首页 > 建站教程 > CMS教程 > ECShop教程 >

ECSHOP商品库存会突变为65535的异常BUG要如何解决

时间:2014-06-10 11:03来源: 作者: 点击:
下面就具体说一说怎么来防止这种错误的发生。 1 )第一步,主要是对 includes/lib_order.php 文件进行一下二次开发。 先找到下面这段代码 $number= ($number 0) ? '+ ' . $number : $number; /* 处理货品
(责任编辑:admin)

下面就具体说一说怎么来防止这种错误的发生。
1
)第一步,主要是对 includes/lib_order.php 文件进行一下二次开发。
先找到下面这段代码

$number = ($number > 0) ? '+ ' . $number : $number;

 /* 处理货品库存 */

    $products_query = true;

    if (!empty($product_id))

    {

        $sql = "UPDATE " . $GLOBALS['ecs']->table('products') ."

                SET product_number = product_number $number

                WHERE goods_id = '$good_id'

                AND product_id = '$product_id'

                LIMIT 1";

        $products_query = $GLOBALS['db']->query($sql);

    }

     /* 处理商品库存 */

    $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') ."

            SET goods_number = goods_number $number

            WHERE goods_id = '$good_id'

            LIMIT 1";

    $query = $GLOBALS['db']->query($sql);
将其修改为

 if($number>=0) 

  /* 处理货品库存 */ 

  $products_query = true; 

  if (!empty($product_id)) 

  { 

   $sql = "UPDATE " . $GLOBALS['ecs']->table('products') .

     " SET product_number = product_number + $number  ".

     " WHERE goods_id = '$good_id'  AND product_id = '$product_id' LIMIT 1"; 

   $products_query = $GLOBALS['db']->query($sql); 

  } 

/* 处理商品库存 */ 

  $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') .

    " SET goods_number = goods_number + $number ".   

    " WHERE goods_id = '$good_id' LIMIT 1"; 

  $query = $GLOBALS['db']->query($sql); 

else 

   /* 处理货品库存 */ 

  $products_query = true; 

  $abs_number = abs($number); 

  if (!empty($product_id)) 

  { 

   $sql = "UPDATE " . $GLOBALS['ecs']->table('products') . " SET product_number =".

     " if( product_number >= $abs_number,product_number - $abs_number,0)  ".

     " WHERE goods_id = '$good_id' AND product_id = '$product_id' LIMIT 1"; 

   $products_query = $GLOBALS['db']->query($sql); 

  } 

  /* 处理商品库存 */ 

  $sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " SET goods_number = ".

      " if( goods_number >= $abs_number , goods_number - $abs_number ,0) ".   

    " WHERE goods_id = '$good_id' LIMIT 1"; 

  $query = $GLOBALS['db']->query($sql);   

}

2)、接下来还需要修改后台文件  /admin/order.php

找到下面代码,大概在811行左右。

if (!empty($value['product_id']))

 {

        $minus_stock_sql = "UPDATE " . $GLOBALS['ecs']->table('products') . "

                       SET product_number = product_number - " . $value['sums'] . "

                        WHERE product_id = " . $value['product_id'];

       $GLOBALS['db']->query($minus_stock_sql, 'SILENT');

}

 $minus_stock_sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . " 

                SET goods_number = goods_number - " . $value['sums'] . " 

                WHERE goods_id = " . $value['goods_id'];

 $GLOBALS['db']->query($minus_stock_sql, 'SILENT');

将之修改为
 if (!empty($value['product_id']))

{

       $minus_stock_sql = "UPDATE " . $GLOBALS['ecs']->table('products') . "

       SET product_number = if( product_number > $value[sums], product_number -$value[sums],0 )  
       WHERE product_id = " . $value['product_id'];

     $GLOBALS['db']->query($minus_stock_sql, 'SILENT');

 }

$minus_stock_sql = "UPDATE " . $GLOBALS['ecs']->table('goods') . "
     SET goods_number = if (  goods_number > $value[sums], goods_number -$value[sums],0 ) 

     WHERE goods_id = " . $value['goods_id'];

  $GLOBALS['db']->query($minus_stock_sql, 'SILENT');

这样就OK了。

 

 

 

------分隔线----------------------------
栏目列表
推荐内容