Commit ebf35c0b by 冷斌

fix bug

parent 1b78bd4b
<?php
function xmlToArray($xmlStr)
{
return (array)simplexml_load_string($xmlStr, 'SimpleXMLElement', LIBXML_NOCDATA);
}
function returnInfo($type, $msg)
{
if ($type == "SUCCESS") {
return $returnXml = "<xml><return_code><![CDATA[{$type}]]></return_code></xml>";
} else {
return $returnXml = "<xml><return_code><![CDATA[{$type}]]></return_code><return_msg><![CDATA[{$msg}]]></return_msg></xml>";
}
}
function getConfig($link)
{
$config=M("options")->where("option_name='configpri'")->getField("option_value");
$result = mysqli_query($link, "select option_value from cmf_options where option_name='configpri' ");
$row = mysqli_fetch_assoc($result);
return json_decode($config,$row['option_value']);
}
$xmlInfo = file_get_contents("php://input");
$arrayInfo = xmlToArray($xmlInfo);
file_put_contents('./logali.txt', date('y-m-d h:i:s') . ' msg:' . ' 返回参数:' . http_build_query($xmlInfo) . "\r\n", FILE_APPEND);
$link = mysqli_connect("mysql", "zhibo", "Rni43v7RpkWUP9FD");
if (!$link) {
file_put_contents('./logali.txt', date('y-m-d h:i:s') . ' msg:' . ' 数据库连接失败:' . "\r\n", FILE_APPEND);
echo $this->returnInfo("FAIL", "数据库连接失败");
die;
}
mysqli_select_db($link, 'zhibo');
mysqli_query($link, "set names utf8");
$config = getConfig($link);
var_dump($config);
die;
if ($arrayInfo['return_code'] == "SUCCESS") {
$wxSign = $arrayInfo['sign'];
unset($arrayInfo['sign']);
$arrayInfo['appid'] = $config['wx_appid'];
$arrayInfo['mch_id'] = $config['wx_mchid'];
$key = $config['wx_key'];
ksort($arrayInfo);//按照字典排序参数数组
$sign = $this->sign($arrayInfo, $key);//生成签名
$this->logwx("数据打印测试签名signmy:" . $sign . ":::微信sign:" . $wxSign);//log打印保存
if ($this->checkSign($wxSign, $sign)) {
echo $this->returnInfo("SUCCESS", "OK");
$this->logwx("签名验证结果成功:" . $sign);//log打印保存
$this->orderServer();//订单处理业务逻辑
exit;
} else {
echo $this->returnInfo("FAIL", "签名失败");
$this->logwx("签名验证结果失败:本地加密:" . $sign . ':::::三方加密' . $wxSign);//log打印保存
exit;
}
} else {
echo $this->returnInfo("FAIL", "签名失败");
$this->logwx($arrayInfo['return_code']);//log打印保存
exit;
}
if ($trade_status == 'TRADE_SUCCESS') {
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
//注意:
//付款完成后,支付宝系统发送该交易状态通知
//请务必判断请求时的total_fee、seller_id与通知时获取的total_fee、seller_id为一致的
//调试用,写文本函数记录程序运行情况是否正常
//logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
$out_trade_no = $_POST['out_trade_no'];
//支付宝交易号
$trade_no = $_POST['trade_no'];
$link = mysqli_connect("mysql", "zhibo", "Rni43v7RpkWUP9FD");
if ($link) {
mysqli_select_db($link, 'zhibo');
mysqli_query($link, "set names utf8");
$result = mysqli_query($link, "select * from cmf_users_charge where orderno='$out_trade_no' and status='0' and type='1'");
$row = mysqli_fetch_assoc($result);
if ($row) {
mysqli_query($link, "update cmf_users set coin=coin+{$row['coin']} where id='$row[touid]'");
mysqli_query($link, "update cmf_users_charge set status='1',trade_no='$trade_no' where id={$row['id']}");
file_put_contents('./logali.txt', date('y-m-d h:i:s') . ' msg:' . "支付成功:\r\n", FILE_APPEND);
} else {
file_put_contents('./logali.txt', date('y-m-d h:i:s') . ' msg:' . "orderno:" . $out_trade_no . ' 订单信息不存在' . "\r\n", FILE_APPEND);
}
}
echo "success"; //请不要修改或删除
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} else {
file_put_contents('./logali.txt', date('y-m-d h:i:s') . ' msg:' . ' 验证失败:' . http_build_query($_POST) . "\r\n", FILE_APPEND);
//验证失败
echo "fail";
//调试用,写文本函数记录程序运行情况是否正常
//logResult("这里写入想要调试的代码变量值,或其他运行的结果记录");
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment