<?php
class shopauction extends netsDb {
	private $sysErrorClassID='0000';
	private $sysErrorFuncID=0;
	private $sysErrorID=0;
	
	public function shopauction($pConnection){
		$this->netsDb($pConnection);
	}
	public function Check(&$pTableDescriptAR,$pExceptionAR1,$pExceptionAR2){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		
		if(count($pExceptionAR1)==0){
			$pExceptionAR1=array();
		}
		parent::Check($pTableDescriptAR,$pExceptionAR1,$pExceptionAR2);
		//
		$tmpSTR='shatName';
		if(strlen($pTableDescriptAR[0]['Columns'][$tmpSTR]['Value'])<1 && !in_array($tmpSTR,$pExceptionAR2)){
			$this->sysLastError='提交内容错误:1.名称不能为空';
			return $this->sysErrorFuncID.'001';
		}
		return 0;
	}
	public function initialObject($pID){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$tmpCode=new netsCode();
		$tmpHtml=new netsHtml();
		$this->TransStart();
		//-- ------ #Check cookie exist ------ --
		//Get cookie
		$tmpCookieName=$this->sysCookieHead.'Cookie_Shopauction_'.$pID;
		$tmpAR0=$tmpHtml->AnalyerRequest($tmpCookieName,'',2);
		//-- ------ #Update data ------ --
		//-- #Update Discuss --
		$tmpCountConfigs=array();
		//#Info
		$tmpAR1=$this->sCountUpdateConfig_Template;
		$tmpAR1['Parent_TableName']=$this->sysTableHead.'shopauctioncont';
		$tmpAR1['Parent_CountColumnName']='shactCount_Discuss';
		$tmpAR1['Parent_Condition']=' AND shactIndexID='.$pID;
		$tmpAR1['Child_A_TableName']=$this->sysTableHead.'shopsalediscuss';
		$tmpAR1['Child_A_CountColumnName']='shadtID';
		$tmpAR1['Child_A_Condition']=' AND shadtRecycle=0 AND shadtChecked>1 AND shadtParid='.$pID;
		$tmpCountConfigs[]=$tmpAR1;
		//#Group
		$tmpSQL=' SELECT A.shatID,A.shatParid
			FROM {Nets.TableHead}shopauction AS A 
			WHERE 1=1 AND A.shatRecycle=0 AND A.shatChecked>1 AND A.shatID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$pID,$tmpSTR);
		$tmpData0=$this->Search($tmpSTR);
		$tmpParid=0;
		if (count($tmpData0)>0) {
			$tmpParid=$tmpData0[0]['shatParid'];
		}
		
		$tmpAR1=$this->sCountUpdateConfig_Template;
		$tmpAR1['Parent_TableName']=$this->sysTableHead.'shopauctiongroupcont';
		$tmpAR1['Parent_CountColumnName']='shagctCount_Info';
		$tmpAR1['Parent_Condition']=' AND shagctID='.$tmpParid;
		$tmpAR1['Child_A_TableName']=$this->sysTableHead.'shopauctiongroup';
		$tmpAR1['Child_A_CountColumnName']='shatID';
		$tmpAR1['Child_A_Condition']=' AND shatRecycle=0 AND shatChecked>1 AND shatParid='.$tmpParid;
		$tmpCountConfigs[]=$tmpAR1;
		
		$tmpINT=$this->updateCount($tmpCountConfigs);
		//-- #Update Hit --
		if($tmpAR0[0]==''){
			$tmpSQL=' UPDATE {Nets.TableHead}shopauctioncont SET shactCount_Views=shactCount_Views+1 WHERE 1=1 AND shactIndexID={Nets.ID} ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.ID}',$pID,$tmpSTR);
			$tmpINT=$this->Execute($tmpSTR);
			if($tmpINT!=0){
				$this->sysLastError='更新商品数据时出错，请稍后再试。';
				$this->TransRollback();
				return $tmpINT;
			}
			$this->writeCookie($this->sysNormalCookiePath,$tmpCookieName,1);
		}
		
		$this->TransCommit();
		return 0;
	}
	
	
}
?>