ConfigSetting.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: z-yang
  5. * Date: 2020/10/27
  6. * Time: 15:22
  7. */
  8. namespace App\Console\Commands\Tool;
  9. use DB;
  10. use Redis;
  11. use Illuminate\Console\Command;
  12. class ConfigSetting extends Command
  13. {
  14. const SPLIT_BOOK_PRIMARY_CHAPTER_NAME = 'config:split_book_primary_chapter_name';
  15. const INNER_SITE_ACTIVITY = 'config:inner_site_activity';
  16. /**
  17. * The name and signature of the console command.
  18. *
  19. * @var string
  20. */
  21. protected $signature = 'Tool:ConfigSetting';
  22. /**
  23. * The console command description.
  24. *
  25. * @var string
  26. */
  27. protected $description = '站点配置';
  28. /**
  29. * Create a new command instance.
  30. *
  31. * @return void
  32. */
  33. public function __construct()
  34. {
  35. parent::__construct();
  36. }
  37. /**
  38. * Execute the console command.
  39. *
  40. * @return mixed
  41. */
  42. public function handle()
  43. {
  44. $this->splitBookShowPrimaryConfig();
  45. $this->innerActivity();
  46. }
  47. //切割章节后,章节名的显示配置
  48. private function splitBookShowPrimaryConfig(){
  49. $sql = "SELECT id FROM distribution_channels WHERE channel_user_id IN (SELECT id FROM channel_users WHERE phone in (
  50. '18668420256'))";
  51. $result = DB::select($sql);
  52. foreach ($result as $item){
  53. Redis::sadd(self::SPLIT_BOOK_PRIMARY_CHAPTER_NAME,$item->id);
  54. }
  55. }
  56. //内部活动
  57. private function innerActivity(){
  58. $sql = "SELECT id FROM distribution_channels WHERE channel_user_id IN (SELECT id FROM channel_users WHERE phone in (
  59. '18668420256'))";
  60. $result = DB::select($sql);
  61. foreach ($result as $item){
  62. if(in_array($item->id, [])){
  63. continue;
  64. }
  65. Redis::sadd(self::INNER_SITE_ACTIVITY,$item->id);
  66. }
  67. }
  68. }