Sfoglia il codice sorgente

add live awards function

abiao 5 anni fa
parent
commit
e51ae5c836
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  1. 10 0
      app/models/live_award.rb

+ 10 - 0
app/models/live_award.rb

@@ -3,7 +3,17 @@ class LiveAward < ActiveRecord::Base
     self.table_name = "live_awards"
     validates :openid, presence: true
     belongs_to :wx_user, :foreign_key => :wx_user_id
+    after_create :update_user_info
 
+    def update_user_info
+      # 找出会员
+      wxUser = WxUser.where("openid = ?", self.openid).first
+      if !wxUser.blank?
+        self.wx_user_id=wxUser.id
+        self.save
+      end
+
+    end
 
     def prodcut1
       prd1 = Product.where("id = ?", self.prod1).first