educode_sales 0.5.1 → 0.5.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/controllers/educode_sales/businesses_controller.rb +5 -1
- data/app/controllers/educode_sales/follow_ups_controller.rb +2 -1
- data/app/controllers/educode_sales/operation_plans_controller.rb +22 -2
- data/app/controllers/educode_sales/operation_reports_controller.rb +33 -3
- data/app/controllers/educode_sales/plans_controller.rb +22 -2
- data/app/controllers/educode_sales/roles_controller.rb +5 -0
- data/app/controllers/educode_sales/sale_reports_controller.rb +33 -3
- data/app/controllers/educode_sales/sale_trends_controller.rb +196 -0
- data/app/controllers/educode_sales/sales_controller.rb +4 -0
- data/app/controllers/educode_sales/upload_files_controller.rb +33 -26
- data/app/models/educode_sales/common.rb +2 -1
- data/app/views/educode_sales/businesses/edit_follow_record.html.erb +3 -3
- data/app/views/educode_sales/businesses/file.html.erb +4 -5
- data/app/views/educode_sales/businesses/index.html.erb +14 -2
- data/app/views/educode_sales/businesses/index.json.jbuilder +1 -0
- data/app/views/educode_sales/businesses/new_follow_record.html.erb +2 -2
- data/app/views/educode_sales/businesses/show_follow_record.html.erb +1 -1
- data/app/views/educode_sales/operation_plans/index.html.erb +6 -1
- data/app/views/educode_sales/operation_reports/audit.html.erb +5 -3
- data/app/views/educode_sales/operation_reports/show.html.erb +4 -7
- data/app/views/educode_sales/places/index.html.erb +20 -5
- data/app/views/educode_sales/places/index.json.jbuilder +18 -2
- data/app/views/educode_sales/plans/index.html.erb +6 -1
- data/app/views/educode_sales/roles/index.html.erb +19 -1
- data/app/views/educode_sales/roles/rename.html.erb +50 -0
- data/app/views/educode_sales/sale_reports/audit.html.erb +5 -3
- data/app/views/educode_sales/sale_reports/show.html.erb +3 -6
- data/app/views/educode_sales/sale_trends/trends.html.erb +284 -4
- data/app/views/educode_sales/sale_trends/trends.json.jbuilder +14 -0
- data/app/views/educode_sales/sales/index.html.erb +75 -9
- data/app/views/educode_sales/sales/index.json.jbuilder +35 -1
- data/app/views/educode_sales/sales/operations.json.jbuilder +11 -1
- data/app/views/educode_sales/staffs/index.html.erb +6 -1
- data/app/views/educode_sales/staffs/index.json.jbuilder +11 -1
- data/app/views/educode_sales/teachers/add_keys.html.erb +1 -1
- data/app/views/educode_sales/teachers/index.html.erb +6 -1
- data/app/views/educode_sales/teachers/new.html.erb +1 -0
- data/app/views/educode_sales/upload_files/index.json.jbuilder +1 -1
- data/config/routes.rb +3 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c060696641e16a80fea2b02631788112e85082b8ccba0a037a2635d6563dbe24
|
4
|
+
data.tar.gz: 07230a0582b71a0ebfceddc1ce347a667651f778fed3640a0c82b22ee952f620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 110a25d3261f894f5ce6c5fed8e08d7afd62dd186ce6e18a10fe8d7f68033f03e48e2bdeca23df1408495e608899fc1383e5f3a0da25f1c13736b04488179820
|
7
|
+
data.tar.gz: 876c22dbca43a2624dbb2407cd5520c1ea0e044d696b4e3adb9571d65220560b0de3c13ecb337a9d914097b93cce6373db0a598dc5be440bbd925ee8744f995e
|
@@ -4,7 +4,7 @@ module EducodeSales
|
|
4
4
|
class BusinessesController < ApplicationController
|
5
5
|
|
6
6
|
def file
|
7
|
-
|
7
|
+
gon.folder = edu_setting('attachment_folder') + '/'
|
8
8
|
render layout: false
|
9
9
|
end
|
10
10
|
def upload_file
|
@@ -176,6 +176,7 @@ module EducodeSales
|
|
176
176
|
last_follow.reception_at,
|
177
177
|
last_follow.bidded_date,
|
178
178
|
last_follow.signed_date,
|
179
|
+
last_follow.actual_amount,
|
179
180
|
last_follow.total_amount").joins("
|
180
181
|
LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id
|
181
182
|
").page(params[:page]).per(params[:limit])
|
@@ -319,5 +320,8 @@ module EducodeSales
|
|
319
320
|
params.permit(:clazz_id, :stage_id, :invitation_at, :reception_at, :total_amount, :actual_amount, :divide_amount, :description, :advise, :place_id)
|
320
321
|
end
|
321
322
|
|
323
|
+
def edu_setting name
|
324
|
+
EduSetting.get(name)
|
325
|
+
end
|
322
326
|
end
|
323
327
|
end
|
@@ -132,7 +132,8 @@ module EducodeSales
|
|
132
132
|
)
|
133
133
|
teacher.save
|
134
134
|
key_peprson = KeyPerson.new(teacher_params)
|
135
|
-
|
135
|
+
teacher_id = EducodeSales::Teacher.find_by(name: user.real_name, department_id: user.department_id).id
|
136
|
+
key_peprson.teacher_id = teacher_id
|
136
137
|
end
|
137
138
|
|
138
139
|
follow_up.key_person << key_peprson
|
@@ -78,7 +78,17 @@ module EducodeSales
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def new_weekly
|
81
|
-
|
81
|
+
d = @current_admin
|
82
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
83
|
+
if d.areas.present?
|
84
|
+
if d.areas.ids.sort.to_s == area_ids
|
85
|
+
@area = '全国'
|
86
|
+
else
|
87
|
+
@area = d.areas.pluck(:name).join("、")
|
88
|
+
end
|
89
|
+
else
|
90
|
+
@area = ''
|
91
|
+
end
|
82
92
|
@name = @current_admin.user.real_name
|
83
93
|
sale_plans = OperationPlan.where(month: Time.now.strftime("%Y-%m") + "-01 00:00:00", weekly: Time.now.strftime('%W').to_i, staff_id: @current_admin.id)
|
84
94
|
@rate = sale_plans.present? ? (sale_plans.sum("finish_rate") / sale_plans.size) : 0
|
@@ -95,7 +105,17 @@ module EducodeSales
|
|
95
105
|
end
|
96
106
|
|
97
107
|
def new_monthly
|
98
|
-
|
108
|
+
d = @current_admin
|
109
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
110
|
+
if d.areas.present?
|
111
|
+
if d.areas.ids.sort.to_s == area_ids
|
112
|
+
@area = '全国'
|
113
|
+
else
|
114
|
+
@area = d.areas.pluck(:name).join("、")
|
115
|
+
end
|
116
|
+
else
|
117
|
+
@area = ''
|
118
|
+
end
|
99
119
|
@name = @current_admin.user.real_name
|
100
120
|
sale_plans = OperationPlan.where(month: Time.now.strftime("%Y-%m") + "-01 00:00:00", staff_id: @current_admin.id, weekly: nil)
|
101
121
|
@rate = sale_plans.present? ? (sale_plans.sum("finish_rate") / sale_plans.size) : 0
|
@@ -68,7 +68,17 @@ module EducodeSales
|
|
68
68
|
def show
|
69
69
|
@sale_report = OperationReport.find(params[:id])
|
70
70
|
@name = @sale_report.staff.user.real_name
|
71
|
-
|
71
|
+
d = @sale_report.staff
|
72
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
73
|
+
if d.areas.present?
|
74
|
+
if d.areas.ids.sort.to_s == area_ids
|
75
|
+
@area = '全国'
|
76
|
+
else
|
77
|
+
@area = d.areas.pluck(:name).join("、")
|
78
|
+
end
|
79
|
+
else
|
80
|
+
@area = ''
|
81
|
+
end
|
72
82
|
render layout: false
|
73
83
|
end
|
74
84
|
|
@@ -81,7 +91,17 @@ module EducodeSales
|
|
81
91
|
def edit
|
82
92
|
@sale_report = OperationReport.find(params[:id])
|
83
93
|
@name = @sale_report.staff.user.real_name
|
84
|
-
|
94
|
+
d = @sale_report.staff
|
95
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
96
|
+
if d.areas.present?
|
97
|
+
if d.areas.ids.sort.to_s == area_ids
|
98
|
+
@area = '全国'
|
99
|
+
else
|
100
|
+
@area = d.areas.pluck(:name).join("、")
|
101
|
+
end
|
102
|
+
else
|
103
|
+
@area = ''
|
104
|
+
end
|
85
105
|
render layout: false
|
86
106
|
end
|
87
107
|
|
@@ -118,7 +138,17 @@ module EducodeSales
|
|
118
138
|
def audit
|
119
139
|
@sale_report = OperationReport.find(params[:id])
|
120
140
|
@name = @sale_report.staff.user.real_name
|
121
|
-
|
141
|
+
d = @sale_report.staff
|
142
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
143
|
+
if d.areas.present?
|
144
|
+
if d.areas.ids.sort.to_s == area_ids
|
145
|
+
@area = '全国'
|
146
|
+
else
|
147
|
+
@area = d.areas.pluck(:name).join("、")
|
148
|
+
end
|
149
|
+
else
|
150
|
+
@area = ''
|
151
|
+
end
|
122
152
|
render layout: false
|
123
153
|
end
|
124
154
|
|
@@ -86,7 +86,17 @@ module EducodeSales
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def new_weekly
|
89
|
-
|
89
|
+
d = @current_admin
|
90
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
91
|
+
if d.areas.present?
|
92
|
+
if d.areas.ids.sort.to_s == area_ids
|
93
|
+
@area = '全国'
|
94
|
+
else
|
95
|
+
@area = d.areas.pluck(:name).join("、")
|
96
|
+
end
|
97
|
+
else
|
98
|
+
@area = ''
|
99
|
+
end
|
90
100
|
@name = @current_admin.user.real_name
|
91
101
|
sale_plans = SalePlan.where(month: Time.now.strftime("%Y-%m") + "-01 00:00:00", weekly: Time.now.strftime('%W').to_i, staff_id: @current_admin.id)
|
92
102
|
@rate = sale_plans.present? ? (sale_plans.sum("finish_rate") / sale_plans.size) : 0
|
@@ -104,7 +114,17 @@ module EducodeSales
|
|
104
114
|
end
|
105
115
|
|
106
116
|
def new_monthly
|
107
|
-
|
117
|
+
d = @current_admin
|
118
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
119
|
+
if d.areas.present?
|
120
|
+
if d.areas.ids.sort.to_s == area_ids
|
121
|
+
@area = '全国'
|
122
|
+
else
|
123
|
+
@area = d.areas.pluck(:name).join("、")
|
124
|
+
end
|
125
|
+
else
|
126
|
+
@area = ''
|
127
|
+
end
|
108
128
|
@name = @current_admin.user.real_name
|
109
129
|
sale_plans = SalePlan.where(month: Time.now.strftime("%Y-%m") + "-01 00:00:00", staff_id: @current_admin.id, weekly: nil)
|
110
130
|
@rate = sale_plans.present? ? (sale_plans.sum("finish_rate") / sale_plans.size) : 0
|
@@ -24,7 +24,17 @@ module EducodeSales
|
|
24
24
|
def show
|
25
25
|
@sale_report = SaleReport.find(params[:id])
|
26
26
|
@name = @sale_report.staff.user.real_name
|
27
|
-
|
27
|
+
d = @sale_report.staff
|
28
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
29
|
+
if d.areas.present?
|
30
|
+
if d.areas.ids.sort.to_s == area_ids
|
31
|
+
@area = '全国'
|
32
|
+
else
|
33
|
+
@area = d.areas.pluck(:name).join("、")
|
34
|
+
end
|
35
|
+
else
|
36
|
+
@area = ''
|
37
|
+
end
|
28
38
|
render layout: false
|
29
39
|
end
|
30
40
|
|
@@ -86,7 +96,17 @@ module EducodeSales
|
|
86
96
|
def edit
|
87
97
|
@sale_report = SaleReport.find(params[:id])
|
88
98
|
@name = @sale_report.staff.user.real_name
|
89
|
-
|
99
|
+
d = @sale_report.staff
|
100
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
101
|
+
if d.areas.present?
|
102
|
+
if d.areas.ids.sort.to_s == area_ids
|
103
|
+
@area = '全国'
|
104
|
+
else
|
105
|
+
@area = d.areas.pluck(:name).join("、")
|
106
|
+
end
|
107
|
+
else
|
108
|
+
@area = ''
|
109
|
+
end
|
90
110
|
render layout: false
|
91
111
|
end
|
92
112
|
|
@@ -123,7 +143,17 @@ module EducodeSales
|
|
123
143
|
def audit
|
124
144
|
@sale_report = SaleReport.find(params[:id])
|
125
145
|
@name = @sale_report.staff.user.real_name
|
126
|
-
|
146
|
+
d = @sale_report.staff
|
147
|
+
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
148
|
+
if d.areas.present?
|
149
|
+
if d.areas.ids.sort.to_s == area_ids
|
150
|
+
@area = '全国'
|
151
|
+
else
|
152
|
+
@area = d.areas.pluck(:name).join("、")
|
153
|
+
end
|
154
|
+
else
|
155
|
+
@area = ''
|
156
|
+
end
|
127
157
|
render layout: false
|
128
158
|
end
|
129
159
|
|
@@ -16,13 +16,85 @@ module EducodeSales
|
|
16
16
|
@business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.clazz_id != ?", x, o).sum(:total_amount).round(2)
|
17
17
|
stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
18
18
|
@goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", stage_ids).sum(:total_amount).round(2)
|
19
|
+
@actual_goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", stage_ids).sum(:actual_amount).round(2)
|
19
20
|
s_stage_ids = Common.where(clazz: '商机阶段', name: ['已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
20
21
|
@service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.signed_date >= ? AND educode_sales_follow_ups.signed_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", s_stage_ids).sum(:total_amount).round(2)
|
22
|
+
@actual_service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.signed_date >= ? AND educode_sales_follow_ups.signed_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", s_stage_ids).sum(:actual_amount).round(2)
|
21
23
|
@return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", year_time, year_over_time).sum(:amount).round(2)
|
22
24
|
a = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::ATYPE)&.name).pluck(:id)
|
23
25
|
@a_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", a).sum(:total_amount).round(2)
|
24
26
|
b = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::BTYPE)&.name).pluck(:id)
|
25
27
|
@b_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", b).sum(:total_amount).round(2)
|
28
|
+
|
29
|
+
count_type = params[:count_type] || "actual_amount"
|
30
|
+
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
31
|
+
names = Staff.includes(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id] }
|
32
|
+
x_business_ids = []
|
33
|
+
default_dates = (30.day.ago.to_date..Date.today).map { |d| d.strftime("%Y-%W")}.uniq #默认时间范围
|
34
|
+
Business.all.each do |d|
|
35
|
+
if d.last_follow_up&.clazz&.id == x
|
36
|
+
x_business_ids << d.id
|
37
|
+
end
|
38
|
+
end
|
39
|
+
colors = ['#44D7B6','#4CACFF','#F7B500','#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#8B00FF', 'rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ,'rgba(255, 0, 250, 1)']
|
40
|
+
@follow_count_range = params[:follow_count_range] || "week"
|
41
|
+
@goal_count_range = params[:goal_count_range] || "month"
|
42
|
+
# 商机跟进数图表
|
43
|
+
@follow_count_data = week_follow_count_chart(default_dates,names,x_business_ids,colors)
|
44
|
+
if params[:follow_count_range].present?
|
45
|
+
case params[:follow_count_range]
|
46
|
+
when "week" #按周
|
47
|
+
if params[:date_week].present?
|
48
|
+
date = params[:date_week].split(" - ")
|
49
|
+
dates = (date[0].to_date..date[1].to_date).map { |d|
|
50
|
+
d.strftime("%Y-%W")}.uniq
|
51
|
+
@follow_count_data = week_follow_count_chart(dates,names,x_business_ids,colors)
|
52
|
+
end
|
53
|
+
when "month" #按月
|
54
|
+
if params[:date_month].present?
|
55
|
+
# (Date.new(2020,12,1)..Date.new(2021,12,1)).map { |d| d.strftime("%Y-%m")}.uniq
|
56
|
+
date = params[:date_month].split(" - ")
|
57
|
+
dates = ((date[0]+"-01").to_date..(date[1]+"-01").to_date).map { |d| d.strftime("%Y-%m")}.uniq
|
58
|
+
@follow_count_data = month_follow_count_chart(dates,names,x_business_ids,colors)
|
59
|
+
end
|
60
|
+
when "year" #按年
|
61
|
+
if params[:date_year].present?
|
62
|
+
date = params[:date_year].split(" - ")
|
63
|
+
dates = (date[0]..date[1]).to_a
|
64
|
+
@follow_count_data = year_follow_count_chart(dates,names,x_business_ids,colors)
|
65
|
+
end
|
66
|
+
else #按天
|
67
|
+
if params[:date].present?
|
68
|
+
date = params[:date].split(" - ")
|
69
|
+
dates = (date[0].to_date..date[1].to_date).to_a
|
70
|
+
@follow_count_data = day_follow_count_chart(dates,names,x_business_ids,colors)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# 已中标图表
|
77
|
+
goal_default_dates = ("#{Time.now.year}-01".."#{Time.now.year}-#{Time.now.month}").to_a
|
78
|
+
sale_names = ['已中标','已签单','已回款']
|
79
|
+
10.times{p count_type}
|
80
|
+
@goal_count_data = month_sale_chart(goal_default_dates,sale_names,colors,x,stage_ids,s_stage_ids,count_type)
|
81
|
+
if params[:goal_count_range].present?
|
82
|
+
case params[:goal_count_range]
|
83
|
+
when "week"
|
84
|
+
when "month" #按月
|
85
|
+
if params[:goal_date_month].present?
|
86
|
+
date = params[:goal_date_month].split(" - ")
|
87
|
+
dates = ((date[0]+"-01").to_date..(date[1]+"-01").to_date).map { |d| d.strftime("%Y-%m")}.uniq
|
88
|
+
@goal_count_data = month_sale_chart(dates,sale_names,colors,x,stage_ids,s_stage_ids,count_type)
|
89
|
+
end
|
90
|
+
else #按年
|
91
|
+
if params[:goal_date_year].present?
|
92
|
+
date = params[:goal_date_year].split(" - ")
|
93
|
+
dates = (date[0]..date[1]).to_a
|
94
|
+
@goal_count_data = year_sale_chart(dates,sale_names,colors,x,stage_ids,s_stage_ids,count_type)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
26
98
|
end
|
27
99
|
|
28
100
|
def sale_trends
|
@@ -44,5 +116,129 @@ module EducodeSales
|
|
44
116
|
params.permit(:chance_money, :ballot_money, :sign_money, :returned_money)
|
45
117
|
end
|
46
118
|
|
119
|
+
def day_follow_count_chart(dates,names,x_business_ids,colors)
|
120
|
+
{
|
121
|
+
labels: dates,
|
122
|
+
datasets:names.map.with_index do |name,i|
|
123
|
+
{
|
124
|
+
hidden: i < 3 ? false : true,
|
125
|
+
label: name[0],
|
126
|
+
data: dates.map{ |d| @follow_up = FollowUp.where(staff_id: name[1], created_at: d.beginning_of_day..d.end_of_day).where.not(business: x_business_ids).count },
|
127
|
+
backgroundColor: "#fff",
|
128
|
+
pointBorderColor: colors[i%15+1],
|
129
|
+
borderColor: colors[i%15+1],
|
130
|
+
pointBackgroundColor: colors[i%15+1],
|
131
|
+
borderWidth: 2
|
132
|
+
}
|
133
|
+
end
|
134
|
+
}
|
135
|
+
end
|
136
|
+
def week_follow_count_chart(dates,names,x_business_ids,colors)
|
137
|
+
{
|
138
|
+
labels: dates,
|
139
|
+
datasets:names.map.with_index do |name,i|
|
140
|
+
{
|
141
|
+
hidden: i < 3 ? false : true,
|
142
|
+
label: name[0],
|
143
|
+
data: dates.map{ |d|
|
144
|
+
d = d.split("-")
|
145
|
+
year = d[0].to_i
|
146
|
+
week = d[1].to_i
|
147
|
+
if week == 0
|
148
|
+
@follow_up = 0
|
149
|
+
else
|
150
|
+
@follow_up = FollowUp.where(staff_id: name[1]).where("created_at >= ? AND created_at <= ?", Date.commercial(year,week).strftime("%Y-%m-%d"), Date.commercial(year,week,7).strftime("%Y-%m-%d")).where.not(business: x_business_ids).count
|
151
|
+
end
|
152
|
+
},
|
153
|
+
backgroundColor: "#fff",
|
154
|
+
pointBorderColor: colors[i%15+1],
|
155
|
+
borderColor: colors[i%15+1],
|
156
|
+
pointBackgroundColor: colors[i%15+1],
|
157
|
+
borderWidth: 2
|
158
|
+
}
|
159
|
+
end
|
160
|
+
}
|
161
|
+
end
|
162
|
+
def month_follow_count_chart(dates,names,x_business_ids,colors)
|
163
|
+
{
|
164
|
+
labels: dates,
|
165
|
+
datasets:names.map.with_index do |name,i|
|
166
|
+
{
|
167
|
+
hidden: i < 3 ? false : true,
|
168
|
+
label: name[0],
|
169
|
+
data: dates.map { |d| @follow_up = FollowUp.where( staff_id: name[1]).where("created_at >= ? AND created_at <= ?", "#{d}-01", "#{d}-31").where.not(business: x_business_ids).count },
|
170
|
+
backgroundColor: "#fff",
|
171
|
+
pointBorderColor: colors[i%15+1],
|
172
|
+
borderColor: colors[i%15+1],
|
173
|
+
pointBackgroundColor: colors[i%15+1],
|
174
|
+
borderWidth: 2,
|
175
|
+
}
|
176
|
+
end
|
177
|
+
}
|
178
|
+
end
|
179
|
+
def year_follow_count_chart(dates,names,x_business_ids,colors)
|
180
|
+
{
|
181
|
+
labels: dates,
|
182
|
+
datasets:names.map.with_index do |name,i|
|
183
|
+
{
|
184
|
+
hidden: i < 3 ? false : true,
|
185
|
+
label: name[0],
|
186
|
+
data: dates.map { |d| @follow_up = FollowUp.where( staff_id: name[1]).where("created_at >= ? AND created_at <= ?", "#{d}-01-01", "#{d}-12-31").where.not(business: x_business_ids).count },
|
187
|
+
backgroundColor: "#fff",
|
188
|
+
pointBorderColor: colors[i%15+1],
|
189
|
+
borderColor: colors[i%15+1],
|
190
|
+
pointBackgroundColor: colors[i%15+1],
|
191
|
+
borderWidth: 2
|
192
|
+
}
|
193
|
+
end
|
194
|
+
}
|
195
|
+
end
|
196
|
+
|
197
|
+
def month_sale_chart(dates,names,colors,x,stage_ids,s_stage_ids,count_type)
|
198
|
+
{
|
199
|
+
labels: dates,
|
200
|
+
datasets: names.map.with_index do |name,i|{
|
201
|
+
label: name,
|
202
|
+
data: dates.map{ |d|
|
203
|
+
case i
|
204
|
+
when 0
|
205
|
+
Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{d}-01", "#{d}-31", stage_ids).sum(count_type).round(2)
|
206
|
+
when 1
|
207
|
+
Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.signed_date >= ? AND educode_sales_follow_ups.signed_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{d}-01", "#{d}-31", s_stage_ids).sum(count_type).round(2)
|
208
|
+
else
|
209
|
+
Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", "#{d}-01", "#{d}-31").sum(:amount).round(2)
|
210
|
+
end
|
211
|
+
},
|
212
|
+
backgroundColor: colors[i],
|
213
|
+
borderColor: colors[i],
|
214
|
+
borderWidth: 1
|
215
|
+
}
|
216
|
+
end
|
217
|
+
}
|
218
|
+
end
|
219
|
+
|
220
|
+
def year_sale_chart(dates,names,colors,x,stage_ids,s_stage_ids,count_type)
|
221
|
+
{
|
222
|
+
labels: dates,
|
223
|
+
datasets:names.map.with_index do |name,i| {
|
224
|
+
label: name,
|
225
|
+
data: dates.map{ |d|
|
226
|
+
case i
|
227
|
+
when 0
|
228
|
+
Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{d}-01-01", "#{d}-12-31", stage_ids).sum(count_type).round(2)
|
229
|
+
when 1
|
230
|
+
Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.signed_date >= ? AND educode_sales_follow_ups.signed_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{d}-01-01", "#{d}-12-31", s_stage_ids).sum(count_type).round(2)
|
231
|
+
else
|
232
|
+
Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", "#{d}-01-01", "#{d}-12-31").sum(:amount).round(2)
|
233
|
+
end },
|
234
|
+
backgroundColor: colors[i],
|
235
|
+
borderColor: colors[i],
|
236
|
+
borderWidth: 1
|
237
|
+
}
|
238
|
+
end
|
239
|
+
}
|
240
|
+
end
|
241
|
+
|
242
|
+
|
47
243
|
end
|
48
244
|
end
|
@@ -14,6 +14,10 @@ module EducodeSales
|
|
14
14
|
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
15
15
|
@a_clazz = Common.find_by(clazz: 'business_type', name: Common.find_by(extras: EducodeSales::Common::ATYPE)&.name)
|
16
16
|
@b_clazz = Common.find_by(clazz: 'business_type', name: Common.find_by(extras: EducodeSales::Common::BTYPE)&.name)
|
17
|
+
@c_clazz = Common.find_by(clazz: 'business_type', name: Common.find_by(extras: EducodeSales::Common::CTYPE)&.name)
|
18
|
+
@d_clazz = Common.find_by(clazz: 'business_type', name: Common.find_by(extras: EducodeSales::Common::DTYPE)&.name)
|
19
|
+
@e_clazz = Common.find_by(clazz: 'business_type', name: Common.find_by(extras: EducodeSales::Common::ETYPE)&.name)
|
20
|
+
@o_clazz = Common.find_by(clazz: 'business_type', name: Common.find_by(extras: EducodeSales::Common::OTYPE)&.name)
|
17
21
|
@x = Common.find_by(extras: EducodeSales::Common::XTYPE)
|
18
22
|
@step_ids = Common.where(name: %w(已中标 已签单 已验收 回款中 服务中 已结束), clazz: 'business_step').pluck(:id)
|
19
23
|
|
@@ -20,43 +20,50 @@ module EducodeSales
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
23
|
+
folder = File.join(Rails.root, "public", "files", 'educode_sales')
|
24
|
+
upload_file = params["file"]
|
25
|
+
raise "未上传文件" unless upload_file
|
26
|
+
save_path = File.join(folder)
|
27
|
+
ext = file_ext(upload_file.original_filename)
|
28
|
+
local_path, digest = file_save_to_local(save_path, upload_file.tempfile, ext)
|
29
|
+
content_type = upload_file.content_type.presence || 'application/octet-stream'
|
30
|
+
disk_filename = local_path[save_path.size + 1, local_path.size]
|
31
|
+
@attachment = Attachment.where(disk_filename: disk_filename,
|
32
|
+
author_id: @current_admin.user_id).first
|
33
|
+
if @attachment.blank?
|
34
|
+
@attachment = Attachment.new
|
35
|
+
@attachment.filename = upload_file.original_filename
|
36
|
+
@attachment.description = "business"
|
37
|
+
@attachment.disk_filename = local_path[save_path.size + 1, local_path.size]
|
38
|
+
@attachment.filesize = upload_file.tempfile.size
|
39
|
+
@attachment.content_type = content_type
|
40
|
+
@attachment.digest = digest
|
41
|
+
@attachment.author_id = @current_admin.user_id
|
42
|
+
@attachment.container_id = params[:business_id]
|
43
|
+
@attachment.save!
|
44
|
+
else
|
45
|
+
logger.info "文件已存在,id = #{@attachment.id}, filename = #{@attachment.filename}"
|
46
|
+
end
|
47
|
+
render_success
|
47
48
|
end
|
48
49
|
|
49
50
|
def destroy
|
51
|
+
folder = File.join(Rails.root, "public", "files", 'educode_sales')
|
50
52
|
file = Attachment.find(params[:id])
|
51
53
|
file.destroy
|
52
|
-
File.delete("
|
54
|
+
File.delete(folder + "/" +file.disk_filename) if FileTest::exist?(folder + "/" +file.disk_filename)
|
53
55
|
render_success
|
54
56
|
end
|
55
57
|
|
56
58
|
def download
|
59
|
+
folder = File.join(Rails.root, "public", "files", 'educode_sales')
|
57
60
|
file = Attachment.find_by_id(params[:id])
|
58
61
|
raise "未找到文件" unless file
|
59
|
-
send_file("
|
62
|
+
send_file(folder + "/" +file.disk_filename, filename: file.title, stream: true, type: file.content_type.presence || 'application/octet-stream')
|
63
|
+
end
|
64
|
+
|
65
|
+
def edu_setting name
|
66
|
+
EduSetting.get(name)
|
60
67
|
end
|
61
68
|
|
62
69
|
|
@@ -8,6 +8,7 @@ module EducodeSales
|
|
8
8
|
BTYPE = 'b_class'
|
9
9
|
CTYPE = 'c_class'
|
10
10
|
DTYPE = 'd_class'
|
11
|
+
ETYPE = 'e_class'
|
11
12
|
|
12
13
|
validates :name, uniqueness: {scope: :clazz, message: '已存在'}
|
13
14
|
|
@@ -25,7 +26,7 @@ module EducodeSales
|
|
25
26
|
}
|
26
27
|
|
27
28
|
def self.job_type_name
|
28
|
-
self.where(clazz: 'staff_type'
|
29
|
+
self.where(clazz: 'staff_type').pluck(:id, :name).to_h
|
29
30
|
end
|
30
31
|
|
31
32
|
def self.teacher_source_name
|
@@ -65,13 +65,13 @@
|
|
65
65
|
</div>
|
66
66
|
<br>
|
67
67
|
<div class="layui-inline">
|
68
|
-
<label class="layui-form-label"
|
68
|
+
<label class="layui-form-label">总额(万)</label>
|
69
69
|
<div class="layui-input-inline">
|
70
70
|
<input name="total_amount" type="number" class="layui-input" value="<%= @follow_up.total_amount %>">
|
71
71
|
</div>
|
72
72
|
</div>
|
73
73
|
<div class="layui-inline">
|
74
|
-
<label class="layui-form-label"
|
74
|
+
<label class="layui-form-label">合同额(万)</label>
|
75
75
|
<div class="layui-input-inline">
|
76
76
|
<input name="actual_amount" type="number" class="layui-input" placeholder="本单位的签单金额" value="<%= @follow_up.actual_amount %>">
|
77
77
|
</div>
|
@@ -84,7 +84,7 @@
|
|
84
84
|
</div>
|
85
85
|
</div>
|
86
86
|
<div class="layui-inline">
|
87
|
-
<label class="layui-form-label"
|
87
|
+
<label class="layui-form-label">渠道分成(万)</label>
|
88
88
|
<div class="layui-input-inline">
|
89
89
|
<input name="divide_amount" class="layui-input" value="<%= @follow_up.divide_amount%>">
|
90
90
|
</div>
|
@@ -1,3 +1,4 @@
|
|
1
|
+
<%= Gon::Base.render_data %>
|
1
2
|
<script type="text/html" id="toolbarDemo">
|
2
3
|
<div class="layui-btn-container">
|
3
4
|
<span class="table-label">附件信息</span>
|
@@ -112,21 +113,19 @@
|
|
112
113
|
});
|
113
114
|
|
114
115
|
|
115
|
-
|
116
116
|
table.on('tool(file)', function (obj) {
|
117
117
|
var data = obj.data;
|
118
118
|
var id = data.id
|
119
119
|
name = data.disk_filename
|
120
|
+
folder = gon.folder
|
120
121
|
if (obj.event === 'preview') {
|
121
122
|
if (data.content_type.split("/")[0] === "image"){
|
122
|
-
// var img = "<img src='/images/" + name + "' />";
|
123
123
|
layer.photos({
|
124
|
-
photos: { "data": [{"src": '/
|
124
|
+
photos: { "data": [{"src": '/files/educode_sales/' + name}] }
|
125
125
|
,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机
|
126
126
|
});
|
127
127
|
}else if (data.content_type.split("/")[1] === "pdf"){
|
128
|
-
var pdf = '/
|
129
|
-
console.log(pdf);
|
128
|
+
var pdf = '/files/educode_sales/' + name;
|
130
129
|
var openWH = miniPage.getOpenWidthHeight();
|
131
130
|
layer.open({
|
132
131
|
title: data.name,
|