<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网银在线支付接口</title>
</head>
<body>
<?php
$obj = new payment();
$obj->set_where("pay_code = 'chinabank'");
$one = $obj->get_one();
$pay_config = $one['pay_config'];
$arr = explode('|',$pay_config);
$url = str_replace('\\','/',dirname($_SERVER['SCRIPT_NAME']));
$url = 'http://' . $_SERVER['SERVER_NAME'] . str_replace('payment/chinabank','',$url);
	
//////////////////////////////
	
$key = $arr[1];
	
$v_oid = post('v_oid');
$v_pmode = post('v_pmode');
$v_pstatus = post('v_pstatus');
$v_pstring = post('v_pstring');
$v_amount = post('v_amount');
$v_moneytype = post('v_moneytype');
$remark1 = post('remark1');
$remark2 = post('remark2');
$v_md5str = post('v_md5str');
 
$md5string = strtoupper(md5($v_oid . $v_pstatus . $v_amount . $v_moneytype . $key));
	
if($v_md5str == $md5string)
{
	if($v_pstatus == '20')
	{
		$user_id = check_user_login();
		$obj = new account();
		$obj->set_where('acc_status = 1');
		$obj->set_where("acc_user_id = $user_id");
		$obj->set_where("acc_sn = '$v_oid'");
		if($obj->get_count() == 1)
		{
			$obj->set_value('acc_status',2);
			$obj->set_value('acc_edit_time',time());
			$obj->edit();
			
			$obj = new orders();
			$obj->set_where('ord_status = 0');
			$obj->set_where("ord_user_id = $user_id");
			$obj->set_where("ord_sn = '$v_oid'");
			$obj->set_where("ord_price_total = $v_amount");
			if($obj->get_count() == 1)
			{
				$obj->set_value('ord_status',1);
				$obj->set_value('ord_pay_time',time());
				$obj->edit();
				
				$obj = new account();
				$obj->set_value('acc_user_id',$user_id);
				$obj->set_value('acc_sn',$v_oid);
				$obj->set_value('acc_increase',0);
				$obj->set_value('acc_amount',sprintf('%.2f',$v_amount));
				$obj->set_value('acc_add_time',time());
				$obj->set_value('acc_edit_time',time());
				$obj->set_value('acc_status',2);
				$obj->add();
			}else{
				$money = sprintf('%.2f',get_data('users',$user_id,'use_money'));
				$obj = new users();
				$obj->set_value('use_money',$money + sprintf('%.2f',$v_amount));
				$obj->set_where("use_id = $user_id");
				$obj->edit();
			}
		}
		echo '支付成功，可关闭此窗口';
	}else{
		echo '支付失败';
	}
}else{
	echo '校验失败,数据可疑';
}
	
?>
</body>
</html>