|
|
<?php
|
|
|
|
|
|
namespace AukeySwrpc\Commands;
|
|
|
|
|
|
use AukeyCommon\Http\Orm\By\SheinOrderOrm;
|
|
|
use AukeyCommon\Http\Orm\By\SheinStoreInfoOrm;
|
|
|
use AukeyCommon\Http\Service\RabbitMq\RabbitMqDelayedSingleton;
|
|
|
use AukeyDataCenter\Http\Orm\Shein\SheinBrandOrm;
|
|
|
use AukeyDataCenter\Http\Orm\Shein\SheinProductItemOrm;
|
|
|
use AukeyDataCenter\Http\Service\DataTimeService;
|
|
|
use AukeyDataCenter\Http\Service\Shein\Request\RequestClient;
|
|
|
use AukeyDataCenter\Http\Service\Shein\RouteMethod\OpenApiRouteMethod;
|
|
|
use AukeyDataCenter\Http\Service\Shein\RoutePath\OpenApiRoutePath;
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
/**
|
|
|
* SheinBrandCom.php
|
|
|
* @Date 2024/03/12 22:23
|
|
|
* @author pengjch
|
|
|
*/
|
|
|
class TestCom extends Command
|
|
|
{
|
|
|
/**
|
|
|
* The name and signature of the console command.
|
|
|
*
|
|
|
* @var string
|
|
|
*/
|
|
|
protected $signature = 'swrpc:test';
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Create a new command instance.
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
public function __construct()
|
|
|
{
|
|
|
print_r(111);exit();
|
|
|
parent::__construct();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Execute the console command.
|
|
|
* @throws \ErrorException
|
|
|
*/
|
|
|
public function handle()
|
|
|
{
|
|
|
$this->syncAllProduct();
|
|
|
}
|
|
|
|
|
|
public function syncAllProduct()
|
|
|
{
|
|
|
$allAccounts = SheinStoreInfoOrm::query()->get();
|
|
|
if($allAccounts->isEmpty()){
|
|
|
return false;
|
|
|
}
|
|
|
$languageMap = [
|
|
|
'US' => 'en',
|
|
|
'FR' => 'fr',
|
|
|
'ES' => 'es',
|
|
|
'DE' => 'de',
|
|
|
'TH' => 'th',
|
|
|
'BR' => 'pt-br',
|
|
|
];
|
|
|
foreach ($allAccounts as $account){
|
|
|
$this->error('account_name:'.$account->account_name.', account_id:'.$account->account_id.' 开始同步......');
|
|
|
$params = [
|
|
|
'path' => OpenApiRoutePath::GOODS_QUERY_BRAND_LIST,
|
|
|
'method' => OpenApiRouteMethod::$routeMethod[OpenApiRoutePath::GOODS_QUERY_BRAND_LIST],
|
|
|
'openKeyId' => $account->open_key_id,
|
|
|
'secretKey' => $account->secretKey,
|
|
|
'queryParams' => [],
|
|
|
'headers' => [
|
|
|
'language' => $languageMap[$account->site] ?? 'en',
|
|
|
],
|
|
|
];
|
|
|
$body = di(RequestClient::class)->sendRequest(
|
|
|
$params['path'],
|
|
|
$params['method'],
|
|
|
$params['openKeyId'],
|
|
|
$params['secretKey'],
|
|
|
$params['queryParams'],
|
|
|
$params['headers']
|
|
|
);
|
|
|
if(isset($body['error'])){
|
|
|
$this->error('错误信息:'.json_encode($body['error']));
|
|
|
continue;
|
|
|
}
|
|
|
if(!$body['info']['data']){
|
|
|
continue;
|
|
|
}
|
|
|
$data = $body['info']['data'];
|
|
|
if(!is_array($data) || !$data){
|
|
|
continue;
|
|
|
}
|
|
|
foreach ($data as $datum){
|
|
|
$setAttr = [
|
|
|
'account_id' => $account['account_id'],
|
|
|
'account_name' => $account['account_name'],
|
|
|
'account_site' => $account['site'],
|
|
|
'dept_id' => $account['dept_id'],
|
|
|
'dept_name' => $account['dept_name'],
|
|
|
'brand_code' => $datum['brand_code'],
|
|
|
'brand_name' => $datum['brand_name'],
|
|
|
];
|
|
|
$findAttr = [
|
|
|
'account_id' => $account['account_id'],
|
|
|
'account_name' => $account['account_name'],
|
|
|
'account_site' => $account['site'],
|
|
|
'dept_id' => $account['dept_id'],
|
|
|
'dept_name' => $account['dept_name'],
|
|
|
'brand_code' => $datum['brand_code'],
|
|
|
];
|
|
|
db_util()->saveModel(new SheinBrandOrm(),$setAttr,$findAttr);
|
|
|
$this->info('品牌编号:'.$datum['brand_code'].' - '.$datum['brand_name'].'同步完成.........');
|
|
|
}
|
|
|
}
|
|
|
$this->info('品牌同步完成.........');
|
|
|
}
|
|
|
} |
...
|
...
|
|