| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- # encoding:utf-8
- class OrderBaseDetail < ActiveRecord::Base
- has_paper_trail
- self.table_name = "order_base_details"
- validates :order_no,:order_dt_id,:product_id, presence: true
- belongs_to :order, :foreign_key => :order_id
- attr_accessor :get_order_state
- def get_order_state(x)
- case x
- when "unpay"
- return "未支付"
- when "closed"
- return "已关闭"
- when "unconfirmed"
- return "待确认"
- when "processing"
- return "处理中"
- when "complete"
- return "已完成"
- when "dispatch"
- return "待收货"
- when "refunded"
- return "已退款"
- else
- return "--"
- end
- end
- def get_order_pay_way(x)
- case x
- when "weixinpay"
- return "微信支付"
- when "balance"
- return "提货券支付"
- when "cent"
- return "积分支付"
- else
- return "--"
- end
- end
- rails_admin do
- navigation_label '订单基本明细'
- weight -300
- parent Order
- list do
- filters [:order_no,:product_id,:order_dt_id]
- # include_all_fields
- field :id
- field :order_no
- field :product_id
- field :title
- field :nums
- field :order_dt_id
- field :paid_time do
- filterable true
- formatted_value do
- #bindings[:object].order.paied_time
- if !bindings[:object].order.blank?
- (bindings[:object].order.paied_at == 0 || bindings[:object].order.paied_at == nil) ? Time.at(0) : Time.at(bindings[:object].order.paied_at)
- end
- end
- end
- field :order_dt_state do
- filterable true
- formatted_value do
- if !bindings[:object].order.blank?
- bindings[:object].get_order_state(bindings[:object].order.status)
- end
- end
- end
- field :pay_way do
- filterable true
- formatted_value do
- if !bindings[:object].order.blank?
- bindings[:object].get_order_pay_way(bindings[:object].order.pay_way)
- end
- end
- end
- field :send
- end
- show do
- field :id
- field :order_no
- field :product_id
- field :title
- field :nums
- field :order_dt_id
- field :send
- end
- edit do
- field :order_no
- field :product_id
- field :title
- field :nums
- field :order_dt_id
- field :send
- end
- export do
- include_all_fields
- field :wx_user_id do
- formatted_value do
- bindings[:object].order.wx_user_id
- end
- end
- field :paid_time do
- filterable true
- formatted_value do
- #bindings[:object].order.paied_time
- if !bindings[:object].order.blank?
- (bindings[:object].order.paied_at == 0 || bindings[:object].order.paied_at == nil) ? Time.at(0) : Time.at(bindings[:object].order.paied_at)
- end
- end
- end
- field :order_dt_state do
- filterable true
- formatted_value do
- if !bindings[:object].order.blank?
- bindings[:object].get_order_state(bindings[:object].order.status)
- end
- end
- end
- field :pay_way do
- filterable true
- formatted_value do
- if !bindings[:object].order.blank?
- bindings[:object].get_order_pay_way(bindings[:object].order.pay_way)
- end
- end
- end
- end
- end
- end
|