-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcron.php
executable file
·72 lines (62 loc) · 2.97 KB
/
cron.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
require './includes/common.php';
if($_GET['do']=='settle'){
$thtime=date("Y-m-d").' 00:00:00';
$row=$DB->query("SELECT * FROM pay_batch WHERE time>='{$thtime}' limit 1")->fetch();
if($row)exit('batch list is already created');
$limit='1000';
$rs=$DB->query("SELECT * from pay_user where (money>={$conf['settle_money']} or apply=1) and account is not null and username is not null and type!=2 limit {$limit}");
$batch=date("Ymd").rand(111,999);
$i=0;
$allmoney=0;
while($row = $rs->fetch())
{
$i++;
//if($row['apply']==1 && $row['money']<$conf['settle_money']){$fee=$conf['settle_fee'];$row['money']-=$fee;}
//else $fee=0;
$fee=round($row['money']*$conf['settle_rate'],2);
if($fee<$conf['settle_fee_min'] || $row['money']<50)$fee=$conf['settle_fee_min'];
if($fee>$conf['settle_fee_max'])$fee=$conf['settle_fee_max'];
$row['money']=$row['money']-$fee;
$DB->exec("INSERT INTO `pay_settle` (`pid`, `batch`, `type`, `username`, `account`, `money`, `fee`, `time`, `status`) VALUES ('{$row['id']}', '{$batch}', '{$row['settle_id']}', '{$row['username']}', '{$row['account']}', '{$row['money']}', '{$fee}', '{$date}', '0')");
$allmoney+=$row['money'];
}
$DB->exec("INSERT INTO `pay_batch` (`batch`, `allmoney`, `time`, `status`) VALUES ('{$batch}', '{$allmoney}', '{$date}', '0')");
exit('ok allmony='.$allmoney.' num='.$i);
}
$thtime=date("Y-m-d H:i:s",time()-3600*6);
$DB->exec("delete from pay_order where status=0 and addtime<'{$thtime}'");
$rs=$DB->query("SELECT * from pay_user where money!='0.00'");
$allmoney=0;
while($row = $rs->fetch())
{
$allmoney+=$row['money'];
}
$data['usermoney']=$allmoney;
$rs=$DB->query("SELECT * from pay_settle");
$allmoney=0;
while($row = $rs->fetch())
{
$allmoney+=$row['money'];
}
$data['settlemoney']=$allmoney;
$lastday=date("Y-m-d",strtotime("-1 day")).' 00:00:00';
$today=date("Y-m-d").' 00:00:00';
$rs=$DB->query("SELECT * from pay_order where status=1 and endtime>='$today'");
$order_today=array('alipay.trade.precreate'=>0,'tenpay.trade.precreate'=>0,'qq.pay.native'=>0,'wxpay.pay.unifiedorder'=>0,'all'=>0);
while($row = $rs->fetch())
{
$order_today[$row['type']]+=$row['money'];
}
$order_today['all']=$order_today['alipay.trade.precreate']+$order_today['tenpay.trade.precreate']+$order_today['qq.pay.native']+$order_today['wxpay.pay.unifiedorder'];
$rs=$DB->query("SELECT * from pay_order where status=1 and endtime>='$lastday' and endtime<'$today'");
$order_lastday=array('alipay.trade.precreate'=>0,'tenpay.trade.precreate'=>0,'qq.pay.native'=>0,'wxpay.pay.unifiedorder'=>0,'all'=>0);
while($row = $rs->fetch())
{
$order_lastday[$row['type']]+=$row['money'];
}
$order_lastday['all']=$order_today['alipay.trade.precreate']+$order_today['tenpay.trade.precreate']+$order_today['qq.pay.native']+$order_today['wxpay.pay.unifiedorder'];
$data['order_today']=$order_today;
$data['order_lastday']=$order_lastday;
file_put_contents(SYSTEM_ROOT.'db.txt',serialize($data));
echo 'ok';