educode_sales 0.7.2 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/images/educode_sales/assessment.png +0 -0
- data/app/assets/images/educode_sales/indexlogo.png +0 -0
- data/app/controllers/educode_sales/assessments_controller.rb +490 -0
- data/app/controllers/educode_sales/businesses_controller.rb +13 -4
- data/app/controllers/educode_sales/customers_controller.rb +3 -0
- data/app/controllers/educode_sales/follow_ups_controller.rb +13 -1
- data/app/controllers/educode_sales/home_controller.rb +4 -3
- data/app/controllers/educode_sales/money_plans_controller.rb +2 -0
- data/app/controllers/educode_sales/plans_controller.rb +1 -0
- data/app/controllers/educode_sales/results_controller.rb +54 -0
- data/app/controllers/educode_sales/roles_controller.rb +4 -1
- data/app/controllers/educode_sales/sessions_controller.rb +2 -1
- data/app/helpers/educode_sales/application_helper.rb +61 -0
- data/app/helpers/educode_sales/assessments_help.rb +52 -0
- data/app/models/educode_sales/assessments_setting.rb +28 -0
- data/app/models/educode_sales/business.rb +2 -1
- data/app/models/educode_sales/follow_up.rb +1 -1
- data/app/models/educode_sales/money_plan.rb +1 -0
- data/app/models/educode_sales/permission.rb +2 -1
- data/app/models/educode_sales/result.rb +4 -0
- data/app/models/educode_sales/role_area.rb +2 -1
- data/app/views/educode_sales/assessments/_progress.html.erb +433 -0
- data/app/views/educode_sales/assessments/_setup.html.erb +331 -0
- data/app/views/educode_sales/assessments/edit.html.erb +238 -0
- data/app/views/educode_sales/assessments/get_export_data.json.jbuilder +197 -0
- data/app/views/educode_sales/assessments/index.html.erb +63 -0
- data/app/views/educode_sales/assessments/index.json.jbuilder +26 -0
- data/app/views/educode_sales/assessments/new.html.erb +310 -0
- data/app/views/educode_sales/assessments/progress.json.jbuilder +372 -0
- data/app/views/educode_sales/businesses/edit_follow_record.html.erb +150 -114
- data/app/views/educode_sales/businesses/get_export_data.json.jbuilder +1 -0
- data/app/views/educode_sales/businesses/index.html.erb +25 -19
- data/app/views/educode_sales/businesses/index.json.jbuilder +1 -0
- data/app/views/educode_sales/businesses/new_follow_record.html.erb +163 -126
- data/app/views/educode_sales/businesses/show_follow.html.erb +25 -20
- data/app/views/educode_sales/businesses/show_follow.json.jbuilder +1 -0
- data/app/views/educode_sales/businesses/show_follow_record.html.erb +8 -1
- data/app/views/educode_sales/places/index.html.erb +5 -3
- data/app/views/educode_sales/plans/_monthPlan.html.erb +3 -1
- data/app/views/educode_sales/plans/new_month.html.erb +2 -0
- data/app/views/educode_sales/plans/new_week.html.erb +5 -1
- data/app/views/educode_sales/results/edit.html.erb +111 -0
- data/app/views/educode_sales/results/index.html.erb +0 -0
- data/app/views/educode_sales/results/index.json.jbuilder +13 -0
- data/app/views/educode_sales/results/new.html.erb +58 -0
- data/app/views/educode_sales/results/show.json.jbuilder +9 -0
- data/app/views/educode_sales/roles/edit.html.erb +26 -18
- data/app/views/educode_sales/sale_reports/index.json.jbuilder +1 -0
- data/app/views/layouts/educode_sales/application.html.erb +18 -12
- data/app/views/layouts/educode_sales/login.html.erb +1 -1
- data/config/routes.rb +18 -1
- data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +9 -1
- data/db/migrate/20220314053856_add_service_start_time_to_follow_ups.rb +6 -0
- data/db/migrate/20220314074354_add_service_time_long_to_follow_ups.rb +5 -0
- data/db/migrate/20220402020233_create_educode_sales_assessments_settings.rb +27 -0
- data/db/migrate/20220411021641_add_new_column_assessments_settings.rb +20 -0
- data/db/migrate/20220413090940_add_september_progress_to_assessment_settings.rb +5 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +31 -6
@@ -0,0 +1,54 @@
|
|
1
|
+
require_dependency "educode_sales/application_controller"
|
2
|
+
|
3
|
+
module EducodeSales
|
4
|
+
class ResultsController < ApplicationController
|
5
|
+
|
6
|
+
def index
|
7
|
+
respond_to do |format|
|
8
|
+
format.html do
|
9
|
+
end
|
10
|
+
format.json do
|
11
|
+
# @commons = Common.group("clazz").page(params[:page]).per(params[:limit])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# def create
|
17
|
+
# common = Common.new(name: params[:name], clazz: params[:clazz])
|
18
|
+
# if common.save
|
19
|
+
# render_success
|
20
|
+
# else
|
21
|
+
# render_failure common
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# def edit
|
26
|
+
# @common = Common.find(params[:id])
|
27
|
+
# render layout: false
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# def update
|
31
|
+
# common = Common.find(params[:id])
|
32
|
+
# if common.update(common_params)
|
33
|
+
# render_success
|
34
|
+
# else
|
35
|
+
# render_failure common
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# def new
|
40
|
+
# render layout: false
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# def show
|
44
|
+
# commons = Common.find(params[:id])
|
45
|
+
# @commons = Common.where(clazz: commons.clazz).order('position')
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# private
|
49
|
+
#
|
50
|
+
# def common_params
|
51
|
+
# params.permit(:name, :position)
|
52
|
+
# end
|
53
|
+
end
|
54
|
+
end
|
@@ -16,7 +16,7 @@ module EducodeSales
|
|
16
16
|
|
17
17
|
def create
|
18
18
|
role = Role.new(name: params[:name])
|
19
|
-
role.role_areas.build([{ clazz: 'Business' }, { clazz: 'SalePlan' }, { clazz: 'Teacher' }, { clazz: 'Operation' }, {clazz:'Customer'}, {clazz:'MoneyPlan'}])
|
19
|
+
role.role_areas.build([{ clazz: 'Business' }, { clazz: 'SalePlan' }, { clazz: 'Teacher' }, { clazz: 'Operation' }, { clazz: 'Customer' }, { clazz: 'MoneyPlan' }, { clazz: 'AssessmentsSetting' }])
|
20
20
|
if role.save
|
21
21
|
render_success
|
22
22
|
else
|
@@ -84,6 +84,9 @@ module EducodeSales
|
|
84
84
|
r = role.role_areas.find_or_initialize_by(clazz: 'MoneyPlan')
|
85
85
|
r.level = params[:money_plan]
|
86
86
|
r.save
|
87
|
+
r = role.role_areas.find_or_initialize_by(clazz: 'AssessmentsSetting')
|
88
|
+
r.level = params[:assessments_setting]
|
89
|
+
r.save
|
87
90
|
render_success
|
88
91
|
end
|
89
92
|
|
@@ -2,7 +2,8 @@ require_dependency "educode_sales/application_controller"
|
|
2
2
|
|
3
3
|
module EducodeSales
|
4
4
|
class SessionsController < ApplicationController
|
5
|
-
layout "educode_sales/login"
|
5
|
+
layout "educode_sales/login" #todo 注意 修改模板(感觉是 整个控制器的html下都先导入该模板在导入对应的html)
|
6
|
+
# 行 动 前 跳 过
|
6
7
|
skip_before_action :authenticate_request
|
7
8
|
|
8
9
|
def login
|
@@ -52,5 +52,66 @@ module EducodeSales
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
|
56
|
+
# 完成率completion_rate
|
57
|
+
def completion_rate(setting,progress)
|
58
|
+
if setting.to_i == 0
|
59
|
+
'100%'
|
60
|
+
else
|
61
|
+
(progress.to_f/setting.to_f*100).round(2).to_s + "%"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
# 签单金额 得分规则
|
67
|
+
def signed_amount_score(setting,progress)
|
68
|
+
progress.to_f >= setting.to_f || setting.to_i == 0 ? 40:(progress.to_f/setting.to_f*40).round(2)
|
69
|
+
end
|
70
|
+
|
71
|
+
# 回款金额 得分规则
|
72
|
+
def collection_amount_score(setting,progress)
|
73
|
+
(progress.to_i >= setting.to_i) || (setting.to_i == 0) ? 20:(progress.to_f/setting.to_f*20).round(2)
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# 拜访量 得分规则
|
78
|
+
def visits_score(d)
|
79
|
+
d.to_i > 30 ? 20:0
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
#新增商机数 得分规则
|
84
|
+
def add_businesses_score(staff_id,start_time,end_time)
|
85
|
+
if @current_admin.is_admin?
|
86
|
+
@businesses = Business
|
87
|
+
else
|
88
|
+
level = @current_admin.role.role_areas.find_by(clazz: '商机管理').level
|
89
|
+
case level
|
90
|
+
when '自己'
|
91
|
+
# Business.joins(Business字段: :表的名称)----> Business表(belongs_to) Business字段关联的表(has_many) Business字段关联的表在关联的表(belongs_to)
|
92
|
+
business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
|
93
|
+
@businesses = Business.where("educode_sales_businesses.staff_id = ? OR educode_sales_businesses.id in (?)", @current_admin.id, business_ids)
|
94
|
+
when '区域'
|
95
|
+
school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id) + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
|
96
|
+
business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
|
97
|
+
@businesses = Business.joins("JOIN departments ON educode_sales_businesses.department_id = departments.id").where("departments.school_id in (?) OR educode_sales_businesses.staff_id = #{@current_admin.id} OR educode_sales_businesses.id in (?)", school_ids, business_ids)
|
98
|
+
else
|
99
|
+
@businesses = Business
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
ids_a_b = Common.where(extras: %w[a_class b_class ]).pluck(:id)
|
104
|
+
ids_c_d = Common.where(extras: %w[c_class d_class]).pluck(:id)
|
105
|
+
@businesses_a_b_count = @businesses.joins("JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id").where("educode_sales_follow_ups.clazz_id in (?)",ids_a_b)
|
106
|
+
.where("educode_sales_businesses.staff_id = ?",staff_id)
|
107
|
+
.where("educode_sales_businesses.created_at >= ? and educode_sales_businesses.created_at <= ?", "#{@assessment_year}-#{start_time} 00:00:00".to_date,
|
108
|
+
"#{@assessment_year}-#{end_time} 23:59:00".to_date)
|
109
|
+
@businesses_c_d_count = @businesses.joins("JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id").where("educode_sales_follow_ups.clazz_id in (?)",ids_c_d)
|
110
|
+
.where("educode_sales_businesses.staff_id = ?",staff_id)
|
111
|
+
.where("educode_sales_businesses.created_at >= ? and educode_sales_businesses.created_at <= ?", "#{@assessment_year}-#{start_time} 00:00:00".to_date,
|
112
|
+
"#{@assessment_year}-#{end_time} 23:59:00".to_date)
|
113
|
+
@businesses_a_b_count.count.to_i*10 + @businesses_c_d_count.count.to_i*5
|
114
|
+
end
|
115
|
+
|
55
116
|
end
|
56
117
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module EducodeSales
|
4
|
+
module AssessmentsHelper
|
5
|
+
|
6
|
+
|
7
|
+
# def business_score
|
8
|
+
# if @current_admin.is_admin?
|
9
|
+
# @businesses = Business
|
10
|
+
# else
|
11
|
+
# level = @current_admin.role.role_areas.find_by(clazz: '商机管理').level
|
12
|
+
# case level
|
13
|
+
# when '自己'
|
14
|
+
# # Business.joins(Business字段: :表的名称)----> Business表(belongs_to) Business字段关联的表(has_many) Business字段关联的表在关联的表(belongs_to)
|
15
|
+
# business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
|
16
|
+
# @businesses = Business.where("educode_sales_businesses.staff_id = ? OR educode_sales_businesses.id in (?)", @current_admin.id, business_ids)
|
17
|
+
# when '区域'
|
18
|
+
# school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id) + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
|
19
|
+
# business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
|
20
|
+
# @businesses = Business.joins("JOIN departments ON educode_sales_businesses.department_id = departments.id").where("departments.school_id in (?) OR educode_sales_businesses.staff_id = #{@current_admin.id} OR educode_sales_businesses.id in (?)", school_ids, business_ids)
|
21
|
+
# else
|
22
|
+
# @businesses = Business
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
|
26
|
+
# @businesses = @businesses.where("follow_ups_count > ?", '0').where("educode_sales_businesses.created_at >= ? and educode_sales_businesses.created_at <= ?", "#{@assessment_year}-01-01 00:00:00".to_date,"#{@assessment_year}-12-31 23:59:00".to_date)
|
27
|
+
# @businesses = @businesses.where(staff_id: d_staff_id)
|
28
|
+
# # 2.销售人员新增的商机数量,过滤E、O、X类商机,包含:ABCD类商机; 上面有连接follow_up表
|
29
|
+
# ids = Common.where(extras: %w[a_class b_class c_class d_claass]).pluck(:id) # 数组[1,5,2,15]
|
30
|
+
# @businesses = @businesses.joins("JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id").where("educode_sales_follow_ups.clazz_id in (?) ",ids)
|
31
|
+
# # 先把staff写死
|
32
|
+
# # @businesses = @businesses.where(staff_id: d_staff_id)
|
33
|
+
# case time
|
34
|
+
# when '1'
|
35
|
+
# @businesses = @businesses.where("educode_sales_businesses.created_at >= ? and educode_sales_businesses.created <= ?", "#{@assessment_year}-01-01 00:00:00".to_date,"#{@assessment_year}-12-31 23:59:00".to_date)
|
36
|
+
# when '2'
|
37
|
+
# when '3'
|
38
|
+
# when '4'
|
39
|
+
# when '5'
|
40
|
+
# when '6'
|
41
|
+
# when '7'
|
42
|
+
# when '8'
|
43
|
+
# when '9'
|
44
|
+
# when '10'
|
45
|
+
# when '11'
|
46
|
+
# when '12'
|
47
|
+
# end
|
48
|
+
|
49
|
+
# end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module EducodeSales
|
2
|
+
class AssessmentsSetting < ApplicationRecord
|
3
|
+
# belongs_to :educode_sales_staff, :class_name => 'EducodeSales::Staff'
|
4
|
+
belongs_to :staff
|
5
|
+
belongs_to :user
|
6
|
+
|
7
|
+
|
8
|
+
# todo 签单金额 : assessment_id(1)
|
9
|
+
# todo 回款金额 : assessment_id(2)
|
10
|
+
# todo 拜访量 : assessment_id(3)
|
11
|
+
# todo 新增商机数 : assessment_id(4)
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -3,11 +3,12 @@ module EducodeSales
|
|
3
3
|
|
4
4
|
belongs_to :staff
|
5
5
|
belongs_to :department
|
6
|
-
belongs_to :last_follow_up, class_name: 'FollowUp', optional: true
|
6
|
+
belongs_to :last_follow_up, class_name: 'FollowUp', optional: true # 允许last_follow_up_id字段中的数为nil
|
7
7
|
|
8
8
|
has_many :sale_plans
|
9
9
|
has_many :follow_ups
|
10
10
|
|
11
|
+
#每次查询时 默认的查询条件
|
11
12
|
default_scope -> {where(deleted_at: nil)}
|
12
13
|
|
13
14
|
def soft_destroy(user_id)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module EducodeSales
|
2
2
|
class FollowUp < ApplicationRecord
|
3
3
|
include ::Deletable
|
4
|
-
belongs_to :business, counter_cache: true
|
4
|
+
belongs_to :business, counter_cache: true # counter_cache(自动计算 business对应follow_up表中对应的个数)
|
5
5
|
belongs_to :place, optional: true
|
6
6
|
has_many :money_plans
|
7
7
|
has_many :key_person
|