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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 666b9ec9b763cfce87df4b2b6a2304625100ba52d94df0cd806fe36266062b3c
|
4
|
+
data.tar.gz: 494c7222e60d7114c95cd6f213fd11bb5070e2b6f40d45bfdaa3fa880c7e4a0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cc7914ec32c5e3cda9fa353bf35ddba314450b75f7401d1063469ab4f10b117437a4a93392783ddd7049e21f6012b1faba947be5b05874fd4b235c327c553c4
|
7
|
+
data.tar.gz: c5276a5f2d6ea22604cea8d6f81acb320f8e8ec7975138741e8e5ab6326f7f368f210a9b983fa0ab48688709de0053ad923a1043eab701b3ab19dac08910c1fc
|
@@ -5,6 +5,11 @@ module EducodeSales
|
|
5
5
|
before_action :authenticate_request
|
6
6
|
|
7
7
|
|
8
|
+
def is_commissioner_above?
|
9
|
+
return true if @current_admin.is_admin?
|
10
|
+
["销售总监", "副总", "生态运营总监", "方案总监", "售后总监", "课程组总监"].include? @current_admin.role.name
|
11
|
+
end
|
12
|
+
|
8
13
|
def subject_members
|
9
14
|
common = Common.find_by(clazz: 'staff_type', name: '课程')
|
10
15
|
@manages = Staff.joins(:user).where(job_type: common.id.to_i).where.not(role_id: 11).map { |d| {name: d.user.real_name, value: d.id}}
|
@@ -15,6 +20,11 @@ module EducodeSales
|
|
15
20
|
@staffs = Staff.joins(:user).where(job_type: common.id).where.not(role_id: 11).map { |d| { value: d.id, name: d.name } }
|
16
21
|
end
|
17
22
|
|
23
|
+
def subject_url
|
24
|
+
@url = "https://data.educoder.net"
|
25
|
+
@admins_url = "https://data.educoder.net"
|
26
|
+
end
|
27
|
+
|
18
28
|
def render_success
|
19
29
|
render json: { success: true }
|
20
30
|
end
|
@@ -5,7 +5,8 @@ module EducodeSales
|
|
5
5
|
# 商机交付课程
|
6
6
|
class BusinessCoursesController < ApplicationController
|
7
7
|
include BusinessCoursesHelper
|
8
|
-
|
8
|
+
include? SubjectHelper
|
9
|
+
before_action :subject_members, :subject_url
|
9
10
|
|
10
11
|
def index
|
11
12
|
authorize! :business, BusinessDeliverSubject
|
@@ -13,7 +14,18 @@ module EducodeSales
|
|
13
14
|
format.html do
|
14
15
|
end
|
15
16
|
format.json do
|
16
|
-
@business_deliver = BusinessDeliverSubject.
|
17
|
+
@business_deliver = BusinessDeliverSubject.all
|
18
|
+
|
19
|
+
unless is_commissioner_above?
|
20
|
+
business_ids = @business_deliver.pluck(:business_id)
|
21
|
+
last_follow_staff_business = Business.where(id: business_ids).joins(last_follow_up: [assign_follow_ups: [staff: :user]]).where("CONCAT(users.lastname, users.firstname) = '#{@current_admin.user.real_name}' ")
|
22
|
+
|
23
|
+
last_follow_staff_business_ids = last_follow_staff_business.pluck("educode_sales_businesses.id")
|
24
|
+
staff_business = Business.where(id: business_ids - last_follow_staff_business_ids).joins(staff: :user).where("CONCAT(users.lastname, users.firstname) = '#{@current_admin.user.real_name}' ")
|
25
|
+
@business_deliver = BusinessDeliverSubject.where(business_id: last_follow_staff_business_ids + staff_business.ids)
|
26
|
+
end
|
27
|
+
|
28
|
+
@business_deliver = @business_deliver.joins(business: [:school, :staff, :last_follow_up])
|
17
29
|
|
18
30
|
# 查询条件 交付状态 state == 0 代表全部
|
19
31
|
if params[:q] && params[:q][:state].present? && params[:q][:state] != '0'
|
@@ -119,7 +131,7 @@ module EducodeSales
|
|
119
131
|
|
120
132
|
BusinessSubjectStaff.bulk_insert(:staff_id, :container_id, :container_type, :created_at, :updated_at, :category) do |d|
|
121
133
|
params[:business][:manage_id].split(",").each do |m|
|
122
|
-
d.add [m.to_i, add_item.id, BusinessSubjectStaff::CONTAINER_TYPES::BUSSINESS, Time.now, Time.now, BusinessSubjectStaff::CATEGORY_TYPES::BUSINESS_MANAGE
|
134
|
+
d.add [m.to_i, add_item.id, BusinessSubjectStaff::CONTAINER_TYPES::BUSSINESS, Time.now, Time.now, BusinessSubjectStaff::CATEGORY_TYPES::BUSINESS_MANAGE]
|
123
135
|
end
|
124
136
|
end
|
125
137
|
|
@@ -133,18 +145,17 @@ module EducodeSales
|
|
133
145
|
def select_business
|
134
146
|
respond_to do |format|
|
135
147
|
format.json do
|
136
|
-
stage_id = Common.where(clazz: '商机阶段', name: ['已签单']).
|
148
|
+
stage_id = Common.where(clazz: '商机阶段', name: ['已签单']).take.id.to_i
|
137
149
|
@businesses = Business.joins(:last_follow_up, :school)
|
138
|
-
.where("educode_sales_businesses.
|
139
|
-
.where("educode_sales_businesses.id not in (?) ", BusinessDeliverSubject.pluck(:business_id).map(&:to_i)
|
150
|
+
.where("educode_sales_businesses.name LIKE '%#{params[:q]}%' and educode_sales_follow_ups.stage_id = #{stage_id} ")
|
151
|
+
.where("educode_sales_businesses.id not in (?) ", BusinessDeliverSubject.pluck(:business_id).map(&:to_i)) # todo 数组中包含nil会导致查询失败,无法找到数据
|
140
152
|
.select("educode_sales_businesses.*, schools.name as s_name, schools.id as s_id")
|
141
|
-
|
142
|
-
|
143
|
-
|
153
|
+
|
154
|
+
@count = @businesses.count("educode_sales_businesses.id")
|
155
|
+
@businesses = @businesses.page(params[:page]).per(10)
|
144
156
|
render json: {
|
145
157
|
data: @businesses,
|
146
|
-
code: 0
|
147
|
-
count: @businesses.total_count / 10
|
158
|
+
code: 0
|
148
159
|
}
|
149
160
|
end
|
150
161
|
end
|
@@ -157,20 +168,34 @@ module EducodeSales
|
|
157
168
|
render layout: false
|
158
169
|
end
|
159
170
|
format.json do
|
171
|
+
shixuns = BusinessSubjectShixun
|
172
|
+
if params[:id].present?
|
160
173
|
business_deliver = BusinessDeliverSubject.find_by(id: params[:id])
|
174
|
+
shixuns = BusinessSubjectShixun.joins(:shixun, business_subject: [:business_deliver_subject, :subject]).left_joins(:last_dectect).where("educode_sales_business_deliver_subjects.id = #{business_deliver.id }")
|
175
|
+
elsif params[:subject_id].present?
|
176
|
+
shixuns = BusinessSubjectShixun.joins(:shixun, business_subject: [:business_deliver_subject, :subject]).left_joins(:last_dectect).where("educode_sales_business_subjects.id = #{params[:subject_id] }")
|
177
|
+
end
|
161
178
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
179
|
+
if params[:q].present? && params[:q][:shixun_name].present?
|
180
|
+
shixuns = shixuns.where("shixuns.name like '%#{params[:q][:shixun_name]}%'")
|
181
|
+
end
|
182
|
+
if params[:q].present? && params[:q][:subject_name].present?
|
183
|
+
shixuns = shixuns.where("subjects.name like '%#{params[:q][:subject_name]}%'")
|
184
|
+
end
|
185
|
+
shixuns = shixuns.search_category(params[:q][:category]) if params[:q].present?
|
186
|
+
shixuns = shixuns.search_status(params[:q][:status]) if params[:q].present?
|
187
|
+
shixuns = shixuns.search_level(params[:q][:level]) if params[:q].present?
|
188
|
+
@count = shixuns.count
|
189
|
+
|
190
|
+
@shixuns = shixuns.select("educode_sales_business_subject_shixuns.*, shixuns.name s_name, shixuns.identifier s_identifier,
|
191
|
+
subjects.name as subjects_name,subjects.identifier as subjects_identifier,
|
192
|
+
educode_sales_shixun_dectects.content dectect_content, educode_sales_shixun_dectects.date dectect_time ")
|
193
|
+
.page(params[:page]).per(params[:limit])
|
169
194
|
end
|
195
|
+
end
|
170
196
|
end
|
171
197
|
|
172
|
-
|
173
|
-
def list_subjects # todo 接口该为 list_subjects
|
198
|
+
def list_subjects
|
174
199
|
respond_to do |format|
|
175
200
|
format.html do
|
176
201
|
render layout: false
|
@@ -181,28 +206,28 @@ module EducodeSales
|
|
181
206
|
|
182
207
|
# subject.status => :0 编辑中 1 审核中 2 发布
|
183
208
|
# public: 2: 公开
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
# todo 搜索 subjects.where("subjects.字段 = x") # 不需要单位搜索
|
209
|
+
subjects = BusinessSubject.joins("INNER JOIN subjects bs ON bs.id = educode_sales_business_subjects.subject_id
|
210
|
+
INNER JOIN educode_sales_business_deliver_subjects e_s_b_d_s ON educode_sales_business_subjects.business_deliver_subject_id = e_s_b_d_s.id and e_s_b_d_s.id = #{bussiness_deliver_id}
|
211
|
+
INNER JOIN educode_sales_businesses esb ON esb.id = educode_sales_business_subjects.business_id
|
212
|
+
LEFT JOIN educode_sales_follow_ups fu ON fu.id = esb.last_follow_up_id
|
213
|
+
")
|
190
214
|
|
191
215
|
# 搜索条件
|
192
216
|
if params[:q].present? && params[:q][:name].present?
|
193
|
-
subjects = subjects.where("
|
217
|
+
subjects = subjects.where("bs.name like '%#{params[:q][:name]}%'")
|
194
218
|
end
|
195
219
|
if params[:q].present? && params[:q][:p_state].present?
|
196
220
|
status = params[:q][:p_state].to_i
|
197
|
-
if status
|
198
|
-
subjects = subjects.where("
|
221
|
+
if status == 1
|
222
|
+
subjects = subjects.where("bs.public = #{status}")
|
223
|
+
elsif [0, 2].include? status
|
224
|
+
subjects = subjects.where("bs.status = #{status} and public not in (1,2) ")
|
199
225
|
else
|
200
|
-
subjects = subjects.where("
|
226
|
+
subjects = subjects.where("bs.public = 2")
|
201
227
|
end
|
202
228
|
end
|
203
|
-
@subjects = subjects.
|
204
|
-
|
205
|
-
@url = "https://test.educoder.net/paths/"
|
229
|
+
@subjects = subjects.includes(business_subject_shixuns: :shixun).select("educode_sales_business_subjects.*, bs.identifier, bs.status status, bs.name name, bs.public, IFNULL(fu.reception_at, '--') reception_at").page(params[:page]).per(params[:limit])
|
230
|
+
|
206
231
|
end
|
207
232
|
end
|
208
233
|
|
@@ -296,28 +296,28 @@ module EducodeSales
|
|
296
296
|
|
297
297
|
if params[:q].present? && params[:q][:date].present?
|
298
298
|
date = params[:q][:date].split(" - ")
|
299
|
-
@businesses = @businesses.where("educode_sales_businesses.created_at
|
299
|
+
@businesses = @businesses.where("educode_sales_businesses.created_at >= ? AND educode_sales_businesses.created_at <= ?", date[0] + ' 00:00:00', date[1] + ' 23:59:59')
|
300
300
|
end
|
301
301
|
|
302
302
|
if params[:q].present? && params[:q][:invitation_at].present?
|
303
303
|
date = params[:q][:invitation_at].split(" - ")
|
304
304
|
@businesses = @businesses.joins("
|
305
305
|
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
306
|
-
").where("educode_sales_follow_ups.invitation_at
|
306
|
+
").where("educode_sales_follow_ups.invitation_at >= ? AND educode_sales_follow_ups.invitation_at <= ?", date[0] + ' 00:00:00', date[1] + ' 23:59:59')
|
307
307
|
end
|
308
308
|
|
309
309
|
if params[:q].present? && params[:q][:plan_return_date].present?
|
310
310
|
date = params[:q][:plan_return_date].split(" - ")
|
311
311
|
@businesses = @businesses.joins("
|
312
312
|
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
313
|
-
").where("educode_sales_follow_ups.plan_return_date
|
313
|
+
").where("educode_sales_follow_ups.plan_return_date >= ? AND educode_sales_follow_ups.plan_return_date <= ?", date[0] + ' 00:00:00', date[1] + ' 23:59:59')
|
314
314
|
end
|
315
315
|
|
316
316
|
if params[:q].present? && params[:q][:plan_a_date].present?
|
317
317
|
date = params[:q][:plan_a_date].split(" - ")
|
318
318
|
@businesses = @businesses.joins("
|
319
319
|
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
320
|
-
").where("educode_sales_follow_ups.plan_a_date
|
320
|
+
").where("educode_sales_follow_ups.plan_a_date >= ? AND educode_sales_follow_ups.plan_a_date <= ?", date[0] + ' 00:00:00', date[1] + ' 23:59:59')
|
321
321
|
end
|
322
322
|
|
323
323
|
# 根据编号获取商机
|
@@ -345,7 +345,7 @@ module EducodeSales
|
|
345
345
|
elsif params[:q][:source_way] == '渠道代理'
|
346
346
|
sourcable_id = EducodeSales::Place.where("name like ?", "%#{params[:q][:source_name]}%").limit(20).pluck(:id)
|
347
347
|
elsif params[:q][:source_way] == '客户'
|
348
|
-
sourcable_id =
|
348
|
+
sourcable_id = Department.where("name like ?", "%#{params[:q][:source_name]}%").limit(20).pluck(:id)
|
349
349
|
end
|
350
350
|
|
351
351
|
if sourcable_id.present?
|
@@ -484,7 +484,7 @@ module EducodeSales
|
|
484
484
|
elsif params[:source_way] == '渠道代理'
|
485
485
|
params[:sourcable_type] = 'EducodeSales::Place'
|
486
486
|
elsif params[:source_way] == '客户'
|
487
|
-
params[:sourcable_type] = '
|
487
|
+
params[:sourcable_type] = 'Department'
|
488
488
|
else
|
489
489
|
params[:sourcable_id] = ""
|
490
490
|
end
|
@@ -572,7 +572,7 @@ module EducodeSales
|
|
572
572
|
elsif params[:source_way] == '渠道代理'
|
573
573
|
params[:sourcable_type] = 'EducodeSales::Place'
|
574
574
|
elsif params[:source_way] == '客户'
|
575
|
-
params[:sourcable_type] = '
|
575
|
+
params[:sourcable_type] = 'Department'
|
576
576
|
else
|
577
577
|
params[:sourcable_id] = ""
|
578
578
|
end
|
@@ -889,6 +889,42 @@ module EducodeSales
|
|
889
889
|
@businesses = @businesses.where(id: my_ids)
|
890
890
|
end
|
891
891
|
|
892
|
+
if params[:is_area].present?
|
893
|
+
# 区域管理商机
|
894
|
+
# 排查看区域商机,需要排除掉其它人员手上的监管学校
|
895
|
+
other_staff_school_id = EducodeSales::StaffSchool.where.not(staff_id: @current_admin.id).where("school_id IN (SELECT school_id FROM educode_sales_staff_schools WHERE staff_id = #{@current_admin.id}) IS NOT TRUE").distinct.pluck :school_id
|
896
|
+
|
897
|
+
school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id) + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id) - other_staff_school_id
|
898
|
+
@businesses = Business.joins("JOIN departments AS dp ON educode_sales_businesses.department_id = dp.id").where("dp.school_id in (?)", school_ids)
|
899
|
+
end
|
900
|
+
|
901
|
+
if params[:special].present?
|
902
|
+
# 专项商机
|
903
|
+
school_tag_ids = @current_admin.staff_school_tags.pluck(:school_tag_id)
|
904
|
+
school_ids = SchoolTagMiddle.where(school_tag_id: school_tag_ids).pluck(:school_id)
|
905
|
+
@businesses = Business.joins("JOIN departments AS dp ON educode_sales_businesses.department_id = dp.id").where("dp.school_id in (?)", school_ids)
|
906
|
+
end
|
907
|
+
|
908
|
+
if params[:delete_list].present?
|
909
|
+
@businesses = Business.unscoped.where(state_id: [1, 3])
|
910
|
+
end
|
911
|
+
|
912
|
+
if params[:plan_year].present?
|
913
|
+
if @current_admin.is_admin?
|
914
|
+
@businesses = Business
|
915
|
+
else
|
916
|
+
# 年度计划,按负责区域和专项客户类型查看对应的年度商机
|
917
|
+
school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id) + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
|
918
|
+
if @current_admin.staff_school_tags.present?
|
919
|
+
# 如果设置专项客户类型,则视为专项经理,根据专项客户查看对应商机
|
920
|
+
school_ids += School.joins(:school_tags).where("school_tags.id in (?)", @current_admin.staff_school_tags.pluck(:school_tag_id)).pluck(:id)
|
921
|
+
end
|
922
|
+
@businesses = Business.joins("JOIN departments ON educode_sales_businesses.department_id = departments.id").where("departments.school_id in (?) ", school_ids.uniq)
|
923
|
+
end
|
924
|
+
|
925
|
+
@businesses = @businesses.joins(:last_follow_up).where("educode_sales_follow_ups.plan_a_date > :year OR educode_sales_follow_ups.plan_return_date > :year OR educode_sales_follow_ups.invitation_at > :year", year: Time.now.beginning_of_year)
|
926
|
+
end
|
927
|
+
|
892
928
|
@businesses = @businesses
|
893
929
|
if params[:name].present? # && params[:name] != "(销售态势-" + @year + "-已中标商机)" && params[:name] != "(销售态势-" + @year + "-已签单商机)" && params[:name] != "(销售态势-" + @year + "-已回款商机)" && params[:name] != "(销售态势-" + @year + "-现有商机)"&& params[:name] != "(销售态势-" + @year + "-应收款商机)"
|
894
930
|
@businesses = @businesses.where("educode_sales_businesses.name like ?", "%#{params[:name]}%")
|
@@ -32,6 +32,9 @@ module EducodeSales
|
|
32
32
|
gon.business_step = Common.where(clazz: 'business_step', name: ['已中标', '已签单', '已验收', '回款中', '服务中', '已结束']).order("position").map do |d|
|
33
33
|
{value: d.id, name: d.name, selected: business_step.include?(d.name)}
|
34
34
|
end
|
35
|
+
if params[:date_at].present? && params[:date_at] != '全部'
|
36
|
+
gon.bidded_date = Time.new(params[:date_at]).beginning_of_year.strftime("%Y-%m-%d") + " - " + Time.new(params[:date_at]).end_of_year.strftime("%Y-%m-%d")
|
37
|
+
end
|
35
38
|
end
|
36
39
|
format.json do
|
37
40
|
@businesses = Business
|
@@ -279,6 +282,9 @@ module EducodeSales
|
|
279
282
|
@staffs = staffs.map { |d| [d.user.real_name, d.id]}
|
280
283
|
role = Role.find_by(name: '售后工程师')
|
281
284
|
@after_sales_staffs = Staff.joins(:user).where(role_id: role.id).map { |d| [d.user.real_name, d.id]}
|
285
|
+
if params[:date_at].present? && params[:date_at] != '全部'
|
286
|
+
gon.bidded_date = Time.new(params[:date_at]).beginning_of_year.strftime("%Y-%m-%d") + " - " + Time.new(params[:date_at]).end_of_year.strftime("%Y-%m-%d")
|
287
|
+
end
|
282
288
|
end
|
283
289
|
|
284
290
|
def new_follow_up
|
@@ -14,6 +14,10 @@ module EducodeSales
|
|
14
14
|
gon.staff_id = @current_admin.id
|
15
15
|
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
16
16
|
gon.staffs = Staff.joins(:user).where(job_type: common.id).where.not(role_id: 11).map { |d| {name: d.user.real_name, value: d.id } }
|
17
|
+
|
18
|
+
if params[:date_at].present? && params[:date_at] != '全部'
|
19
|
+
gon.date = Time.new(params[:date_at]).beginning_of_year.strftime("%Y-%m-%d") + " - " + Time.new(params[:date_at]).end_of_year.strftime("%Y-%m-%d")
|
20
|
+
end
|
17
21
|
end
|
18
22
|
format.json do
|
19
23
|
@money_plan_records = MoneyPlanRecord.left_joins(:money_plan_claims).group("educode_sales_money_plan_records.id").select("educode_sales_money_plan_records.*, COUNT(educode_sales_money_plan_claims.id) AS claim_num")
|
@@ -45,7 +49,7 @@ module EducodeSales
|
|
45
49
|
|
46
50
|
if params[:q].present? && params[:q][:date_at].present?
|
47
51
|
date = params[:q][:date_at].split(" - ")
|
48
|
-
@money_plan_records = @money_plan_records.where("date_at BETWEEN ? AND ?", date[0], date[1])
|
52
|
+
@money_plan_records = @money_plan_records.where("date_at BETWEEN ? AND ?", date[0] + ' 00:00:00', date[1] + ' 23:59:59')
|
49
53
|
end
|
50
54
|
if params[:q].present? && params[:q][:state].present?
|
51
55
|
if params[:q][:state] == '已认领'
|
@@ -207,7 +211,7 @@ module EducodeSales
|
|
207
211
|
# money.save
|
208
212
|
# end
|
209
213
|
# 上次的回款计划的跟进也要同步到最新的跟进id,不然回款计划列表会找不到
|
210
|
-
EducodeSales::MoneyPlan.where(business_id: d.id,
|
214
|
+
EducodeSales::MoneyPlan.where(business_id: d.id, follow_up_id: last_follow_up.id).update_all(follow_up_id: follow_up.id)
|
211
215
|
|
212
216
|
# 合同里签到日期全同步到最新跟进
|
213
217
|
last_follow_up.contract_date_lists.update_all(follow_up_id: follow_up.id)
|
@@ -80,6 +80,9 @@ module EducodeSales
|
|
80
80
|
gon.edit_money_plan = can?(:update, EducodeSales::MoneyPlan)
|
81
81
|
gon.edit_money_plan_self = can?(:update_self, EducodeSales::MoneyPlan)
|
82
82
|
gon.staff_id = @current_admin.id
|
83
|
+
if params[:date_at].present? && params[:date_at] != '全部'
|
84
|
+
gon.date = Time.new(params[:date_at]).beginning_of_year.strftime("%Y-%m-%d") + " - " + Time.new(params[:date_at]).end_of_year.strftime("%Y-%m-%d")
|
85
|
+
end
|
83
86
|
end
|
84
87
|
|
85
88
|
end
|
@@ -943,7 +943,7 @@ module EducodeSales
|
|
943
943
|
staff_id = params[:staff_id] || nil
|
944
944
|
@forecast_count_range = params[:forecast_count_range] || "month"
|
945
945
|
forecast_default_dates = ("#{Time.now.year}-01-01".to_date.."#{Time.now.year}-#{Time.now.month}-01".to_date).map { |d| d.strftime("%Y-%m") }.uniq
|
946
|
-
sale_names = %w[
|
946
|
+
sale_names = %w[计划回款额 计划回款额-全部 实际回款额 实际回款额-累计 计划回款额-O类]
|
947
947
|
case @forecast_count_range
|
948
948
|
when "week"
|
949
949
|
# 年初第一天周数是0会导致周数重复计算
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# 实践项目管理
|
4
4
|
module EducodeSales
|
5
5
|
class ShixunDectectsController < ApplicationController
|
6
|
-
before_action :subject_members
|
7
|
-
|
6
|
+
before_action :subject_members, :subject_url
|
8
7
|
def index
|
8
|
+
authorize! :checkout, BusinessDeliverSubject
|
9
9
|
respond_to do |format|
|
10
10
|
format.html do
|
11
11
|
end
|
@@ -15,7 +15,7 @@ module EducodeSales
|
|
15
15
|
if params[:q].present? && params[:q][:index].present?
|
16
16
|
index = params[:q][:index].to_i
|
17
17
|
end
|
18
|
-
@shixun_dectects = BusinessSubjectShixun.
|
18
|
+
@shixun_dectects = BusinessSubjectShixun.left_joins(:shixun)
|
19
19
|
.left_joins(:school)
|
20
20
|
.joins(last_dectect: [reviewed_staff: :user])
|
21
21
|
|
@@ -27,17 +27,38 @@ module EducodeSales
|
|
27
27
|
end
|
28
28
|
|
29
29
|
case index
|
30
|
-
when 1 # 显示待审核的
|
31
|
-
@shixun_dectects = @shixun_dectects.where("dectect_type
|
30
|
+
when 1 # 显示待审核的
|
31
|
+
@shixun_dectects = @shixun_dectects.where("dectect_type = 0")
|
32
32
|
|
33
33
|
when 2 # 显示已审核的
|
34
|
-
|
34
|
+
str = 'dectect_type = 1 or dectect_type = 2'
|
35
|
+
if params[:q].present? && params[:q][:dectect_type].present?
|
36
|
+
if params[:q][:dectect_type].to_i == 1
|
37
|
+
str = "dectect_type = 1"
|
38
|
+
elsif params[:q][:dectect_type].to_i == 2
|
39
|
+
str = "dectect_type = 2"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
@shixun_dectects = @shixun_dectects.where(str)
|
35
43
|
else
|
36
44
|
render_failure("操作失败,index只能为1,2")
|
37
45
|
end
|
46
|
+
times = {}
|
47
|
+
BusinessSubjectShixun.includes(business_subject:[ business_deliver_subject: [:manages, business: [:school, last_follow_up: :assign_follow_ups]] ]).find_each do |d|
|
48
|
+
b_d_s = d.business_subject
|
49
|
+
if b_d_s.blank? || b_d_s.business.blank?
|
50
|
+
times.merge!({"#{d.id}": d.deliver_date })
|
51
|
+
elsif b_d_s.business.present?
|
52
|
+
times.merge!({ "#{d.id}": b_d_s.business.last_follow_up.reception_at })
|
53
|
+
end
|
54
|
+
end
|
55
|
+
@times = times.stringify_keys
|
56
|
+
@url
|
38
57
|
@shixun_dectects = @shixun_dectects.select("educode_sales_business_subject_shixuns.*,
|
39
58
|
schools.name as school_name,
|
40
|
-
shixuns.
|
59
|
+
shixuns.identifier,
|
60
|
+
educode_sales_business_subject_shixuns.name as shixun_name,
|
61
|
+
educode_sales_business_subject_shixuns.id as shixuns_id,
|
41
62
|
CONCAT(users.lastname, users.firstname) as real_name,
|
42
63
|
educode_sales_shixun_dectects.dectect_type,
|
43
64
|
educode_sales_shixun_dectects.content")
|
@@ -50,15 +71,24 @@ module EducodeSales
|
|
50
71
|
|
51
72
|
# 审核提交
|
52
73
|
def submit
|
74
|
+
authorize! :checkout, BusinessDeliverSubject
|
53
75
|
respond_to do |format|
|
54
76
|
format.json do
|
55
77
|
ActiveRecord::Base.transaction do
|
56
|
-
@shixuns = ShixunDectect.find_by(business_subject_shixun_id: params[:id])
|
78
|
+
@shixuns = ShixunDectect.order(created_at: :desc).find_by(business_subject_shixun_id: params[:id])
|
57
79
|
if @shixuns.blank?
|
58
80
|
@shixuns = ShixunDectect.create!(business_subject_shixun_id: params[:id],
|
59
81
|
reviewed_id: current_user.id,
|
60
82
|
dectect_type: 0)
|
61
|
-
BusinessSubjectShixun.find(params[:id]).update(shixun_dectect_id: @shixuns.id
|
83
|
+
BusinessSubjectShixun.find(params[:id]).update(shixun_dectect_id: @shixuns.id,
|
84
|
+
shixun_status:4)
|
85
|
+
render_success
|
86
|
+
elsif @shixuns.present? && @shixuns.dectect_type == 'agreed'
|
87
|
+
@shixuns = ShixunDectect.create!(business_subject_shixun_id: params[:id],
|
88
|
+
reviewed_id: current_user.id,
|
89
|
+
dectect_type: 0)
|
90
|
+
BusinessSubjectShixun.find(params[:id]).update(shixun_dectect_id: @shixuns.id,
|
91
|
+
shixun_status:4)
|
62
92
|
render_success
|
63
93
|
else
|
64
94
|
render_failure("已经提交过了")
|
@@ -70,16 +100,43 @@ module EducodeSales
|
|
70
100
|
|
71
101
|
# 通过审核
|
72
102
|
def examine
|
103
|
+
authorize! :checkout, BusinessDeliverSubject
|
73
104
|
ActiveRecord::Base.transaction do
|
74
105
|
if params[:id].present? && params[:type].present?
|
75
106
|
business_subject_shixun = BusinessSubjectShixun.find(params[:id])
|
76
|
-
if business_subject_shixun.present?
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
107
|
+
if business_subject_shixun.present? && business_subject_shixun.last_dectect.present?
|
108
|
+
|
109
|
+
shixun_dectect = business_subject_shixun.last_dectect
|
110
|
+
.update(reviewed_id: current_user.id,
|
111
|
+
date: Time.now,
|
112
|
+
content: params[:content].gsub(/\r\n?/, "\n").strip,
|
113
|
+
business_subject_shixun_id: params[:id],
|
114
|
+
dectect_type: params[:type].to_i)
|
115
|
+
if params[:type].to_i == 2
|
116
|
+
business_subject_shixun.update( shixun_status: 5)
|
117
|
+
elsif params[:type].to_i == 1
|
118
|
+
# 审核通过
|
119
|
+
business_subject_shixun.update( shixun_status: 9)
|
120
|
+
end
|
121
|
+
arrs = []
|
122
|
+
user_list = business_subject_shixun.all_staff.map{ |item| item.id}
|
123
|
+
|
124
|
+
user_list.each do |item|
|
125
|
+
attr = {
|
126
|
+
user_id: item,
|
127
|
+
trigger_user_id: 0,
|
128
|
+
container_id: business_subject_shixun.shixun_dectect_id.to_i,
|
129
|
+
container_type: 'EducodeSales::ShixunDectect',
|
130
|
+
tiding_type: "Project",
|
131
|
+
belong_container_type: "User",
|
132
|
+
belong_container_id: item,
|
133
|
+
created_at: Time.now,
|
134
|
+
updated_at: Time.now
|
135
|
+
}
|
136
|
+
arrs << attr
|
137
|
+
end
|
138
|
+
Tiding.create!(arrs)
|
139
|
+
|
83
140
|
end
|
84
141
|
render_success
|
85
142
|
else
|
@@ -91,13 +148,16 @@ module EducodeSales
|
|
91
148
|
# 审核拒绝通过
|
92
149
|
|
93
150
|
def edit
|
151
|
+
authorize! :checkout, BusinessDeliverSubject
|
94
152
|
render layout: false
|
95
153
|
end
|
96
154
|
|
97
155
|
def update
|
156
|
+
authorize! :checkout, BusinessDeliverSubject
|
98
157
|
end
|
99
158
|
|
100
159
|
def new
|
160
|
+
authorize! :checkout, BusinessDeliverSubject
|
101
161
|
render layout: false
|
102
162
|
end
|
103
163
|
|
@@ -105,6 +165,7 @@ module EducodeSales
|
|
105
165
|
end
|
106
166
|
|
107
167
|
def markdown
|
168
|
+
authorize! :checkout, BusinessDeliverSubject
|
108
169
|
render layout: false
|
109
170
|
end
|
110
171
|
end
|