Class: EducodeSales::BusinessDeliverSubject

Inherits:
ApplicationRecord show all
Defined in:
app/models/educode_sales/business_deliver_subject.rb

Instance Method Summary collapse

Instance Method Details

#add_subjects(subject_ids = []) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'app/models/educode_sales/business_deliver_subject.rb', line 36

def add_subjects(subject_ids = [])
  subjects = Subject.where.not(id: BusinessSubject.joins(:business_deliver_subject).pluck(:subject_id)).unhidden # 1先创建实践项目下,通过实践课程无法选该实践项目
  subject_ids.each do |item|
      now_subject = subjects.find_by(id: item)
      if now_subject.present?
        add_item = BusinessSubject.find_or_create_by(subject_id: item)
        add_item.update(business: business, business_deliver_subject_id: id)
      end
  end
end

#delvier_dateObject



32
33
34
# File 'app/models/educode_sales/business_deliver_subject.rb', line 32

def delvier_date
  business.last_follow_up&.reception_at
end

#shixun_competed_countObject

实训项目完成进度



22
23
24
# File 'app/models/educode_sales/business_deliver_subject.rb', line 22

def shixun_competed_count
  " #{business_subjects.joins(:business_subject_shixuns).where("educode_sales_business_subject_shixuns.shixun_status in (6,7,8)").count } / #{business_subjects.joins(:business_subject_shixuns).count} "
end

#subject_competed_countObject

实践课程完成统计



14
15
16
17
18
19
# File 'app/models/educode_sales/business_deliver_subject.rb', line 14

def subject_competed_count
  all_count = subjects.count
  completed_count = subjects.where("subjects.status = 2 or subjects.public = 2").count

  " #{completed_count} / #{all_count} "
end

#subject_managesObject

课程经理



27
28
29
# File 'app/models/educode_sales/business_deliver_subject.rb', line 27

def subject_manages
  manages.joins(staff: :user).pluck("CONCAT(users.lastname, users.firstname) ").join("") || "--"
end