<?php
saxue_includedb();
class saxuemembermoney extends saxueobjectdata {
		function saxuemembermoney() {
				$this -> initvar( "id", SAXUE_TYPE_INT, 0, "流水ID", false, 11 );
				$this -> initvar( "uid", SAXUE_TYPE_INT, 0, "会员ID", false, 11 );
				$this -> initvar( "amount", SAXUE_TYPE_OTHER, "0.00", "金钱数额", false, null );
				$this -> initvar( "balance", SAXUE_TYPE_OTHER, "0.00", "金钱余额", false, null );
				$this -> initvar( "time", SAXUE_TYPE_INT, 0, "流水日期", false, 10 );
				$this -> initvar( "aid", SAXUE_TYPE_INT, 0, "文章ID", false, 11 );
				$this -> initvar( "type", SAXUE_TYPE_INT, 0, "说明", false, 4 );
		} 
} 

class saxuemembermoneyhandler extends saxueobjecthandler {
		function saxuemembermoneyhandler( $_db = "" ) {
				$this -> saxueobjecthandler( $_db );
				$this -> basename = "membermoney";
				$this -> autoid = "id";
				$this -> dbname = "member_money";
		} 

		function addlog( $_data ) {
				if ( empty( $_data ) || !is_array( $_data ) || empty( $_data['uid'] ) || empty( $_data['amount'] ) || $_data['amount'] == 0 ) {
						return false;
				} 
				$_newlog = $this -> create();
				$_newlog -> setvar( "id", 0 );
				$_newlog -> setvar( "uid", intval( $_data['uid'] ) );
				$_newlog -> setvar( "amount", saxue_dround( $_data['amount'] ) );
				$_newlog -> setvar( "balance", saxue_dround( $_data['balance'] ) );
				$_newlog -> setvar( "time", SAXUE_NOW_TIME );
				$_newlog -> setvar( "aid", intval( $_data['aid'] ) );
				$_newlog -> setvar( "type", intval( $_data['type'] ) );
				return $this -> insert( $_newlog );
		} 
}