Phase1 后端核心:
- 新增 fsgx_v1.sql 迁移脚本(is_queue_goods/frozen_points/available_points/no_assess)
- SystemConfigServices 返佣设置扩展(周期人数/分档比例/范围/时机)
- StoreOrderCreateServices 周期循环佣金计算
- StoreOrderTakeServices 佣金发放后同步冻结积分
- StoreProductServices/StoreProduct 保存 is_queue_goods
Phase2 后端接口:
- GET /api/hjf/brokerage/progress 佣金周期进度
- GET /api/hjf/assets/overview 资产总览
- HjfPointsServices 每日 frozen_points 0.4‰ 释放定时任务
- PUT /adminapi/hjf/member/{uid}/no_assess 不考核接口
- GET /adminapi/hjf/points/release_log 积分日志接口
Phase3 前端清理:
- hjfCustom.js 路由精简(仅保留 points/log)
- hjfQueue.js/hjfMember.js API 清理/重定向至 CRMEB 原生接口
- pages.json 公排→推荐佣金/佣金记录/佣金规则
Phase4-5 前端改造:
- queue/status.vue 推荐佣金进度页整体重写
- 商品详情/订单确认/支付结果页文案与逻辑改造
- 个人中心/资产页/引导页/规则页文案改造
- HjfQueueProgress/HjfRefundNotice/HjfAssetCard 组件改造
- 推广中心嵌入佣金进度摘要
- hjfMockData.js 全量更新(公排字段→佣金字段)
Phase6 Admin 增强:
- 用户列表新增 frozen_points/available_points 列及不考核操作按钮
- hjfPoints.js USE_MOCK=false 对接真实积分日志接口
Phase7 配置文档:
- docs/fsgx-phase7-config-checklist.md 后台配置与全链路验收清单
Made-with: Cursor
335 lines
11 KiB
PHP
Executable File
335 lines
11 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace League\Flysystem;
|
|
|
|
use function sprintf;
|
|
|
|
class MountManager implements FilesystemOperator
|
|
{
|
|
/**
|
|
* @var array<string, FilesystemOperator>
|
|
*/
|
|
private $filesystems = [];
|
|
|
|
/**
|
|
* MountManager constructor.
|
|
*
|
|
* @param array<string,FilesystemOperator> $filesystems
|
|
*/
|
|
public function __construct(array $filesystems = [])
|
|
{
|
|
$this->mountFilesystems($filesystems);
|
|
}
|
|
|
|
public function fileExists(string $location): bool
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
return $filesystem->fileExists($path);
|
|
} catch (UnableToCheckFileExistence $exception) {
|
|
throw UnableToCheckFileExistence::forLocation($location, $exception);
|
|
}
|
|
}
|
|
|
|
public function read(string $location): string
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
return $filesystem->read($path);
|
|
} catch (UnableToReadFile $exception) {
|
|
throw UnableToReadFile::fromLocation($location, $exception->reason(), $exception);
|
|
}
|
|
}
|
|
|
|
public function readStream(string $location)
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
return $filesystem->readStream($path);
|
|
} catch (UnableToReadFile $exception) {
|
|
throw UnableToReadFile::fromLocation($location, $exception->reason(), $exception);
|
|
}
|
|
}
|
|
|
|
public function listContents(string $location, bool $deep = self::LIST_SHALLOW): DirectoryListing
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path, $mountIdentifier] = $this->determineFilesystemAndPath($location);
|
|
|
|
return
|
|
$filesystem
|
|
->listContents($path, $deep)
|
|
->map(
|
|
function (StorageAttributes $attributes) use ($mountIdentifier) {
|
|
return $attributes->withPath(sprintf('%s://%s', $mountIdentifier, $attributes->path()));
|
|
}
|
|
);
|
|
}
|
|
|
|
public function lastModified(string $location): int
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
return $filesystem->lastModified($path);
|
|
} catch (UnableToRetrieveMetadata $exception) {
|
|
throw UnableToRetrieveMetadata::lastModified($location, $exception->reason(), $exception);
|
|
}
|
|
}
|
|
|
|
public function fileSize(string $location): int
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
return $filesystem->fileSize($path);
|
|
} catch (UnableToRetrieveMetadata $exception) {
|
|
throw UnableToRetrieveMetadata::fileSize($location, $exception->reason(), $exception);
|
|
}
|
|
}
|
|
|
|
public function mimeType(string $location): string
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
return $filesystem->mimeType($path);
|
|
} catch (UnableToRetrieveMetadata $exception) {
|
|
throw UnableToRetrieveMetadata::mimeType($location, $exception->reason(), $exception);
|
|
}
|
|
}
|
|
|
|
public function visibility(string $location): string
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
return $filesystem->visibility($path);
|
|
} catch (UnableToRetrieveMetadata $exception) {
|
|
throw UnableToRetrieveMetadata::visibility($location, $exception->reason(), $exception);
|
|
}
|
|
}
|
|
|
|
public function write(string $location, string $contents, array $config = []): void
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
$filesystem->write($path, $contents, $config);
|
|
} catch (UnableToWriteFile $exception) {
|
|
throw UnableToWriteFile::atLocation($location, $exception->reason(), $exception);
|
|
}
|
|
}
|
|
|
|
public function writeStream(string $location, $contents, array $config = []): void
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
$filesystem->writeStream($path, $contents, $config);
|
|
}
|
|
|
|
public function setVisibility(string $path, string $visibility): void
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($path);
|
|
$filesystem->setVisibility($path, $visibility);
|
|
}
|
|
|
|
public function delete(string $location): void
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
$filesystem->delete($path);
|
|
} catch (UnableToDeleteFile $exception) {
|
|
throw UnableToDeleteFile::atLocation($location, '', $exception);
|
|
}
|
|
}
|
|
|
|
public function deleteDirectory(string $location): void
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
$filesystem->deleteDirectory($path);
|
|
} catch (UnableToDeleteDirectory $exception) {
|
|
throw UnableToDeleteDirectory::atLocation($location, '', $exception);
|
|
}
|
|
}
|
|
|
|
public function createDirectory(string $location, array $config = []): void
|
|
{
|
|
/** @var FilesystemOperator $filesystem */
|
|
[$filesystem, $path] = $this->determineFilesystemAndPath($location);
|
|
|
|
try {
|
|
$filesystem->createDirectory($path, $config);
|
|
} catch (UnableToCreateDirectory $exception) {
|
|
throw UnableToCreateDirectory::dueToFailure($location, $exception);
|
|
}
|
|
}
|
|
|
|
public function move(string $source, string $destination, array $config = []): void
|
|
{
|
|
/** @var FilesystemOperator $sourceFilesystem */
|
|
/* @var FilesystemOperator $destinationFilesystem */
|
|
[$sourceFilesystem, $sourcePath] = $this->determineFilesystemAndPath($source);
|
|
[$destinationFilesystem, $destinationPath] = $this->determineFilesystemAndPath($destination);
|
|
|
|
$sourceFilesystem === $destinationFilesystem ? $this->moveInTheSameFilesystem(
|
|
$sourceFilesystem,
|
|
$sourcePath,
|
|
$destinationPath,
|
|
$source,
|
|
$destination
|
|
) : $this->moveAcrossFilesystems($source, $destination);
|
|
}
|
|
|
|
public function copy(string $source, string $destination, array $config = []): void
|
|
{
|
|
/** @var FilesystemOperator $sourceFilesystem */
|
|
/* @var FilesystemOperator $destinationFilesystem */
|
|
[$sourceFilesystem, $sourcePath] = $this->determineFilesystemAndPath($source);
|
|
[$destinationFilesystem, $destinationPath] = $this->determineFilesystemAndPath($destination);
|
|
|
|
$sourceFilesystem === $destinationFilesystem ? $this->copyInSameFilesystem(
|
|
$sourceFilesystem,
|
|
$sourcePath,
|
|
$destinationPath,
|
|
$source,
|
|
$destination
|
|
) : $this->copyAcrossFilesystem(
|
|
$config['visibility'] ?? null,
|
|
$sourceFilesystem,
|
|
$sourcePath,
|
|
$destinationFilesystem,
|
|
$destinationPath,
|
|
$source,
|
|
$destination
|
|
);
|
|
}
|
|
|
|
private function mountFilesystems(array $filesystems): void
|
|
{
|
|
foreach ($filesystems as $key => $filesystem) {
|
|
$this->guardAgainstInvalidMount($key, $filesystem);
|
|
/* @var string $key */
|
|
/* @var FilesystemOperator $filesystem */
|
|
$this->mountFilesystem($key, $filesystem);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param mixed $key
|
|
* @param mixed $filesystem
|
|
*/
|
|
private function guardAgainstInvalidMount($key, $filesystem): void
|
|
{
|
|
if ( ! is_string($key)) {
|
|
throw UnableToMountFilesystem::becauseTheKeyIsNotValid($key);
|
|
}
|
|
|
|
if ( ! $filesystem instanceof FilesystemOperator) {
|
|
throw UnableToMountFilesystem::becauseTheFilesystemWasNotValid($filesystem);
|
|
}
|
|
}
|
|
|
|
private function mountFilesystem(string $key, FilesystemOperator $filesystem): void
|
|
{
|
|
$this->filesystems[$key] = $filesystem;
|
|
}
|
|
|
|
/**
|
|
* @param string $path
|
|
*
|
|
* @return array{0:FilesystemOperator, 1:string}
|
|
*/
|
|
private function determineFilesystemAndPath(string $path): array
|
|
{
|
|
if (strpos($path, '://') < 1) {
|
|
throw UnableToResolveFilesystemMount::becauseTheSeparatorIsMissing($path);
|
|
}
|
|
|
|
/** @var string $mountIdentifier */
|
|
/** @var string $mountPath */
|
|
[$mountIdentifier, $mountPath] = explode('://', $path, 2);
|
|
|
|
if ( ! array_key_exists($mountIdentifier, $this->filesystems)) {
|
|
throw UnableToResolveFilesystemMount::becauseTheMountWasNotRegistered($mountIdentifier);
|
|
}
|
|
|
|
return [$this->filesystems[$mountIdentifier], $mountPath, $mountIdentifier];
|
|
}
|
|
|
|
private function copyInSameFilesystem(
|
|
FilesystemOperator $sourceFilesystem,
|
|
string $sourcePath,
|
|
string $destinationPath,
|
|
string $source,
|
|
string $destination
|
|
): void {
|
|
try {
|
|
$sourceFilesystem->copy($sourcePath, $destinationPath);
|
|
} catch (UnableToCopyFile $exception) {
|
|
throw UnableToCopyFile::fromLocationTo($source, $destination, $exception);
|
|
}
|
|
}
|
|
|
|
private function copyAcrossFilesystem(
|
|
?string $visibility,
|
|
FilesystemOperator $sourceFilesystem,
|
|
string $sourcePath,
|
|
FilesystemOperator $destinationFilesystem,
|
|
string $destinationPath,
|
|
string $source,
|
|
string $destination
|
|
): void {
|
|
try {
|
|
$visibility = $visibility ?? $sourceFilesystem->visibility($sourcePath);
|
|
$stream = $sourceFilesystem->readStream($sourcePath);
|
|
$destinationFilesystem->writeStream($destinationPath, $stream, compact('visibility'));
|
|
} catch (UnableToRetrieveMetadata | UnableToReadFile | UnableToWriteFile $exception) {
|
|
throw UnableToCopyFile::fromLocationTo($source, $destination, $exception);
|
|
}
|
|
}
|
|
|
|
private function moveInTheSameFilesystem(
|
|
FilesystemOperator $sourceFilesystem,
|
|
string $sourcePath,
|
|
string $destinationPath,
|
|
string $source,
|
|
string $destination
|
|
): void {
|
|
try {
|
|
$sourceFilesystem->move($sourcePath, $destinationPath);
|
|
} catch (UnableToMoveFile $exception) {
|
|
throw UnableToMoveFile::fromLocationTo($source, $destination, $exception);
|
|
}
|
|
}
|
|
|
|
private function moveAcrossFilesystems(string $source, string $destination): void
|
|
{
|
|
try {
|
|
$this->copy($source, $destination);
|
|
$this->delete($source);
|
|
} catch (UnableToCopyFile | UnableToDeleteFile $exception) {
|
|
throw UnableToMoveFile::fromLocationTo($source, $destination, $exception);
|
|
}
|
|
}
|
|
}
|