Merge commit 'd8e4449f1009bc03b167c0e5667413585b2b3e53' as 'core'
This commit is contained in:
33
core/backend/app/models/pricing.py
Normal file
33
core/backend/app/models/pricing.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from sqlalchemy import Column, Integer, String, Float, Boolean, DateTime, ForeignKey, JSON
|
||||
from sqlalchemy.sql import func
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class ElectricityPricing(Base):
|
||||
"""电价配置"""
|
||||
__tablename__ = "electricity_pricing"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String(200), nullable=False)
|
||||
energy_type = Column(String(50), default="electricity") # electricity, heat, water, gas
|
||||
pricing_type = Column(String(20), nullable=False) # flat, tou, tiered
|
||||
effective_from = Column(DateTime(timezone=True))
|
||||
effective_to = Column(DateTime(timezone=True))
|
||||
is_active = Column(Boolean, default=True)
|
||||
created_by = Column(Integer, ForeignKey("users.id"))
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
class PricingPeriod(Base):
|
||||
"""分时电价时段"""
|
||||
__tablename__ = "pricing_periods"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
pricing_id = Column(Integer, ForeignKey("electricity_pricing.id"), nullable=False)
|
||||
period_name = Column(String(50), nullable=False) # peak, valley, flat, shoulder, sharp
|
||||
start_time = Column(String(10), nullable=False) # HH:MM format
|
||||
end_time = Column(String(10), nullable=False) # HH:MM format
|
||||
price_per_unit = Column(Float, nullable=False) # yuan per kWh
|
||||
applicable_months = Column(JSON) # [1,2,3,...12] or null for all months
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
Reference in New Issue
Block a user