first commit
This commit is contained in:
16
models/BaseModel.php
Normal file
16
models/BaseModel.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
class BaseModel extends ActiveRecord
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
TimestampBehavior::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
56
models/Brand.php
Normal file
56
models/Brand.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "brand".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property string|null $name
|
||||
* @property string|null $show_name
|
||||
* @property int|null $is_deleted
|
||||
*/
|
||||
class Brand extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'brand';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'show_name'], 'default', 'value' => null],
|
||||
[['is_deleted'], 'default', 'value' => 0],
|
||||
[['created_at', 'updated_at', 'is_deleted'], 'integer'],
|
||||
[['name', 'show_name'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'name' => 'Name',
|
||||
'show_name' => 'Show Name',
|
||||
'is_deleted' => 'Is Deleted',
|
||||
];
|
||||
}
|
||||
}
|
||||
58
models/BrandAlias.php
Normal file
58
models/BrandAlias.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "brand_alias".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property string|null $name
|
||||
* @property int $brand_id
|
||||
* @property int|null $is_deleted
|
||||
*/
|
||||
class BrandAlias extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'brand_alias';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'default', 'value' => null],
|
||||
[['is_deleted'], 'default', 'value' => 0],
|
||||
[['created_at', 'updated_at', 'brand_id', 'is_deleted'], 'integer'],
|
||||
[['brand_id'], 'required'],
|
||||
[['name'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'name' => 'Name',
|
||||
'brand_id' => 'Brand ID',
|
||||
'is_deleted' => 'Is Deleted',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
68
models/BrandRunway.php
Normal file
68
models/BrandRunway.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "brand_runway".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $title
|
||||
* @property string|null $description
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property int|null $is_deleted
|
||||
* @property int|null $image_count
|
||||
* @property int $brand_id
|
||||
* @property int|null $year
|
||||
* @property string|null $cover
|
||||
* @property string|null $source_url
|
||||
*/
|
||||
class BrandRunway extends \app\models\BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'brand_runway';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['source_url'], 'default', 'value' => ''],
|
||||
[['year'], 'default', 'value' => 0],
|
||||
[['created_at', 'updated_at', 'is_deleted', 'image_count', 'brand_id', 'year'], 'integer'],
|
||||
[['title', 'cover', 'source_url'], 'string', 'max' => 255],
|
||||
[['description'], 'string', 'max' => 1024],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'is_deleted' => 'Is Deleted',
|
||||
'image_count' => 'Image Count',
|
||||
'brand_id' => 'Brand ID',
|
||||
'year' => 'Year',
|
||||
'cover' => 'Cover',
|
||||
'source_url' => 'Source Url',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
61
models/BrandRunwayImages.php
Normal file
61
models/BrandRunwayImages.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "brand_runway_images".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property int|null $is_deleted
|
||||
* @property string|null $image
|
||||
* @property int $runway_id
|
||||
* @property int $brand_id
|
||||
* @property string|null $name
|
||||
*/
|
||||
class BrandRunwayImages extends \app\models\BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'brand_runway_images';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['brand_id'], 'default', 'value' => 0],
|
||||
[['name'], 'default', 'value' => ''],
|
||||
[['created_at', 'updated_at', 'is_deleted', 'runway_id', 'brand_id'], 'integer'],
|
||||
[['image', 'name'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'is_deleted' => 'Is Deleted',
|
||||
'image' => 'Image',
|
||||
'runway_id' => 'Runway ID',
|
||||
'brand_id' => 'Brand ID',
|
||||
'name' => 'Name',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
60
models/BrandSource.php
Normal file
60
models/BrandSource.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "brand_source".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $source
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property int|null $is_deleted
|
||||
* @property int $brand_id
|
||||
* @property string|null $source_url
|
||||
*/
|
||||
class BrandSource extends \app\models\BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'brand_source';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['created_at', 'updated_at'], 'default', 'value' => null],
|
||||
[['brand_id'], 'default', 'value' => 0],
|
||||
[['source_url'], 'default', 'value' => ''],
|
||||
[['source', 'created_at', 'updated_at', 'is_deleted', 'brand_id'], 'integer'],
|
||||
[['source_url'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'source' => 'Source',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'is_deleted' => 'Is Deleted',
|
||||
'brand_id' => 'Brand ID',
|
||||
'source_url' => 'Source Url',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
150
models/Clue.php
Normal file
150
models/Clue.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "clue".
|
||||
*
|
||||
* @property int $id 自增ID
|
||||
* @property string $clue_id 平台线索ID
|
||||
* @property string|null $req_id 请求ID
|
||||
* @property int|null $local_account_id 本地商户ID
|
||||
* @property string|null $advertiser_name 广告主名称
|
||||
* @property string|null $promotion_id 推广计划ID
|
||||
* @property string|null $promotion_name 推广计划名称
|
||||
* @property string|null $action_type 行为类型
|
||||
* @property int|null $ad_type 广告类型
|
||||
* @property string|null $video_id 视频ID
|
||||
* @property string|null $content_id 内容ID
|
||||
* @property string|null $title_id 标题ID
|
||||
* @property string|null $name 姓名
|
||||
* @property string|null $telephone 手机号
|
||||
* @property string|null $weixin 微信
|
||||
* @property string|null $gender 性别
|
||||
* @property int|null $age 年龄
|
||||
* @property string|null $province_name
|
||||
* @property string|null $city_name
|
||||
* @property string|null $county_name
|
||||
* @property string|null $address
|
||||
* @property string|null $auto_province_name 系统识别省
|
||||
* @property string|null $auto_city_name 系统识别市
|
||||
* @property string|null $country_name
|
||||
* @property string|null $author_aweme_id
|
||||
* @property string|null $author_nickname
|
||||
* @property string|null $author_role
|
||||
* @property string|null $staff_aweme_id
|
||||
* @property string|null $staff_nickname
|
||||
* @property string|null $allocation_status 分配状态
|
||||
* @property int|null $convert_status 是否转化
|
||||
* @property string|null $clue_type 线索类型
|
||||
* @property string|null $clue_return_status 线索回传状态
|
||||
* @property int|null $effective_state 是否有效
|
||||
* @property string|null $effective_state_name
|
||||
* @property string|null $follow_state_name
|
||||
* @property string|null $is_private_clue
|
||||
* @property string|null $remark 备注
|
||||
* @property string|null $remark_dict 问答/聊天记录
|
||||
* @property string|null $system_tags 系统标签
|
||||
* @property string|null $tags 自定义标签
|
||||
* @property string|null $create_time_detail 线索创建时间
|
||||
* @property string|null $modify_time 平台更新时间
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property string|null $note
|
||||
* @property int|null $is_virtual
|
||||
*/
|
||||
class Clue extends \app\models\BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'clue';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['req_id', 'local_account_id', 'advertiser_name', 'promotion_id', 'promotion_name', 'action_type', 'ad_type', 'video_id', 'content_id', 'title_id', 'name', 'telephone', 'weixin', 'gender', 'province_name', 'city_name', 'county_name', 'address', 'auto_province_name', 'auto_city_name', 'country_name', 'author_aweme_id', 'author_nickname', 'author_role', 'staff_aweme_id', 'staff_nickname', 'allocation_status', 'clue_type', 'clue_return_status', 'effective_state_name', 'follow_state_name', 'remark', 'remark_dict', 'system_tags', 'tags', 'create_time_detail', 'modify_time', 'note'], 'default', 'value' => null],
|
||||
[['is_virtual'], 'default', 'value' => 0],
|
||||
[['is_private_clue'], 'default', 'value' => 'NO'],
|
||||
[['clue_id'], 'required'],
|
||||
[['local_account_id', 'ad_type', 'age', 'convert_status', 'effective_state', 'created_at', 'updated_at', 'is_virtual'], 'integer'],
|
||||
[['remark', 'remark_dict', 'system_tags', 'tags', 'note'], 'string'],
|
||||
[['create_time_detail', 'modify_time'], 'safe'],
|
||||
[['clue_id', 'action_type', 'content_id', 'author_aweme_id', 'staff_aweme_id'], 'string', 'max' => 32],
|
||||
[['req_id'], 'string', 'max' => 64],
|
||||
[['advertiser_name', 'promotion_id', 'promotion_name', 'video_id', 'title_id', 'is_private_clue'], 'string', 'max' => 100],
|
||||
[['name', 'weixin', 'province_name', 'city_name', 'county_name', 'auto_province_name', 'auto_city_name', 'country_name', 'author_nickname', 'staff_nickname'], 'string', 'max' => 50],
|
||||
[['telephone', 'author_role', 'allocation_status', 'clue_type', 'clue_return_status', 'effective_state_name', 'follow_state_name'], 'string', 'max' => 20],
|
||||
[['gender'], 'string', 'max' => 16],
|
||||
[['address'], 'string', 'max' => 255],
|
||||
[['clue_id'], 'unique'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => '自增ID',
|
||||
'clue_id' => '平台线索ID',
|
||||
'req_id' => '请求ID',
|
||||
'local_account_id' => '本地商户ID',
|
||||
'advertiser_name' => '广告主名称',
|
||||
'promotion_id' => '推广计划ID',
|
||||
'promotion_name' => '推广计划名称',
|
||||
'action_type' => '行为类型',
|
||||
'ad_type' => '广告类型',
|
||||
'video_id' => '视频ID',
|
||||
'content_id' => '内容ID',
|
||||
'title_id' => '标题ID',
|
||||
'name' => '姓名',
|
||||
'telephone' => '手机号',
|
||||
'weixin' => '微信',
|
||||
'gender' => '性别',
|
||||
'age' => '年龄',
|
||||
'province_name' => 'Province Name',
|
||||
'city_name' => 'City Name',
|
||||
'county_name' => 'County Name',
|
||||
'address' => 'Address',
|
||||
'auto_province_name' => '系统识别省',
|
||||
'auto_city_name' => '系统识别市',
|
||||
'country_name' => 'Country Name',
|
||||
'author_aweme_id' => 'Author Aweme ID',
|
||||
'author_nickname' => 'Author Nickname',
|
||||
'author_role' => 'Author Role',
|
||||
'staff_aweme_id' => 'Staff Aweme ID',
|
||||
'staff_nickname' => 'Staff Nickname',
|
||||
'allocation_status' => '分配状态',
|
||||
'convert_status' => '是否转化',
|
||||
'clue_type' => '线索类型',
|
||||
'clue_return_status' => '线索回传状态',
|
||||
'effective_state' => '是否有效',
|
||||
'effective_state_name' => 'Effective State Name',
|
||||
'follow_state_name' => 'Follow State Name',
|
||||
'is_private_clue' => 'Is Private Clue',
|
||||
'remark' => '备注',
|
||||
'remark_dict' => '问答/聊天记录',
|
||||
'system_tags' => '系统标签',
|
||||
'tags' => '自定义标签',
|
||||
'create_time_detail' => '线索创建时间',
|
||||
'modify_time' => '平台更新时间',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'note' => 'Note',
|
||||
'is_virtual' => 'Is Virtual',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
65
models/ContactForm.php
Normal file
65
models/ContactForm.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
*/
|
||||
class ContactForm extends Model
|
||||
{
|
||||
public $name;
|
||||
public $email;
|
||||
public $subject;
|
||||
public $body;
|
||||
public $verifyCode;
|
||||
|
||||
|
||||
/**
|
||||
* @return array the validation rules.
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// name, email, subject and body are required
|
||||
[['name', 'email', 'subject', 'body'], 'required'],
|
||||
// email has to be a valid email address
|
||||
['email', 'email'],
|
||||
// verifyCode needs to be entered correctly
|
||||
['verifyCode', 'captcha'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array customized attribute labels
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'verifyCode' => 'Verification Code',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an email to the specified email address using the information collected by this model.
|
||||
* @param string $email the target email address
|
||||
* @return bool whether the model passes validation
|
||||
*/
|
||||
public function contact($email)
|
||||
{
|
||||
if ($this->validate()) {
|
||||
Yii::$app->mailer->compose()
|
||||
->setTo($email)
|
||||
->setFrom([Yii::$app->params['senderEmail'] => Yii::$app->params['senderName']])
|
||||
->setReplyTo([$this->email => $this->name])
|
||||
->setSubject($this->subject)
|
||||
->setTextBody($this->body)
|
||||
->send();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
81
models/LoginForm.php
Normal file
81
models/LoginForm.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
|
||||
/**
|
||||
* LoginForm is the model behind the login form.
|
||||
*
|
||||
* @property-read User|null $user
|
||||
*
|
||||
*/
|
||||
class LoginForm extends Model
|
||||
{
|
||||
public $username;
|
||||
public $password;
|
||||
public $rememberMe = true;
|
||||
|
||||
private $_user = false;
|
||||
|
||||
|
||||
/**
|
||||
* @return array the validation rules.
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// username and password are both required
|
||||
[['username', 'password'], 'required'],
|
||||
// rememberMe must be a boolean value
|
||||
['rememberMe', 'boolean'],
|
||||
// password is validated by validatePassword()
|
||||
['password', 'validatePassword'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the password.
|
||||
* This method serves as the inline validation for password.
|
||||
*
|
||||
* @param string $attribute the attribute currently being validated
|
||||
* @param array $params the additional name-value pairs given in the rule
|
||||
*/
|
||||
public function validatePassword($attribute, $params)
|
||||
{
|
||||
if (!$this->hasErrors()) {
|
||||
$user = $this->getUser();
|
||||
|
||||
if (!$user || !$user->validatePassword($this->password)) {
|
||||
$this->addError($attribute, 'Incorrect username or password.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in a user using the provided username and password.
|
||||
* @return bool whether the user is logged in successfully
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if ($this->validate()) {
|
||||
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds user by [[username]]
|
||||
*
|
||||
* @return User|null
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
if ($this->_user === false) {
|
||||
$this->_user = User::findByUsername($this->username);
|
||||
}
|
||||
|
||||
return $this->_user;
|
||||
}
|
||||
}
|
||||
74
models/Oauth.php
Normal file
74
models/Oauth.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "oauth".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $access_token
|
||||
* @property string $refresh_token
|
||||
* @property int $created_at
|
||||
* @property int $updated_at
|
||||
* @property string $app_id
|
||||
* @property string $auth_code
|
||||
* @property string $material_auth_status
|
||||
* @property string $scope
|
||||
* @property string $uid
|
||||
* @property int $is_init
|
||||
* @property int|null $is_delete
|
||||
* @property string|null $advertiser_ids
|
||||
*/
|
||||
class Oauth extends \app\models\BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'oauth';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['advertiser_ids'], 'default', 'value' => null],
|
||||
[['uid'], 'default', 'value' => ''],
|
||||
[['is_delete'], 'default', 'value' => 0],
|
||||
[['created_at', 'updated_at', 'is_init', 'is_delete'], 'integer'],
|
||||
[['advertiser_ids'], 'string'],
|
||||
[['access_token', 'refresh_token', 'auth_code', 'material_auth_status', 'scope', 'uid'], 'string', 'max' => 255],
|
||||
[['app_id'], 'string', 'max' => 64],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'access_token' => 'Access Token',
|
||||
'refresh_token' => 'Refresh Token',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'app_id' => 'App ID',
|
||||
'auth_code' => 'Auth Code',
|
||||
'material_auth_status' => 'Material Auth Status',
|
||||
'scope' => 'Scope',
|
||||
'uid' => 'Uid',
|
||||
'is_init' => 'Is Init',
|
||||
'is_delete' => 'Is Delete',
|
||||
'advertiser_ids' => 'Advertiser Ids',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
60
models/OauthAccount.php
Normal file
60
models/OauthAccount.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "oauth_account".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property string $admin_uid
|
||||
* @property string $account_id
|
||||
* @property string $account_name
|
||||
* @property int|null $is_delete
|
||||
*/
|
||||
class OauthAccount extends \app\models\BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'oauth_account';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['is_delete'], 'default', 'value' => 0],
|
||||
[['account_name'], 'default', 'value' => ''],
|
||||
[['created_at', 'updated_at', 'is_delete'], 'integer'],
|
||||
[['admin_uid', 'account_id'], 'string', 'max' => 64],
|
||||
[['account_name'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'admin_uid' => 'Admin Uid',
|
||||
'account_id' => 'Account ID',
|
||||
'account_name' => 'Account Name',
|
||||
'is_delete' => 'Is Delete',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
64
models/OauthAccountLocal.php
Normal file
64
models/OauthAccountLocal.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "oauth_account_local".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property string $admin_uid
|
||||
* @property string $account_id
|
||||
* @property string $advertiser_name
|
||||
* @property string $advertiser_id
|
||||
* @property int|null $is_delete
|
||||
* @property int $is_active
|
||||
*/
|
||||
class OauthAccountLocal extends \app\models\BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'oauth_account_local';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['is_active'], 'default', 'value' => 0],
|
||||
[['advertiser_id'], 'default', 'value' => ''],
|
||||
[['created_at', 'updated_at', 'is_delete', 'is_active'], 'integer'],
|
||||
[['admin_uid', 'account_id', 'advertiser_id'], 'string', 'max' => 64],
|
||||
[['advertiser_name'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'admin_uid' => 'Admin Uid',
|
||||
'account_id' => 'Account ID',
|
||||
'advertiser_name' => 'Advertiser Name',
|
||||
'advertiser_id' => 'Advertiser ID',
|
||||
'is_delete' => 'Is Delete',
|
||||
'is_active' => 'Is Active',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
158
models/User.php
Normal file
158
models/User.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveRecord;
|
||||
use yii\db\BaseActiveRecord;
|
||||
use yii\web\IdentityInterface;
|
||||
|
||||
/**
|
||||
* This is the model class for table "user".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $username
|
||||
* @property string $auth_key
|
||||
* @property string $password_hash
|
||||
* @property string|null $password_reset_token
|
||||
* @property string $email
|
||||
* @property int $status
|
||||
* @property int $created_at
|
||||
* @property int $updated_at
|
||||
* @property string $role
|
||||
*/
|
||||
class User extends BaseModel implements IdentityInterface
|
||||
{
|
||||
|
||||
const STATUS_DELETED = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'user';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['password_reset_token'], 'default', 'value' => null],
|
||||
[['status'], 'default', 'value' => 10],
|
||||
[['username', 'auth_key', 'password_hash', 'email', 'created_at', 'updated_at'], 'required'],
|
||||
[['status', 'created_at', 'updated_at'], 'integer'],
|
||||
[['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
|
||||
[['auth_key', 'role'], 'string', 'max' => 32],
|
||||
[['username'], 'unique'],
|
||||
[['email'], 'unique'],
|
||||
[['password_reset_token'], 'unique'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'username' => 'Username',
|
||||
'auth_key' => 'Auth Key',
|
||||
'password_hash' => 'Password Hash',
|
||||
'password_reset_token' => 'Password Reset Token',
|
||||
'email' => 'Email',
|
||||
'status' => 'Status',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'role' => 'Role',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function findIdentity($id)
|
||||
{
|
||||
return static::find()
|
||||
->where(['id' => $id])
|
||||
->andWhere(['status' => self::STATUS_ACTIVE])
|
||||
->one();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function findIdentityByAccessToken($token, $type = null)
|
||||
{
|
||||
die(__FILE__);
|
||||
foreach (self::$users as $user) {
|
||||
if ($user['accessToken'] === $token) {
|
||||
return new static($user);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds user by username
|
||||
*
|
||||
* @param string $username
|
||||
* @return static|null
|
||||
*/
|
||||
public static function findByUsername($username)
|
||||
{
|
||||
return static::find()
|
||||
->where(['username' => $username])
|
||||
->andWhere(['status' => self::STATUS_ACTIVE])
|
||||
->one();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthKey()
|
||||
{
|
||||
return $this->auth_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateAuthKey($authKey)
|
||||
{
|
||||
return $this->auth_key === $authKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates password
|
||||
*
|
||||
* @param string $password password to validate
|
||||
* @return bool if password provided is valid for current user
|
||||
*/
|
||||
public function validatePassword($password)
|
||||
{
|
||||
return Yii::$app->security->validatePassword(
|
||||
$password,
|
||||
$this->password_hash
|
||||
);
|
||||
}
|
||||
|
||||
public function getRole()
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
}
|
||||
63
models/UserAdvertiser.php
Normal file
63
models/UserAdvertiser.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "user_advertiser".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $advertiser_id
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
* @property int|null $is_delete
|
||||
* @property int $local_id
|
||||
* @property string $advertiser_name
|
||||
*/
|
||||
class UserAdvertiser extends \app\models\BaseModel
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'user_advertiser';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['is_delete'], 'default', 'value' => 0],
|
||||
[['advertiser_id'], 'default', 'value' => ''],
|
||||
[['user_id', 'created_at', 'updated_at', 'is_delete', 'local_id'], 'integer'],
|
||||
[['local_id', 'advertiser_name'], 'required'],
|
||||
[['advertiser_id'], 'string', 'max' => 255],
|
||||
[['advertiser_name'], 'string', 'max' => 64],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'user_id' => 'User ID',
|
||||
'advertiser_id' => 'Advertiser ID',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'is_delete' => 'Is Delete',
|
||||
'local_id' => 'Local ID',
|
||||
'advertiser_name' => 'Advertiser Name',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
104
models/User_bak.php
Normal file
104
models/User_bak.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
class User_bak extends \yii\base\BaseObject implements \yii\web\IdentityInterface
|
||||
{
|
||||
public $id;
|
||||
public $username;
|
||||
public $password;
|
||||
public $authKey;
|
||||
public $accessToken;
|
||||
|
||||
private static $users = [
|
||||
'100' => [
|
||||
'id' => '100',
|
||||
'username' => 'admin',
|
||||
'password' => 'admin',
|
||||
'authKey' => 'test100key',
|
||||
'accessToken' => '100-token',
|
||||
],
|
||||
'101' => [
|
||||
'id' => '101',
|
||||
'username' => 'demo',
|
||||
'password' => 'demo',
|
||||
'authKey' => 'test101key',
|
||||
'accessToken' => '101-token',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function findIdentity($id)
|
||||
{
|
||||
return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function findIdentityByAccessToken($token, $type = null)
|
||||
{
|
||||
foreach (self::$users as $user) {
|
||||
if ($user['accessToken'] === $token) {
|
||||
return new static($user);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds user by username
|
||||
*
|
||||
* @param string $username
|
||||
* @return static|null
|
||||
*/
|
||||
public static function findByUsername($username)
|
||||
{
|
||||
foreach (self::$users as $user) {
|
||||
if (strcasecmp($user['username'], $username) === 0) {
|
||||
return new static($user);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAuthKey()
|
||||
{
|
||||
return $this->authKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateAuthKey($authKey)
|
||||
{
|
||||
return $this->authKey === $authKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates password
|
||||
*
|
||||
* @param string $password password to validate
|
||||
* @return bool if password provided is valid for current user
|
||||
*/
|
||||
public function validatePassword($password)
|
||||
{
|
||||
return $this->password === $password;
|
||||
}
|
||||
}
|
||||
113
models/Xiansuo.php
Normal file
113
models/Xiansuo.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "xiansuo".
|
||||
*
|
||||
* @property int $id 主键ID
|
||||
* @property int|null $xs_id 线索ID(业务ID)
|
||||
* @property int|null $leads_id 广告平台线索ID
|
||||
* @property string|null $name 姓名
|
||||
* @property string|null $telphone 电话
|
||||
* @property string|null $weixin 微信
|
||||
* @property string|null $gender 性别
|
||||
* @property string|null $location 所在地
|
||||
* @property string|null $tel_logic_location 电话逻辑归属地
|
||||
* @property string|null $keshi 科室
|
||||
* @property string|null $gj_value 跟进状态
|
||||
* @property string|null $beizhu 备注
|
||||
* @property string|null $adv_id 广告账户ID
|
||||
* @property string|null $adv_name 广告账户名称
|
||||
* @property int|null $promotion_id 计划ID
|
||||
* @property string|null $promotion_name 计划名
|
||||
* @property string|null $app_name 来源平台
|
||||
* @property string|null $root_adv_id 根账户ID
|
||||
* @property string|null $external_url 外部URL
|
||||
* @property string|null $clue_convert_status 转化状态
|
||||
* @property int|null $user_id 分配用户ID
|
||||
* @property string|null $user_name 分配用户名
|
||||
* @property int|null $is_daili 是否代理 0否 1是
|
||||
* @property string|null $remark_dict 问答/聊天记录
|
||||
* @property string|null $content 原始内容JSON
|
||||
* @property string|null $push_return_data 推送返回数据
|
||||
* @property string|null $date 分配时间
|
||||
* @property string|null $created_at 创建时间
|
||||
* @property string|null $updated_at 更新时间
|
||||
*/
|
||||
class Xiansuo extends \yii\db\ActiveRecord
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'xiansuo';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['xs_id', 'promotion_id', 'user_id', 'remark_dict', 'content', 'push_return_data', 'date', 'created_at', 'updated_at'], 'default', 'value' => null],
|
||||
[['is_daili'], 'default', 'value' => 0],
|
||||
[['user_name'], 'default', 'value' => ''],
|
||||
[['id'], 'required'],
|
||||
[['id', 'xs_id', 'leads_id', 'promotion_id', 'user_id', 'is_daili'], 'integer'],
|
||||
[['remark_dict', 'date', 'created_at', 'updated_at'], 'safe'],
|
||||
[['content', 'push_return_data'], 'string'],
|
||||
[['name', 'weixin', 'keshi', 'gj_value', 'adv_id', 'app_name', 'root_adv_id', 'clue_convert_status', 'user_name'], 'string', 'max' => 50],
|
||||
[['telphone'], 'string', 'max' => 20],
|
||||
[['gender'], 'string', 'max' => 10],
|
||||
[['location', 'tel_logic_location', 'adv_name'], 'string', 'max' => 100],
|
||||
[['beizhu', 'external_url'], 'string', 'max' => 255],
|
||||
[['promotion_name'], 'string', 'max' => 150],
|
||||
[['id'], 'unique'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => '主键ID',
|
||||
'xs_id' => '线索ID(业务ID)',
|
||||
'leads_id' => '广告平台线索ID',
|
||||
'name' => '姓名',
|
||||
'telphone' => '电话',
|
||||
'weixin' => '微信',
|
||||
'gender' => '性别',
|
||||
'location' => '所在地',
|
||||
'tel_logic_location' => '电话逻辑归属地',
|
||||
'keshi' => '科室',
|
||||
'gj_value' => '跟进状态',
|
||||
'beizhu' => '备注',
|
||||
'adv_id' => '广告账户ID',
|
||||
'adv_name' => '广告账户名称',
|
||||
'promotion_id' => '计划ID',
|
||||
'promotion_name' => '计划名',
|
||||
'app_name' => '来源平台',
|
||||
'root_adv_id' => '根账户ID',
|
||||
'external_url' => '外部URL',
|
||||
'clue_convert_status' => '转化状态',
|
||||
'user_id' => '分配用户ID',
|
||||
'user_name' => '分配用户名',
|
||||
'is_daili' => '是否代理 0否 1是',
|
||||
'remark_dict' => '问答/聊天记录',
|
||||
'content' => '原始内容JSON',
|
||||
'push_return_data' => '推送返回数据',
|
||||
'date' => '分配时间',
|
||||
'created_at' => '创建时间',
|
||||
'updated_at' => '更新时间',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
93
models/jobs/RunwayJob.php
Normal file
93
models/jobs/RunwayJob.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace app\models\jobs;
|
||||
|
||||
use app\common\CommonHelper;
|
||||
use app\enums\SourceEnum;
|
||||
use app\models\BrandRunway;
|
||||
use app\models\BrandRunwayImages;
|
||||
use app\models\BrandSource;
|
||||
use app\models\jobs\base\BaseJob;
|
||||
use app\models\logics\commands\SpiderVogue;
|
||||
use yii\debug\models\search\Db;
|
||||
use yii\queue\Queue;
|
||||
|
||||
class RunwayJob extends BaseJob
|
||||
{
|
||||
public BrandSource|null $source = null;
|
||||
|
||||
public function execute($queue)
|
||||
{
|
||||
$spiderModel = new SpiderVogue();
|
||||
$runwayList = ($spiderModel->getBrandRunwayList(rtrim(SourceEnum::VOGEU->baseUrl(), '/') . $this->source->source_url));
|
||||
echo '获取到了 --> ' . count($runwayList ?: []) . '篇文章' . PHP_EOL;
|
||||
try {
|
||||
foreach ($runwayList as $runwayItem) {
|
||||
$tr = \Yii::$app->db->beginTransaction();
|
||||
echo "正在处理{$runwayItem['hed']}" . PHP_EOL;
|
||||
if (!$model = BrandRunway::find()->where(['brand_id' => $this->source->brand_id, 'title' => $runwayItem['hed']])->one()) {
|
||||
$model = new BrandRunway();
|
||||
$model->title = $runwayItem['hed'];
|
||||
$model->brand_id = $this->source->brand_id;
|
||||
$model->year = CommonHelper::getYear($runwayItem['hed']);
|
||||
$model->cover = '';
|
||||
$model->save();
|
||||
var_dump($model->errors);
|
||||
if (!$sourceModel = BrandSource::find()->where(['brand_id' => $this->source->brand_id, 'is_deleted' => 0])->one()) {
|
||||
$sourceModel = new BrandSource();
|
||||
$sourceModel->brand_id = $this->source->brand_id;
|
||||
$sourceModel->source = SourceEnum::VOGEU->value();
|
||||
$sourceModel->save();
|
||||
var_dump($sourceModel->errors);
|
||||
}
|
||||
|
||||
$pageUri = $runwayItem['url'];
|
||||
$requestUrl = rtrim(SourceEnum::VOGEU->baseUrl(), '/') . $pageUri . '/slideshow/collection';
|
||||
$detailData = $spiderModel->getDetail($requestUrl);
|
||||
|
||||
preg_match_all('/window\.__PRELOADED_STATE__ = (.*?);</s', $detailData, $matches);
|
||||
|
||||
$saveUrl = $detailUrl = [];
|
||||
if (count($matches) > 1) {
|
||||
$val = json_decode(current($matches[1]), true);
|
||||
$images = $val['transformed']['runwayGalleries']['galleries'][0]['items'] ?? false;
|
||||
|
||||
if ($images === false) {
|
||||
echo '获取图片失败' . PHP_EOL;
|
||||
// $this->logger->warning($requestUrl . '获取图片失败.');
|
||||
$tr->rollBack();
|
||||
continue;
|
||||
// return;
|
||||
}
|
||||
echo "文章图片数量" . count($images) . PHP_EOL;
|
||||
foreach (is_array($images) ? $images : [] as $img) {
|
||||
$saveUrl[] = [
|
||||
'src' => $img['image']['sources']['xxl']['url']
|
||||
];
|
||||
// foreach ($img['details'] ?? [] as $detail) {
|
||||
// $detailUrl[] = ['src' => $detail['image']['sources']['xxl']['url']];
|
||||
$brandModel = new BrandRunwayImages();
|
||||
$brandModel->image = $img['image']['sources']['xxl']['url'];
|
||||
$brandModel->runway_id = $model->id;
|
||||
$brandModel->brand_id = $this->source->brand_id;
|
||||
$brandModel->save();
|
||||
var_dump($brandModel->errors);
|
||||
// }
|
||||
}
|
||||
|
||||
// $model->images = json_encode($saveUrl);
|
||||
$model->image_count = count($saveUrl);
|
||||
$model->cover = current($saveUrl)['src'];
|
||||
$model->source_url = $requestUrl;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
|
||||
$tr->commit();
|
||||
}
|
||||
}catch (\Throwable $exception) {
|
||||
var_dump($exception->getMessage());
|
||||
}
|
||||
// TODO: Implement execute() method.
|
||||
}
|
||||
}
|
||||
14
models/jobs/base/BaseJob.php
Normal file
14
models/jobs/base/BaseJob.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace app\models\jobs\base;
|
||||
|
||||
use yii\queue\Queue;
|
||||
|
||||
class BaseJob extends \yii\base\BaseObject implements \yii\queue\JobInterface
|
||||
{
|
||||
|
||||
public function execute($queue)
|
||||
{
|
||||
// TODO: Implement execute() method.
|
||||
}
|
||||
}
|
||||
38
models/logics/commands/Base/BaseCommandSpiderLogic.php
Normal file
38
models/logics/commands/Base/BaseCommandSpiderLogic.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace app\models\logics\commands\base;
|
||||
|
||||
use app\common\CurlApp;
|
||||
|
||||
class BaseCommandSpiderLogic
|
||||
{
|
||||
|
||||
protected ?CurlApp $curl = null;
|
||||
|
||||
protected string $brandName = '';
|
||||
|
||||
protected string $baseUrl = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
ini_set('pcre.backtrack_limit', '-1');
|
||||
$this->curl = new CurlApp();
|
||||
}
|
||||
|
||||
public function exec()
|
||||
{
|
||||
|
||||
$url = rtrim($this->baseUrl, '/') . '/fashion-shows/designer/' . $this->brandName;
|
||||
// var_dump($url);
|
||||
// list($request, $httpCode) = $curl->setUrl($url)->exec();
|
||||
$request = $this->curl->setUrl($url)->exec();
|
||||
|
||||
if ($request) {
|
||||
preg_match_all('/window.__PRELOADED_STATE__ = ([\s\S]*?);<\/script>/', $request, $matches);
|
||||
$val = json_decode(current(end($matches)), true);
|
||||
return $val['transformed']['runwayDesignerContent']['designerCollections'] ?? [];
|
||||
} else {
|
||||
// $this->logger->info('未找到数据.');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
190
models/logics/commands/SpiderVogue.php
Normal file
190
models/logics/commands/SpiderVogue.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace app\models\logics\commands;
|
||||
|
||||
use app\common\CommonHelper;
|
||||
use app\enums\SourceEnum;
|
||||
use app\models\Brand;
|
||||
use app\models\BrandRunway;
|
||||
use app\models\BrandRunwayImages;
|
||||
use app\models\BrandSource;
|
||||
use app\models\logics\commands\base\BaseCommandSpiderLogic;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
class SpiderVogue extends BaseCommandSpiderLogic
|
||||
{
|
||||
protected string $baseUrl = 'https://www.vogue.com/';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->curl->setProxy('127.0.0.1', 58591);
|
||||
}
|
||||
|
||||
public function setBrandName(string $name = ''): SpiderVogue
|
||||
{
|
||||
$this->brandName = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function start()
|
||||
{
|
||||
$source = BrandSource::find()->where(['source' => SourceEnum::VOGEU->value()])->asArray()->all();
|
||||
// var_dump(ArrayHelper::getColumn($source, 'brand_id'));
|
||||
$i = 0;
|
||||
$brandNameContainer = [];
|
||||
$brandIdContainer = [];
|
||||
foreach (Brand::find()->where(
|
||||
['>','id', 5747] // 5897
|
||||
)->each() as $item) {
|
||||
$item['name'] = strtr($item['name'], [
|
||||
' ' => '-',
|
||||
'.' => '-'
|
||||
]);
|
||||
// var_dump(strtolower($item['name']));
|
||||
// $runwayList = $this->setBrandName($item['name'])->_getBrandRunwayList(strtolower($item['name']));
|
||||
echo $item['name'] . PHP_EOL;
|
||||
|
||||
$brandNameContainer[] = strtolower($item['name']);
|
||||
$brandIdContainer[] = $item['id'];
|
||||
$i++;
|
||||
|
||||
if ($i != 5) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$runwayList = $this->_getBrandRunwayListMulti($brandNameContainer);
|
||||
|
||||
foreach ($runwayList as $index => $listItem) {
|
||||
// var_dump('id---', $brandIdContainer[$index]);
|
||||
// var_dump($listItem);
|
||||
if (!$listItem) {
|
||||
continue;
|
||||
}
|
||||
if (!$sourceModel = BrandSource::find()->where(['brand_id' => $brandIdContainer[$index], 'is_deleted' => 0])->one()) {
|
||||
$sourceModel = new BrandSource();
|
||||
$sourceModel->brand_id = $brandIdContainer[$index];
|
||||
$sourceModel->source = SourceEnum::VOGEU->value();
|
||||
$sourceModel->save();
|
||||
var_dump($sourceModel->errors);
|
||||
}
|
||||
}
|
||||
|
||||
$brandNameContainer = $brandIdContainer = [];
|
||||
$i = 0;
|
||||
|
||||
if (!$runwayList) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
var_dump($runwayList);
|
||||
foreach ($runwayList as $runwayItem) {
|
||||
var_dump($runwayItem['hed']);
|
||||
if (!$model = BrandRunway::find()->where(['brand_id' => $item['id'], 'title' => $runwayItem['hed']])->one()) {
|
||||
echo $runwayItem['hed'] . PHP_EOL;
|
||||
$model = new BrandRunway();
|
||||
$model->title = $runwayItem['hed'];
|
||||
$model->brand_id = $item['id'];
|
||||
$model->year = CommonHelper::getYear($runwayItem['hed']);
|
||||
$model->cover = '';
|
||||
$model->save();
|
||||
var_dump($model->errors);
|
||||
if (!$sourceModel = BrandSource::find()->where(['brand_id' => $item['id'], 'is_deleted' => 0])->one()) {
|
||||
$sourceModel = new BrandSource();
|
||||
$sourceModel->brand_id = $item['id'];
|
||||
$sourceModel->source = SourceEnum::VOGEU->value();
|
||||
$sourceModel->save();
|
||||
var_dump($sourceModel->errors);
|
||||
}
|
||||
|
||||
$pageUri = $runwayItem['url'];
|
||||
$requestUrl = rtrim($this->baseUrl, '/') . $pageUri . '/slideshow/collection';
|
||||
$detailData = $this->_getDetail($requestUrl);
|
||||
|
||||
preg_match_all('/window\.__PRELOADED_STATE__ = (.*?);</s', $detailData, $matches);
|
||||
|
||||
$saveUrl = $detailUrl = [];
|
||||
if (count($matches) > 1) {
|
||||
$val = json_decode(current($matches[1]), true);
|
||||
$images = $val['transformed']['runwayGalleries']['galleries'][0]['items'] ?? false;
|
||||
|
||||
if ($images === false) {
|
||||
echo '获取图片失败' . PHP_EOL;
|
||||
// $this->logger->warning($requestUrl . '获取图片失败.');
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (is_array($images) ? $images : [] as $img) {
|
||||
$saveUrl[] = [
|
||||
'src' => $img['image']['sources']['xxl']['url']
|
||||
];
|
||||
foreach ($img['details'] ?? [] as $detail) {
|
||||
$detailUrl[] = ['src' => $detail['image']['sources']['xxl']['url']];
|
||||
$brandModel = new BrandRunwayImages();
|
||||
$brandModel->image = $detail['image']['sources']['xxl']['url'];
|
||||
$brandModel->runway_id = $model->id;
|
||||
$brandModel->brand_id = $item['id'];
|
||||
$brandModel->save();
|
||||
var_dump($brandModel->errors);
|
||||
}
|
||||
}
|
||||
|
||||
// $model->images = json_encode($saveUrl);
|
||||
$model->cover = '';
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getDetail($url): bool|string
|
||||
{
|
||||
return $this->curl->setUrl($url)->exec();
|
||||
}
|
||||
|
||||
|
||||
public function getBrandRunwayList(string $url)
|
||||
{
|
||||
$request = $this->curl->setUrl($url)->exec();
|
||||
|
||||
if ($request) {
|
||||
preg_match_all('/window.__PRELOADED_STATE__ = ([\s\S]*?);<\/script>/', $request, $matches);
|
||||
$val = json_decode(current(end($matches)), true);
|
||||
return $val['transformed']['runwayDesignerContent']['designerCollections'] ?? [];
|
||||
} else {
|
||||
// $this->logger->info('未找到数据.');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function _getBrandRunwayListMulti(array $brandNames = []): array
|
||||
{
|
||||
// $brandNames = [];
|
||||
$resp = [];
|
||||
foreach ($brandNames as $brandName) {
|
||||
$url[] = rtrim($this->baseUrl, '/') . '/fashion-shows/designer/' . $brandName;
|
||||
// var_dump($url);
|
||||
// list($request, $httpCode) = $curl->setUrl($url)->exec();
|
||||
|
||||
}
|
||||
|
||||
$request = $this->curl->execMulti($url);
|
||||
// var_dump($request);die;
|
||||
foreach ($request as $item) {
|
||||
if ($item) {
|
||||
preg_match_all('/window.__PRELOADED_STATE__ = ([\s\S]*?);<\/script>/', $item, $matches);
|
||||
$val = json_decode(current(end($matches)), true);
|
||||
$resp[] = $val['transformed']['runwayDesignerContent']['designerCollections'] ?? [];
|
||||
} else {
|
||||
// $this->logger->info('未找到数据.');
|
||||
$resp[] = [];
|
||||
}
|
||||
}
|
||||
|
||||
return $resp;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user