fansMaximumNotice.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tandunzhao
  5. * Date: 2017/11/20
  6. * Time: 下午5:26
  7. */
  8. namespace App\Console\Commands;
  9. use App\Modules\Channel\Services\ChannelService;
  10. use App\Modules\User\Services\UserSubscribeBehaviorStatsService;
  11. use Log;
  12. use Illuminate\Console\Command;
  13. use DB;
  14. class fansMaximumNotice extends Command
  15. {
  16. /**
  17. * 执行命令 php artisan force_user_active
  18. *
  19. * The name and signature of the console command.
  20. *
  21. * @var string
  22. */
  23. protected $signature = 'addFansMaximumNotice';
  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. /*$channels = ChannelService::getAllChannels();
  38. foreach ($channels as $channel) {
  39. $item = DB::table('official_accounts')
  40. ->where([
  41. ['distribution_channel_id','=',$channel->id],
  42. ['subscribe_day_maximum','=',0],
  43. ['is_enabled','=',1]
  44. ])
  45. ->first();
  46. }*/
  47. $res = DB::select("select official_accounts.* from distribution_channels left join official_accounts
  48. on official_accounts.distribution_channel_id=distribution_channels.id
  49. where official_accounts.subscribe_day_maximum=0 and official_accounts.is_enabled=1
  50. and not exists( select fln.id from fans_limit_notice as fln
  51. where fln.distribution_channel_id=official_accounts.distribution_channel_id
  52. and fln.date='".date('Y-m-d')."' and fln.appid=official_accounts.appid)");
  53. $data = [];
  54. foreach ($res as $item){
  55. $data[] = array(
  56. 'distribution_channel_id'=>$item->distribution_channel_id,
  57. 'appid'=>$item->appid,
  58. 'title'=>'阈值提醒',
  59. 'account_nickname'=>$item->nickname,
  60. 'is_read'=>0,
  61. 'date'=>date('Y-m-d'),
  62. 'created_at'=>date('Y-m-d H:i:s'),
  63. 'updated_at'=>date('Y-m-d H:i:s')
  64. );
  65. }
  66. $inserted = DB::table('fans_limit_notice')->insert($data);
  67. }
  68. }