You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/app/models/training.rb

47 lines
1.2 KiB

6 years ago
#encoding: utf-8
class Training < ActiveRecord::Base
attr_accessible :address, :email, :name, :phone, :position, :school, :sex, :openid, :training_type,
:major, :student_id, :job_title, :uncertified_major
6 years ago
6 years ago
# training_type 1 2018-培训会 2 警察学院大数据培训会 3 大数据和人工智能 4 工程教育认证
6 years ago
has_one :training_payinfo
Training_Type = 2 #警察学院大数据培训会
## 是否填过支付信息
def pay?
!training_payinfo.nil? && !training_payinfo.status.nil?
end
## 是否已真正支付
# 1. 微信支付
# 2. 银行卡支付,后台已确认
def payed?
pay? && training_payinfo.payed?
end
6 years ago
def research_field_include?(str)
research_field.present? && research_field.split(',').include?(str)
end
def pay_order_title
case training_type
when 3 then '全国高校大数据和人工智能暑期师资培训会-报名费'
when 4 then '工程教育认证培训会-报名费'
end
end
def registration_fee(num = 1)
case training_type
when 3 then
# 三人以上 8折
num >= 3 ? 3000.0 * 0.8 * num : 3000.0 * num
when 4 then
700.0 * num
else
raise ArgumentError
end
end
6 years ago
end