MobileGetCommand.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. class MobileGetCommand extends CConsoleCommand{
  3. public function run($args) {
  4. error_reporting(E_ALL);
  5. ini_set('memory_limit', '1024M');
  6. set_time_limit(0);
  7. $month = array('2015-9','2015-10','2015-11','2015-12','2016-1','2016-2');
  8. foreach ($month as $key => $value) {
  9. if($key == count($month)-1){
  10. break;
  11. }
  12. $value = array();
  13. $start_time = strtotime($value);
  14. $end_time = strtotime($month[$key+1]);
  15. $criteria = new EMongoCriteria();
  16. $criteria->order_time('<=',$start_time);
  17. $criteria->order_time('>=',$end_time);
  18. $cursor = ROrder::model()->findAll($criteria);
  19. foreach ($cursor as $order) {
  20. if(isset($order->address['mobile']) && $order->address['mobile']){
  21. if(!in_array($order->address['mobile'], $$value)){
  22. // $$value[] = $order->address['mobile'];
  23. array_push($$value, $order->address['mobile']);
  24. }
  25. }
  26. }
  27. $str = implode("\r\n", $$value);
  28. file_put_contents(APP_PATH.'/download/'.$value.'_order_mobile.txt',$str);
  29. unset($str);
  30. }
  31. // $criteria = new EMongoCriteria();
  32. // $criteria->order_time('<=',$current_time);
  33. // $criteria->order_time('>=',$current_time);
  34. // $criteria->status('==',1);
  35. // $cursor = ROrder::model()->findAll($criteria);
  36. // // $cache = new ARedisCache();
  37. // foreach ($cursor as $order) {
  38. // if(isset($order->address['mobile']) && $order->address['mobile']){
  39. // if(!$cache->get('sendsms_'.$order->address['mobile'])){
  40. // file_put_contents(APP_PATH.'/download/shanghai_foreign_mobile.txt',$order->address['mobile']."\r\n",FILE_APPEND);
  41. // // $cache->set('sendsms_'.$order->address['mobile'],1,86400);
  42. // }
  43. // }
  44. // }
  45. // $file = file_get_contents("D://shanghai_foreign_mobile.txt");
  46. // $mobile_arr = explode("\r\n",$file);
  47. // $mobile = array_unique($mobile_arr);
  48. // $file = file_get_contents("D://wz_shanghai_mobile.txt");
  49. // $wz_mobile = explode("\r\n",$file);
  50. // foreach ($mobile as $key => $value) {
  51. // if(!in_array($value,$wz_mobile)){
  52. // file_put_contents("D://only_foreign_mobile.txt",$value."\r\n",FILE_APPEND);
  53. // }
  54. // }
  55. }
  56. }