|
|
@@ -2,7 +2,15 @@ class BalancePromotion < ActiveRecord::Base
|
|
|
has_paper_trail
|
|
|
self.table_name = "balance_promotions"
|
|
|
validates :begin_time,:end_time,:name, presence: true
|
|
|
-
|
|
|
+ validate :product_validation
|
|
|
+ def product_validation
|
|
|
+ if self.send_prod1 > 0
|
|
|
+ prd1 = Product.where("id = ?", self.send_prod1).first
|
|
|
+ if prd1.blank?
|
|
|
+ self.errors.add(:send_prod1,"赠品1不存在,请重新填写。")
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
def send_prodcut1
|
|
|
prd1 = Product.where("id = ?", self.send_prod1).first
|
|
|
if !prd1.blank?
|