<?php
/*--------------------------------------------------------- 
 * File:tradeEntry.php
 * Author:Tomix
 * Description: 產品交易邏輯核心類
 * Created:2009
 * -------------------------------------------------------
 * Modified history:
 * -------------------------------------------------------
 * Copyright:
 * -------------------------------------------------------
 */
 require_once dirname(__FILE__)."/bllBase.php";
 class tradeEntry
 {
 	//更新購物車,$updateMode為1時，購物車數量遞增；為0時，直接不進行遞增操作
 	static public function updateCart($sessionID,$productID,$sizeID,$quantity,$updateMode=0)
 	{
 		require_once dirname(__FILE__)."/../dal/cartDAL.php";
 		$cart=new cartDAL();
 		$cart->SessionID=$sessionID;
 		$cart->ProductID=$productID;
 		$cart->SizeID=$sizeID;

 		if($cart->checkExists($sessionID,$productID,$sizeID))
 		{
 			$cart->loadRecord();
 			if($updateMode==1)
 			{
 				$cart->Quantity += $quantity;
 			}
 			else
 			{
 				$cart->Quantity = $quantity;
 				if($quantity == 0)
 					return $cart->deleteRecord($sessionID,$productID,$sizeID);
 			}
 			return $cart->updateRecord();
 		}
 		else
 		{
 			$cart->Quantity = $quantity;
 			return $cart->insertRecord();
 		}
 	}
 }
?>