educode_sales 0.5.7 → 0.6.1
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//345/256/242/346/210/267/347/256/241/347/220/206.png +0 -0
- data/app/controllers/educode_sales/businesses_controller.rb +20 -3
- data/app/controllers/educode_sales/customer_extensions_controller.rb +17 -0
- data/app/controllers/educode_sales/customer_follows_controller.rb +41 -0
- data/app/controllers/educode_sales/customers_controller.rb +194 -0
- data/app/controllers/educode_sales/follow_ups_controller.rb +9 -9
- data/app/controllers/educode_sales/home_controller.rb +9 -4
- data/app/controllers/educode_sales/roles_controller.rb +4 -1
- data/app/controllers/educode_sales/sale_trends_controller.rb +18 -7
- data/app/controllers/educode_sales/sales_controller.rb +3 -0
- data/app/controllers/educode_sales/teachers_controller.rb +5 -0
- data/app/models/educode_sales/customer.rb +4 -0
- data/app/models/educode_sales/customer_extension.rb +7 -0
- data/app/models/educode_sales/customer_follow.rb +5 -0
- data/app/models/educode_sales/permission.rb +2 -1
- data/app/models/educode_sales/role_area.rb +1 -0
- data/app/views/educode_sales/businesses/_follows.html.erb +43 -18
- data/app/views/educode_sales/businesses/edit_follow_record.html.erb +13 -0
- data/app/views/educode_sales/businesses/index.html.erb +27 -6
- data/app/views/educode_sales/businesses/index.json.jbuilder +1 -1
- data/app/views/educode_sales/businesses/new.html.erb +3 -0
- data/app/views/educode_sales/businesses/new_follow_record.html.erb +13 -0
- data/app/views/educode_sales/businesses/show_follow.html.erb +6 -1
- data/app/views/educode_sales/businesses/show_follow.json.jbuilder +1 -0
- data/app/views/educode_sales/businesses/show_follow_record.html.erb +8 -0
- data/app/views/educode_sales/customers/edit.html.erb +60 -0
- data/app/views/educode_sales/customers/edit_department.html.erb +54 -0
- data/app/views/educode_sales/customers/edit_follow_record.html.erb +50 -0
- data/app/views/educode_sales/customers/give.html.erb +51 -0
- data/app/views/educode_sales/customers/index.html.erb +493 -0
- data/app/views/educode_sales/customers/index.json.jbuilder +25 -0
- data/app/views/educode_sales/customers/new.html.erb +89 -0
- data/app/views/educode_sales/customers/new_department.html.erb +56 -0
- data/app/views/educode_sales/customers/new_follow_record.html.erb +54 -0
- data/app/views/educode_sales/customers/show_department.json.jbuilder +13 -0
- data/app/views/educode_sales/customers/show_follow.html.erb +442 -0
- data/app/views/educode_sales/customers/show_follow.json.jbuilder +13 -0
- data/app/views/educode_sales/customers/show_follow_record.html.erb +18 -0
- data/app/views/educode_sales/follow_ups/index.json.jbuilder +1 -0
- data/app/views/educode_sales/operation_plans/_monthPlan.html.erb +6 -0
- data/app/views/educode_sales/operation_plans/_monthly.html.erb +2 -0
- data/app/views/educode_sales/operation_plans/_weekPlan.html.erb +6 -0
- data/app/views/educode_sales/operation_plans/_weekly.html.erb +2 -0
- data/app/views/educode_sales/places/index.json.jbuilder +1 -1
- data/app/views/educode_sales/plans/_monthPlan.html.erb +5 -0
- data/app/views/educode_sales/plans/_monthly.html.erb +1 -0
- data/app/views/educode_sales/plans/_weekPlan.html.erb +5 -0
- data/app/views/educode_sales/plans/_weekly.html.erb +1 -0
- data/app/views/educode_sales/roles/edit.html.erb +8 -0
- data/app/views/educode_sales/sales/index.html.erb +70 -19
- data/app/views/educode_sales/sales/index.json.jbuilder +46 -16
- data/app/views/educode_sales/sales/operations.html.erb +1 -0
- data/app/views/educode_sales/teachers/index.html.erb +6 -1
- data/app/views/educode_sales/teachers/index.json.jbuilder +2 -2
- data/app/views/educode_sales/teachers/show_follow.html.erb +10 -5
- data/app/views/educode_sales/teachers/show_follow.json.jbuilder +1 -0
- data/app/views/layouts/educode_sales/application.html.erb +8 -1
- data/config/routes.rb +25 -0
- data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +15 -0
- data/db/migrate/20211206054756_add_year_to_follow_ups.rb +5 -0
- data/db/migrate/20211214100803_create_customer_extensions.rb +9 -0
- data/db/migrate/20211215025029_create_educode_sales_customer_follows.rb +12 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88c76bb62d36b9922c99d80e365218b4dbde3bfe9632773d71ba40bdda28ef2f
|
4
|
+
data.tar.gz: 4ba6723ac69f19bb92c57a876b1e7c7299fc15bf1d213eede7ce215e12a932bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 608ee9cf6238d241410cb879004c9d18d5ee4e2fa346f285a6f81e3391b3438b905997dbc03c5b37c83c1c9dbd5f2cda1c7f11c3c831c3f986ceda2b443fe925
|
7
|
+
data.tar.gz: 0f5c04324244916fe4a6fd75625076b8ae56bf6398f04676d168b41af251dd66b0db586f53881bbb68ddfaebef7d0ef95d0b47f790b64ed34729c57b5533d856
|
Binary file
|
@@ -35,6 +35,7 @@ module EducodeSales
|
|
35
35
|
@staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
|
36
36
|
@more = can?(:create, EducodeSales::SalePlan) || can?(:update, EducodeSales::Business) || can?(:destroy, EducodeSales::Business)
|
37
37
|
gon.menus = []
|
38
|
+
gon.place = params[:place_id].present? ? [{ value: params[:place_id], name: EducodeSales::Place.find(params[:place_id]).name }] : []
|
38
39
|
if can?(:create, EducodeSales::SalePlan)
|
39
40
|
gon.menus << { title: '添加周计划', event: 'week' }
|
40
41
|
gon.menus << { title: '添加月计划', event: 'month' }
|
@@ -149,10 +150,24 @@ module EducodeSales
|
|
149
150
|
|
150
151
|
if params[:q].present? && params[:q][:area].present?
|
151
152
|
p = EducodeSales::Common.find(params[:q][:area]).name
|
152
|
-
|
153
|
+
if @current_admin.is_admin?
|
154
|
+
@businesses = @businesses.joins("
|
155
|
+
JOIN departments ON educode_sales_businesses.department_id = departments.id
|
156
|
+
JOIN schools ON departments.school_id = schools.id
|
157
|
+
").where("province = ?", p)
|
158
|
+
else
|
159
|
+
level = @current_admin.role.role_areas.find_by(clazz: '商机管理').level
|
160
|
+
if level == "区域"
|
161
|
+
@businesses = @businesses.joins("
|
162
|
+
JOIN schools ON departments.school_id = schools.id
|
163
|
+
").where("province = ?", p)
|
164
|
+
else
|
165
|
+
@businesses = @businesses.joins("
|
153
166
|
JOIN departments ON educode_sales_businesses.department_id = departments.id
|
154
167
|
JOIN schools ON departments.school_id = schools.id
|
155
168
|
").where("province = ?", p)
|
169
|
+
end
|
170
|
+
end
|
156
171
|
end
|
157
172
|
|
158
173
|
if params[:q].present? && params[:q][:date].present?
|
@@ -261,6 +276,7 @@ module EducodeSales
|
|
261
276
|
|
262
277
|
def new_follow_record
|
263
278
|
load_business
|
279
|
+
@years = (2015..Time.now.year).to_a.reverse
|
264
280
|
@o_name = EducodeSales::Common.find_by(extras: EducodeSales::Common::OTYPE)&.name
|
265
281
|
@clazz = Common.where(clazz: 'business_type').order("position").pluck(:name, :id)
|
266
282
|
@stages = Common.where(clazz: 'business_step').order("position").pluck(:name, :id)
|
@@ -270,7 +286,7 @@ module EducodeSales
|
|
270
286
|
gon.sales = @last_follow_up.assign_follow_ups.map do |d|
|
271
287
|
{value: d.staff_id, name: d.staff.user.full_name}
|
272
288
|
end
|
273
|
-
gon.place = [{ value: @last_follow_up.place&.id, name: @last_follow_up.place&.name }]
|
289
|
+
gon.place = @last_follow_up.place.present? ? [{ value: @last_follow_up.place&.id, name: @last_follow_up.place&.name }] : []
|
274
290
|
end
|
275
291
|
render layout: false
|
276
292
|
end
|
@@ -296,6 +312,7 @@ module EducodeSales
|
|
296
312
|
end
|
297
313
|
|
298
314
|
def edit_follow_record
|
315
|
+
@years = (2015..Time.now.year).to_a.reverse
|
299
316
|
@o_name = EducodeSales::Common.find_by(extras: EducodeSales::Common::OTYPE)&.name
|
300
317
|
@follow_up = FollowUp.find(params[:follow_up_id])
|
301
318
|
@clazz = Common.where(clazz: 'business_type').order("position").pluck(:name, :id)
|
@@ -304,7 +321,7 @@ module EducodeSales
|
|
304
321
|
gon.sales = @follow_up.assign_follow_ups.map do |d|
|
305
322
|
{value: d.staff_id, name: d.staff.user.full_name}
|
306
323
|
end
|
307
|
-
gon.place = [{ value: @follow_up.place&.id, name: @follow_up.place&.name }]
|
324
|
+
gon.place = @follow_up.place.present? ? [{ value: @follow_up.place&.id, name: @follow_up.place&.name }] : [value: '', name: '']
|
308
325
|
render layout: false
|
309
326
|
end
|
310
327
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_dependency "educode_sales/application_controller"
|
2
|
+
|
3
|
+
module EducodeSales
|
4
|
+
class CustomerExtensionsController < ApplicationController
|
5
|
+
|
6
|
+
def create
|
7
|
+
params[:school_ids].each do |d|
|
8
|
+
if EducodeSales::CustomerExtension.find_by(school_id: d).present?
|
9
|
+
EducodeSales::CustomerExtension.find_by(school_id: d).update(customer_staff_id: params[:staff_id])
|
10
|
+
else
|
11
|
+
EducodeSales::CustomerExtension.create(customer_staff_id: params[:staff_id], school_id: d)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
render_success
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_dependency "educode_sales/application_controller"
|
2
|
+
|
3
|
+
module EducodeSales
|
4
|
+
class CustomerFollowsController < ApplicationController
|
5
|
+
def create
|
6
|
+
follow_up = EducodeSales::CustomerFollow.new(follow_up_params)
|
7
|
+
follow_up.staff = @current_admin
|
8
|
+
if follow_up.save
|
9
|
+
render_success
|
10
|
+
else
|
11
|
+
render_failure follow_up
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def destroy
|
16
|
+
follow_up = CustomerFollow.find(params[:id])
|
17
|
+
if follow_up.destroy
|
18
|
+
render_success
|
19
|
+
else
|
20
|
+
render_failure follow_up
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def update
|
25
|
+
follow_up = CustomerFollow.find(params[:id])
|
26
|
+
follow_up.assign_attributes(follow_up_params)
|
27
|
+
if follow_up.save
|
28
|
+
render_success
|
29
|
+
else
|
30
|
+
render_failure follow_up
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def follow_up_params
|
37
|
+
params.permit(:school_id, :department_id, :content)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require_dependency "educode_sales/application_controller"
|
2
|
+
|
3
|
+
module EducodeSales
|
4
|
+
class CustomersController < ApplicationController
|
5
|
+
# before_action :find_school, only: [:edit, :update]
|
6
|
+
# before_action :must_admin!, only: [:destroy]
|
7
|
+
|
8
|
+
def new_department
|
9
|
+
render layout: false
|
10
|
+
end
|
11
|
+
def create_department
|
12
|
+
department_name = params[:department_name].to_s.strip
|
13
|
+
school = School.find(params[:school_id])
|
14
|
+
|
15
|
+
return render_failure('部门名称重复') if school.departments.exists?(name: department_name)
|
16
|
+
|
17
|
+
ActiveRecord::Base.transaction do
|
18
|
+
department = school.departments.create!(name: department_name, is_auth: 1)
|
19
|
+
ApplyAddDepartment.create!(school_id: school.id, status: 1, name: department.name,
|
20
|
+
department_id: department.id, user_id: current_user.id)
|
21
|
+
end
|
22
|
+
|
23
|
+
render_success
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit_department
|
27
|
+
@department = Department.find(params[:id])
|
28
|
+
render layout: false
|
29
|
+
end
|
30
|
+
def update_department
|
31
|
+
department = Department.find(params[:id])
|
32
|
+
department.update(name: params[:department_name])
|
33
|
+
render_success
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def index
|
38
|
+
authorize! :read, Customer
|
39
|
+
respond_to do |format|
|
40
|
+
format.html do
|
41
|
+
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
42
|
+
@staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
|
43
|
+
end
|
44
|
+
format.json do
|
45
|
+
if @current_admin.is_admin?
|
46
|
+
@customers = School
|
47
|
+
else
|
48
|
+
level = @current_admin.role.role_areas.find_by(clazz: '客户管理').level
|
49
|
+
case level
|
50
|
+
when '自己'
|
51
|
+
school_ids = CustomerExtension.where(customer_staff_id: @current_admin.id).pluck(:school_id)
|
52
|
+
@customers = School.where(id: school_ids)
|
53
|
+
when '区域'
|
54
|
+
a_school_ids = School.where(province: @current_admin.areas.pluck(:name)).ids
|
55
|
+
b_school_ids = CustomerExtension.where(customer_staff_id: @current_admin.id).pluck(:school_id)
|
56
|
+
school_ids = a_school_ids + b_school_ids
|
57
|
+
@customers = School.where(id: school_ids)
|
58
|
+
else
|
59
|
+
@customers = School
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if params[:q].present? && params[:q][:name].present?
|
64
|
+
@customers = @customers.where("schools.name like ?", "%#{params[:q][:name]}%")
|
65
|
+
end
|
66
|
+
if params[:q].present? && params[:q][:area].present?
|
67
|
+
@customers = @customers.where("schools.province = ?", "#{params[:q][:area]}")
|
68
|
+
end
|
69
|
+
if params[:q].present? && params[:q][:staff_id].present?
|
70
|
+
school_ids = EducodeSales::CustomerExtension.where(customer_staff_id: params[:q][:staff_id]).pluck(:school_id)
|
71
|
+
@customers = @customers.where(id: school_ids)
|
72
|
+
end
|
73
|
+
|
74
|
+
# if params[:q].present? && params[:q][:date].present?
|
75
|
+
# department_ids =
|
76
|
+
# business_ids = EducodeSales::Business.where(department_id: department_ids).ids
|
77
|
+
# follow_ups = EducodeSales::FollowUp.where(business_id: business_ids)
|
78
|
+
# customer_follows = EducodeSales::CustomerFollow.where(school_id: d.id)
|
79
|
+
# a_last_follow_time = follow_ups.last&.created_at&.to_s(:date)
|
80
|
+
# b_last_follow_time = customer_follows.last&.created_at&.to_s(:date)
|
81
|
+
# if a_last_follow_time.present? && b_last_follow_time.present?
|
82
|
+
# json.last_follow_time a_last_follow_time < b_last_follow_time ? b_last_follow_time : a_last_follow_time
|
83
|
+
# else
|
84
|
+
# json.last_follow_time a_last_follow_time || b_last_follow_time
|
85
|
+
# end
|
86
|
+
# date = params[:q][:date].split(" - ")
|
87
|
+
# @customers = @customers.where("educode_sales_businesses.created_at > ? AND educode_sales_businesses.created_at < ?", date[0], date[1])
|
88
|
+
# end
|
89
|
+
|
90
|
+
@customers = @customers.order(id: :desc).page(params[:page]).per(params[:limit])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def give
|
96
|
+
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
97
|
+
@staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
|
98
|
+
render layout: false
|
99
|
+
end
|
100
|
+
|
101
|
+
def show_follow
|
102
|
+
respond_to do |format|
|
103
|
+
format.html do
|
104
|
+
@school_name = School.find(params[:id]).name
|
105
|
+
@area = School.find(params[:id]).province
|
106
|
+
@staff = EducodeSales::CustomerExtension.find_by(school_id: params[:id])&.customer_staff&.user&.real_name
|
107
|
+
render layout: false
|
108
|
+
end
|
109
|
+
format.json do
|
110
|
+
@follow_ups = EducodeSales::CustomerFollow.where(school_id: params[:id])
|
111
|
+
@latest = @follow_ups.order(created_at: :desc).first
|
112
|
+
# if params[:field]
|
113
|
+
# @follow_ups = @follow_ups.order("#{params[:field]} #{params[:order]}")
|
114
|
+
# else
|
115
|
+
# @follow_ups = @follow_ups.order("created_at desc")
|
116
|
+
# end
|
117
|
+
@follow_ups = @follow_ups.order("created_at desc")
|
118
|
+
@follow_ups = @follow_ups.page(params[:page]).per(params[:limit])
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def show_department
|
124
|
+
@departments = School.find(params[:id]).departments
|
125
|
+
# if params[:field]
|
126
|
+
# @follow_ups = @follow_ups.order("#{params[:field]} #{params[:order]}")
|
127
|
+
# else
|
128
|
+
# @follow_ups = @follow_ups.order("created_at desc")
|
129
|
+
# end
|
130
|
+
@departments = @departments.order("created_at desc")
|
131
|
+
@departments = @departments.page(params[:page]).per(params[:limit])
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
def new_follow_record
|
136
|
+
@school = School.find(params[:id])
|
137
|
+
render layout: false
|
138
|
+
end
|
139
|
+
|
140
|
+
def show_follow_record
|
141
|
+
@follow_up = EducodeSales::CustomerFollow.find(params[:id])
|
142
|
+
@school = School.find(@follow_up.school_id)
|
143
|
+
render layout: false
|
144
|
+
end
|
145
|
+
|
146
|
+
def edit_follow_record
|
147
|
+
@follow_up = EducodeSales::CustomerFollow.find(params[:id])
|
148
|
+
@school = School.find(@follow_up.school_id)
|
149
|
+
render layout: false
|
150
|
+
end
|
151
|
+
|
152
|
+
def new
|
153
|
+
render layout: false
|
154
|
+
end
|
155
|
+
|
156
|
+
def create
|
157
|
+
@school = School.find(params[:id])
|
158
|
+
ActiveRecord::Base.transaction do
|
159
|
+
property = SchoolProperty.find_or_create_by!(school_property_params)
|
160
|
+
@school = School.new
|
161
|
+
@school.attributes = school_params
|
162
|
+
@school.school_property = property
|
163
|
+
@school.save!
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def edit
|
168
|
+
@school = School.find(params[:id])
|
169
|
+
render layout: false
|
170
|
+
end
|
171
|
+
|
172
|
+
def update
|
173
|
+
@school = School.find(params[:id])
|
174
|
+
ActiveRecord::Base.transaction do
|
175
|
+
property = SchoolProperty.find_or_create_by!(school_property_params)
|
176
|
+
@school.attributes = school_params
|
177
|
+
@school.school_property = property
|
178
|
+
@school.save!
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
private
|
183
|
+
|
184
|
+
|
185
|
+
def school_property_params
|
186
|
+
params.require(:school).permit(:project_985, :project_211, :regular_college, :junior_college, :secondary_school, :military_school, :enterprise)
|
187
|
+
end
|
188
|
+
|
189
|
+
def school_params
|
190
|
+
params.require(:school).permit(:name, :province, :city, :address)
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|
@@ -29,22 +29,22 @@ module EducodeSales
|
|
29
29
|
@follow_ups = FollowUp.all
|
30
30
|
end
|
31
31
|
end
|
32
|
-
if params[:q].present? && params[:q][:
|
33
|
-
@follow_ups = @follow_ups.joins(:business).where("educode_sales_businesses.name LIKE ?", "%#{params[:q][:
|
32
|
+
if params[:q].present? && params[:q][:name].present?
|
33
|
+
@follow_ups = @follow_ups.joins(:business).where("educode_sales_businesses.name LIKE ?", "%#{params[:q][:name]}%")
|
34
34
|
end
|
35
35
|
if params[:q].present? && params[:q][:follows_date].present?
|
36
36
|
date = params[:q][:follows_date].split(" - ")
|
37
37
|
@follow_ups = @follow_ups.where("educode_sales_follow_ups.created_at > ? AND educode_sales_follow_ups.created_at < ?", date[0], date[1])
|
38
38
|
end
|
39
|
-
if params[:q].present? && params[:q][:
|
40
|
-
@follow_ups = @follow_ups.where(staff_id: params[:q][:
|
39
|
+
if params[:q].present? && params[:q][:staff_id].present?
|
40
|
+
@follow_ups = @follow_ups.where(staff_id: params[:q][:staff_id])
|
41
41
|
end
|
42
|
-
if params[:q].present? && params[:q][:
|
43
|
-
departments_ids = Department.joins(:school).where("schools.name like ?", "%#{params[:q][:
|
42
|
+
if params[:q].present? && params[:q][:department].present?
|
43
|
+
departments_ids = Department.joins(:school).where("schools.name like ?", "%#{params[:q][:department]}%").pluck(:id)
|
44
44
|
@follow_ups = @follow_ups.joins(business: :department).where("departments.id in (?)", departments_ids)
|
45
45
|
end
|
46
|
-
if params[:q].present? && params[:q][:
|
47
|
-
p = EducodeSales::Common.find(params[:q][:
|
46
|
+
if params[:q].present? && params[:q][:area].present?
|
47
|
+
p = EducodeSales::Common.find(params[:q][:area]).name
|
48
48
|
@follow_ups = @follow_ups.joins(:business).joins("
|
49
49
|
JOIN departments ON educode_sales_businesses.department_id = departments.id
|
50
50
|
JOIN schools ON departments.school_id = schools.id
|
@@ -214,7 +214,7 @@ module EducodeSales
|
|
214
214
|
end
|
215
215
|
|
216
216
|
def follow_up_params
|
217
|
-
params.permit(:clazz_id, :stage_id, :invitation_at, :reception_at, :total_amount, :actual_amount, :divide_amount, :description, :advise, :place_id, :bidded_date, :signed_date)
|
217
|
+
params.permit(:clazz_id, :stage_id, :invitation_at, :reception_at, :total_amount, :actual_amount, :divide_amount, :description, :advise, :place_id, :bidded_date, :signed_date, :year)
|
218
218
|
end
|
219
219
|
|
220
220
|
def teacher_params
|
@@ -42,21 +42,26 @@ module EducodeSales
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def sales_staff
|
45
|
-
|
45
|
+
@staffs = Staff
|
46
46
|
if params[:teacher_assist].present?
|
47
47
|
common = Common.find_by(clazz: 'staff_type', name: '运营')
|
48
|
+
else
|
49
|
+
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
48
50
|
end
|
49
|
-
@staffs = Staff
|
50
51
|
if params[:q].present?
|
51
52
|
@staffs = @staffs.joins(user: :user_extension).where("concat(lastname, firstname) like :q", q: "%#{params[:q]}%")
|
52
53
|
end
|
53
|
-
|
54
|
+
if params[:teacher_assist].present?
|
55
|
+
@staffs = @staffs.where(is_admin: false).where(job_type: common.id).page(params[:page]).per(10)
|
56
|
+
else
|
57
|
+
@staffs = @staffs.where(is_admin: false).where.not(id: @current_admin.id).where(job_type: common.id).page(params[:page]).per(10)
|
58
|
+
end
|
54
59
|
end
|
55
60
|
|
56
61
|
def sales_place
|
57
62
|
@places = EducodeSales::Place
|
58
63
|
if params[:q].present?
|
59
|
-
@places = @places.where("name like :q", q: "%#{params[:q]}%")
|
64
|
+
@places = @places.where("name like :q", q: "%#{params[:q].strip}%")
|
60
65
|
end
|
61
66
|
@places = @places.page(params[:page]).per(10)
|
62
67
|
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' }])
|
19
|
+
role.role_areas.build([{ clazz: 'Business' }, { clazz: 'SalePlan' }, { clazz: 'Teacher' }, { clazz: 'Operation' }, {clazz:'Customer'}])
|
20
20
|
if role.save
|
21
21
|
render_success
|
22
22
|
else
|
@@ -78,6 +78,9 @@ module EducodeSales
|
|
78
78
|
role.role_areas.find_by(clazz: 'Operation').update(level: params[:operation])
|
79
79
|
role.role_areas.find_by(clazz: 'SalePlan').update(level: params[:sale_plan])
|
80
80
|
role.role_areas.find_by(clazz: 'Teacher').update(level: params[:teacher])
|
81
|
+
r = role.role_areas.find_or_initialize_by(clazz: 'Customer')
|
82
|
+
r.level = params[:customer]
|
83
|
+
r.save
|
81
84
|
render_success
|
82
85
|
end
|
83
86
|
|
@@ -120,7 +120,7 @@ module EducodeSales
|
|
120
120
|
labels: dates,
|
121
121
|
datasets:names.map.with_index do |name,i|
|
122
122
|
{
|
123
|
-
hidden: i < 3 ? false : true,
|
123
|
+
# hidden: i < 3 ? false : true,
|
124
124
|
label: name[0],
|
125
125
|
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 },
|
126
126
|
backgroundColor: "#fff",
|
@@ -134,21 +134,32 @@ module EducodeSales
|
|
134
134
|
end
|
135
135
|
def week_follow_count_chart(dates,names,x_business_ids,colors)
|
136
136
|
{
|
137
|
-
labels: dates
|
137
|
+
labels: dates.map{ |date|
|
138
|
+
d = date.split("-")
|
139
|
+
year = d[0].to_i
|
140
|
+
week = d[1].to_i
|
141
|
+
if week == 0
|
142
|
+
0
|
143
|
+
else
|
144
|
+
month = Date.commercial(year,week).strftime("%m月%d日")
|
145
|
+
day = Date.commercial(year,week,7).strftime("%m月%d日")
|
146
|
+
date.to_s + "(#{month}-#{day})"
|
147
|
+
end
|
148
|
+
} - [0],
|
138
149
|
datasets:names.map.with_index do |name,i|
|
139
150
|
{
|
140
|
-
hidden: i < 3 ? false : true,
|
151
|
+
# hidden: i < 3 ? false : true,
|
141
152
|
label: name[0],
|
142
153
|
data: dates.map{ |d|
|
143
154
|
d = d.split("-")
|
144
155
|
year = d[0].to_i
|
145
156
|
week = d[1].to_i
|
146
157
|
if week == 0
|
147
|
-
@follow_up =
|
158
|
+
@follow_up = 999999
|
148
159
|
else
|
149
160
|
@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
|
150
161
|
end
|
151
|
-
},
|
162
|
+
} - [999999],
|
152
163
|
backgroundColor: "#fff",
|
153
164
|
pointBorderColor: colors[i%15+1],
|
154
165
|
borderColor: colors[i%15+1],
|
@@ -163,7 +174,7 @@ module EducodeSales
|
|
163
174
|
labels: dates,
|
164
175
|
datasets:names.map.with_index do |name,i|
|
165
176
|
{
|
166
|
-
hidden: i < 3 ? false : true,
|
177
|
+
# hidden: i < 3 ? false : true,
|
167
178
|
label: name[0],
|
168
179
|
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 },
|
169
180
|
backgroundColor: "#fff",
|
@@ -180,7 +191,7 @@ module EducodeSales
|
|
180
191
|
labels: dates,
|
181
192
|
datasets:names.map.with_index do |name,i|
|
182
193
|
{
|
183
|
-
hidden: i < 3 ? false : true,
|
194
|
+
# hidden: i < 3 ? false : true,
|
184
195
|
label: name[0],
|
185
196
|
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 },
|
186
197
|
backgroundColor: "#fff",
|
@@ -9,8 +9,11 @@ module EducodeSales
|
|
9
9
|
authorize! :sales, Staff
|
10
10
|
respond_to do |format|
|
11
11
|
format.html do
|
12
|
+
@year = params[:year] ? params[:year] : "全部"
|
13
|
+
@years = ["全部"]+(2015..Time.now.year).to_a.reverse
|
12
14
|
end
|
13
15
|
format.json do
|
16
|
+
@year = params[:year] ? params[:year] : "全部"
|
14
17
|
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
15
18
|
@a_clazz = Common.find_by(clazz: 'business_type', name: Common.find_by(extras: EducodeSales::Common::ATYPE)&.name)
|
16
19
|
@b_clazz = Common.find_by(clazz: 'business_type', name: Common.find_by(extras: EducodeSales::Common::BTYPE)&.name)
|
@@ -57,6 +57,11 @@ module EducodeSales
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
if @current_admin.job_type == Common.find_by(clazz: 'staff_type', name: '销售').id
|
61
|
+
public_teacher_ids = EducodeSales::Teacher.where(staff_id: 0).pluck(:id) - EducodeSales::TeacherAssignFollow.where(staff_id: @current_admin.id).pluck(:teacher_id)
|
62
|
+
@teachers = @teachers.where.not(id: public_teacher_ids)
|
63
|
+
end
|
64
|
+
|
60
65
|
|
61
66
|
|
62
67
|
if params[:q].present? && params[:q][:assist].present?
|