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
142 lines
4.9 KiB
PHP
142 lines
4.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Component\HttpClient\Internal;
|
|
|
|
use Http\Client\Exception\NetworkException;
|
|
use Http\Promise\Promise;
|
|
use Psr\Http\Message\RequestInterface as Psr7RequestInterface;
|
|
use Psr\Http\Message\ResponseFactoryInterface;
|
|
use Psr\Http\Message\ResponseInterface as Psr7ResponseInterface;
|
|
use Psr\Http\Message\StreamFactoryInterface;
|
|
use Symfony\Component\HttpClient\Response\StreamableInterface;
|
|
use Symfony\Component\HttpClient\Response\StreamWrapper;
|
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|
use Symfony\Contracts\HttpClient\ResponseInterface;
|
|
|
|
/**
|
|
* @author Nicolas Grekas <p@tchwork.com>
|
|
*
|
|
* @internal
|
|
*/
|
|
final class HttplugWaitLoop
|
|
{
|
|
private $client;
|
|
private ?\SplObjectStorage $promisePool;
|
|
private $responseFactory;
|
|
private $streamFactory;
|
|
|
|
/**
|
|
* @param \SplObjectStorage<ResponseInterface, array{Psr7RequestInterface, Promise}>|null $promisePool
|
|
*/
|
|
public function __construct(HttpClientInterface $client, ?\SplObjectStorage $promisePool, ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory)
|
|
{
|
|
$this->client = $client;
|
|
$this->promisePool = $promisePool;
|
|
$this->responseFactory = $responseFactory;
|
|
$this->streamFactory = $streamFactory;
|
|
}
|
|
|
|
public function wait(?ResponseInterface $pendingResponse, float $maxDuration = null, float $idleTimeout = null): int
|
|
{
|
|
if (!$this->promisePool) {
|
|
return 0;
|
|
}
|
|
|
|
$guzzleQueue = \GuzzleHttp\Promise\Utils::queue();
|
|
|
|
if (0.0 === $remainingDuration = $maxDuration) {
|
|
$idleTimeout = 0.0;
|
|
} elseif (null !== $maxDuration) {
|
|
$startTime = microtime(true);
|
|
$idleTimeout = max(0.0, min($maxDuration / 5, $idleTimeout ?? $maxDuration));
|
|
}
|
|
|
|
do {
|
|
foreach ($this->client->stream($this->promisePool, $idleTimeout) as $response => $chunk) {
|
|
try {
|
|
if (null !== $maxDuration && $chunk->isTimeout()) {
|
|
goto check_duration;
|
|
}
|
|
|
|
if ($chunk->isFirst()) {
|
|
// Deactivate throwing on 3/4/5xx
|
|
$response->getStatusCode();
|
|
}
|
|
|
|
if (!$chunk->isLast()) {
|
|
goto check_duration;
|
|
}
|
|
|
|
if ([, $promise] = $this->promisePool[$response] ?? null) {
|
|
unset($this->promisePool[$response]);
|
|
$promise->resolve($this->createPsr7Response($response, true));
|
|
}
|
|
} catch (\Exception $e) {
|
|
if ([$request, $promise] = $this->promisePool[$response] ?? null) {
|
|
unset($this->promisePool[$response]);
|
|
|
|
if ($e instanceof TransportExceptionInterface) {
|
|
$e = new NetworkException($e->getMessage(), $request, $e);
|
|
}
|
|
|
|
$promise->reject($e);
|
|
}
|
|
}
|
|
|
|
$guzzleQueue->run();
|
|
|
|
if ($pendingResponse === $response) {
|
|
return $this->promisePool->count();
|
|
}
|
|
|
|
check_duration:
|
|
if (null !== $maxDuration && $idleTimeout && $idleTimeout > $remainingDuration = max(0.0, $maxDuration - microtime(true) + $startTime)) {
|
|
$idleTimeout = $remainingDuration / 5;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!$count = $this->promisePool->count()) {
|
|
return 0;
|
|
}
|
|
} while (null === $maxDuration || 0 < $remainingDuration);
|
|
|
|
return $count;
|
|
}
|
|
|
|
public function createPsr7Response(ResponseInterface $response, bool $buffer = false): Psr7ResponseInterface
|
|
{
|
|
$psrResponse = $this->responseFactory->createResponse($response->getStatusCode());
|
|
|
|
foreach ($response->getHeaders(false) as $name => $values) {
|
|
foreach ($values as $value) {
|
|
$psrResponse = $psrResponse->withAddedHeader($name, $value);
|
|
}
|
|
}
|
|
|
|
if ($response instanceof StreamableInterface) {
|
|
$body = $this->streamFactory->createStreamFromResource($response->toStream(false));
|
|
} elseif (!$buffer) {
|
|
$body = $this->streamFactory->createStreamFromResource(StreamWrapper::createResource($response, $this->client));
|
|
} else {
|
|
$body = $this->streamFactory->createStream($response->getContent(false));
|
|
}
|
|
|
|
if ($body->isSeekable()) {
|
|
$body->seek(0);
|
|
}
|
|
|
|
return $psrResponse->withBody($body);
|
|
}
|
|
}
|