educode_sales 1.10.49 → 1.10.58
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/stylesheets/educode_sales/modules/easyeditor/easyeditor.css +1 -1
- data/app/controllers/educode_sales/application_controller.rb +10 -0
- data/app/controllers/educode_sales/business_courses_controller.rb +58 -33
- data/app/controllers/educode_sales/businesses_controller.rb +43 -7
- data/app/controllers/educode_sales/contracts_controller.rb +6 -0
- data/app/controllers/educode_sales/money_plan_records_controller.rb +6 -2
- data/app/controllers/educode_sales/money_plans_controller.rb +3 -0
- data/app/controllers/educode_sales/sale_trends_controller.rb +1 -1
- data/app/controllers/educode_sales/shixun_dectects_controller.rb +77 -16
- data/app/controllers/educode_sales/shixuns_controller.rb +65 -4
- data/app/controllers/educode_sales/subject_trends_controller.rb +99 -892
- data/app/controllers/educode_sales/subjects_controller.rb +29 -18
- data/app/helpers/educode_sales/application_helper.rb +3 -1
- data/app/helpers/educode_sales/business_courses_helper.rb +29 -6
- data/app/helpers/educode_sales/sale_trends_helper.rb +52 -52
- data/app/helpers/educode_sales/subject_helper.rb +5 -1
- data/app/models/educode_sales/business.rb +5 -5
- data/app/models/educode_sales/business_deliver_subject.rb +3 -2
- data/app/models/educode_sales/business_subject.rb +9 -3
- data/app/models/educode_sales/business_subject_shixun.rb +37 -8
- data/app/models/educode_sales/business_subject_staff.rb +1 -0
- data/app/views/educode_sales/business_courses/edit.html.erb +30 -4
- data/app/views/educode_sales/business_courses/index.html.erb +34 -12
- data/app/views/educode_sales/business_courses/index.json.jbuilder +2 -2
- data/app/views/educode_sales/business_courses/list_shixuns.html.erb +132 -64
- data/app/views/educode_sales/business_courses/list_shixuns.json.jbuilder +12 -6
- data/app/views/educode_sales/business_courses/list_subjects.html.erb +29 -34
- data/app/views/educode_sales/business_courses/list_subjects.json.jbuilder +7 -2
- data/app/views/educode_sales/business_courses/new.html.erb +45 -20
- data/app/views/educode_sales/businesses/index.html.erb +11 -9
- data/app/views/educode_sales/contracts/_list.html.erb +16 -1
- data/app/views/educode_sales/contracts/index.html.erb +5 -2
- data/app/views/educode_sales/contracts/list.js.erb +4 -1
- data/app/views/educode_sales/money_plan_records/_index.html.erb +21 -5
- data/app/views/educode_sales/money_plan_records/index.js.erb +4 -1
- data/app/views/educode_sales/money_plans/list.html.erb +6 -2
- data/app/views/educode_sales/sale_trends/_return_money_forecast.html.erb +1 -1
- data/app/views/educode_sales/sale_trends/_user_stat.html.erb +1 -1
- data/app/views/educode_sales/sale_trends/_visit_analysis.html.erb +1 -1
- data/app/views/educode_sales/sale_trends/return_money_forecast.js.erb +1 -1
- data/app/views/educode_sales/sale_trends/trends.html.erb +6 -6
- data/app/views/educode_sales/sale_trends/user_stat.js.erb +1 -1
- data/app/views/educode_sales/sale_trends/visit_analysis.js.erb +1 -1
- data/app/views/educode_sales/shixun_dectects/index.html.erb +97 -47
- data/app/views/educode_sales/shixun_dectects/index.json.jbuilder +4 -3
- data/app/views/educode_sales/shixun_dectects/markdown.html.erb +1 -1
- data/app/views/educode_sales/shixuns/edit.html.erb +35 -13
- data/app/views/educode_sales/shixuns/index.html.erb +348 -138
- data/app/views/educode_sales/shixuns/index.json.jbuilder +9 -5
- data/app/views/educode_sales/shixuns/new.html.erb +22 -12
- data/app/views/educode_sales/subject_trends/trends.html.erb +177 -575
- data/app/views/educode_sales/subjects/edit.html.erb +4 -4
- data/app/views/educode_sales/subjects/index.html.erb +50 -12
- data/app/views/educode_sales/subjects/index.json.jbuilder +3 -3
- data/app/views/educode_sales/subjects/list_shixuns.html.erb +143 -17
- data/app/views/educode_sales/subjects/list_shixuns.json.jbuilder +9 -4
- data/app/views/educode_sales/subjects/new.html.erb +4 -4
- data/app/views/layouts/educode_sales/application.html.erb +1 -1
- data/lib/educode_sales/version.rb +1 -1
- metadata +6 -7
- data/app/assets/images/educode_sales/indexlogo.png +0 -0
@@ -5,7 +5,7 @@ module EducodeSales
|
|
5
5
|
|
6
6
|
# 实践课程管理
|
7
7
|
class SubjectsController < ApplicationController
|
8
|
-
before_action :subject_members
|
8
|
+
before_action :subject_members, :subject_url
|
9
9
|
|
10
10
|
def index
|
11
11
|
authorize! :subject, BusinessDeliverSubject
|
@@ -13,11 +13,20 @@ module EducodeSales
|
|
13
13
|
format.html do
|
14
14
|
end
|
15
15
|
format.json do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
|
17
|
+
if is_commissioner_above?
|
18
|
+
business_subject = BusinessSubject
|
19
|
+
else
|
20
|
+
deliver_staffs = BusinessSubject.joins(business_deliver_subject: [manages: :staff])
|
21
|
+
business_subject_ids = deliver_staffs.where("educode_sales_staffs.id = #{@current_admin.id} ").ids
|
22
|
+
subject_staffs = BusinessSubject.where(id: BusinessSubject.ids - deliver_staffs.ids).joins(manages: :staff).where("educode_sales_staffs.id = #{@current_admin.id} ")
|
23
|
+
business_subject = BusinessSubject.where(id: business_subject_ids + subject_staffs.ids )
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
business_subject = business_subject.joins(:subject).left_joins(business_deliver_subject: [:manages, business: [:last_follow_up]])
|
28
|
+
if params[:q] && params[:q][:business_name].present?
|
29
|
+
business_subject = business_subject.joins(:business).where("educode_sales_businesses.name like '%#{params[:q][:business_name]}%' ")
|
21
30
|
end
|
22
31
|
# 查询条件 实践课程名称
|
23
32
|
if params[:q] && params[:q][:subjects_name].present?
|
@@ -30,23 +39,22 @@ module EducodeSales
|
|
30
39
|
business_subject = business_subject.where("educode_sales_business_subjects.deliver_date BETWEEN '#{start_time}' AND '#{end_time}' OR
|
31
40
|
educode_sales_follow_ups.reception_at BETWEEN'#{start_time}' AND '#{end_time}'")
|
32
41
|
end
|
33
|
-
|
34
42
|
business_subject_schools = {}
|
35
43
|
business_subject_manges = {}
|
36
44
|
business_subject_staffs = {}
|
37
|
-
BusinessSubject.includes(:school, :manages, :subject, :staffs, business_deliver_subject: [:manages, business: [:school, last_follow_up: :assign_follow_ups] ]).
|
45
|
+
BusinessSubject.includes(:school, :manages, :subject, :staffs, business_deliver_subject: [:manages, business: [:school, last_follow_up: :assign_follow_ups] ]).find_each do |d|
|
38
46
|
b_d_s = d.business_deliver_subject
|
39
47
|
|
40
|
-
b_d_s.present? ? business_subject_schools.merge!({ "#{d.id}": d.business.
|
48
|
+
b_d_s.present? ? business_subject_schools.merge!({ "#{d.id}": d.business.school.name }) : business_subject_schools.merge!({"#{d.id}": d.school_name })
|
41
49
|
b_d_s.present? ? business_subject_manges.merge!({ "#{d.id}": b_d_s.subject_manages}) : business_subject_manges.merge!({"#{d.id}": d.manges_name })
|
42
|
-
b_d_s.present? ? business_subject_staffs.merge!({ "#{d.id}": d.business.staff_name }) : business_subject_staffs.merge!({"#{d.id}":
|
50
|
+
b_d_s.present? ? business_subject_staffs.merge!({ "#{d.id}": d.business.staff_name }) : business_subject_staffs.merge!({"#{d.id}": d.staffs_name })
|
43
51
|
|
44
52
|
end
|
45
53
|
@business_subject_schools = business_subject_schools.stringify_keys
|
46
54
|
@business_subject_staffs = business_subject_staffs.stringify_keys
|
47
55
|
@business_subject_manges = business_subject_manges.stringify_keys
|
48
|
-
|
49
56
|
business_subject = business_subject.select("subjects.name s_name,
|
57
|
+
subjects.identifier s_identifier,
|
50
58
|
subjects.status status,
|
51
59
|
subjects.public public,
|
52
60
|
educode_sales_business_subjects.id,
|
@@ -95,7 +103,7 @@ module EducodeSales
|
|
95
103
|
}
|
96
104
|
new_object = BusinessSubject.create(attr)
|
97
105
|
|
98
|
-
|
106
|
+
new_object.add_subject_shixuns(params[:shixun_ids].split(',').map(&:to_i))
|
99
107
|
|
100
108
|
|
101
109
|
BusinessSubjectStaff.bulk_insert(:staff_id, :container_id, :container_type, :created_at, :updated_at, :category) do |d|
|
@@ -145,7 +153,7 @@ module EducodeSales
|
|
145
153
|
def shixun_list
|
146
154
|
respond_to do |format|
|
147
155
|
format.json do
|
148
|
-
@list = Shixun.
|
156
|
+
@list = Shixun.where(hidden: 0).where.not(id: BusinessSubjectShixun.joins(:business_subject).pluck(:shixun_id) ) # 1先创建实践项目下,通过实践课程无法选该
|
149
157
|
if params[:q].present?
|
150
158
|
@list = @list.where("name like '%#{params[:q]}%'").page(params[:page]).per(10)
|
151
159
|
end
|
@@ -174,9 +182,10 @@ module EducodeSales
|
|
174
182
|
end
|
175
183
|
|
176
184
|
def list_shixuns
|
177
|
-
|
178
|
-
|
179
|
-
.
|
185
|
+
@shixuns = BusinessSubjectShixun.left_joins(:last_dectect)
|
186
|
+
.left_joins(:shixun)
|
187
|
+
.where("business_subject_id = #{params[:id]}")
|
188
|
+
|
180
189
|
if params[:q].present? && params[:q][:shixun_name].present?
|
181
190
|
@shixuns = @shixuns.where("shixuns.name like '%#{params[:q][:shixun_name]}%'")
|
182
191
|
end
|
@@ -191,10 +200,12 @@ module EducodeSales
|
|
191
200
|
@shixuns = @shixuns.where(category: params[:q][:category])
|
192
201
|
end
|
193
202
|
@shixuns = @shixuns.select("educode_sales_business_subject_shixuns.*,
|
194
|
-
|
203
|
+
shixuns.name as shixun_name,
|
204
|
+
shixuns.identifier,
|
205
|
+
educode_sales_shixun_dectects.created_at as shixun_dectects_time,
|
206
|
+
educode_sales_shixun_dectects.content as dectects_content")
|
195
207
|
.page(params[:page])
|
196
208
|
.per(params[:limit])
|
197
|
-
end
|
198
209
|
render layout: false
|
199
210
|
end
|
200
211
|
|
@@ -16,7 +16,9 @@ module EducodeSales
|
|
16
16
|
def handled_time_data(item)
|
17
17
|
item.blank? ? "--" : item.strftime("%Y-%m-%d")
|
18
18
|
end
|
19
|
-
|
19
|
+
def handled_time_data_accurate(item)
|
20
|
+
item.blank? ? "--" : item.strftime("%Y-%m-%d %H:%M:%S")
|
21
|
+
end
|
20
22
|
def url_to_avatar(source)
|
21
23
|
return "" if source.blank?
|
22
24
|
if File.exist?(disk_filename(source&.class, source&.id)) && File.file?(disk_filename(source&.class, source&.id))
|
@@ -1,20 +1,19 @@
|
|
1
1
|
module EducodeSales
|
2
2
|
module BusinessCoursesHelper
|
3
3
|
|
4
|
-
def
|
5
|
-
case
|
4
|
+
def real_shixun_category(categor)
|
5
|
+
case categor.to_i
|
6
6
|
when 1
|
7
7
|
"管培"
|
8
8
|
when 2
|
9
|
-
"专职"
|
10
|
-
when 3
|
11
9
|
"全职"
|
10
|
+
when 3
|
11
|
+
"专职"
|
12
12
|
else
|
13
13
|
"管培"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
17
|
def real_shixun_level(level)
|
19
18
|
case level.to_i
|
20
19
|
when 1
|
@@ -22,7 +21,7 @@ module EducodeSales
|
|
22
21
|
when 2
|
23
22
|
"重要紧急"
|
24
23
|
when 3
|
25
|
-
"
|
24
|
+
"重要不紧急"
|
26
25
|
when 4
|
27
26
|
"不重要紧急"
|
28
27
|
when 5
|
@@ -31,6 +30,30 @@ module EducodeSales
|
|
31
30
|
"不明确"
|
32
31
|
end
|
33
32
|
end
|
33
|
+
# 项目状态: 待建设(constructed) 已签协议(signed) 建设中(construction) 审核中(review),返修中(repair) 已内部公开(public), 已公开发布(published) 已经付费(paid)
|
34
|
+
def real_shixun_status(status)
|
35
|
+
case status.to_i
|
36
|
+
when 1
|
37
|
+
"待建设"
|
38
|
+
when 2
|
39
|
+
"已签协议"
|
40
|
+
when 3
|
41
|
+
"建设中"
|
42
|
+
when 4
|
43
|
+
"审核中"
|
44
|
+
when 5
|
45
|
+
"返修中"
|
46
|
+
when 6
|
47
|
+
"已内部发布"
|
48
|
+
when 7
|
49
|
+
"已公开发布"
|
50
|
+
when 8
|
51
|
+
"已付费用"
|
52
|
+
when 9
|
53
|
+
"审核通过"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
34
57
|
|
35
58
|
|
36
59
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module EducodeSales
|
2
2
|
module SaleTrendsHelper
|
3
3
|
NAMES = %w[计划投标额 计划投标额累计 实际中标额 实际中标额累计]
|
4
|
-
RETURN_NAMES = %w[
|
4
|
+
RETURN_NAMES = %w[计划回款额 计划回款额-全部 实际回款额 实际回款额-累计 计划回款额-O类]
|
5
5
|
|
6
6
|
def goal_forecast_quarter(labels, selects, staff_id = nil, property)
|
7
7
|
plan_get = plan_get(staff_id, labels, "quarter", property)
|
@@ -349,7 +349,7 @@ module EducodeSales
|
|
349
349
|
week = d.split("-").last
|
350
350
|
year = d.split("-").first
|
351
351
|
yearweek = "#{year}#{week}".to_i
|
352
|
-
|
352
|
+
plan_return[yearweek].to_f.round(3)
|
353
353
|
end
|
354
354
|
elsif select == RETURN_NAMES[1]
|
355
355
|
arr = labels.map do |d|
|
@@ -367,12 +367,13 @@ module EducodeSales
|
|
367
367
|
actual_return[yearweek].to_f.round(3)
|
368
368
|
end
|
369
369
|
elsif select == RETURN_NAMES[3]
|
370
|
-
labels.map do |d|
|
370
|
+
arr = labels.map do |d|
|
371
371
|
week = d.split("-").last
|
372
372
|
year = d.split("-").first
|
373
373
|
yearweek = "#{year}#{week}".to_i
|
374
|
-
|
374
|
+
actual_return[yearweek].to_f.round(3)
|
375
375
|
end
|
376
|
+
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
376
377
|
elsif select == RETURN_NAMES[4]
|
377
378
|
arr = labels.map do |d|
|
378
379
|
week = d.split("-").last
|
@@ -382,16 +383,15 @@ module EducodeSales
|
|
382
383
|
end
|
383
384
|
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
384
385
|
end
|
385
|
-
type = if select == RETURN_NAMES[0] || select == RETURN_NAMES[
|
386
|
+
type = if select == RETURN_NAMES[0] || select == RETURN_NAMES[2]
|
386
387
|
'bar'
|
387
388
|
else
|
388
389
|
"line"
|
389
390
|
end
|
390
|
-
backgroundColor = if select == RETURN_NAMES[0] || select == RETURN_NAMES[
|
391
|
-
'rgba(54, 162, 235, 1)'
|
392
|
-
else
|
391
|
+
backgroundColor = if select == RETURN_NAMES[0] || select == RETURN_NAMES[2]
|
393
392
|
SaleTrend::COLORS[i]
|
394
|
-
|
393
|
+
else
|
394
|
+
'rgba(54, 162, 235, 0.2)'
|
395
395
|
end
|
396
396
|
{
|
397
397
|
type: type,
|
@@ -405,11 +405,11 @@ module EducodeSales
|
|
405
405
|
|
406
406
|
hash_a = {
|
407
407
|
labels: labels,
|
408
|
-
datasets: [datasets[0], datasets[
|
408
|
+
datasets: [datasets[0], datasets[2]]
|
409
409
|
}
|
410
410
|
hash_b = {
|
411
411
|
labels: labels,
|
412
|
-
datasets: [datasets[
|
412
|
+
datasets: [datasets[1], datasets[4], datasets[3]]
|
413
413
|
}
|
414
414
|
[hash_a, hash_b]
|
415
415
|
end
|
@@ -423,7 +423,7 @@ module EducodeSales
|
|
423
423
|
labels.map do |d|
|
424
424
|
quarter = d.split("-").last.to_i
|
425
425
|
year = d.split("-").first.to_i
|
426
|
-
|
426
|
+
plan_return[[year, quarter]]&.pluck(:plan_return_money)&.reject(&:blank?)&.sum.to_f.round(3)
|
427
427
|
end
|
428
428
|
elsif select == RETURN_NAMES[1]
|
429
429
|
arr = labels.map do |d|
|
@@ -439,11 +439,12 @@ module EducodeSales
|
|
439
439
|
actual_return[[year, quarter]]&.pluck(:amount)&.reject(&:blank?)&.sum.to_f.round(3)
|
440
440
|
end
|
441
441
|
elsif select == RETURN_NAMES[3]
|
442
|
-
labels.map do |d|
|
442
|
+
arr = labels.map do |d|
|
443
443
|
quarter = d.split("-").last.to_i
|
444
444
|
year = d.split("-").first.to_i
|
445
|
-
|
445
|
+
actual_return[[year, quarter]]&.pluck(:amount)&.reject(&:blank?)&.sum.to_f.round(3)
|
446
446
|
end
|
447
|
+
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
447
448
|
elsif select == RETURN_NAMES[4]
|
448
449
|
arr = labels.map do |d|
|
449
450
|
quarter = d.split("-").last.to_i
|
@@ -452,16 +453,15 @@ module EducodeSales
|
|
452
453
|
end
|
453
454
|
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
454
455
|
end
|
455
|
-
type = if select == RETURN_NAMES[0] || select == RETURN_NAMES[
|
456
|
+
type = if select == RETURN_NAMES[0] || select == RETURN_NAMES[2]
|
456
457
|
'bar'
|
457
458
|
else
|
458
459
|
"line"
|
459
460
|
end
|
460
|
-
backgroundColor = if select == RETURN_NAMES[0] || select == RETURN_NAMES[
|
461
|
-
'rgba(54, 162, 235, 1)'
|
462
|
-
else
|
461
|
+
backgroundColor = if select == RETURN_NAMES[0] || select == RETURN_NAMES[2]
|
463
462
|
SaleTrend::COLORS[i]
|
464
|
-
|
463
|
+
else
|
464
|
+
'rgba(54, 162, 235, 0.2)'
|
465
465
|
end
|
466
466
|
{
|
467
467
|
type: type,
|
@@ -475,11 +475,11 @@ module EducodeSales
|
|
475
475
|
|
476
476
|
hash_a = {
|
477
477
|
labels: labels,
|
478
|
-
datasets: [datasets[0], datasets[
|
478
|
+
datasets: [datasets[0], datasets[2]]
|
479
479
|
}
|
480
480
|
hash_b = {
|
481
481
|
labels: labels,
|
482
|
-
datasets: [datasets[
|
482
|
+
datasets: [datasets[1], datasets[4], datasets[3]]
|
483
483
|
}
|
484
484
|
[hash_a, hash_b]
|
485
485
|
end
|
@@ -492,47 +492,47 @@ module EducodeSales
|
|
492
492
|
datasets = selects.map.with_index do |select, i|
|
493
493
|
data = if select == RETURN_NAMES[0]
|
494
494
|
labels.map do |d|
|
495
|
-
|
495
|
+
month = d.split("-").last.to_i
|
496
496
|
year = d.split("-").first.to_i
|
497
|
-
|
497
|
+
plan_return[[year, month]]&.pluck(:plan_return_money)&.reject(&:blank?)&.sum.to_f.round(3)
|
498
498
|
end
|
499
499
|
elsif select == RETURN_NAMES[1]
|
500
500
|
arr = labels.map do |d|
|
501
|
-
|
501
|
+
month = d.split("-").last.to_i
|
502
502
|
year = d.split("-").first.to_i
|
503
|
-
plan_return[[year,
|
503
|
+
plan_return[[year, month]]&.pluck(:plan_return_money)&.reject(&:blank?)&.sum.to_f.round(3)
|
504
504
|
end
|
505
505
|
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
506
506
|
elsif select == RETURN_NAMES[2]
|
507
507
|
labels.map do |d|
|
508
|
-
|
508
|
+
month = d.split("-").last.to_i
|
509
509
|
year = d.split("-").first.to_i
|
510
|
-
actual_return[[year,
|
510
|
+
actual_return[[year, month]]&.pluck(:amount)&.reject(&:blank?)&.sum.to_f.round(3)
|
511
511
|
end
|
512
512
|
elsif select == RETURN_NAMES[3]
|
513
|
-
labels.map do |d|
|
514
|
-
|
513
|
+
arr = labels.map do |d|
|
514
|
+
month = d.split("-").last.to_i
|
515
515
|
year = d.split("-").first.to_i
|
516
|
-
|
516
|
+
actual_return[[year, month]]&.pluck(:amount)&.reject(&:blank?)&.sum.to_f.round(3)
|
517
517
|
end
|
518
|
+
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
518
519
|
elsif select == RETURN_NAMES[4]
|
519
520
|
arr = labels.map do |d|
|
520
|
-
|
521
|
+
month = d.split("-").last.to_i
|
521
522
|
year = d.split("-").first.to_i
|
522
|
-
plan_return_by_o[[year,
|
523
|
+
plan_return_by_o[[year, month]]&.pluck(:plan_return_money)&.reject(&:blank?)&.sum.to_f.round(3)
|
523
524
|
end
|
524
525
|
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
525
526
|
end
|
526
|
-
type = if select == RETURN_NAMES[0] || select == RETURN_NAMES[
|
527
|
+
type = if select == RETURN_NAMES[0] || select == RETURN_NAMES[2]
|
527
528
|
'bar'
|
528
529
|
else
|
529
530
|
"line"
|
530
531
|
end
|
531
|
-
backgroundColor = if select == RETURN_NAMES[0] || select == RETURN_NAMES[
|
532
|
-
'rgba(54, 162, 235, 1)'
|
533
|
-
else
|
532
|
+
backgroundColor = if select == RETURN_NAMES[0] || select == RETURN_NAMES[2]
|
534
533
|
SaleTrend::COLORS[i]
|
535
|
-
|
534
|
+
else
|
535
|
+
'rgba(54, 162, 235, 0.2)'
|
536
536
|
end
|
537
537
|
{
|
538
538
|
type: type,
|
@@ -546,11 +546,11 @@ module EducodeSales
|
|
546
546
|
|
547
547
|
hash_a = {
|
548
548
|
labels: labels,
|
549
|
-
datasets: [datasets[0], datasets[
|
549
|
+
datasets: [datasets[0], datasets[2]]
|
550
550
|
}
|
551
551
|
hash_b = {
|
552
552
|
labels: labels,
|
553
|
-
datasets: [datasets[
|
553
|
+
datasets: [datasets[1], datasets[4], datasets[3]]
|
554
554
|
}
|
555
555
|
[hash_a, hash_b]
|
556
556
|
end
|
@@ -561,29 +561,29 @@ module EducodeSales
|
|
561
561
|
plan_return_by_o = plan_return_by_o(staff_id, labels, "year", property)
|
562
562
|
datasets = selects.map.with_index do |select, i|
|
563
563
|
data = if select == RETURN_NAMES[0]
|
564
|
-
labels.map { |d|
|
564
|
+
labels.map { |d| plan_return[d.to_i] || 0 }
|
565
565
|
elsif select == RETURN_NAMES[1]
|
566
566
|
arr = labels.map { |d| plan_return[d.to_i] || 0 }
|
567
567
|
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
568
568
|
elsif select == RETURN_NAMES[2]
|
569
569
|
labels.map { |d| actual_return[d.to_i] || 0 }
|
570
570
|
elsif select == RETURN_NAMES[3]
|
571
|
-
labels.map { |d|
|
571
|
+
arr = labels.map { |d| actual_return[d.to_i] || 0 }
|
572
|
+
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
572
573
|
elsif select == RETURN_NAMES[4]
|
573
574
|
arr = labels.map { |d| plan_return_by_o[d.to_i] || 0 }
|
574
575
|
arr.map.with_index(1) { |num, i| arr.first(i).inject(:+) }
|
575
576
|
end
|
576
577
|
|
577
|
-
type = if select == RETURN_NAMES[0] || select == RETURN_NAMES[
|
578
|
+
type = if select == RETURN_NAMES[0] || select == RETURN_NAMES[2]
|
578
579
|
'bar'
|
579
580
|
else
|
580
581
|
"line"
|
581
582
|
end
|
582
|
-
backgroundColor = if RETURN_NAMES[0] || select == RETURN_NAMES[
|
583
|
-
'rgba(54, 162, 235, 1)'
|
584
|
-
else
|
583
|
+
backgroundColor = if select == RETURN_NAMES[0] || select == RETURN_NAMES[2]
|
585
584
|
SaleTrend::COLORS[i]
|
586
|
-
|
585
|
+
else
|
586
|
+
'rgba(54, 162, 235, 0.2)'
|
587
587
|
end
|
588
588
|
{
|
589
589
|
type: type,
|
@@ -597,11 +597,11 @@ module EducodeSales
|
|
597
597
|
|
598
598
|
hash_a = {
|
599
599
|
labels: labels,
|
600
|
-
datasets: [datasets[0], datasets[
|
600
|
+
datasets: [datasets[0], datasets[2]]
|
601
601
|
}
|
602
602
|
hash_b = {
|
603
603
|
labels: labels,
|
604
|
-
datasets: [datasets[
|
604
|
+
datasets: [datasets[1], datasets[4], datasets[3]]
|
605
605
|
}
|
606
606
|
[hash_a, hash_b]
|
607
607
|
end
|
@@ -725,7 +725,7 @@ module EducodeSales
|
|
725
725
|
time_range.last.split("-").first + "-12-31"
|
726
726
|
end
|
727
727
|
staff_id = staff_id.present? ? Array(staff_id) : nil
|
728
|
-
data = Business.joins(:last_follow_up)
|
728
|
+
data = Business.joins(:last_follow_up).where("educode_sales_businesses.deleted_at is null")
|
729
729
|
.where("educode_sales_follow_ups.plan_return_date >= ? and educode_sales_follow_ups.plan_return_date <= ?", start_time, end_time)
|
730
730
|
if staff_id.present?
|
731
731
|
data = data.joins("LEFT JOIN educode_sales_follow_ups AS last_follow_up ON educode_sales_businesses.last_follow_up_id = last_follow_up.id AND last_follow_up.deleted_at IS NULL
|
@@ -773,14 +773,14 @@ module EducodeSales
|
|
773
773
|
time_range.last.split("-").first + "-12-31"
|
774
774
|
end
|
775
775
|
staff_id = staff_id.present? ? Array(staff_id) : nil
|
776
|
-
data = MoneyPlanRecord.
|
776
|
+
data = MoneyPlanRecord.where("educode_sales_money_plan_records.date_at >= ? and educode_sales_money_plan_records.date_at <= ?", start_time, end_time)
|
777
777
|
if staff_id.present?
|
778
778
|
data = data.joins("LEFT JOIN educode_sales_follow_ups AS last_follow_up ON educode_sales_businesses.last_follow_up_id = last_follow_up.id AND last_follow_up.deleted_at IS NULL
|
779
779
|
LEFT JOIN educode_sales_assign_follow_ups ON educode_sales_assign_follow_ups.follow_up_id = last_follow_up.id").
|
780
780
|
where("(educode_sales_assign_follow_ups.id IS NOT NULL AND educode_sales_assign_follow_ups.staff_id = ?) OR (educode_sales_assign_follow_ups.id IS NULL AND educode_sales_businesses.staff_id = ?)", staff_id, staff_id)
|
781
781
|
end
|
782
782
|
if property.present?
|
783
|
-
data = data.where("school_tags.id = ?", property)
|
783
|
+
data = data.joins(business: [department: [school: :school_tags]]).where("school_tags.id = ?", property)
|
784
784
|
end
|
785
785
|
case type
|
786
786
|
when "week"
|
@@ -820,7 +820,7 @@ module EducodeSales
|
|
820
820
|
time_range.last.split("-").first + "-12-31"
|
821
821
|
end
|
822
822
|
staff_id = staff_id.present? ? Array(staff_id) : nil
|
823
|
-
data = Business.joins(:last_follow_up).where("educode_sales_businesses.clazz_id = ?", clazz_id)
|
823
|
+
data = Business.joins(:last_follow_up).where("educode_sales_businesses.deleted_at is null").where("educode_sales_businesses.clazz_id = ?", clazz_id)
|
824
824
|
.where("educode_sales_follow_ups.plan_return_date >= ? and educode_sales_follow_ups.plan_return_date <= ?", start_time, end_time)
|
825
825
|
if staff_id.present?
|
826
826
|
data = data.joins("LEFT JOIN educode_sales_follow_ups AS last_follow_up ON educode_sales_businesses.last_follow_up_id = last_follow_up.id AND last_follow_up.deleted_at IS NULL
|
@@ -2,12 +2,16 @@ module EducodeSales
|
|
2
2
|
module SubjectHelper
|
3
3
|
|
4
4
|
|
5
|
+
def status(d)
|
6
|
+
d.public == 2 ? "已公开" : d.public == 1 ? "待审核" : d.status == 2 ? "已发布" : "编辑中"
|
7
|
+
end
|
8
|
+
|
5
9
|
def school_name(item)
|
6
10
|
item.business ? item.business.school.name : item.school_name
|
7
11
|
end
|
8
12
|
|
9
13
|
# def deliver_date(item)
|
10
|
-
# item.business ? item.business.p_course_time : item.deliver_date.
|
14
|
+
# item.business ? item.business.p_course_time : item.deliver_date.strft审核中ime("%Y-%m-%d")
|
11
15
|
# end
|
12
16
|
|
13
17
|
|
@@ -82,11 +82,11 @@ module EducodeSales
|
|
82
82
|
# 创建商机交付课程数据
|
83
83
|
def change_diliver
|
84
84
|
|
85
|
-
if previous_changes["last_follow_up_id"].present?
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
85
|
+
# if previous_changes["last_follow_up_id"].present?
|
86
|
+
# last_clazz_id = previous_changes["last_follow_up_id"][-1]
|
87
|
+
# common_type = FollowUp.find_by(id: last_clazz_id)&.stage&.name == "已中标"
|
88
|
+
# BusinessDeliverSubject.find_or_create_by(business_id: self.id) if common_type
|
89
|
+
# end
|
90
90
|
end
|
91
91
|
|
92
92
|
def school_name
|
@@ -9,17 +9,18 @@ module EducodeSales
|
|
9
9
|
# constructed:待建设, signed: 已签协议,construction: 建设中,completed: 已完成,delivered: 已交付, accepted: 已验收
|
10
10
|
enum status: { constructed:1, signed:2, construction: 3, completed:4, delivered: 5, accepted: 6 }
|
11
11
|
|
12
|
+
scope :undelivered, -> {where.not(status: "delivered")}
|
12
13
|
# 实践课程完成统计
|
13
14
|
def subject_competed_count
|
14
15
|
all_count = subjects.count
|
15
|
-
completed_count = subjects.where("subjects.status = 2
|
16
|
+
completed_count = subjects.where("subjects.status = 2 or subjects.public = 2").count
|
16
17
|
|
17
18
|
" #{completed_count} / #{all_count} "
|
18
19
|
end
|
19
20
|
|
20
21
|
# 实训项目完成进度
|
21
22
|
def shixun_competed_count
|
22
|
-
" #{
|
23
|
+
" #{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} "
|
23
24
|
end
|
24
25
|
|
25
26
|
# 课程经理
|
@@ -12,7 +12,13 @@ module EducodeSales
|
|
12
12
|
|
13
13
|
# 销售名称
|
14
14
|
def staffs_name
|
15
|
-
|
15
|
+
staff_names = BusinessSubjectStaff.joins(staff: :user)
|
16
|
+
.where("educode_sales_business_subject_staffs.category = #{ BusinessSubjectStaff::CATEGORY_TYPES::SUBJECT_STAFF } and educode_sales_business_subject_staffs.container_id = #{self.id} and
|
17
|
+
educode_sales_business_subject_staffs.container_type = #{BusinessSubjectStaff::CONTAINER_TYPES::SUBJECT} ")
|
18
|
+
.pluck("DISTINCT CONCAT(users.lastname, users.firstname) ")
|
19
|
+
.join(",")
|
20
|
+
# staffs.joins(staff: :user).pluck("CONCAT(users.lastname, users.firstname) ").join(",")
|
21
|
+
staff_names
|
16
22
|
end
|
17
23
|
|
18
24
|
# 课程经理名称
|
@@ -22,7 +28,7 @@ module EducodeSales
|
|
22
28
|
|
23
29
|
# 实训完成统计
|
24
30
|
def shixun_compeled_count
|
25
|
-
" #{business_subject_shixuns.
|
31
|
+
" #{business_subject_shixuns.where("educode_sales_business_subject_shixuns.shixun_status in (6,7,8)").count} / #{business_subject_shixuns.count}"
|
26
32
|
end
|
27
33
|
|
28
34
|
def school_name
|
@@ -48,7 +54,7 @@ module EducodeSales
|
|
48
54
|
|
49
55
|
|
50
56
|
def add_subject_shixuns(shixun_ids=[]) # 1先创建实践项目下,通过实践课程无法选该实践项目
|
51
|
-
shixuns = Shixun.where.not(id: BusinessSubjectShixun.joins(:business_subject).pluck(:shixun_id))
|
57
|
+
shixuns = Shixun.where.not(id: BusinessSubjectShixun.joins(:business_subject).pluck(:shixun_id)) # 1先创建实践项目下,通过实践课程无法选该实践项目
|
52
58
|
shixun_ids.each do |item|
|
53
59
|
now_shixun = shixuns.find_by(id: item)
|
54
60
|
if now_shixun.present?
|
@@ -5,39 +5,68 @@ module EducodeSales
|
|
5
5
|
belongs_to :school, optional: true
|
6
6
|
belongs_to :shixun, optional: true
|
7
7
|
has_many :staffs, as: :container, dependent: :destroy, class_name: "EducodeSales::BusinessSubjectStaff"
|
8
|
+
has_many :shixun_members, as: :container, dependent: :destroy, class_name: "EducodeSales::BusinessSubjectStaff"
|
9
|
+
has_many :shixun_producer, ->{ shixun_producer }, as: :container, dependent: :destroy, class_name: "EducodeSales::BusinessSubjectStaff"
|
8
10
|
belongs_to :last_dectect, foreign_key: :shixun_dectect_id, class_name: "EducodeSales::ShixunDectect", optional: true
|
9
11
|
|
10
12
|
module CATEGORY_TYPE
|
11
13
|
TRAINING = 1 # 管培
|
12
|
-
WORKER = 2
|
14
|
+
WORKER = 2 # 全职
|
13
15
|
PLURALIST = 3 # 兼职
|
14
16
|
end
|
15
17
|
|
18
|
+
scope :search_type, ->(type) {where(shixun_type: type.to_i) if type.to_i != 0}
|
19
|
+
scope :search_level, ->(level) {where(level: level.to_i) if level.to_i != 0}
|
20
|
+
scope :search_status, ->(status) {where(shixun_status: status.to_i) if status.to_i != 0}
|
21
|
+
scope :search_category, ->(category) {where(category: category.to_i) if category.to_i != 0}
|
22
|
+
scope :training, -> {where(category: CATEGORY_TYPE::TRAINING)}
|
23
|
+
scope :worker, -> {where(category: CATEGORY_TYPE::WORKER)}
|
24
|
+
scope :pluralist, -> {where(category: CATEGORY_TYPE::PLURALIST)}
|
25
|
+
scope :completed, -> {where(shixun_status: [6,7,8])}
|
26
|
+
scope :un_completed, -> {where.not(shixun_status: [6,7,8])}
|
16
27
|
# 项目状态: 待建设(constructed) 已签协议(signed) 建设中(construction) 审核中(review),返修中(repair) 已内部公开(public), 已公开发布(published) 已经付费(paid)
|
17
|
-
# enum
|
28
|
+
# enum shixun_status: { constructed: 1, signed: 2, construction: 3, review: 4, repair: 5, public: 6, published: 7,paid: 8}
|
18
29
|
|
19
30
|
def shixun_manages
|
20
|
-
staffs.joins(staff: :user).where(category:BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_MANAGE).pluck("CONCAT(users.lastname, users.firstname) ").join(",")
|
31
|
+
staffs.joins(staff: :user).where(category: BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_MANAGE).pluck("CONCAT(users.lastname, users.firstname) ").join(",")
|
21
32
|
end
|
33
|
+
|
22
34
|
def shixun_producer
|
23
|
-
staffs.joins(staff: :user).where(category:BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_PRODUCER).pluck("CONCAT(users.lastname, users.firstname) ").join(",")
|
35
|
+
staffs.joins(staff: :user).where(category: BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_PRODUCER).pluck("CONCAT(users.lastname, users.firstname) ").join(",")
|
24
36
|
end
|
37
|
+
|
25
38
|
def shixun_staff
|
26
|
-
|
27
|
-
|
39
|
+
staffs.joins(staff: :user).where(category: BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_STAFF).pluck("CONCAT(users.lastname, users.firstname) ").join(",")
|
40
|
+
end
|
41
|
+
def all_staff
|
42
|
+
staffs.joins(staff: :user).distinct.select("users.id")
|
43
|
+
end
|
44
|
+
def shixun_school
|
45
|
+
name = ""
|
46
|
+
shixuns = BusinessSubjectShixun.find(id)
|
47
|
+
if shixuns.school.present?
|
48
|
+
name = shixuns.school.name
|
49
|
+
end
|
50
|
+
if shixuns.business_subject.present?
|
51
|
+
if shixuns.business_subject.business.present?
|
52
|
+
name = shixuns.business_subject.business.school.name
|
53
|
+
end
|
54
|
+
end
|
55
|
+
p name
|
28
56
|
end
|
29
|
-
|
30
57
|
|
31
58
|
# 查询审核历史和审核人
|
32
59
|
def audit_history
|
33
60
|
ShixunDectect.joins("join educode_sales_staffs on educode_sales_staffs.id = educode_sales_shixun_dectects.reviewed_id
|
34
61
|
join users on users.id = educode_sales_staffs.user_id")
|
35
|
-
.where(business_subject_shixun_id:id)
|
62
|
+
.where(business_subject_shixun_id: id)
|
36
63
|
.where("dectect_type != 0")
|
37
64
|
.select("educode_sales_shixun_dectects.*,
|
38
65
|
CONCAT(users.lastname, users.firstname) as examine_name")
|
66
|
+
.order("created_at desc")
|
39
67
|
.all
|
40
68
|
end
|
69
|
+
|
41
70
|
# def school_name
|
42
71
|
# business_subject ? business_subject.school_name : school.name
|
43
72
|
# end
|
@@ -29,6 +29,7 @@ module EducodeSales
|
|
29
29
|
|
30
30
|
scope :subject_staffs, ->{where(category: CATEGORY_TYPES::SUBJECT_STAFF)}
|
31
31
|
scope :subject_manges, ->{where(category: CATEGORY_TYPES::SUBJECT_MANAGE)}
|
32
|
+
scope :shixun_producer, ->{where(category: CATEGORY_TYPES::SHIXUN_PRODUCER)}
|
32
33
|
|
33
34
|
end
|
34
35
|
|