MaintainMenus.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. 维护渠道菜单
  4. */
  5. namespace App\Console\Commands\Tool;
  6. use App\Modules\OfficialAccount\Models\OfficialAccount;
  7. use App\Modules\OfficialAccount\Services\CustomMsgService;
  8. use App\Modules\OfficialAccount\Services\OfficialAccountService;
  9. use Log;
  10. use Illuminate\Console\Command;
  11. use App\Modules\Channel\Models\Channel;
  12. use DB;
  13. class MaintainMenus extends Command
  14. {
  15. /**
  16. * nohup php artisan Tool:MaintainMenus --distribution_channel_id="-1" &
  17. * The name and signature of the console command.
  18. *
  19. * @var string
  20. */
  21. protected $signature = 'Tool:MaintainMenus {--appid=} {--account=} ';
  22. /**
  23. * The console command description.
  24. *
  25. * @var string
  26. */
  27. protected $description = '维护渠道菜单';
  28. /**
  29. * Execute the console command.
  30. *
  31. * @return mixed
  32. */
  33. public function handle()
  34. {
  35. ini_set('memory_limit', '1024M');
  36. print_r('memory_used:'.memory_get_usage()."\n");
  37. print_r("======维护菜单【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
  38. $appid = $this->option('appid');
  39. $account = $this->option('account');
  40. if(empty($appid) && empty($account)){
  41. \Log::info('MaintainMenus_param_is_null:'.$appid);
  42. exit();
  43. }
  44. $appids = [];
  45. if(empty($account)){
  46. $appids[] = $appid;
  47. }else{
  48. $appids = OfficialAccountService::get_account_appids($account);
  49. }
  50. \Log::info('MaintainMenus_start:appids_num:'.count($appids));
  51. \Log::info($appids);
  52. foreach($appids as $key=>$appid){
  53. \Log::info('MaintainMenus_one_start:'.$appid);
  54. OfficialAccountService::update_official_account_menu($appid);
  55. }
  56. \Log::info('MaintainMenus_end');
  57. print_r("======维护菜单 【任务执行结束】=====".date("y-m-d H:i:s"."\n"));
  58. print_r('memory_used:'.memory_get_usage()."\n");
  59. }
  60. }