Cron.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Passport\Lib;
  3. use Dever;
  4. class Cron
  5. {
  6. public function combine_api()
  7. {
  8. }
  9. # 定时合并
  10. public function combine()
  11. {
  12. $combine = Dever::project('combine');
  13. if ($combine) {
  14. $where['status'] = 1;
  15. $data = Dever::db('passport/combine')->state($where);
  16. if ($data) {
  17. foreach ($data as $k => $v) {
  18. //$drop = implode(',', $v['old_uid']);
  19. $drop = $v['old_uid'];
  20. Dever::load('combine/lib/core.handle?uid=' . $v['new_uid'] . '&drop=' . $drop);
  21. $update['where_id'] = $v['id'];
  22. $update['status'] = 2;
  23. Dever::db('passport/combine')->update($update);
  24. }
  25. }
  26. //Dever::daemon('lib/core.handle?uid=' . $cur . '&drop=' . $drop, 'combine');
  27. }
  28. return 'ok';
  29. }
  30. # 获取用户每日新增数量
  31. public function user_api(){}
  32. public function user()
  33. {
  34. $num = Dever::input('num', 1);
  35. $start = Dever::input('start', date('Y-m-d', strtotime('-'.$num.' day')));
  36. $end = Dever::input('end', date('Y-m-d'));
  37. $start = Dever::maketime($start . ' 00:00:00');
  38. $end = Dever::maketime($end . ' 23:59:59');
  39. $day = intval(($end - $start)/86400);
  40. for($i=0; $i<=$day; $i++) {
  41. $where['start'] = $start + 86400*$i;
  42. $where['end'] = $start + 86400*$i + 86399;
  43. $num = Dever::db('passport/user')->getNum($where);
  44. if ($num <= 0) {
  45. continue;
  46. }
  47. $data = array();
  48. $data['day'] = $where['start'];
  49. $info = Dever::db('passport/stat')->find($data);
  50. $data['user'] = $num;
  51. $order = Dever::config('base')->passport_stat_order;
  52. if ($order) {
  53. $order = Dever::load($order, $where);
  54. $data['order_user'] = $order;
  55. }
  56. $data['hb'] = 0;
  57. if (!$info) {
  58. Dever::db('passport/stat')->insert($data);
  59. } else {
  60. $data['where_id'] = $info['id'];
  61. Dever::db('passport/stat')->update($data);
  62. }
  63. }
  64. }
  65. }