abiao лет назад: 4
Родитель
Сommit
a93e33d9c9
2 измененных файлов с 8 добавлено и 1 удалено
  1. 6 0
      app/models/cash_balance.rb
  2. 2 1
      config/locales/models/cash_balance.yml

+ 6 - 0
app/models/cash_balance.rb

@@ -5,6 +5,7 @@ class CashBalance < ActiveRecord::Base
   belongs_to :wx_user, :foreign_key => :wx_uid
   belongs_to :wx_user, :foreign_key => :wx_uid
   validates_presence_of :wx_uid, :count, :relate_id, :source
   validates_presence_of :wx_uid, :count, :relate_id, :source
   attr_accessor :remain_sum
   attr_accessor :remain_sum
+  after_find :get_happen_total
 
 
   SOURCE_ENUM = [["提货券充值佣金", "balance_benefit"],
   SOURCE_ENUM = [["提货券充值佣金", "balance_benefit"],
                  ["商品佣金", "product_benefit"],
                  ["商品佣金", "product_benefit"],
@@ -40,6 +41,11 @@ class CashBalance < ActiveRecord::Base
       return self.count
       return self.count
     end
     end
   end
   end
+  total=0
+  def get_happen_total
+    total= total+self.count
+    return total
+  end
 
 
   def profit_state
   def profit_state
     if self.trade_no.length>0
     if self.trade_no.length>0

+ 2 - 1
config/locales/models/cash_balance.yml

@@ -16,4 +16,5 @@ zh-CN:
         profit_flag: 分账状态
         profit_flag: 分账状态
         profit_state: 分账状态
         profit_state: 分账状态
         created_at: 创建时间
         created_at: 创建时间
-        updated_at: 更新时间
+        updated_at: 更新时间
+        get_happen_total: 金额统计