MexPriceAdjustmentDto.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Module\Mex\Dto;
  3. use App\Module\Mex\Enums\PriceAdjustmentType;
  4. use App\Module\Mex\Models\MexPriceAdjustment;
  5. use UCore\Dto\BaseDto;
  6. /**
  7. * 农贸市场价格调整记录DTO
  8. */
  9. class MexPriceAdjustmentDto extends BaseDto
  10. {
  11. public int $id;
  12. public int $priceConfigId;
  13. public int $itemId;
  14. public int $adminUserId;
  15. public PriceAdjustmentType $adjustmentType;
  16. public ?float $oldMinPrice;
  17. public ?float $newMinPrice;
  18. public ?float $oldMaxPrice;
  19. public ?float $newMaxPrice;
  20. public ?int $oldProtectionThreshold;
  21. public ?int $newProtectionThreshold;
  22. public ?bool $oldIsEnabled;
  23. public ?bool $newIsEnabled;
  24. public ?string $adjustmentReason;
  25. public ?string $marketImpactNote;
  26. public string $createdAt;
  27. public string $priceChangeSummary;
  28. /**
  29. * 从模型创建DTO
  30. */
  31. public static function fromModel(MexPriceAdjustment $model): self
  32. {
  33. $dto = new self();
  34. $dto->id = $model->id;
  35. $dto->priceConfigId = $model->price_config_id;
  36. $dto->itemId = $model->item_id;
  37. $dto->adminUserId = $model->admin_user_id;
  38. $dto->adjustmentType = $model->adjustment_type;
  39. $dto->oldMinPrice = $model->old_min_price;
  40. $dto->newMinPrice = $model->new_min_price;
  41. $dto->oldMaxPrice = $model->old_max_price;
  42. $dto->newMaxPrice = $model->new_max_price;
  43. $dto->oldProtectionThreshold = $model->old_protection_threshold;
  44. $dto->newProtectionThreshold = $model->new_protection_threshold;
  45. $dto->oldIsEnabled = $model->old_is_enabled;
  46. $dto->newIsEnabled = $model->new_is_enabled;
  47. $dto->adjustmentReason = $model->adjustment_reason;
  48. $dto->marketImpactNote = $model->market_impact_note;
  49. $dto->createdAt = $model->created_at->format('Y-m-d H:i:s');
  50. $dto->priceChangeSummary = $model->price_change_summary;
  51. return $dto;
  52. }
  53. }