<?php
class shopuserpay extends netsDb {
	private $sysErrorClassID='0000';
	private $sysErrorFuncID=0;
	private $sysErrorID=0;
	
	public function shopuserpay($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='shuptName';
		if(strlen($pTableDescriptAR[0]['Columns'][$tmpSTR]['Value'])<1 && !in_array($tmpSTR,$pExceptionAR2)){
			$this->sysLastError='提交内容错误:1.名称不能为空';
			return $this->sysErrorFuncID.'001';
		}
		
		return 0;
	}
	
	//-- ------ #PAY ------ --
	/**
	 * Enter description here...
	 *
	 * @return unknown
	 */
	public function Pay_Generation(&$pDescriptions,$pUserinfo,&$pURL){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$this->TransStart();
		//-- ------ #Record user HABITS ------ --
		$tmpAR0=array('Userpay_Userpaytype',);
		foreach ($tmpAR0 as $Row0){
			//-- #VALUE --
			$tmpValue='';
			if ($Row0=='Userpay_Userpaytype') {
				$tmpValue=$pDescriptions[1]['Columns']['shupctPaytypeid']['Value'];

			}
			//-- #SEARCH --
			$tmpSQL=' SELECT A.uihtID,A.uihtFlag,A.uihtValue
				FROM {Nets.TableHead}netsuserinfohabits AS A
				WHERE 1=1 AND A.uihtRecycle=0 AND A.uihtChecked>1 AND 
				A.uihtCreateBy={Nets.CreateBy} AND A.uihtFlag LIKE \'{Nets.Flag}\' ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.CreateBy}',$pUserinfo[0]['Columns']['uitID']['Value'],$tmpSTR);
			$tmpSTR=str_replace('{Nets.Flag}',$Row0,$tmpSTR);
			$tmpData0=$this->Search($tmpSTR);
			if (count($tmpData0)==0) {
				//-- #ADD --
				$tmpDbDescriptions=$this->sDbDescriptions_Other[0];
				//#Get numCode
				$tmpSTR='uihtNumCode';
				$tmpDbDescriptions[0]['TableDescription']['SearchColumn']=$tmpSTR;
				$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']='N'.$this->sysSPLIT11.date('YmdHis');
				$this->numCode($tmpDbDescriptions[0]);
				
				//-- #Setting --
				$tmpDbDescriptions[0]['Columns']['uihtName']['Value']=$Row0;
				$tmpDbDescriptions[0]['Columns']['uihtChecked']['Value']=2;
				$tmpDbDescriptions[0]['Columns']['uihtFlag']['Value']=$Row0;
				$tmpDbDescriptions[0]['Columns']['uihtValue']['Value']=$tmpValue;
				
				$tmpDbDescriptions[0]['Columns']['uihtCreateBy']['Value']=$pUserinfo[0]['Columns']['uitID']['Value'];
				$tmpDbDescriptions[0]['Columns']['uihtCreateTime']['Value']=date($this->sysTimeFormat);
				//-- #Add --
				$tmpDbDescriptions[0]['TableDescription']['SearchColumn']='uihtNumCode,uihtID';
				$tmpDbDescriptions[1]['TableDescription']['SearchColumn']='uihctIndexID';
				$tmpINT=$this->add($tmpDbDescriptions);
				if($tmpINT!=0){
					$this->TransRollback();
					$this->sysLastError='保存用户习惯信息出错，请客服人员联系。';
					return $tmpINT;
				}
				
			}else if ($tmpData0[0]['uihtValue']!=$tmpValue) {
				//-- #MODIFY --
				$tmpDbDescriptions=$this->sDbDescriptions_Other[0];
				//#Get one
				$Coun0=0;
				while(count($tmpDbDescriptions)>$Coun0){
					if($Coun0==0){
						$tmpDbDescriptions[$Coun0]['Columns']['uihtID']['Value']=$tmpData0[0]['uihtID'];
					}else {
						$tmpDbDescriptions[$Coun0]['Columns']['uihctIndexID']['Value']=$tmpData0[0]['uihtID'];
					}
					$Coun0++;
				}
				$this->getOne($tmpDbDescriptions);
				//-- #Setting --
				$tmpDbDescriptions[0]['Columns']['uihtName']['Value']=$Row0;
				$tmpDbDescriptions[0]['Columns']['uihtChecked']['Value']=2;
				$tmpDbDescriptions[0]['Columns']['uihtFlag']['Value']=$Row0;
				$tmpDbDescriptions[0]['Columns']['uihtValue']['Value']=$tmpValue;
				
				$tmpDbDescriptions[0]['Columns']['uihtCreateBy']['Value']=$pUserinfo[0]['Columns']['uitID']['Value'];
				$tmpDbDescriptions[0]['Columns']['uihtCreateTime']['Value']=date($this->sysTimeFormat);
				
				//#Modify
				$tmpINT=$this->modify($tmpDbDescriptions);
				if($tmpINT!=0){
					$this->TransRollback();
					$this->sysLastError='保存用户习惯信息出错，请客服人员联系。';
					return $tmpINT;
				}
				
				
			}
		}
		//-- ------ #GET ------ --
		$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptNumCode,A.shuptState_Pay,A.shuptState_Get,A.shuptTotalPrice,
			B.shupctPayUserid,B.shupctPaytypeid
			FROM {Nets.TableHead}shopuserpay AS A
			INNER JOIN {Nets.TableHead}shopuserpaycont AS B ON B.shupctIndexID=A.shuptID
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$pDescriptions[0]['Columns']['shuptNumCode']['Value'],$tmpSTR);
		$tmpData_Userpay=$this->Search($tmpSTR);
		if (count($tmpData_Userpay)>1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的支付单并不存在，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Check state ------ --
		if (count($tmpData_Userpay)==1) {
			if ($tmpData_Userpay[0]['shuptState_Pay']>1) {
				$this->TransRollback();
				$this->sysLastError='对不起，您的支付单已被锁定，请确认支付单状态后再试或与客服人员联系。';
				return $this->sysErrorFuncID.'001';
			}
		}
		//-- ------ #ADD OR MODIFY ------ --
		$tmpNumcode='';
		if (count($tmpData_Userpay)==0) {
			//-- ------ #ADD ------ --
			$tmpDbDescriptions=$pDescriptions;
			//#Get numCode
			$tmpSTR='shuptNumCode';
			$tmpDbDescriptions[0]['TableDescription']['SearchColumn']=$tmpSTR;
			$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']=$this->sysFileConfig['NumCodeHead_Userpay'].'_'.date('YmdHis');
			$this->numCode($tmpDbDescriptions[0]);
			
			$tmpNumcode=$tmpDbDescriptions[0]['Columns']['shuptNumCode']['Value'];
			$tmpDbDescriptions[0]['Columns']['shuptName']['Value']=$tmpDbDescriptions[0]['Columns']['shuptNumCode']['Value'];
			$tmpDbDescriptions[0]['Columns']['shuptCreateBy']['Value']=$pUserinfo[0]['Columns']['uitID']['Value'];
			$tmpDbDescriptions[0]['Columns']['shuptCreateTime']['Value']=date($this->sysTimeFormat);
			$tmpDbDescriptions[0]['Columns']['shuptType']['Value']=0;
			$tmpDbDescriptions[0]['Columns']['shuptState_Pay']['Value']=1;
			$tmpDbDescriptions[0]['Columns']['shuptState_Get']['Value']=0;
			$tmpDbDescriptions[0]['Columns']['shuptTotalPrice']['Value']=$pDescriptions[0]['Columns']['shuptTotalPrice']['Value'];
			
			$tmpDbDescriptions[1]['Columns']['shupctPayUsername']['Value']=$pDescriptions[1]['Columns']['shupctPayUsername']['Value'];
			$tmpSQL=' SELECT A.uitID,A.uitName
				FROM {Nets.TableHead}netsuserinfo AS A
				WHERE 1=1 AND A.uitRecycle=0 AND A.uitChecked>1 AND A.uitName LIKE \'{Nets.Name}\' ';
			$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
			$tmpSTR=str_replace('{Nets.Name}',$pDescriptions[1]['Columns']['shupctPayUsername']['Value'],$tmpSTR);
			$tmpData0=$this->Search($tmpSTR);
			if (count($tmpData0)!=1) {
				$this->TransRollback();
				$this->sysLastError='对不起，您要充值的用户并不存在，请确认后再试或与客服人员联系。';
				return $this->sysErrorFuncID.'001';
			}
			$tmpDbDescriptions[1]['Columns']['shupctPayUserid']['Value']=$tmpData0[0]['uitID'];
			$tmpDbDescriptions[1]['Columns']['shupctPaytypeid']['Value']=$pDescriptions[1]['Columns']['shupctPaytypeid']['Value'];
			//-- #ADD --
			$tmpDbDescriptions[0]['TableDescription']['SearchColumn']='shuptNumCode,shuptID';
			$tmpDbDescriptions[1]['TableDescription']['SearchColumn']='shupctIndexID';
			$tmpINT=$this->add($tmpDbDescriptions);
			if($tmpINT!=0){
				$this->TransRollback();
				$this->sysLastError='对不起，保存用户支付单时出错，请与客服人员联系。';
				return $tmpINT;
			}
			
		}else if (count($tmpData_Userpay)==1) {
			//-- ------ #MODIFY ------ --
			$tmpDbDescriptions=$pDescriptions;
			//#Get one
			$tmpDbDescriptions[0]['Columns']['shuptID']['Value']=$tmpData_Userpay[0]['shuptID'];
			$tmpDbDescriptions[1]['Columns']['shupctIndexID']['Value']=$tmpData_Userpay[0]['shuptID'];
			$this->getOne($tmpDbDescriptions);
			
			$tmpNumcode=$tmpDbDescriptions[0]['Columns']['shuptNumCode']['Value'];
			$tmpDbDescriptions[0]['Columns']['shuptType']['Value']=0;
			$tmpDbDescriptions[0]['Columns']['shuptState_Pay']['Value']=1;
			$tmpDbDescriptions[0]['Columns']['shuptState_Get']['Value']=0;
			
			$tmpDbDescriptions[1]['Columns']['shupctPaytypeid']['Value']=$pDescriptions[1]['Columns']['shupctPaytypeid']['Value'];
			//-- #MODIFY --
			$tmpINT=$this->modify($tmpDbDescriptions);
			if($tmpINT!=0){
				$this->TransRollback();
				$this->sysLastError='对不起，保存用户支付单时出错，请与客服人员联系。';
				return $tmpINT;
			}
			
		}
		//-- ------ #URL ------ --
		$tmpSQL=' SELECT B.shuptctWebpaySiteURL
			FROM {Nets.TableHead}shopuserpaytype AS A
			INNER JOIN {Nets.TableHead}shopuserpaytypecont AS B ON B.shuptctIndexID=A.shupttID
			WHERE 1=1 AND A.shupttID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$pDescriptions[1]['Columns']['shupctPaytypeid']['Value'],$tmpSTR);
		$tmpData0=$this->Search($tmpSTR);
		if (count($tmpData0)==0) {
			$pURL=$this->sysFileConfig['PaySubmit_Default'];
		}else {
			$pURL=$tmpData0[0]['shuptctWebpaySiteURL'];
		}
		$pURL.='?NumCode='.$tmpNumcode;
		$this->sysLastMessage='用户支付单已提交成功！本单总金额为：'.$pDescriptions[0]['Columns']['shuptTotalPrice']['Value'].'(人民币)。';
		
		
		$this->TransCommit();
		return 0;
	}
	public function Pay_Confirm(&$pDescriptions,$pUserinfo){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$this->TransStart();
		//-- ------ #GET ------ --
		$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptNumCode,A.shuptState_Pay,A.shuptState_Get,A.shuptTotalPrice,
			B.shupctPayUserid,B.shupctPaytypeid
			FROM {Nets.TableHead}shopuserpay AS A
			INNER JOIN {Nets.TableHead}shopuserpaycont AS B ON B.shupctIndexID=A.shuptID
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$pDescriptions[0]['Columns']['shuptNumCode']['Value'],$tmpSTR);
		$tmpData_Userpay=$this->Search($tmpSTR);
		if (count($tmpData_Userpay)!=1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的支付单并不存在，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Check state ------ --
		if ($tmpData_Userpay[0]['shuptState_Pay']>1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的支付单已被锁定，请确认支付单状态后再试或与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Update userinfo of money(ADD) ------ --
		$tmpSQL=' UPDATE {Nets.TableHead}netsuserinfo AS A
			SET A.uitMoney=A.uitMoney+{Nets.Pay}
			WHERE 1=1 AND A.uitID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Pay}',$tmpData_Userpay[0]['shuptTotalPrice'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.ID}',$tmpData_Userpay[0]['shupctPayUserid'],$tmpSTR);
		$tmpINT=$this->Execute($tmpSTR);
		if ($tmpINT!=0) {
			$this->TransRollback();
			$this->sysLastError='对不起，更新用户资金时出错，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Update userpay ------ --
		$tmpSQL=' UPDATE {Nets.TableHead}shopuserpay AS A
			SET A.shuptState_Pay=2
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$pDescriptions[0]['Columns']['shuptNumCode']['Value'],$tmpSTR);
		$tmpINT=$this->Execute($tmpSTR);
		if ($tmpINT!=0) {
			$this->TransRollback();
			$this->sysLastError='对不起，更新用户支付单时出错，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		
		$this->TransCommit();
		return 0;
	}
	public function Pay_Cancel(&$pDescriptions,$pUserinfo){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$this->TransStart();
		//-- ------ #GET ------ --
		$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptNumCode,A.shuptState_Pay,A.shuptState_Get,A.shuptTotalPrice,
			B.shupctPayUserid,B.shupctPaytypeid
			FROM {Nets.TableHead}shopuserpay AS A
			INNER JOIN {Nets.TableHead}shopuserpaycont AS B ON B.shupctIndexID=A.shuptID
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$pDescriptions[0]['Columns']['shuptNumCode']['Value'],$tmpSTR);
		$tmpData_Userpay=$this->Search($tmpSTR);
		if (count($tmpData_Userpay)!=1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的支付单并不存在，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Check state ------ --
		if ($tmpData_Userpay[0]['shuptState_Pay']>1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的支付单已被锁定，请确认支付单状态后再试或与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Update userpay ------ --
		$tmpSQL=' UPDATE {Nets.TableHead}shopuserpay AS A
			SET A.shuptState_Pay=3
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$pDescriptions[0]['Columns']['shuptNumCode']['Value'],$tmpSTR);
		$tmpINT=$this->Execute($tmpSTR);
		if ($tmpINT!=0) {
			$this->TransRollback();
			$this->sysLastError='对不起，更新用户支付单时出错，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		
		$this->TransCommit();
		return 0;
	}
	//-- ------ #GET ------ --
	/**
	 * Enter description here...
	 *
	 * @return unknown
	 */
	public function Get_Generation(&$pDescriptions,$pUserinfo){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$this->TransStart();
		//-- ------ #GET ------ --
		$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptNumCode,A.shuptState_Pay,A.shuptState_Get,A.shuptTotalPrice,
			B.shupctPayUserid,B.shupctPaytypeid
			FROM {Nets.TableHead}shopuserpay AS A
			INNER JOIN {Nets.TableHead}shopuserpaycont AS B ON B.shupctIndexID=A.shuptID
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$pDescriptions[0]['Columns']['shuptNumCode']['Value'],$tmpSTR);
		$tmpData_Userpay=$this->Search($tmpSTR);
		if (count($tmpData_Userpay)>1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的支付单并不存在，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Check state ------ --
		if (count($tmpData_Userpay)==1) {
			if ($tmpData_Userpay[0]['shuptState_Get']>1) {
				$this->TransRollback();
				$this->sysLastError='对不起，您的支付单已被锁定，请确认支付单状态后再试或与客服人员联系。';
				return $this->sysErrorFuncID.'001';
			}
		}
		//-- ------ #Update userinfo of money(SUB) ------ --
		//-- #Check --
		$tmpSQL=' SELECT A.uitID,A.uitName,A.uitMoney,
			B.uictPayBankCode,B.uictPayBankName,B.uictPayBankUName,B.uictPayBankAddress,B.uictChecked_Bank
			FROM {Nets.TableHead}netsuserinfo AS A
			INNER JOIN {Nets.TableHead}netsuserinfocont AS B ON B.uictIndexID=A.uitID
			WHERE 1=1 AND A.uitRecycle=0 AND A.uitChecked>1 AND A.uitID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.ID}',$pUserinfo[0]['Columns']['uitID']['Value'],$tmpSTR);
		$tmpData_Userinfo=$this->Search($tmpSTR);
		if (count($tmpData_Userinfo)!=1) {
			$this->TransRollback();
			$this->sysLastError='请登陆后再申请提现。';
			return $this->sysErrorFuncID.'001';
		}
		if ($tmpData_Userinfo[0]['uictChecked_Bank']!=2) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的银行帐户信息未经过认证，不能进行提现。';
			return $this->sysErrorFuncID.'001';
		}
		if ($tmpData_Userinfo[0]['uitMoney']<$pDescriptions[0]['Columns']['shuptTotalPrice']['Value']) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的用户资金不足，请确认后再试。';
			return $this->sysErrorFuncID.'001';
		}
		//-- #Update --
		$tmpSQL=' UPDATE {Nets.TableHead}netsuserinfo AS A
			SET A.uitMoney=A.uitMoney-{Nets.Pay}
			WHERE 1=1 AND A.uitID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Pay}',$pDescriptions[0]['Columns']['shuptTotalPrice']['Value'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.ID}',$pUserinfo[0]['Columns']['uitID']['Value'],$tmpSTR);
		$tmpINT=$this->Execute($tmpSTR);
		if ($tmpINT!=0) {
			$this->TransRollback();
			$this->sysLastError='对不起，更新用户资金时出错，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #ADD OR MODIFY ------ --
		if (count($tmpData_Userpay)==0) {
			//-- ------ #ADD ------ --
			$tmpDbDescriptions=$pDescriptions;
			//#Get numCode
			$tmpSTR='shuptNumCode';
			$tmpDbDescriptions[0]['TableDescription']['SearchColumn']=$tmpSTR;
			$tmpDbDescriptions[0]['Columns'][$tmpSTR]['Value']=$this->sysFileConfig['NumCodeHead_Userpay'].'_'.date('YmdHis');
			$this->numCode($tmpDbDescriptions[0]);
			
			$tmpDbDescriptions[0]['Columns']['shuptName']['Value']=$tmpData_Userinfo[0]['Columns']['shuptNumCode']['Value'];
			$tmpDbDescriptions[0]['Columns']['shuptCreateBy']['Value']=$pUserinfo[0]['Columns']['uitID']['Value'];
			$tmpDbDescriptions[0]['Columns']['shuptCreateTime']['Value']=date($this->sysTimeFormat);
			$tmpDbDescriptions[0]['Columns']['shuptType']['Value']=1;
			$tmpDbDescriptions[0]['Columns']['shuptState_Pay']['Value']=0;
			$tmpDbDescriptions[0]['Columns']['shuptState_Get']['Value']=1;
			$tmpDbDescriptions[0]['Columns']['shuptTotalPrice']['Value']=$pDescriptions[0]['Columns']['shuptTotalPrice']['Value'];
			
			$tmpDbDescriptions[1]['Columns']['shupctPayUsername']['Value']=$tmpData_Userinfo[0]['uitName'];
			$tmpDbDescriptions[1]['Columns']['shupctPayUserid']['Value']=$tmpData_Userinfo[0]['uitID'];
			$tmpDbDescriptions[1]['Columns']['shupctPaytypeid']['Value']=0;
			
			$tmpDbDescriptions[1]['Columns']['shupctReceiveCode']['Value']=$tmpData_Userinfo[0]['uictPayBankCode'];
			$tmpDbDescriptions[1]['Columns']['shupctReceiveBank']['Value']=$tmpData_Userinfo[0]['uictPayBankName'];
			$tmpDbDescriptions[1]['Columns']['shupctReceiveName']['Value']=$tmpData_Userinfo[0]['uictPayBankUName'];
			$tmpDbDescriptions[1]['Columns']['shupctReceiveAddress']['Value']=$tmpData_Userinfo[0]['uictPayBankAddress'];
			
			//-- #ADD --
			$tmpDbDescriptions[0]['TableDescription']['SearchColumn']='shuptNumCode,shuptID';
			$tmpDbDescriptions[1]['TableDescription']['SearchColumn']='shupctIndexID';
			$tmpINT=$this->add($tmpDbDescriptions);
			if($tmpINT!=0){
				$this->TransRollback();
				$this->sysLastError='对不起，保存用户支付单时出错，请与客服人员联系。';
				return $tmpINT;
			}
			
		}else if (count($tmpData_Userpay)==1) {
			//-- ------ #MODIFY ------ --
			$tmpDbDescriptions=$pDescriptions;
			//#Get one
			$tmpDbDescriptions[0]['Columns']['shuptID']['Value']=$tmpData_Userpay[0]['shuptID'];
			$tmpDbDescriptions[1]['Columns']['shupctIndexID']['Value']=$tmpData_Userpay[0]['shuptID'];
			$this->getOne($tmpDbDescriptions);
			
			$tmpDbDescriptions[0]['Columns']['shuptType']['Value']=1;
			$tmpDbDescriptions[0]['Columns']['shuptState_Pay']['Value']=0;
			$tmpDbDescriptions[0]['Columns']['shuptState_Get']['Value']=1;
			$tmpDbDescriptions[0]['Columns']['shuptTotalPrice']['Value']=$pDescriptions[0]['Columns']['shuptTotalPrice']['Value'];
			
			$tmpDbDescriptions[1]['Columns']['shupctPayUsername']['Value']=$tmpData_Userinfo[0]['uitName'];
			$tmpDbDescriptions[1]['Columns']['shupctPayUserid']['Value']=$tmpData_Userinfo[0]['uitID'];
			$tmpDbDescriptions[1]['Columns']['shupctPaytypeid']['Value']=0;
			
			$tmpDbDescriptions[1]['Columns']['shupctReceiveCode']['Value']=$tmpData_Userinfo[0]['uictPayBankCode'];
			$tmpDbDescriptions[1]['Columns']['shupctReceiveBank']['Value']=$tmpData_Userinfo[0]['uictPayBankName'];
			$tmpDbDescriptions[1]['Columns']['shupctReceiveName']['Value']=$tmpData_Userinfo[0]['uictPayBankUName'];
			$tmpDbDescriptions[1]['Columns']['shupctReceiveAddress']['Value']=$tmpData_Userinfo[0]['uictPayBankAddress'];
			
			//-- #MODIFY --
			$tmpINT=$this->modify($tmpDbDescriptions);
			if($tmpINT!=0){
				$this->TransRollback();
				$this->sysLastError='对不起，保存用户支付单时出错，请与客服人员联系。';
				return $tmpINT;
			}
			
		}
		
		$this->TransCommit();
		return 0;
	}
	public function Get_Processed(&$pDescriptions,$pUserinfo){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$this->TransStart();
		//-- ------ #GET ------ --
		$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptNumCode,A.shuptState_Pay,A.shuptState_Get,A.shuptTotalPrice,
			B.shupctPayUserid,B.shupctPaytypeid
			FROM {Nets.TableHead}shopuserpay AS A
			INNER JOIN {Nets.TableHead}shopuserpaycont AS B ON B.shupctIndexID=A.shuptID
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$pDescriptions[0]['Columns']['shuptNumCode']['Value'],$tmpSTR);
		$tmpData_Userpay=$this->Search($tmpSTR);
		if (count($tmpData_Userpay)!=1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的支付单并不存在，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Check state ------ --
		if ($tmpData_Userpay[0]['shuptState_Get']>1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的提现单已被锁定，请确认支付单状态后再试或与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Update userpay ------ --
		$tmpSQL=' UPDATE {Nets.TableHead}shopuserpay AS A
			SET A.shuptState_Pay=2
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$tmpData_Userpay[0]['shuptNumCode'],$tmpSTR);
		$tmpINT=$this->Execute($tmpSTR);
		if ($tmpINT!=0) {
			$this->TransRollback();
			$this->sysLastError='对不起，更新用户支付单时出错，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		
		
		$this->TransCommit();
		return 0;
	}
	public function Get_Confirm(&$pDescriptions,$pUserinfo){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$this->TransStart();
		//-- ------ #GET ------ --
		$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptNumCode,A.shuptState_Pay,A.shuptState_Get,A.shuptTotalPrice,
			B.shupctPayUserid,B.shupctPaytypeid
			FROM {Nets.TableHead}shopuserpay AS A
			INNER JOIN {Nets.TableHead}shopuserpaycont AS B ON B.shupctIndexID=A.shuptID
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$pDescriptions[0]['Columns']['shuptNumCode']['Value'],$tmpSTR);
		$tmpData_Userpay=$this->Search($tmpSTR);
		if (count($tmpData_Userpay)!=1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的支付单并不存在，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Check state ------ --
		if ($tmpData_Userpay[0]['shuptState_Get']!=2) {
			$this->TransRollback();
			$this->sysLastError='对不起，本提现单还未支付或已锁定不能确认，请确认支付单状态后再试或与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Update userpay ------ --
		$tmpSQL=' UPDATE {Nets.TableHead}shopuserpay AS A
			SET A.shuptState_Pay=3
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$tmpData_Userpay[0]['shuptNumCode'],$tmpSTR);
		$tmpINT=$this->Execute($tmpSTR);
		if ($tmpINT!=0) {
			$this->TransRollback();
			$this->sysLastError='对不起，更新用户支付单时出错，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		
		
		$this->TransCommit();
		return 0;
	}
	public function Get_Cancel(&$pDescriptions,$pUserinfo){
		$this->sysErrorFuncID=$this->sysErrorClassID.'02';
		$this->TransStart();
		//-- ------ #GET ------ --
		$tmpSQL=' SELECT A.shuptID,A.shuptName,A.shuptNumCode,A.shuptState_Pay,A.shuptState_Get,A.shuptTotalPrice,
			B.shupctPayUserid,B.shupctPaytypeid
			FROM {Nets.TableHead}shopuserpay AS A
			INNER JOIN {Nets.TableHead}shopuserpaycont AS B ON B.shupctIndexID=A.shuptID
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$pDescriptions[0]['Columns']['shuptNumCode']['Value'],$tmpSTR);
		$tmpData_Userpay=$this->Search($tmpSTR);
		if (count($tmpData_Userpay)!=1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的支付单并不存在，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Check state ------ --
		if ($tmpData_Userpay[0]['shuptState_Get']>1) {
			$this->TransRollback();
			$this->sysLastError='对不起，您的提现单已被锁定，请确认支付单状态后再试或与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Update userinfo of money(SUB) ------ --
		$tmpSQL=' UPDATE {Nets.TableHead}netsuserinfo AS A
			SET A.uitMoney=A.uitMoney+{Nets.Pay}
			WHERE 1=1 AND A.uitID={Nets.ID} ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Pay}',$tmpData_Userpay[0]['shuptTotalPrice'],$tmpSTR);
		$tmpSTR=str_replace('{Nets.ID}',$tmpData_Userpay[0]['shupctPayUserid'],$tmpSTR);
		$tmpINT=$this->Execute($tmpSTR);
		if ($tmpINT!=0) {
			$this->TransRollback();
			$this->sysLastError='对不起，更新用户资金时出错，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		//-- ------ #Update userpay ------ --
		$tmpSQL=' UPDATE {Nets.TableHead}shopuserpay AS A
			SET A.shuptState_Pay=4
			WHERE 1=1 AND A.shuptNumCode LIKE \'{Nets.Numcode}\' ';
		$tmpSTR=str_replace('{Nets.TableHead}',$this->sysTableHead,$tmpSQL);
		$tmpSTR=str_replace('{Nets.Numcode}',$tmpData_Userpay[0]['shuptNumCode'],$tmpSTR);
		$tmpINT=$this->Execute($tmpSTR);
		if ($tmpINT!=0) {
			$this->TransRollback();
			$this->sysLastError='对不起，更新用户支付单时出错，请与客服人员联系。';
			return $this->sysErrorFuncID.'001';
		}
		
		
		$this->TransCommit();
		return 0;
	}
	
	
}
?>