<?php
if (!defined('ROOT')) exit('Can\'t Access !'); 
class mod_autoreceive extends module_class{
 	function main(){
		exit;
	}
	
 	function chinabank(){
       $key = config::get("chinabankkey");
       $v_oid = trim($_POST['v_oid']);       // 商户发送的v_oid定单编号   
       $v_pmode = trim($_POST['v_pmode']);    // 支付方式（字符串）   
       $v_pstatus =trim($_POST['v_pstatus']);   //  支付状态 ：20（支付成功）；30（支付失败）
       $v_pstring =trim($_POST['v_pstring']);   // 支付结果信息 ： 支付完成（当v_pstatus=20时）；失败原因（当v_pstatus=30时,字符串）； 
       $v_amount  =trim($_POST['v_amount']);     // 订单实际支付金额
       $v_moneytype  =trim($_POST['v_moneytype']); //订单实际支付币种    
       $remark1   =trim($_POST['remark1' ]);      //备注字段1
       $remark2   =trim($_POST['remark2' ]);     //备注字段2
       $v_md5str  =trim($_POST['v_md5str' ]);   //拼凑后的MD5校验值                   
       $md5string=strtoupper(md5($v_oid.$v_pstatus.$v_amount.$v_moneytype.$key));
       if($v_md5str==$md5string){
	      if($v_pstatus=="20"){
		     $order =  $this->mysql->select_one("select * from {$this->pre}payorder where orderid='{$v_oid}' and checked=0");
			 if(is_array($order)){
               $this->mysql->update("{$this->pre}payorder",array('checked'=>1),"orderid='{$v_oid}'");
               $this->mysql->query("update {$this->pre}user set `money`=`money`+{$v_amount} where uid='{$order[uid]}'");
		       $log['uid'] = $order[uid];
		       $log['addtime'] = time();
		       $log['content'] = "在线充值{$v_amount}元现金，订单号{$v_oid}";
		       $log['lognum'] = "+".$v_amount;
               $this->mysql->insert("{$this->pre}log",$log);
			 }else{
               exit("定单已经处理");
			 }
	      }else{
		    exit("支付失败");
	      }
       }else{
	      exit("校验失败,数据可疑");
       }	
   }
	
}
?>