Sha256: 4b841980d301375697df7927bbcb58851a84d9fc7f0e882271d1fdeeaa6ab4f0

Contents?: true

Size: 924 Bytes

Versions: 7

Compression:

Stored size: 924 Bytes

Contents

##
# Order 是订单。

class Unidom::Order::Order < Unidom::Order::ApplicationRecord

  self.table_name = 'unidom_orders'

  include Unidom::Common::Concerns::ModelExtension
  include Unidom::Order::Concerns::AsAdjusted

  validates :number,           presence: true, length:       { is: self.columns_hash['number'].limit }
  validates :purchase_amount,  presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
  validates :aggregate_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }

  belongs_to :placer, polymorphic: true
  belongs_to :taker,  polymorphic: true

  has_many :items, class_name: 'Unidom::Order::OrderItem'

  scope :placed_by, ->(placer) { where placer: placer }
  scope :taken_by,  ->(taker)  { where taker:  taker  }

end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::Order'

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
unidom-order-2.0 app/models/unidom/order/order.rb
unidom-order-1.5.9 app/models/unidom/order/order.rb
unidom-order-1.5.8 app/models/unidom/order/order.rb
unidom-order-1.5.7 app/models/unidom/order/order.rb
unidom-order-1.5.6 app/models/unidom/order/order.rb
unidom-order-1.5.5 app/models/unidom/order/order.rb
unidom-order-1.5.4 app/models/unidom/order/order.rb