正在显示
3 个修改的文件
包含
158 行增加
和
2 行删除
| @@ -4,7 +4,7 @@ namespace AukeySwrpc; | @@ -4,7 +4,7 @@ namespace AukeySwrpc; | ||
| 4 | 4 | ||
| 5 | use Illuminate\Support\ServiceProvider; | 5 | use Illuminate\Support\ServiceProvider; |
| 6 | 6 | ||
| 7 | -class AukeyAukeySwrpcProvider extends ServiceProvider | 7 | +class AukeySwrpcProvider extends ServiceProvider |
| 8 | { | 8 | { |
| 9 | public function boot() | 9 | public function boot() |
| 10 | { | 10 | { |
| @@ -22,7 +22,7 @@ class AukeyAukeySwrpcProvider extends ServiceProvider | @@ -22,7 +22,7 @@ class AukeyAukeySwrpcProvider extends ServiceProvider | ||
| 22 | public function register() | 22 | public function register() |
| 23 | { | 23 | { |
| 24 | $provides = [ | 24 | $provides = [ |
| 25 | - 'AukeyDataCenter\Http\RouteServiceProvider', | 25 | + 'AukeySwrpc\Http\RouteServiceProvider', |
| 26 | ]; | 26 | ]; |
| 27 | foreach ($provides as $provider) { | 27 | foreach ($provides as $provider) { |
| 28 | $this->app->register($provider); | 28 | $this->app->register($provider); |
src/Commands/TestCom.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace AukeySwrpc\Commands; | ||
| 4 | + | ||
| 5 | +use AukeyCommon\Http\Orm\By\SheinOrderOrm; | ||
| 6 | +use AukeyCommon\Http\Orm\By\SheinStoreInfoOrm; | ||
| 7 | +use AukeyCommon\Http\Service\RabbitMq\RabbitMqDelayedSingleton; | ||
| 8 | +use AukeyDataCenter\Http\Orm\Shein\SheinBrandOrm; | ||
| 9 | +use AukeyDataCenter\Http\Orm\Shein\SheinProductItemOrm; | ||
| 10 | +use AukeyDataCenter\Http\Service\DataTimeService; | ||
| 11 | +use AukeyDataCenter\Http\Service\Shein\Request\RequestClient; | ||
| 12 | +use AukeyDataCenter\Http\Service\Shein\RouteMethod\OpenApiRouteMethod; | ||
| 13 | +use AukeyDataCenter\Http\Service\Shein\RoutePath\OpenApiRoutePath; | ||
| 14 | +use Illuminate\Console\Command; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * SheinBrandCom.php | ||
| 18 | + * @Date 2024/03/12 22:23 | ||
| 19 | + * @author pengjch | ||
| 20 | + */ | ||
| 21 | +class TestCom extends Command | ||
| 22 | +{ | ||
| 23 | + /** | ||
| 24 | + * The name and signature of the console command. | ||
| 25 | + * | ||
| 26 | + * @var string | ||
| 27 | + */ | ||
| 28 | + protected $signature = 'swrpc:test'; | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * Create a new command instance. | ||
| 33 | + * | ||
| 34 | + * @return void | ||
| 35 | + */ | ||
| 36 | + public function __construct() | ||
| 37 | + { | ||
| 38 | + print_r(111);exit(); | ||
| 39 | + parent::__construct(); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * Execute the console command. | ||
| 44 | + * @throws \ErrorException | ||
| 45 | + */ | ||
| 46 | + public function handle() | ||
| 47 | + { | ||
| 48 | + $this->syncAllProduct(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public function syncAllProduct() | ||
| 52 | + { | ||
| 53 | + $allAccounts = SheinStoreInfoOrm::query()->get(); | ||
| 54 | + if($allAccounts->isEmpty()){ | ||
| 55 | + return false; | ||
| 56 | + } | ||
| 57 | + $languageMap = [ | ||
| 58 | + 'US' => 'en', | ||
| 59 | + 'FR' => 'fr', | ||
| 60 | + 'ES' => 'es', | ||
| 61 | + 'DE' => 'de', | ||
| 62 | + 'TH' => 'th', | ||
| 63 | + 'BR' => 'pt-br', | ||
| 64 | + ]; | ||
| 65 | + foreach ($allAccounts as $account){ | ||
| 66 | + $this->error('account_name:'.$account->account_name.', account_id:'.$account->account_id.' 开始同步......'); | ||
| 67 | + $params = [ | ||
| 68 | + 'path' => OpenApiRoutePath::GOODS_QUERY_BRAND_LIST, | ||
| 69 | + 'method' => OpenApiRouteMethod::$routeMethod[OpenApiRoutePath::GOODS_QUERY_BRAND_LIST], | ||
| 70 | + 'openKeyId' => $account->open_key_id, | ||
| 71 | + 'secretKey' => $account->secretKey, | ||
| 72 | + 'queryParams' => [], | ||
| 73 | + 'headers' => [ | ||
| 74 | + 'language' => $languageMap[$account->site] ?? 'en', | ||
| 75 | + ], | ||
| 76 | + ]; | ||
| 77 | + $body = di(RequestClient::class)->sendRequest( | ||
| 78 | + $params['path'], | ||
| 79 | + $params['method'], | ||
| 80 | + $params['openKeyId'], | ||
| 81 | + $params['secretKey'], | ||
| 82 | + $params['queryParams'], | ||
| 83 | + $params['headers'] | ||
| 84 | + ); | ||
| 85 | + if(isset($body['error'])){ | ||
| 86 | + $this->error('错误信息:'.json_encode($body['error'])); | ||
| 87 | + continue; | ||
| 88 | + } | ||
| 89 | + if(!$body['info']['data']){ | ||
| 90 | + continue; | ||
| 91 | + } | ||
| 92 | + $data = $body['info']['data']; | ||
| 93 | + if(!is_array($data) || !$data){ | ||
| 94 | + continue; | ||
| 95 | + } | ||
| 96 | + foreach ($data as $datum){ | ||
| 97 | + $setAttr = [ | ||
| 98 | + 'account_id' => $account['account_id'], | ||
| 99 | + 'account_name' => $account['account_name'], | ||
| 100 | + 'account_site' => $account['site'], | ||
| 101 | + 'dept_id' => $account['dept_id'], | ||
| 102 | + 'dept_name' => $account['dept_name'], | ||
| 103 | + 'brand_code' => $datum['brand_code'], | ||
| 104 | + 'brand_name' => $datum['brand_name'], | ||
| 105 | + ]; | ||
| 106 | + $findAttr = [ | ||
| 107 | + 'account_id' => $account['account_id'], | ||
| 108 | + 'account_name' => $account['account_name'], | ||
| 109 | + 'account_site' => $account['site'], | ||
| 110 | + 'dept_id' => $account['dept_id'], | ||
| 111 | + 'dept_name' => $account['dept_name'], | ||
| 112 | + 'brand_code' => $datum['brand_code'], | ||
| 113 | + ]; | ||
| 114 | + db_util()->saveModel(new SheinBrandOrm(),$setAttr,$findAttr); | ||
| 115 | + $this->info('品牌编号:'.$datum['brand_code'].' - '.$datum['brand_name'].'同步完成.........'); | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + $this->info('品牌同步完成.........'); | ||
| 119 | + } | ||
| 120 | +} |
src/Http/RouteServiceProvider.php
0 → 100644
| 1 | +<?php | ||
| 2 | +namespace AukeySwrpc\Http; | ||
| 3 | + | ||
| 4 | +use Illuminate\Support\Facades\Route; | ||
| 5 | +use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; | ||
| 6 | + | ||
| 7 | +class RouteServiceProvider extends ServiceProvider{ | ||
| 8 | + public function boot(){ | ||
| 9 | + parent::boot(); | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + public function map(){ | ||
| 13 | + $this->mapWebRoutes(); | ||
| 14 | + | ||
| 15 | + $this->mapApiRoutes(); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * web路由设置 | ||
| 20 | + */ | ||
| 21 | + protected function mapWebRoutes(){ | ||
| 22 | + Route::middleware('web') | ||
| 23 | + ->namespace('AukeySwrpc\Http\Controllers') | ||
| 24 | + ->group(__DIR__ . '/Controllers/routes.php'); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * api路由设置 | ||
| 29 | + */ | ||
| 30 | + protected function mapApiRoutes(){ | ||
| 31 | + Route::prefix('api') | ||
| 32 | + ->middleware('api') | ||
| 33 | + ->namespace('AukeySwrpc\Http\Controllers') | ||
| 34 | + ->group(__DIR__ . '/Controllers/routes.php'); | ||
| 35 | + } | ||
| 36 | +} |
-
请 注册 或 登录 后发表评论