- 基础环境:Docker 部署配置,源码挂载实时同步 - 修复:super_admin 权限补全、登录重定向循环 - 开发:店铺营销账户账单 - 抖音账户(15字段汇总账单) - 开发:店铺营销账户账单 - 淘系支付宝账户(8字段流水账单) - 开发:店铺营销账户账单 - 拼多多账户(7字段流水账单) - 业务页面导航集成:config/business_navigation.php + Business\Pages 控制器 - 各平台独立表结构和视图,互不影响
59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Http\Controllers\Api;
|
|
|
|
use App\Abstracts\Http\ApiController;
|
|
use Illuminate\Database\QueryException;
|
|
use Modules\EcommerceFinance\Http\Requests\ImportBatch as Request;
|
|
use Modules\EcommerceFinance\Jobs\ProcessImportBatch;
|
|
use Modules\EcommerceFinance\Models\ImportBatch;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class ImportBatches extends ApiController
|
|
{
|
|
public function index()
|
|
{
|
|
$batches = ImportBatch::with('store.channel')
|
|
->latest('id')
|
|
->paginate($this->limit());
|
|
|
|
return response()->json($batches);
|
|
}
|
|
|
|
public function show(ImportBatch $importBatch)
|
|
{
|
|
return response()->json($importBatch->load('store.channel'));
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
if (! Storage::disk('uploads')->exists($request->input('source_file'))) {
|
|
return $this->errorBadRequest('The source file does not exist in the private uploads storage.');
|
|
}
|
|
|
|
try {
|
|
$batch = ImportBatch::create(array_merge($request->validated(), [
|
|
'company_id' => company_id(),
|
|
'status' => 'queued',
|
|
'created_by' => user_id(),
|
|
'created_from' => 'ecommerce-finance',
|
|
]));
|
|
} catch (QueryException $exception) {
|
|
return $this->errorBadRequest('An identical import batch has already been created.');
|
|
}
|
|
|
|
$this->dispatch(new ProcessImportBatch($batch->id));
|
|
|
|
$batch->refresh();
|
|
|
|
return response()
|
|
->json($batch, 201)
|
|
->header('Location', route('api.ecommerce-finance.import-batches.show', $batch));
|
|
}
|
|
|
|
private function limit(): int
|
|
{
|
|
return min(max((int) request('limit', 25), 1), 100);
|
|
}
|
|
}
|