浏览代码

add live awards function

abiao 5 年之前
父节点
当前提交
e51ae5c836
共有 1 个文件被更改,包括 10 次插入0 次删除
  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