Explorar o código

add live awards function

abiao %!s(int64=5) %!d(string=hai) anos
pai
achega
e51ae5c836
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  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