<?php
if(!$_SESSION['admin_id']){
	pe_goto("index.php");
}
$menumark = 'cashout_list';
switch ($act) {
	//#####################@ 提现状态更改sql @#####################//
	case 'statesql':
		$info['cashout_ptime'] = intval($_g_state) == 1 ? time() : 0;
	 	$info['cashout_state'] = intval($_g_state);
		if ($db->pe_update('cashout', array('cashout_id'=>$_g_id), $info)) {
			//更改用户账户金额
			$cashout = $db->pe_select('cashout', array('cashout_id'=>$_g_id));
			if ($info['cashout_state'] == 1) {
				$sqlset = " `user_money` = `user_money` - 0";
			}
			else {
				$sqlset = " `user_money` = `user_money` + {$cashout['cashout_money']}";
			}
			$db->pe_update('user', array('user_id'=>$cashout['user_id']), $sqlset);
			pe_success('提现申请状态更改成功!');
		}
		else {
			pe_error('提现申请状态更改失败...');
		}
	break;
	//#####################@ 提现删除sql @#####################//
	case 'delsql':
		if ($db->pe_delete('cashout', array('cashout_id'=>$_g_id))) {
			pe_success('提现删除成功!');
		}
		else {
			pe_error('提现删除失败...');
		}
	break;
	//#####################@ 提现列表 @#####################//
	default:
		$_g_user_name && $sqlwhere .= " and `user_name` like '%{$_g_user_name}%'";
		$_g_cashout_bankname && $sqlwhere .= " and `cashout_bankname` like '%{$_g_cashout_bankname}%'";
		$sqlwhere .= " order by `cashout_id` desc";
		$info_list = $db->pe_selectall('cashout', $sqlwhere, '*', array(20, $_g_page));

		$seo = pe_seo('提现列表', '', '', 'cashout');
		include(pe_tpl('cashout_list.html'));
	break;
}
pe_result();
?>