PartnerCommand.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace App\Console\Commands\Data;
  3. use App\Models\Common\CityModel;
  4. use App\Models\Fpdx\PairModel;
  5. use App\Models\PartnerModel;
  6. use Illuminate\Console\Command;
  7. class PartnerCommand extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'data:partner';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'Command description';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. $genders = [0, 1, 2];
  38. foreach ($genders as $sex) {
  39. $wheres = [
  40. "1 = 1",
  41. "(`qq`!= '' or `weixin`!= '')",
  42. "(`qq`!= '' or `weixin`!= '') AND (`photo_src` is NOT null or `photo_1`IS NOT NULL or `photo_2` IS NOT NULL or `photo_3` IS NOT NULL or `photo_4` IS NOT NULL or `voice` IS NOT NULL)",
  43. "`is_sell`= 1 ",
  44. "`is_sell`= 1 AND `score`> 0",
  45. "`is_sell`= 1 AND `feed_push_type`= 3",
  46. "`is_sell`= 1 AND `score`> 0 AND `feed_push_type`= 3",
  47. "`is_sell`= 1 AND `score`> 0 AND `feed_pool_level` != 'low' AND `feed_push_type` = 3"
  48. ];
  49. foreach ($wheres as $where) {
  50. echo PartnerModel::when($sex, function ($query) use ($sex) {
  51. $query->where('sex', $sex);
  52. })->whereRaw($where)->count();
  53. echo "\t";
  54. echo PartnerModel::when($sex, function ($query) use ($sex) {
  55. $query->where('sex', $sex);
  56. })->whereRaw("`uid` IN( SELECT `uid` FROM `koudai`.`kddx_user_openid` WHERE `public_id`= 'gh_c94c95866ca5' AND `subscribe`= 1)")->whereRaw($where)->count();
  57. echo "\t";
  58. echo PartnerModel::when($sex, function ($query) use ($sex) {
  59. $query->where('sex', $sex);
  60. })->whereRaw("`uid` IN( SELECT `uid` FROM `koudai`.`kddx_user_openid` WHERE `public_id`= 'gh_b598cb7474d8' AND `subscribe`= 1 )")->whereRaw($where)->count();
  61. echo "\t";
  62. echo PartnerModel::when($sex, function ($query) use ($sex) {
  63. $query->where('sex', $sex);
  64. })->whereRaw("`uid` IN( SELECT `uid` FROM `koudai`.`kddx_user_openid` WHERE `public_id`= 'gh_c94c95866ca5' AND `subscribe`= 1 AND `uid` NOT IN( SELECT `uid` FROM `koudai`.`kddx_user_openid` WHERE `public_id`= 'gh_b598cb7474d8') AND `uid`> 0 AND `subscribe`= 1 )")->whereRaw($where)->count();
  65. echo "\t";
  66. echo PartnerModel::when($sex, function ($query) use ($sex) {
  67. $query->where('sex', $sex);
  68. })->whereRaw("`uid` IN( SELECT `uid` FROM `koudai`.`kddx_user_openid` WHERE `public_id`= 'gh_c94c95866ca5' AND `subscribe`= 1 AND `uid` IN( SELECT `uid` FROM `koudai`.`kddx_user_openid` WHERE `public_id`= 'gh_b598cb7474d8') AND `uid`> 0 AND `subscribe`= 1 )")->whereRaw($where)->count();
  69. echo "\n";
  70. }
  71. echo "---------------\n\n";
  72. }
  73. }
  74. }