我只运行了一次,为什么这段代码会执行两次呢?

浏览:1570 发布日期:2017/03/09 分类:求助交流
<?php
namespace app\Api\controller;
use think\Db;

class Data extends \think\Controller
{
private $uid;
function _initialize()
{
$this->Data=\think\Loader::model('Data');
}

function cwxappa()
{ //创建微信安卓APP订单
$cid=input('param.cid','');
$orderid=input('param.orderid','');
$fee=input('param.fee',''); //单位 元
$notifyurl=input('param.notifyurl','');
$attach=input('param.attach','');
$returnurl=input('param.returnurl','');
$paytype='wxpay_android';
$json=array();
if(empty($cid) || !is_numeric($cid)){
$json["result"]="2";
$json["message"]="商户号不正确";
return json_encode($json);
}
$count=Db::name('Commercial')->where('id',$cid)->count('id');
if($count==0){
$json["result"]="3";
$json["message"]="商户号不存在";
return json_encode($json);
}
if(empty($orderid)){
$json["result"]="4";
$json["message"]="订单号不能为空";
return json_encode($json);
}
$count=Db::name('Data')->field('orderid')->where('orderid',$orderid)->count('id');
if($count!=0){
$json["result"]="5";
$json["message"]="订单号重复";
return json_encode($json);
}
if(empty($fee) || !is_numeric($fee)){
$json["result"]="6";
$json["message"]="订单金额错误";
return json_encode($json);
}
if(!$this->Data->check_url($notifyurl)){
$json["result"]="7";
$json["message"]="异步回调地址错误";
return json_encode($json);
}
$list=Db::name('Commercial')->field('id,uid')->where('id',$cid)->find();
$ct['uid']=$list['uid']; //取出UID
$ct['cid']=$cid;
$ct['paymentno']=md5(time() . mt_rand(1000,9999));
$ct['orderid']=$orderid;
$ct['payfee']=$fee;
$ct['stime']=date('Y-m-d H:i:s');
$ct['paytype']=$paytype;
$ct['returnurl']=$returnurl;
$ct['notifyurl']=$notifyurl;
$ct['attach']=$attach;
Db::name('Data')->insert($ct);
}
==========================
执行记录
[ 2017-03-09T16:54:09+08:00 ] ::1 ::1 GET /paytp5/public/Api/Data/cwxappa?cid=1&orderid=wx_hg002_1234575&fee=2¬ifyurl=http://sdf.sdfs51.com&attach=111_222
[ log ] localhost/paytp5/public/Api/Data/cwxappa?cid=1&orderid=wx_hg002_1234575&fee=2¬ifyurl=http://sdf.sdfs51.com&attach=111_222 [运行时间:0.059000s][吞吐率:16.95req/s] [内存消耗:4,147.08kb] [文件加载:40]
[ info ] [ LANG ] D:\wamp\www\paytp5\thinkphp\lang\zh-cn.php
[ info ] [ ROUTE ] array (
'type' => 'module',
'module' =>
array (
0 => 'Api',
1 => 'Data',
2 => 'cwxappa',
),
)
[ info ] [ HEADER ] array (
'host' => 'localhost',
'connection' => 'keep-alive',
'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'upgrade-insecure-requests' => '1',
'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36',
'accept-encoding' => 'gzip, deflate, sdch',
'accept-language' => 'zh-CN,zh;q=0.8',
'cookie' => 'CNZZDATA1254987536=351953663-1488264466-%7C1488264466; CNZZDATA1254987535=952846977-1488260992-%7C1488260992; ads=2; PHPSESSID=mvnohi69j96lgipfcgec6iph67',
)
[ info ] [ PARAM ] array (
'cid' => '1',
'orderid' => 'wx_hg002_1234575',
'fee' => '2',
'notifyurl' => 'http://sdf.sdfs51.com',
'attach' => '111_222',
)
[ info ] [ DB ] INIT mysql
[ info ] [ RUN ] app\Api\controller\Data->cwxappa[ D:\wamp\www\paytp5\application\Api\Controller\Data.php ]
[ info ] [ LOG ] INIT File
[ sql ] [ DB ] CONNECT:[ UseTime:0.001000s ] mysql:dbname=payment;host=127.0.0.1;charset=utf8
[ sql ] [ SQL ] SHOW COLUMNS FROM `py_commercial` [ RunTime:0.001000s ]
[ sql ] [ SQL ] SELECT COUNT(id) AS tp_count FROM `py_commercial` WHERE `id` = 1 LIMIT 1 [ RunTime:0.000000s ]
[ sql ] [ SQL ] SHOW COLUMNS FROM `py_data` [ RunTime:0.000000s ]
[ sql ] [ SQL ] SELECT COUNT(id) AS tp_count FROM `py_data` WHERE `orderid` = 'wx_hg002_1234575' LIMIT 1 [ RunTime:0.001000s ]
[ sql ] [ SQL ] SELECT `id`,`uid` FROM `py_commercial` WHERE `id` = 1 LIMIT 1 [ RunTime:0.001000s ]
[ sql ] [ SQL ] INSERT INTO `py_data` (`uid` , `cid` , `paymentno` , `orderid` , `payfee` , `stime` , `paytype` , `returnurl` , `notifyurl` , `attach`) VALUES (2 , 1 , 'ed52b56f9f8a475708e41bd93fd68237' , 'wx_hg002_1234575' , 2 , '2017-03-09 16:54:09' , 'wxpay_android' , '' , 'http://sdf.sdfs51.com' , '111_222') [ RunTime:0.000000s ]

---------------------------------------------------------------
[ 2017-03-09T16:54:09+08:00 ] ::1 ::1 GET /paytp5/public/Api/Data/cwxappa?cid=1&orderid=wx_hg002_1234575&fee=2¬ifyurl=http://sdf.sdfs51.com&attach=111_222
[ log ] localhost/paytp5/public/Api/Data/cwxappa?cid=1&orderid=wx_hg002_1234575&fee=2¬ifyurl=http://sdf.sdfs51.com&attach=111_222 [运行时间:0.048000s][吞吐率:20.83req/s] [内存消耗:4,137.51kb] [文件加载:40]
[ info ] [ LANG ] D:\wamp\www\paytp5\thinkphp\lang\zh-cn.php
[ info ] [ ROUTE ] array (
'type' => 'module',
'module' =>
array (
0 => 'Api',
1 => 'Data',
2 => 'cwxappa',
),
)
[ info ] [ HEADER ] array (
'host' => 'localhost',
'connection' => 'keep-alive',
'cache-control' => 'max-age=0',
'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'upgrade-insecure-requests' => '1',
'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36',
'accept-encoding' => 'gzip, deflate, sdch',
'accept-language' => 'zh-CN,zh;q=0.8',
'cookie' => 'CNZZDATA1254987536=351953663-1488264466-%7C1488264466; CNZZDATA1254987535=952846977-1488260992-%7C1488260992; ads=2; PHPSESSID=mvnohi69j96lgipfcgec6iph67',
)
[ info ] [ PARAM ] array (
'cid' => '1',
'orderid' => 'wx_hg002_1234575',
'fee' => '2',
'notifyurl' => 'http://sdf.sdfs51.com',
'attach' => '111_222',
)
[ info ] [ DB ] INIT mysql
[ info ] [ RUN ] app\Api\controller\Data->cwxappa[ D:\wamp\www\paytp5\application\Api\Controller\Data.php ]
[ info ] [ LOG ] INIT File
[ sql ] [ DB ] CONNECT:[ UseTime:0.001000s ] mysql:dbname=payment;host=127.0.0.1;charset=utf8
[ sql ] [ SQL ] SHOW COLUMNS FROM `py_commercial` [ RunTime:0.001000s ]
[ sql ] [ SQL ] SELECT COUNT(id) AS tp_count FROM `py_commercial` WHERE `id` = 1 LIMIT 1 [ RunTime:0.001000s ]
[ sql ] [ SQL ] SHOW COLUMNS FROM `py_data` [ RunTime:0.001000s ]
[ sql ] [ SQL ] SELECT COUNT(id) AS tp_count FROM `py_data` WHERE `orderid` = 'wx_hg002_1234575' LIMIT 1 [ RunTime:0.000000s ]

---------------------------------------------------------------

在IE,谷歌,360兼容模式下就没有问题, 但极速模式下就会执行两次
最佳答案
评论( 相关
后面还有条评论,点击查看>>