合并分支 'lyh-server' 到 'master'
变更数据 查看合并请求 !2991
正在显示
1 个修改的文件
包含
31 行增加
和
4 行删除
| @@ -25,6 +25,7 @@ use App\Models\Template\Template; | @@ -25,6 +25,7 @@ use App\Models\Template\Template; | ||
| 25 | use App\Services\ProjectServer; | 25 | use App\Services\ProjectServer; |
| 26 | use Illuminate\Console\Command; | 26 | use Illuminate\Console\Command; |
| 27 | use Illuminate\Support\Facades\DB; | 27 | use Illuminate\Support\Facades\DB; |
| 28 | +use PhpOffice\PhpSpreadsheet\IOFactory; | ||
| 28 | 29 | ||
| 29 | class LyhImportTest extends Command | 30 | class LyhImportTest extends Command |
| 30 | { | 31 | { |
| @@ -52,15 +53,41 @@ class LyhImportTest extends Command | @@ -52,15 +53,41 @@ class LyhImportTest extends Command | ||
| 52 | */ | 53 | */ |
| 53 | public function handle() | 54 | public function handle() |
| 54 | { | 55 | { |
| 55 | - ProjectServer::useProject(3531); | ||
| 56 | - echo date('Y-m-d H:i:s') . 'start->3531' . PHP_EOL; | ||
| 57 | -// $this->importProductCategory('https://ecdn6-nc.globalso.com/upload/p/3654/file/2025-06/products-1.csv',3654); | ||
| 58 | - $this->import3531CustomModule(3531); | 56 | + ProjectServer::useProject(1517); |
| 57 | + echo date('Y-m-d H:i:s') . 'start->1517' . PHP_EOL; | ||
| 58 | + $url1 = 'https://ecdn6.globalso.com/upload/p/1517/file/2025-10/horse-racing-tkd-modification-1.xlsx';//改tdk | ||
| 59 | + $url2 = 'https://v6-file.globalso.com/upload/p/1517/file/2025-10/horse-racing-url-modification.xlsx';//改url路由+tdk | ||
| 60 | + $this->download_1517_action($url1); | ||
| 59 | DB::disconnect('custom_mysql'); | 61 | DB::disconnect('custom_mysql'); |
| 60 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 62 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | /** | 65 | /** |
| 66 | + * @remark :导入 | ||
| 67 | + * @name :download_1517_action | ||
| 68 | + * @author :lyh | ||
| 69 | + * @method :post | ||
| 70 | + * @time :2025/10/22 16:47 | ||
| 71 | + */ | ||
| 72 | + public function download_1517_action($url) | ||
| 73 | + { | ||
| 74 | + // 下载到 Laravel storage 的临时路径 | ||
| 75 | + $tempPath = storage_path('app/temp_url.xlsx'); | ||
| 76 | + file_put_contents($tempPath, file_get_contents($url)); | ||
| 77 | + // 载入 Excel | ||
| 78 | + try { | ||
| 79 | + $spreadsheet = IOFactory::load($tempPath); | ||
| 80 | + $sheet = $spreadsheet->getActiveSheet(); | ||
| 81 | + $rows = $sheet->toArray(); | ||
| 82 | + unlink($tempPath); | ||
| 83 | + dd($rows); | ||
| 84 | + }catch (\Exception $e){ | ||
| 85 | + echo '文件打不开'.PHP_EOL; | ||
| 86 | + DB::disconnect('custom_mysql'); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 64 | * @remark :3951项目导入产品 | 91 | * @remark :3951项目导入产品 |
| 65 | * @name :import3951Product | 92 | * @name :import3951Product |
| 66 | * @author :lyh | 93 | * @author :lyh |
-
请 注册 或 登录 后发表评论