abiao 4 yıl önce
ebeveyn
işleme
36f4661a83
1 değiştirilmiş dosya ile 8 ekleme ve 4 silme
  1. 8 4
      app/models/cash_balance.rb

+ 8 - 4
app/models/cash_balance.rb

@@ -4,7 +4,8 @@ class CashBalance < ActiveRecord::Base
   self.table_name = "cash_balances"
   belongs_to :wx_user, :foreign_key => :wx_uid
   validates_presence_of :wx_uid, :count, :relate_id, :source
-  attr_accessor :remain_sum
+  attr_accessor :remain_sum,get_happen_total
+
   #after_find :get_happen_total
 
   SOURCE_ENUM = [["提货券充值佣金", "balance_benefit"],
@@ -42,10 +43,13 @@ class CashBalance < ActiveRecord::Base
     end
   end
   @total=0
-
+  @list=[]
   def get_happen_total
-    list=[]
-    list.append(self.id)
+
+    unless @list.include?(self.id)
+      @list.append(self.id)
+    end
+    # list.append(self.id)
 
     total =  CashBalance.where(id: list).sum("count")