educode_sales 1.10.49 → 1.10.59
Sign up to get free protection for your applications and to get access to all the features.
- 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/plans_controller.rb +392 -9
- 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/models/educode_sales/permission.rb +7 -0
- data/app/models/educode_sales/sales_target_history.rb +11 -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/plans/_year_execute.html.erb +293 -0
- data/app/views/educode_sales/plans/_year_target.html.erb +677 -0
- data/app/views/educode_sales/plans/index.html.erb +104 -81
- data/app/views/educode_sales/plans/year_execute.js.erb +1 -0
- data/app/views/educode_sales/plans/year_target.js.erb +1 -0
- data/app/views/educode_sales/plans/year_target.json.jbuilder +48 -0
- data/app/views/educode_sales/plans/years_all_target.json.jbuilder +53 -0
- 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 +2 -2
- data/config/routes.rb +7 -2
- data/db/migrate/20230729085359_create_educode_sales_sales_target_histories.rb +45 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +10 -4
- data/app/views/educode_sales/plans/_target_track.html.erb +0 -178
- data/app/views/educode_sales/plans/target_track.js.erb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e79e3bb70dfa210936c30a10cbf201a4fda9065f8d6243f5404cb18e39f4a6c
|
4
|
+
data.tar.gz: f57a3be46b0e597d85025e1bf97cfeb4851cc2a2f76fe6937692063cbb5a0fde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c166871e6c22988d3811c17cd50c6cbea1aee2c4b76ac1b0c908a8c8accabe29dabb75154415a17ee9342291a501e9479a4016611676bef70a8778cba2c8a2d3
|
7
|
+
data.tar.gz: a856cd0c13fae3647dc01acfb2ddcaf95e7c33a27f9075eaa951e723756491e7928b5c541a2988b683ffd7506a46708a81072bfd44204323cef0c6b1bb42a257
|
@@ -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
|