Explorar el Código

balance promotion settings

abiao hace 4 años
padre
commit
02eeca2ead
Se han modificado 1 ficheros con 16 adiciones y 0 borrados
  1. 16 0
      app/models/balance_promotion.rb

+ 16 - 0
app/models/balance_promotion.rb

@@ -10,6 +10,22 @@ class BalancePromotion < ActiveRecord::Base
           self.errors.add(:send_prod1,"赠品1不存在,请重新填写。")
         end
       end
+
+      if self.send_prod2 > 0
+        prd2 = Product.where("id = ?", self.send_prod2).first
+        if prd2.blank?
+          self.errors.add(:send_prod2,"赠品2不存在,请重新填写。")
+        end
+      end
+
+
+      if self.send_prod3 > 0
+        prd3 = Product.where("id = ?", self.send_prod3).first
+        if prd3.blank?
+          self.errors.add(:send_prod3,"赠品3不存在,请重新填写。")
+        end
+      end
+
     end
     def send_prodcut1
       prd1 = Product.where("id = ?", self.send_prod1).first