| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- # encoding: utf-8
- require 'date' # 包含DateTime
- require 'time'
- class UserPerfomance < ActiveRecord::Base
- has_paper_trail
- self.table_name = "user_perfomances"
- belongs_to :wx_user, :foreign_key => :wx_user_id
- #validates_presence_of :wx_user_id
- #after_create :user_perfomance
- after_update :user_perfomance
- validates :wx_user_id,:begin_date,:end_date,presence: true
- def user_perfomance
- #统计订单商品销售数据
- url = "#{CONFIG_FILE["api_host"]}/railsadmin/user/perfomance/#{self.id}"
- p url
- open(url)
- end
- def begin_date_fomat
- if !self.begin_date.nil?
- return self.begin_date.strftime
- end
- end
- def end_date_fomat
- if !self.end_date.nil?
- return self.end_date.strftime
- end
- end
- rails_admin do
- navigation_label '统计汇总'
- weight -500
- list do
- filters [:wx_user_id,:begin_date,:end_date]
- field :id
- field :begin_date do
- visible false
- filterable true
- end
- field :end_date do
- visible false
- filterable true
- end
- field :begin_date_fomat
- field :end_date_fomat
- field :wx_user_id do
- filterable true
- end
- field :nickname
- field :order_perfomance
- field :shop_order_perfomance
- field :shop_perfomance
- field :balance_perfomance
- field :total
- field :created_at
- field :updated_at
- end
- show do
- field :id
- field :begin_date_fomat
- field :end_date_fomat
- field :wx_user_id
- field :nickname
- field :order_perfomance
- field :shop_order_perfomance
- field :shop_perfomance
- field :balance_perfomance
- field :total
- field :created_at
- field :updated_at
- end
- edit do
- field :begin_date
- field :end_date
- field :wx_user_id
- end
- end
- end
|