Class: EducodeSales::BusinessSubject

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

Instance Method Summary collapse

Instance Method Details

#add_subject_shixuns(shixun_ids = []) ⇒ Object

1先创建实践项目下,通过实践课程无法选该实践项目



56
57
58
59
60
61
62
63
64
65
# File 'app/models/educode_sales/business_subject.rb', line 56

def add_subject_shixuns(shixun_ids=[])  # 1先创建实践项目下,通过实践课程无法选该实践项目
  shixuns = Shixun.where.not(id: BusinessSubjectShixun.joins(:business_subject).pluck(:shixun_id)) # 1先创建实践项目下,通过实践课程无法选该实践项目
  shixun_ids.each do |item|
    now_shixun = shixuns.find_by(id: item)
    if now_shixun.present?
      add_item = BusinessSubjectShixun.create_with(name: now_shixun.name).find_or_create_by(shixun_id: item)
      add_item.update(business_subject_id: self.id )
    end
  end
end

#mangesObject



51
52
53
# File 'app/models/educode_sales/business_subject.rb', line 51

def manges
  business_deliver_subject ? business_deliver_subject.subject_manages : manges_name
end

#manges_nameObject

课程经理名称



25
26
27
# File 'app/models/educode_sales/business_subject.rb', line 25

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

#school_nameObject



34
35
36
# File 'app/models/educode_sales/business_subject.rb', line 34

def school_name
  school.try(:name)
end

#shixun_compeled_countObject

实训完成统计



30
31
32
# File 'app/models/educode_sales/business_subject.rb', line 30

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

#staffsObject

def b_name

business ? business.name : '--'

end



47
48
49
# File 'app/models/educode_sales/business_subject.rb', line 47

def staffs
  business ? business.staff&.name : staffs_name
end

#staffs_nameObject

销售名称



14
15
16
17
18
19
20
21
22
# File 'app/models/educode_sales/business_subject.rb', line 14

def staffs_name
  staff_names = BusinessSubjectStaff.joins(staff: :user)
                      .where("educode_sales_business_subject_staffs.category = #{ BusinessSubjectStaff::CATEGORY_TYPES::SUBJECT_STAFF } and educode_sales_business_subject_staffs.container_id = #{self.id} and
                              educode_sales_business_subject_staffs.container_type = #{BusinessSubjectStaff::CONTAINER_TYPES::SUBJECT} ")
                      .pluck("DISTINCT CONCAT(users.lastname, users.firstname) ")
                      .join("")
  # staffs.joins(staff: :user).pluck("CONCAT(users.lastname, users.firstname) ").join(",")
  staff_names
end