<?php
class cls_tab_pay_order extends cls_base_table
{
	private $perms=array();
	//构造函数
	function __construct()
	{
		parent::__construct();
		$this->perms["state"]=array("等待付款"=>0,"付款成功"=>1,"付款失败"=>-1);
		$this->perms["score_type_company"]=array("发布职位"=>0);
	}
	function __get($name){
		if(isset($this->perms["$name"])){
			return $this->perms["$name"];
		}
	}
	function __set($name,$value){
		if(isset($this->perms["$name"])){
			$this->perms["$name"]=$value;
		}else{
		}
	}
	function on_save($arr_fields=array())
	{
		$arr_return=array("err"=>"","id"=>0,"order_number"=>"");
		(!isset($arr_fields["order_id"]))? $arr_fields["order_id"]=0:$arr_fields["order_id"]=intval($arr_fields["order_id"]);
		$lng_id=$arr_fields["order_id"];
		unset($arr_fields["order_id"]);//释放id
		if($lng_id<1){
			if(!isset($arr_fields["order_user_id"])){
				$arr_return["err"]="充值用户不能为空！";
				return $arr_return;
			}
			if(!isset($arr_fields["order_money"])){
				$arr_return["err"]="充值金额不对！";
				return $arr_return;
			}
			$arr_fields["order_number"]=TIME.$arr_fields["order_user_id"];
			$arr_fields["order_addtime"]=TIME;
			$arr_return=parent::on_insert(DB_PRE."pay_order",$arr_fields);
			$arr_return["order_number"]=$arr_fields["order_number"];
		}else{
			$str_where="order_id='".$lng_id."'";
			$arr_return=parent::on_update(DB_PRE."pay_order",$arr_fields,$str_where);
			$arr_return["id"]=$lng_id;
		}
		return $arr_return;
	}
	function on_del($arr_id)
	{
		$arr_return=array("err"=>"");
		$str_id=get_arr_id($arr_id);
		if($str_id==""){
			$arr_return["err"]="没有指定要删除的记录！";
			return $arr_return;
		}
		$arr_return=parent::on_del(DB_PRE."pay_order","order_id in(".$str_id.")");
		return $arr_return;
	}
	function on_state($arr_id,$msg_val)
	{
		$arr_return=array("err"=>"");
		$msg_val=(int)$msg_val;
		$str_id=get_arr_id($arr_id);
		if($str_id==""){
			$arr_return["err"]="没有指定要设置的记录！";
			return $arr_return;
		}
		global $obj_db;
		$arr_return["err"]=$obj_db->execute("update ".DB_PRE."pay_order set order_state=".$msg_val." where order_id in(".$str_id.")");
		return $arr_return;
	}

}
?>
