1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace Passport\Lib;
- use Dever;
- class Cron
- {
- public function combine_api()
- {
- }
- # 定时合并
- public function combine()
- {
- $combine = Dever::project('combine');
- if ($combine) {
- $where['status'] = 1;
- $data = Dever::db('passport/combine')->state($where);
- if ($data) {
- foreach ($data as $k => $v) {
- //$drop = implode(',', $v['old_uid']);
- $drop = $v['old_uid'];
- Dever::load('combine/lib/core.handle?uid=' . $v['new_uid'] . '&drop=' . $drop);
- $update['where_id'] = $v['id'];
- $update['status'] = 2;
- Dever::db('passport/combine')->update($update);
- }
- }
- //Dever::daemon('lib/core.handle?uid=' . $cur . '&drop=' . $drop, 'combine');
- }
- return 'ok';
- }
- # 获取用户每日新增数量
- public function user_api(){}
- public function user()
- {
- $num = Dever::input('num', 1);
- $start = Dever::input('start', date('Y-m-d', strtotime('-'.$num.' day')));
- $end = Dever::input('end', date('Y-m-d'));
- $start = Dever::maketime($start . ' 00:00:00');
- $end = Dever::maketime($end . ' 23:59:59');
- $day = intval(($end - $start)/86400);
- for($i=0; $i<=$day; $i++) {
- $where['start'] = $start + 86400*$i;
- $where['end'] = $start + 86400*$i + 86399;
- $num = Dever::db('passport/user')->getNum($where);
- if ($num <= 0) {
- continue;
- }
- $data = array();
- $data['day'] = $where['start'];
- $info = Dever::db('passport/stat')->find($data);
- $data['user'] = $num;
- $order = Dever::config('base')->passport_stat_order;
- if ($order) {
- $order = Dever::load($order, $where);
- $data['order_user'] = $order;
- }
- $data['hb'] = 0;
-
- if (!$info) {
- Dever::db('passport/stat')->insert($data);
- } else {
- $data['where_id'] = $info['id'];
- Dever::db('passport/stat')->update($data);
- }
- }
- }
- }
|