CheckStatus.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: songdb
  5. * Date: 2017/12/26
  6. * Time: 下午5:26
  7. */
  8. namespace App\Console\Commands\Channel;
  9. use App\Modules\Channel\Services\ChannelService;
  10. use App\Modules\SendOrder\Services\SendOrderService;
  11. use App\Modules\Channel\Services\ChannelUserService;
  12. use Log;
  13. use Illuminate\Console\Command;
  14. class CheckStatus extends Command
  15. {
  16. /**
  17. * 执行命令 php artisan generate_order_day_stat
  18. *
  19. * The name and signature of the console command.
  20. *
  21. * @var string
  22. */
  23. protected $signature = 'channel_user_check_status';
  24. /**
  25. * The console command description.
  26. *
  27. * @var string
  28. */
  29. protected $description = '检测渠道账号状态';
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. print_r("======检测渠道账号状态 【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
  38. Log::info("======检测渠道账号状态 【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
  39. $channel_users = ChannelUserService::getChannelList([],1);
  40. if(count($channel_users))
  41. {
  42. $channel_users->each(function($channel_user) {
  43. $channel_ids = ChannelService::getUserChannelIds($channel_user->id);
  44. $total_send_order_num = 0;
  45. foreach ($channel_ids as $channel_id)
  46. {
  47. $distribution_channel_id = $channel_id;
  48. $total_send_order_num += (int)SendOrderService::getPromotionCount(compact('distribution_channel_id'));
  49. }
  50. $except_channel_user_ids = [];
  51. //判断是否有派单,并且注册时间大于15天 设置为待审核状态
  52. if($total_send_order_num == 0 && time() - strtotime($channel_user->created_at) > 86400*15 && !in_array($channel_user->id,$except_channel_user_ids))
  53. {
  54. ChannelUserService::updateChannelData($channel_user->id,['is_enabled'=>0]);
  55. }
  56. });
  57. }
  58. Log::info("======检测渠道账号状态 【任务执行结束】=====".date("y-m-d H:i:s"."\n"));
  59. print_r("======检测渠道账号状态 【任务执行结束】=====".date("y-m-d H:i:s"."\n"));
  60. }
  61. }