MockThumbTimingJob.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Console\Commands\User;
  3. use App\Jobs\MockThumbJob;
  4. use App\Models\User\UserModel;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\Redis;
  7. /**
  8. * 用户模拟点赞定时触发任务
  9. * Class MockThumbNoLoginJob
  10. * @package App\Console\Commands\User
  11. */
  12. class MockThumbTimingJob extends Command
  13. {
  14. /**
  15. * The name and signature of the console command.
  16. *
  17. * @var string
  18. */
  19. protected $signature = 'mockthumb:timing';
  20. /**
  21. * The console command description.
  22. *
  23. * @var string
  24. */
  25. protected $description = '未登录用户模拟点赞';
  26. /**
  27. * Create a new command instance.
  28. *
  29. * @return void
  30. */
  31. public function __construct()
  32. {
  33. parent::__construct();
  34. }
  35. /**
  36. * Execute the console command.
  37. *
  38. * @return mixed
  39. */
  40. public function handle()
  41. {
  42. try {
  43. $key = "fpdx:mockthumb:timing";
  44. $uids = Redis::smembers($key);
  45. $user = UserModel::join("kdgx_user_auth_key", 'kdgx_partner_charge_user.uid', '=', 'kdgx_user_auth_key.uid')
  46. ->join('kddx_user_openid', 'kdgx_user_auth_key.auth_key', '=', 'kddx_user_openid.unionid')
  47. ->where(array(
  48. ['partner_id', 0],
  49. ['kdgx_user_auth_key.auth_type', 'kdgx_unionid']
  50. ))->whereIn('kddx_user_openid.public_id', ['gh_b598cb7474d8', 'gh_c94c95866ca5'])
  51. ->whereNotIn('kdgx_user_auth_key.uid', $uids)->first([
  52. 'kdgx_user_auth_key.uid',
  53. 'kddx_user_openid.subscribe'
  54. ]);
  55. dump($user->uid);
  56. if (1 == $user->subscribe) {
  57. MockThumbJob::dispatch($user->uid, 1, 1);
  58. } else {
  59. MockThumbJob::dispatch($user->uid, 1, 2);
  60. }
  61. Redis::sadd($key, [$user->uid]);
  62. } catch (\Exception $exception) {
  63. }
  64. }
  65. }