MexPriceAdjustmentService.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App\Module\Mex\Service;
  3. use App\Module\Mex\Dto\MexPriceAdjustmentDto;
  4. use App\Module\Mex\Logic\MexPriceAdjustmentLogic;
  5. use App\Module\Mex\Models\MexPriceConfig;
  6. use Illuminate\Support\Collection;
  7. /**
  8. * 农贸市场价格调整记录服务层
  9. */
  10. class MexPriceAdjustmentService
  11. {
  12. /**
  13. * 记录价格配置调整
  14. */
  15. public static function recordPriceConfigAdjustment(
  16. MexPriceConfig $oldConfig,
  17. MexPriceConfig $newConfig,
  18. int $adminUserId,
  19. ?string $adjustmentReason = null,
  20. ?string $marketImpactNote = null
  21. ): MexPriceAdjustmentDto {
  22. $logic = new MexPriceAdjustmentLogic();
  23. return $logic->recordPriceConfigAdjustment(
  24. $oldConfig,
  25. $newConfig,
  26. $adminUserId,
  27. $adjustmentReason,
  28. $marketImpactNote
  29. );
  30. }
  31. /**
  32. * 获取商品的价格调整历史
  33. */
  34. public static function getItemAdjustmentHistory(int $itemId, int $limit = 50): Collection
  35. {
  36. $logic = new MexPriceAdjustmentLogic();
  37. return $logic->getItemAdjustmentHistory($itemId, $limit);
  38. }
  39. /**
  40. * 获取管理员的调整操作记录
  41. */
  42. public static function getAdminAdjustmentHistory(int $adminUserId, int $limit = 50): Collection
  43. {
  44. $logic = new MexPriceAdjustmentLogic();
  45. return $logic->getAdminAdjustmentHistory($adminUserId, $limit);
  46. }
  47. /**
  48. * 获取指定时间范围内的调整记录
  49. */
  50. public static function getAdjustmentsByDateRange(
  51. string $startDate,
  52. string $endDate,
  53. ?int $itemId = null,
  54. ?int $adminUserId = null
  55. ): Collection {
  56. $logic = new MexPriceAdjustmentLogic();
  57. return $logic->getAdjustmentsByDateRange($startDate, $endDate, $itemId, $adminUserId);
  58. }
  59. /**
  60. * 获取调整统计信息
  61. */
  62. public static function getAdjustmentStatistics(string $startDate, string $endDate): array
  63. {
  64. $logic = new MexPriceAdjustmentLogic();
  65. return $logic->getAdjustmentStatistics($startDate, $endDate);
  66. }
  67. }