first commit

This commit is contained in:
2026-01-25 18:18:09 +08:00
commit 509312e604
8136 changed files with 2349298 additions and 0 deletions

View File

@ -0,0 +1,137 @@
<?php
/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license https://www.yiiframework.com/license/
*/
namespace app\commands;
use app\common\FileHelper;
use app\common\SaltHelper;
use app\enums\SourceEnum;
use app\models\Brand;
use app\models\BrandAlias;
use app\models\BrandRunwayImages;
use app\models\BrandSource;
use app\models\logics\commands\SpiderVogue;
use app\models\User;
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
use yii\console\Controller;
use yii\console\ExitCode;
/**
* This command echoes the first argument that you have entered.
*
* This command is provided as an example for you to learn how to create console commands.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class HelloController extends Controller
{
/**
* This command echoes what you have entered as the message.
* @param string $message the message to be echoed.
* @return int Exit code
*/
public function actionIndex($message = 'hello world')
{
foreach(BrandRunwayImages::find()->each() as $item) {
var_dump($item['image']);
$cont = file_get_contents($item['image']);
$imageName = md5(SaltHelper::addSalt($item['image']));
$imagePath = md5(SaltHelper::addSalt($item['runway_id']));
if (!is_dir(\Yii::getAlias('@runtime') . "/{$imagePath}")) {
FileHelper::createDirectory(\Yii::getAlias('@runtime') . "/{$imagePath}");
}
file_put_contents(\Yii::getAlias('@runtime') . "/{$imagePath}/{$imageName}", $cont);
$accessKey = '7GLHrN7BqrI9JnWZ9Pki2q5rqPazhIFroo19a-Av';
$secretKey = 'gmg6PLgg666Cme-gsyTlsBLhshDv-6_zsEmW4jRY';
$auth = new Auth($accessKey, $secretKey);
$bucket = '23cm';
// 生成上传Token
$token = $auth->uploadToken($bucket);
// 要上传文件的本地路径
$filePath = \Yii::getAlias('@runtime') . "/{$imagePath}/{$imageName}";
// 上传到存储后保存的文件名
$key = "{$imagePath}/{$imageName}";
// 初始化 UploadManager 对象并进行文件的上传。
$uploadMgr = new UploadManager();
// 调用 UploadManager 的 putFile 方法进行文件的上传。
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath, null, 'application/octet-stream', true, null, 'v2');
echo "\n====> putFile result: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}
// 构建 UploadManager 对象
// $uploadMgr = new UploadManager();
$qu = BrandRunwayImages::findOne($item['id']);
$qu->name = $key;
$qu->save();
// die;
}
die;
foreach(BrandSource::find()->each() as $item) {
$brandName = Brand::find()->where(['id' => $item['brand_id']])->one()->name;
$brandName = strtr($brandName, [
' ' => '-',
'.' => '-'
]);
var_dump(strtolower($brandName));
$q = BrandSource::findOne($item['id']);
$q->source_url = '/fashion-shows/designer/'.strtolower($brandName);
$q->save();
}
die;
$model = new SpiderVogue();
$model->setBrandName('gucci');
var_dump($model->start());
die;
ini_set('memory_limit', '1024M');
$content = file_get_contents(\Yii::$app->basePath . '/brand.txt');
var_dump($content);
$content = (json_decode($content, true));
// var_dump(json_last_error());
// var_dump(json_last_error_msg());
// var_dump($content);die;
foreach ($content as $item) {
$model = new Brand();
if (stripos($item['name'], '/') !== false) {
$alias = explode('/', $item['name']);
foreach ($alias as $i => $aliasItem) {
if ($i == 0) {
$model->name = $aliasItem;
$model->show_name = $item['name'];
$model->save();
$lastId = $model->id;
var_dump($model->errors);
} else {
$aliasModel = new BrandAlias();
$aliasModel->brand_id = $lastId;
$aliasModel->name = $aliasItem;
$aliasModel->save();
var_dump($aliasModel->errors);
}
}
} else {
$model->name = $item['name'];
$model->show_name = $item['name'];
$model->save();
// var_dump($model->errors);
}
}
return ExitCode::OK;
}
}

View File

@ -0,0 +1,68 @@
<?php
/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license https://www.yiiframework.com/license/
*/
namespace app\commands;
use app\common\CommonHelper;
use app\common\CurlApp;
use app\common\MobileHelper;
use app\models\Brand;
use app\models\BrandRunway;
use app\models\BrandSource;
use app\models\Clue;
use app\models\jobs\RunwayJob;
use app\models\logics\commands\SpiderVogue;
use app\models\Oauth;
use app\models\OauthAccount;
use app\models\OauthAccountLocal;
use app\models\User;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use yii\console\Controller;
use yii\console\ExitCode;
use GuzzleHttp\Exception\RequestException;
use yii\helpers\ArrayHelper;
/**
* This command echoes the first argument that you have entered.
*
* This command is provided as an example for you to learn how to create console commands.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class SpiderController extends Controller
{
public function __construct($id, $module, $config = [])
{
ini_set('pcre.backtrack_limit', '-1');
parent::__construct($id, $module, $config);
}
public function actionVogue()
{
$model = new SpiderVogue();
$model->start();
}
public function actionRunway()
{
foreach (BrandSource::find()->where(['is_deleted' => 0])->each() as $index => $item) {
if ($index == 1) {
\Yii::$app->queue->push(new RunwayJob([
'source' => $item,
]));die;
}
}
}
}