| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Module\Mex\Dto;
- use App\Module\Mex\Enums\PriceAdjustmentType;
- use App\Module\Mex\Models\MexPriceAdjustment;
- use UCore\Dto\BaseDto;
- /**
- * 农贸市场价格调整记录DTO
- */
- class MexPriceAdjustmentDto extends BaseDto
- {
- public int $id;
- public int $priceConfigId;
- public int $itemId;
- public int $adminUserId;
- public PriceAdjustmentType $adjustmentType;
- public ?float $oldMinPrice;
- public ?float $newMinPrice;
- public ?float $oldMaxPrice;
- public ?float $newMaxPrice;
- public ?int $oldProtectionThreshold;
- public ?int $newProtectionThreshold;
- public ?bool $oldIsEnabled;
- public ?bool $newIsEnabled;
- public ?string $adjustmentReason;
- public ?string $marketImpactNote;
- public string $createdAt;
- public string $priceChangeSummary;
- /**
- * 从模型创建DTO
- */
- public static function fromModel(MexPriceAdjustment $model): self
- {
- $dto = new self();
- $dto->id = $model->id;
- $dto->priceConfigId = $model->price_config_id;
- $dto->itemId = $model->item_id;
- $dto->adminUserId = $model->admin_user_id;
- $dto->adjustmentType = $model->adjustment_type;
- $dto->oldMinPrice = $model->old_min_price;
- $dto->newMinPrice = $model->new_min_price;
- $dto->oldMaxPrice = $model->old_max_price;
- $dto->newMaxPrice = $model->new_max_price;
- $dto->oldProtectionThreshold = $model->old_protection_threshold;
- $dto->newProtectionThreshold = $model->new_protection_threshold;
- $dto->oldIsEnabled = $model->old_is_enabled;
- $dto->newIsEnabled = $model->new_is_enabled;
- $dto->adjustmentReason = $model->adjustment_reason;
- $dto->marketImpactNote = $model->market_impact_note;
- $dto->createdAt = $model->created_at->format('Y-m-d H:i:s');
- $dto->priceChangeSummary = $model->price_change_summary;
-
- return $dto;
- }
- }
|