Index.php
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use think\Db;
use app\api\controller\Excel;
use qx\Qx;
use isc\Api;
class Index extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = '';
public function index()
{
// $qx = new Qx();
//$info = $qx->geturl("http://openapi.qxwz.com/rest/linkx.devices.list/ack/U48c2jnr9901?pageNo=1&pageSize=2000");
// $info = $qx->geturl("http://openapi.qxwz.com/rest/linkx.devices.data/ack/U48c2jnr9901?deviceId=1000000792&startTime=1642643359000&endTime=1644544164936");
// var_dump(json_decode($info,true));
// exit;
// $api = new Api();
// var_dump($api->getPreviewUrl('1ef84de21c0e4aa19cde1c17b38bd065'));
}
public function test()
{
$number = 100000;
$min = 0;
$max = 1;
$total = 0;
for ($i = 0; $i < $number; $i++) {
$num = $min + mt_rand() / mt_getrandmax() * ($max - $min);
$res = sprintf("%.10f", $num); //控制小数后几位
if ($res <= 0.0000010207) {
echo '有' . $res . '</br>';
} else {
echo '没有' . $res . '</br>';
}
if ($res <= 0.000001) {
$total++;
}
}
echo $total;
}
public function apptoken()
{
$appid = 'wx5488f94eb1c0bded';
$secret = 'db6ac40041ecf6c7447620392ce59357';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
$res = json_decode(file_get_contents($url), true);
Db::name('weixin_apptoken')->where('id', '=', 1)->update(['token' => $res['access_token']]);
}
//变更模板消息状态
public function updateWxtemplate()
{
$code = input('get.code');
$openid = input('get.openid');
if (!$code || !$openid) {
$this->error('非法操作', '');
} else {
$res = Db::name('inspection_wxtemplatelog')->where('openid', '=', $openid)->where('code', '=', $code)->update(['status' => '1']);
if ($res) {
$this->success('告警接收成功', '');
} else {
$this->error('非法操作2', '');
}
}
}
}