forked from ouyangss/TGNotifyForEpay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotifyv1.php
50 lines (43 loc) · 1.6 KB
/
notifyv1.php
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
#!/usr/bin/env php
<?php
define ('VERIONS', '1.0.2');
define ('APP_PATH', __DIR__);
define ('APP_URL', rtrim (dirname ($_SERVER['SCRIPT_NAME']), DIRECTORY_SEPARATOR));
define ('SRC', APP_PATH . '/src');
require_once APP_PATH."/config.php";
require_once SRC."/Medoo.php";
require_once SRC."/Tcurl.php";
use Medoo\Medoo;
//加载数据库和redis
try{
$database = new Medoo([
'database_type' => 'mysql',
'server' => $_ENV["servername"],
'port' => $_ENV["port"],
'database_name' => $_ENV["formname"],
'username' => $_ENV["username"],
'password' => $_ENV["passwd"]
]);
$redis = new Redis();
$redis->connect($_ENV["redis_host"], $_ENV["redis_port"]);
$redis->ping();
}catch (Exception $e){
echo $e->getMessage();
die("Fail to connect database or redis!");
}
//设置机器人密钥
Tcurl::SetBotToken($_ENV["bottoken"]);
for($orderNo = $redis->rPop('orderno');$_ENV["number"] && $orderNo;$_ENV["number"]--){
$curOrder = $database->select("pay_order",["uid","out_trade_no","type","name","getmoney","endtime","domain"],["trade_no"=>$orderNo]);
$tgid = $redis->get($curOrder[0]['uid']);
var_dump($curOrder);
if($tgid){
$messsage = "收款通知!\n尊敬的用户{$curOrder[0]['uid']}您好!\n内部订单号{$curOrder[0]['trade_no']}\n外部订单号{$curOrder[0]['out_trade_no']}\n到账金额{$curOrder[0]['getmoney']}\n付款时间{$curOrder[0]['endtime']}\n网站{$curOrder[0]['domain']}";
Tcurl::Tpost("sendMessage",["chat_id"=>$tgid,"text"=>$messsage]);
unset($messsage);
}
unset($tgid);
unset($curOrder);
$orderNo = $redis->rPop('orderno');
}
$redis->close();