Cron.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Clue\Lib;
  3. use Dever;
  4. Class Cron
  5. {
  6. public function stat_api()
  7. {
  8. $start=mktime(0,0,0,date('m'),date('d'),date('Y'))-86400;
  9. $end = $start+86400-1;
  10. $data = Dever::db('work/branch')->state();
  11. foreach ($data as $k => $v) {
  12. $w['follow_group_id'] = $v['group_id'];
  13. $w['start'] = $start;
  14. $w['end'] = $end;
  15. $where['group_id'] = $v['group_id'];
  16. $where['day'] = $start;
  17. // $cy = Dever::db('clue/info_log')->getCountAll($w);
  18. $info = Dever::db('clue/info')->getAll($w);
  19. $create = Dever::db('clue/info')->getAll(array('start'=>$start,'end'=>$end,'create_group_id'=>$v['group_id']));
  20. $cinfo = array_merge($info,$create);
  21. $rest = array();
  22. foreach ($cinfo as $k1 =>$v1) {
  23. $rest[$v1['id']]=$v1;
  24. }
  25. $where['group_num'] = count($rest);
  26. $w['type'] = '1,2,3,4,5';
  27. $where['num'] = Dever::db('clue/info')->getHAll($w);
  28. $w['type'] = 1;
  29. $where['d_num'] = Dever::db('clue/info')->getHAll($w);
  30. $w['type'] = 2;
  31. $where['dg_num'] = Dever::db('clue/info')->getHAll($w);
  32. $wh['type'] = 3;
  33. $wh['gstart'] = $start;
  34. $wh['gend'] = $end;
  35. $wh['follow_group_id'] = $v['group_id'];
  36. $where['g_num'] = Dever::db('clue/info')->getHAll($w);
  37. $w1['follow_group_id'] = $v['group_id'];
  38. $w1['fstart'] = $start;
  39. $w1['fend'] = $end;
  40. $w1['type'] = 5;
  41. $where['qx_num'] = Dever::db('clue/info')->getHAll($w1);
  42. $w1['type'] = 4;
  43. $where['f_num'] = Dever::db('clue/info')->getHAll($w1);
  44. $res = Dever::db('clue/info_stat')->find(array('group_id'=>$v['group_id'],'day'=>$start,'clear'=>true));
  45. $where['clear'] = true;
  46. if ($res) {
  47. $where['where_id'] = $res['id'];
  48. Dever::db('clue/info_stat')->update($where);
  49. } else{
  50. Dever::db('clue/info_stat')->insert($where);
  51. }
  52. // print_R($where);die;
  53. // $data[''] = Dever::db('clue/info')->
  54. }
  55. }
  56. }