Class: EducodeSales::BusinessSubject
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- EducodeSales::BusinessSubject
- Defined in:
- app/models/educode_sales/business_subject.rb
Instance Method Summary collapse
-
#add_subject_shixuns(shixun_ids = []) ⇒ Object
1先创建实践项目下,通过实践课程无法选该实践项目.
- #manges ⇒ Object
-
#manges_name ⇒ Object
课程经理名称.
- #school_name ⇒ Object
-
#shixun_compeled_count ⇒ Object
实训完成统计.
-
#staffs ⇒ Object
def b_name business ? business.name : ‘–’ end.
-
#staffs_name ⇒ Object
销售名称.
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 |
#manges ⇒ Object
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_name ⇒ Object
课程经理名称
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_name ⇒ Object
34 35 36 |
# File 'app/models/educode_sales/business_subject.rb', line 34 def school_name school.try(:name) end |
#shixun_compeled_count ⇒ Object
实训完成统计
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 |
#staffs ⇒ Object
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_name ⇒ Object
销售名称
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 |