<?php
class shopauctiondiscuss extends netsDb {
	private $sysErrorClassID='0000';
	private $sysErrorFuncID=0;
	private $sysErrorID=0;
	
	public function shopauctiondiscuss($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='shadtName';
		if(strlen($pTableDescriptAR[0]['Columns'][$tmpSTR]['Value'])<1 && !in_array($tmpSTR,$pExceptionAR2)){
			$this->sysLastError='提交内容错误:1.名称不能为空';
			return $this->sysErrorFuncID.'001';
		}
		return 0;
	}
	public function OnBid(&$pDescriptions){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$tmpApp_Code=new netsCode();
		$tmpApp_Html=new netsHtml();
		$this->TransStart();
		//-- ------ #Add ------ --
		//-- #Search --
		$tmpSQL=' SELECT A.shatID,A.shatPrice,B.shactInfo_UpdatePrice
			FROM {Nets.TableHead}shopauction A
			INNER JOIN {Nets.TableHead}shopauctioncont B ON B.shactIndexID=A.shatID
			WHERE 1=1 AND A.shatRecycle=0 AND A.shatChecked>1 AND A.shatID={Nets.Parid} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Parid}',$pDescriptions[0]['Columns']['shadtParid']['Value'],$tmpSTR);
		$tmpData0=$this->Search($tmpSTR);
		if (count($tmpData0)!=1) {
			$this->TransRollback();
			$this->sysLastError='请选择出价商品。';
			return $tmpINT;
		}
		//-- #Check --
		$tmpPrice=$tmpData0[0]['shatPrice']+$tmpData0[0]['shactInfo_UpdatePrice'];
		if ($tmpPrice>$pDescriptions[0]['Columns']['shadtPrice']['Value']) {
			$this->TransRollback();
			$this->sysLastError='您的出价不能低于'.$tmpPrice.'。';
			return $tmpINT;
		}
		//-- #Setting --
		$pDescriptions[0]['Columns']['shadtType']['Value']=1;
		$pDescriptions[0]['Columns']['shatChecked']['Value']=2;
		
		//#Other
		$pDescriptions[0]['Columns']['shadtName']['Value']=$pDescriptions[0]['Columns']['shadtNumCode']['Value'];
		$pDescriptions[0]['Columns']['shsotCreateTime']['Value']=date($this->sysTimeFormat);
		//-- #Add --
		$pDescriptions[0]['TableDescription']['SearchColumn']='shadtNumCode,shadtID';
		$pDescriptions[1]['TableDescription']['SearchColumn']='shadctIndexID';
		$tmpINT=$this->add($pDescriptions);
		if($tmpINT!=0){
			$this->TransRollback();
			$this->sysLastError='出价生成错误，请客服人员联系。';
			return $tmpINT;
		}
		//-- ------ #Update auction ------ --
		$tmpSQL=' UPDATE {Nets.TableHead}shopauction A
			SET A.shatPrice={Nets.Price}
			WHERE 1=1 AND A.shatID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Price}',$pDescriptions[0]['Columns']['shadtPrice']['Value'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.ID}',$pDescriptions[0]['Columns']['shadtParid']['Value'],$tmpSTR);
		$tmpINT=$this->Execute($tmpSTR);
		if ($tmpSTR!=0) {
			$this->TransRollback();
			$this->sysLastError='请选择出价商品。';
			return $tmpINT;
		}
		//-- ------ #Write DFlag ------ --
		$tmpINT=$tmpApp_Code->TimeToInt(date($this->sysTimeFormat));
		$tmpPath=$this->sysFileConfig['PathRoot'].$this->sysFileConfig['sysDbFlagPath'].'Shop/auction_bid_'.$pDescriptions[0]['Columns']['shadtParid']['Value'].'.php';
		$tmpContent='<!--S.Data-->{Nets.Time}<!--sendRequest--><!--E.Data-->';
		$tmpSTR=str_replace('{Nets.Time}',$tmpINT,$tmpContent);
		$tmpINT=$this->writeFile($tmpPath,$tmpSTR);
		
		
		$this->TransCommit();
		return 0;
	}
	
	
	
}
?>