|
@@ -0,0 +1,106 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Console\Commands\Push;
|
|
|
+
|
|
|
+
|
|
|
+use App\Consts\PushConst;
|
|
|
+use App\Libs\Push\HuaWei\HwPushCommon;
|
|
|
+use App\Libs\Push\OPPOPush\OPPOPushCommon;
|
|
|
+use App\Libs\Push\VPush\VPush;
|
|
|
+use App\Libs\Push\XMPush\MiPushCommon;
|
|
|
+use App\Modules\Push\Models\QappPushApp;
|
|
|
+use App\Modules\Push\Models\QappPushUser;
|
|
|
+use App\Modules\Push\Services\PushAppService;
|
|
|
+use Illuminate\Console\Command;
|
|
|
+use phpDocumentor\Reflection\Types\True_;
|
|
|
+
|
|
|
+class PushTagBind extends Command
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * The name and signature of the console command.
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $signature = 'push:tag:bind';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The console command description.
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $description = '推送标签绑定';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ # 标签
|
|
|
+ $tag = PushConst::TOPIC_ALL;
|
|
|
+ $provider = 'oppo';
|
|
|
+
|
|
|
+ # 获取所有oppo app,初始化推送
|
|
|
+ $apps = PushAppService::getAppsByProvider($provider);
|
|
|
+ $clients = $this->initCients($apps);
|
|
|
+
|
|
|
+ # 查询所有oppo用户
|
|
|
+ $id = 0;
|
|
|
+ while (True) {
|
|
|
+ var_dump('last id:'.$id);
|
|
|
+
|
|
|
+ # 获取用户列表
|
|
|
+ $users = PushAppService::getAppUsersByProvider($provider, $id);
|
|
|
+ if (empty($users)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ # 循环绑定tag
|
|
|
+ foreach($users as $user) {
|
|
|
+ $regId = getProp($user, 'reg_id');
|
|
|
+ $appId = getProp($user, 'app_id');
|
|
|
+ $client = getProp($clients, $appId);
|
|
|
+ if (empty($client)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // $client->subscribeTags($regId, $tag);
|
|
|
+ var_dump(getProp($user, 'uid'), $regId, getProp($user, 'provider'));
|
|
|
+ }
|
|
|
+
|
|
|
+ # 分页id
|
|
|
+ $len = count($users);
|
|
|
+ $id = $users[$len - 1]['id'];
|
|
|
+ var_dump('next id:'.$id);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化推送实例
|
|
|
+ *
|
|
|
+ * @param [type] $apps
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ private function initCients($apps)
|
|
|
+ {
|
|
|
+ if(empty($apps)) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+ $clients = [];
|
|
|
+ foreach($apps as $app) {
|
|
|
+ $appId = getProp($app, 'app_id');
|
|
|
+ $appKey = getProp($app, 'app_key');
|
|
|
+ $masterSecret = getProp($app, 'master_secret');
|
|
|
+ $clients[$appId] = new OPPOPushCommon($appKey, $masterSecret);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $clients;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function buildOppoPushTag($regId)
|
|
|
+ {
|
|
|
+ # code...
|
|
|
+ }
|
|
|
+}
|