| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace App\Module\Mex\Service;
- use App\Module\Fund\Enums\FUND_CURRENCY_TYPE;
- use App\Module\Mex\Dto\MexDailyPriceTrendDto;
- use App\Module\Mex\Logic\MexDailyPriceTrendLogic;
- use Illuminate\Support\Collection;
- /**
- * 农贸市场每日价格趋势服务层
- */
- class MexDailyPriceTrendService
- {
- /**
- * 生成指定日期的价格趋势数据
- */
- public static function generateDailyTrend(string $date, int $itemId, FUND_CURRENCY_TYPE $currencyType): ?MexDailyPriceTrendDto
- {
- $logic = new MexDailyPriceTrendLogic();
- return $logic->generateDailyTrend($date, $itemId, $currencyType);
- }
- /**
- * 批量生成多日价格趋势数据
- */
- public static function generateMultipleDaysTrends(
- string $startDate,
- string $endDate,
- ?int $itemId = null,
- ?FUND_CURRENCY_TYPE $currencyType = null
- ): Collection {
- $logic = new MexDailyPriceTrendLogic();
- return $logic->generateMultipleDaysTrends($startDate, $endDate, $itemId, $currencyType);
- }
- /**
- * 获取商品的价格趋势历史
- */
- public static function getItemPriceTrends(
- int $itemId,
- FUND_CURRENCY_TYPE $currencyType,
- string $startDate,
- string $endDate,
- int $limit = 100
- ): Collection {
- $logic = new MexDailyPriceTrendLogic();
- return $logic->getItemPriceTrends($itemId, $currencyType, $startDate, $endDate, $limit);
- }
- /**
- * 获取价格趋势统计信息
- */
- public static function getTrendStatistics(
- int $itemId,
- FUND_CURRENCY_TYPE $currencyType,
- string $startDate,
- string $endDate
- ): array {
- $logic = new MexDailyPriceTrendLogic();
- return $logic->getTrendStatistics($itemId, $currencyType, $startDate, $endDate);
- }
- /**
- * 生成今日所有商品的价格趋势
- */
- public static function generateTodayTrends(): Collection
- {
- $today = date('Y-m-d');
- $logic = new MexDailyPriceTrendLogic();
- return $logic->generateMultipleDaysTrends($today, $today);
- }
- /**
- * 生成昨日所有商品的价格趋势
- */
- public static function generateYesterdayTrends(): Collection
- {
- $yesterday = date('Y-m-d', strtotime('-1 day'));
- $logic = new MexDailyPriceTrendLogic();
- return $logic->generateMultipleDaysTrends($yesterday, $yesterday);
- }
- }
|