Cron.php 780 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. #计划任务
  3. namespace Act\Lib;
  4. use Dever;
  5. class Cron
  6. {
  7. # 清理一小时前的待支付数据
  8. public function drop_order_api()
  9. {
  10. $where['where_time'] = time() - 3600;
  11. Dever::db('act/order')->drop($where);
  12. return 'ok';
  13. }
  14. # 将七天前的数据进行迁移 废弃
  15. public function mv_order()
  16. {
  17. return 'error';
  18. $where['where_time'] = time() - (86400 * 7);
  19. $data = Dever::db('act/order')->getAllByDate($where);
  20. if ($data) {
  21. $db = Dever::db('act/order_bak');
  22. foreach ($data as $k => $v) {
  23. $info = $db->one(array('order_id' => $v['order_id']));
  24. if (!$info) {
  25. $id = $v['id'];
  26. unset($v['id']);
  27. $db->insert($v);
  28. Dever::db('act/order')->delete($id);
  29. }
  30. }
  31. }
  32. return 'ok';
  33. }
  34. }