1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Console\Commands\User;
- use App\Models\User\UserModel;
- use App\Models\User\Openid;
- use Illuminate\Console\Command;
- class AvatarCommand extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'user:avatar';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '用户头像微信过期,同步微信最新头像';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $users = UserModel::select('uid', 'headimgurl')->where('headimgurl', 'LIKE', '%wx.qlogo.cn/%')->get();
- foreach ($users as $user) {
- // 转base64码
- $headimgurl = str_replace('/132', '/0', $user->headimgurl);
- $base64 = imageGetBase64($headimgurl);
- if ($base64 == 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAIAAAC2BqGFAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2MkcCgL0FAHaOWJAPQGAAgJlCLMwAIDgCAEMeE80DIEwDoDDSv+CpX3CFuEgBAMDLlc2XS9IzFLiV0Bp38vDg4iHiwmyxQmEXKRBmCeQinJebIxNI5wNMzgwAABr50cH+OD+Q5+bk4eZm52zv9MWi/mv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A83fXtrc7IzU+iCxbJAAly5+wAAdq5euHL3AV7uXL2A4hljKnH57oODeQg+3dq8fPfBztULWEDKAVNJRiH4G5vAAAA+3dpUjSpSwrGWSsfLoDRsV7WVaCLelpaTnXqW4Hi3sKPvfvxl4veQ0lF+7/rFeBalXP0CyN0nPXTLNta7idy9/V7MTHff/fjLe9cvKnTwMt6W6s9wNxLoj+ztvesX9/Z7ulxpbaYDAdpY71LGvrrxXiL3nRtfDGBlLJFAdNQl3jbE+p0bX6AolYvoxyXs7fcGt4SxeJUJ/cHOqIpYRVVMdHhxo3eM87c++Cxl7u5+DwDOrHcZ5/icSpxX17tYWNVSFuOtDz77+qPLSgiWRCYAfHXjPUyfOd1F4eP6E5c2rpjUF3LTH/jnnP/jzrUE8y/X7iRykXPmQEM5YirhD6e7qoqSg7lYGNNff3RZyVQlExwsjzgOUyI30e2BKH1I6491cOH/+con43LVYFRiuDByvtvZRgtw5nR3pEz1dQOVi1WUhAndQPpuZ3v3SQ8AxjWhMwT0w+5/NIr74++7E3IfPe4pVwkTifKPHvfinEePe1NlJuinJz31TKShyU1gri6gf9EevcsUCVPl42G5RPmEzPitGidBzahTnaVx3dYbqddvOrL2b7h8Gk6cOa58pp7kvQFiAv8FkdnKKoiMRhugl810GAyKAdqc6ygKaIOzsdHGRhsyGm2ANkAbMkAv1WRogh1Gow3QhjLT/wcAWEYBFeHW4DEAAAAASUVORK5CYII=') {
- $headimgurl = Openid::where('uid', $user->uid)->where(
- 'public_id',
- 'gh_b598cb7474d8'
- )->where('subscribe', 1)->value('headimgurl');
- if ($headimgurl) {
- $headimgurl = str_replace('/132', '/0', $headimgurl);
- $base64 = imageGetBase64($headimgurl);
- } else {
- $user->headimgurl = 'https://oss.pocketuniversity.cn/headimg/2019-04-04/4a9207b81db57c772ad1f52debaa7128.png';
- $user->save();
- continue;
- }
- }
- $response = \Curl::to("http://www.koudaidaxue.com/Tools/Upload/upHeader")->withData([
- 'base64' => $base64,
- ])->asJsonResponse()->post();
- if ($response->code == 0) {
- $headimgurl = $response->data->url;
- $user->headimgurl = $headimgurl;
- $user->save();
- }
- }
- }
- }
|