if("" != $val && "sign" != $key && $key != 'code') {
$sign .= "$key=$val&";
}
}
$sign .= "key=".$payment['tenpay_key'];
if(strtolower(md5($sign))==strtolower($_GET['sign']))
{
if($trade_state==0)
{
/* 改变订单状态 */
if($this->success_db($out_trade_no))
return $msg = "支付成功!<br> <a href='/'>返回主页</a> <a href='/member'>会员中心</a>";
else return $msg = "支付失败!<br> <a href='/'>返回主页</a> <a href='/member'>会员中心</a>";
}
}
else{
//return $msg = "支付失败!<br> <a href='/'>返回主页</a> <a href='/member'>会员中心</a>";
}
}
/*处理物品交易*/
function success_db($order_sn)
{
$time=time();
$mid=$this->mid;
//获取订单信息,检查订单的有效性
$row = $this->dsql->GetOne("SELECT state,priceCount FROM ym_shops_orders WHERE oid='$order_sn' ");
if($row['state'] > 0)
{
return TRUE;
}
/* 改变订单状态_支付成功 */
$sql = "UPDATE `ym_shops_orders` SET `state`='1' WHERE `oid`='$order_sn' AND `userid`='".$this->mid."'";
if($this->dsql->ExecuteNoneQuery($sql))
{
$this->log_result("verify_success,订单号:".$order_sn); //将验证结果存入文件
return TRUE;
} else {
$this->log_result ("verify_failed,订单号:".$order_sn);//将验证结果存入文件
return FALSE;
}
}
function log_result($word) {
global $cfg_cmspath;
$fp = fopen(dirname(__FILE__)."/../../data/payment/log.txt","a");
flock($fp, LOCK_EX) ;
fwrite($fp,$word.",执行日期:".strftime("%Y-%m-%d %H:%I:%S",time())."\r\n");
flock($fp, LOCK_UN);
fclose($fp);
}
}