OldDataCommand.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. namespace App\Console\Commands\Notices;
  3. use App\Models\Fpdx\PairModel;
  4. use App\Models\User\UserModel;
  5. use App\Models\PartnerModel;
  6. use App\Models\User\Openid;
  7. use Illuminate\Console\Command;
  8. class OldDataCommand extends Command
  9. {
  10. /**
  11. * The name and signature of the console command.
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'notice:data';
  16. /**
  17. * The console command description.
  18. *
  19. * @var string
  20. */
  21. protected $description = '通知数据';
  22. /**
  23. * Create a new command instance.
  24. *
  25. * @return void
  26. */
  27. public function __construct()
  28. {
  29. parent::__construct();
  30. }
  31. /**
  32. * Execute the console command.
  33. *
  34. * @return mixed
  35. */
  36. public function handle()
  37. {
  38. //
  39. $this->vip();
  40. $this->fpdx();
  41. $this->visitor();
  42. $this->recommendCancel();
  43. $this->phoneNotCard();
  44. $this->oncePair();
  45. }
  46. public function vip()
  47. {
  48. dump("老用户召回-激活会员通知");
  49. $uids = \DB::connection('mysql_datalog')
  50. ->table("notice_logs")
  51. ->where('title', '老用户召回-激活会员通知')
  52. ->distinct()
  53. ->pluck('uid');
  54. $unsubscribe_count = Openid::whereIn('uid', $uids)
  55. ->where('public_id', 'gh_b598cb7474d8')
  56. ->where('subscribe', 0)
  57. ->count();
  58. $vip_count = UserModel::where('be_vip_at', '>', 0)->whereIn('uid', $uids)->count();
  59. dump("取关人数{$unsubscribe_count}");
  60. dump("会员人数{$vip_count}");
  61. }
  62. public function fpdx()
  63. {
  64. dump("老用户召回-对象包分配通知");
  65. $uids = \DB::connection('mysql_datalog')
  66. ->table("notice_logs")
  67. ->where('title', '老用户召回-对象包分配通知')
  68. ->distinct()
  69. ->pluck('uid');
  70. $unsubscribe_count = Openid::whereIn('uid', $uids)
  71. ->where('public_id', 'gh_b598cb7474d8')
  72. ->where('subscribe', 0)
  73. ->count();
  74. $pair_count = PairModel::where('uid', $uids)->distinct('uid')->count();
  75. dump("取关人数{$unsubscribe_count}");
  76. dump("匹配人数{$pair_count}");
  77. }
  78. public function visitor()
  79. {
  80. dump("老用户召回-访客通知");
  81. $uids = \DB::connection('mysql_datalog')
  82. ->table("notice_logs")
  83. ->where('title', '老用户召回-访客通知')
  84. ->distinct()
  85. ->pluck('uid');
  86. $unsubscribe_count = Openid::whereIn('uid', $uids)
  87. ->where('public_id', 'gh_b598cb7474d8')
  88. ->where('subscribe', 0)
  89. ->count();
  90. dump("取关人数{$unsubscribe_count}");
  91. }
  92. public function recommendCancel()
  93. {
  94. dump("交友卡片-卡片取消推荐通知");
  95. $uids = \DB::connection('mysql_datalog')
  96. ->table("notice_logs")
  97. ->where('title', '交友卡片-卡片取消推荐通知')
  98. ->where('result', 1)
  99. ->distinct()
  100. ->pluck('uid');
  101. $unsubscribe_count = Openid::whereIn('uid', $uids)
  102. ->where('public_id', 'gh_b598cb7474d8')
  103. ->where('subscribe', 0)
  104. ->count();
  105. $number = $uids->count();
  106. $card = PartnerModel::where('upload_at', '>', 1560873600)->whereIn('uid', $uids)->count();
  107. dump("发送人数{$number}");
  108. dump("取关人数{$unsubscribe_count}");
  109. dump("更换照片人数{$card}");
  110. }
  111. public function phoneNotCard()
  112. {
  113. dump("老用户召回-有手机号但无卡片者通知");
  114. $uids = \DB::connection('mysql_datalog')
  115. ->table("notice_logs")
  116. ->where('title', '老用户召回-有手机号但无卡片者通知')
  117. ->distinct()
  118. ->pluck('uid');
  119. $unsubscribe_count = Openid::whereIn('uid', $uids)
  120. ->where('public_id', 'gh_b598cb7474d8')
  121. ->where('subscribe', 0)
  122. ->count();
  123. $number = $uids->count();
  124. $card_count = UserModel::where('partner_id', '>', 0)->whereIn('uid', $uids)->count();
  125. dump("发送人数{$number}");
  126. dump("取关人数{$unsubscribe_count}");
  127. dump("交友卡片人数{$card_count}");
  128. }
  129. public function oncePair()
  130. {
  131. dump("老用户召回-仅参与过一次活动的用户");
  132. $uids = \DB::connection('mysql_datalog')
  133. ->table("notice_logs")
  134. ->where('title', '老用户召回-仅参与过一次活动的用户')
  135. ->distinct()
  136. ->pluck('uid');
  137. $unsubscribe_count = Openid::whereIn('uid', $uids)
  138. ->where('public_id', 'gh_b598cb7474d8')
  139. ->where('subscribe', 0)
  140. ->count();
  141. $pair_count = PairModel::where('create_time', '>', 1560787200)
  142. ->whereIn('uid', $uids)
  143. ->distinct()
  144. ->count();
  145. dump("取关人数{$unsubscribe_count}");
  146. dump("报名人数{$pair_count}");
  147. }
  148. }