educode_sales 0.8.1 → 0.8.4
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/application_controller.rb +8 -18
- data/app/controllers/educode_sales/assessments_controller.rb +51 -57
- data/app/controllers/educode_sales/businesses_controller.rb +13 -6
- data/app/controllers/educode_sales/follow_ups_controller.rb +1 -1
- data/app/controllers/educode_sales/money_plans_controller.rb +0 -2
- data/app/models/educode_sales/filter.rb +1 -7
- data/app/models/educode_sales/follow_up.rb +8 -0
- data/app/views/educode_sales/assessments/_setup.html.erb +181 -188
- data/app/views/educode_sales/businesses/edit_follow_record.html.erb +13 -0
- data/app/views/educode_sales/businesses/index.html.erb +211 -184
- data/app/views/educode_sales/businesses/index.json.jbuilder +6 -0
- data/app/views/educode_sales/businesses/new_follow_record.html.erb +17 -3
- data/app/views/educode_sales/businesses/show_follow.html.erb +6 -3
- data/app/views/educode_sales/businesses/show_follow.json.jbuilder +7 -0
- data/app/views/educode_sales/businesses/show_follow_record.html.erb +15 -5
- data/app/views/educode_sales/money_plans/index.json.jbuilder +1 -1
- data/db/migrate/20220509073936_update_educode_sales_filters_filter_data.rb +9 -0
- data/db/migrate/20220512031715_add_column_o_business_deployment_to_follow_ups.rb +5 -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: e81ffa1210f4f5cf1b6a1fbed46e14c1e2b48ceadf4d3ddbd783e99105d6f0c5
|
4
|
+
data.tar.gz: 2a72d7ccfbdc57d17da213dfd434413d240db5f875e7dbe93ee4c39999fb3060
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d41222b3cb5afb884164c80fd17f5ce9c2babd2fd8130a21099388d8bfe891972d76519216d06d7be6aad9ec459490ad1bd6c17353c077ad242980557833f42a
|
7
|
+
data.tar.gz: aec876dddf899182e2f5e43fa5adb136d55e9db1864842ce7da6d151b73e99c7325098d6388044fe50648dfa5da0c3f14818917b49a7233c7027bd93fd77f8b2
|
@@ -28,25 +28,15 @@ module EducodeSales
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def filter
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
a = a + d + ','
|
31
|
+
params[:check] = params[:check] == "true" ? 0:1
|
32
|
+
begin
|
33
|
+
filter = Filter.find_or_create_by!(staff_id: @current_admin.id, clazz: params[:type])
|
34
|
+
filter.extras["#{params[:name]}"] = params[:check]
|
35
|
+
filter.save!
|
36
|
+
render json: {success: true ,hidden: params[:check]}
|
37
|
+
rescue => e
|
38
|
+
render_failure("操作失败")
|
41
39
|
end
|
42
|
-
if b.include?(params[:name]) == false
|
43
|
-
p "include"
|
44
|
-
a = a + params[:name] + params[:hidden]
|
45
|
-
p a
|
46
|
-
end
|
47
|
-
filter.filter_data = a
|
48
|
-
filter.save
|
49
|
-
render_success
|
50
40
|
end
|
51
41
|
|
52
42
|
|
@@ -18,19 +18,16 @@ module EducodeSales
|
|
18
18
|
gon.staff_ids = Staff.joins(:user).where(job_type: common.id).map do |d|
|
19
19
|
{value: d.id, name: d.user.real_name }
|
20
20
|
end
|
21
|
-
filter = Filter.find_or_create_by(staff_id: @current_admin.id,
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
gon.filter["#{m}"] = d[-1].to_i # 前端的hide注意时int类型 string类型 获取不到
|
21
|
+
filter = Filter.find_or_create_by(staff_id: @current_admin.id, clazz: "assessments_setup")
|
22
|
+
if filter.extras.present?
|
23
|
+
gon.filter = filter.extras
|
24
|
+
else
|
25
|
+
gon.filter = {}
|
27
26
|
end
|
28
|
-
# p gon.filter
|
29
|
-
# gon.filter2 = {:username => false }
|
30
|
-
# gon.filter3 = '1'
|
31
|
-
# p gon.filter
|
32
27
|
end
|
33
28
|
format.json do
|
29
|
+
@year2 = params[:q]&[:assessment_year] || '2022'
|
30
|
+
p @year2
|
34
31
|
@year = params[:q].present? && params[:q][:assessment_year].present? ? params[:q][:assessment_year]:'2022'
|
35
32
|
@assessments_id = params[:q].present? && params[:q][:assessment_id].present? ? params[:q][:assessment_id]: '1'
|
36
33
|
@assessments = AssessmentsSetting.where("assessment_year >= ? and assessment_year <= ?", "#{@year}-01-01 00:00:00".to_date, "#{@year}-12-31 23:59:00".to_date)
|
@@ -45,18 +42,18 @@ module EducodeSales
|
|
45
42
|
# 新增
|
46
43
|
def create
|
47
44
|
begin
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
assessment = AssessmentsSetting.new(params_create)
|
46
|
+
assessment.user_id = current_user.user_id
|
47
|
+
assessment.assessment_year = "#{params[:assessment_year]}-01-01"
|
48
|
+
AssessmentsSetting.transaction do
|
52
49
|
params[:staffs_ids].split(",").each do |d|
|
53
|
-
staff =
|
50
|
+
staff = assessment.dup
|
54
51
|
staff.staff_id = d.to_i
|
55
52
|
staff.save
|
56
53
|
end
|
57
54
|
end
|
58
55
|
render_success
|
59
|
-
rescue
|
56
|
+
rescue => e
|
60
57
|
render_failure '增加数据错误'
|
61
58
|
end
|
62
59
|
end
|
@@ -96,7 +93,7 @@ module EducodeSales
|
|
96
93
|
assessment = AssessmentsSetting.find(params[:id])
|
97
94
|
assessment.destroy
|
98
95
|
render_success
|
99
|
-
rescue
|
96
|
+
rescue => e
|
100
97
|
render_failure '暂不能删除'
|
101
98
|
end
|
102
99
|
end
|
@@ -170,14 +167,13 @@ module EducodeSales
|
|
170
167
|
@staff_ids.each do |d|
|
171
168
|
# 注意
|
172
169
|
businesses = @businesses.where(staff_id: d)
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
b << {value: m.actual_amount.to_i, date:m.signed_date.to_s[5..6].to_i}
|
170
|
+
data_count=[]
|
171
|
+
data_list = FollowUp.joins("JOIN educode_sales_businesses ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id")
|
172
|
+
.where("educode_sales_businesses.id in (?)",businesses.pluck(:id)).map do |m|
|
173
|
+
{value: m.actual_amount.to_i, date:m.signed_date.to_s[5..6].to_i}
|
178
174
|
end
|
179
|
-
count_data(
|
180
|
-
update_assessments_progress(
|
175
|
+
count_data(data_list,data_count) # 统计数据
|
176
|
+
update_assessments_progress(data_count,d) # 批量更新assessment数据 事物 一个commit
|
181
177
|
end
|
182
178
|
end
|
183
179
|
|
@@ -198,20 +194,19 @@ module EducodeSales
|
|
198
194
|
b_ids = Business.where(school_id: school_ids).pluck(:last_follow_up_id)
|
199
195
|
ids = a_ids + b_ids
|
200
196
|
@money_plans = MoneyPlan.joins(:follow_up).where(follow_up_id: ids)
|
201
|
-
|
197
|
+
else
|
202
198
|
@money_plans = MoneyPlan.joins(:follow_up).where(follow_up_id: follow_up_ids)
|
203
199
|
end
|
204
200
|
end
|
205
201
|
# todo 1 :实际回款 0:计划回款 where(clazz: 1 OR 实际回款 )
|
206
202
|
@money_plans = @money_plans.where(clazz: 1).where.not(date_at: nil)
|
207
203
|
@staff_ids.each do |d|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
b << {date:m.date_at.to_s[5..6].to_i, value:m.amount.to_i}
|
204
|
+
data_count = []
|
205
|
+
data_list = @money_plans.where(staff_id: d).map do |m|
|
206
|
+
{date:m.date_at.to_s[5..6].to_i, value:m.amount.to_i}
|
212
207
|
end
|
213
|
-
count_data(
|
214
|
-
update_assessments_progress(
|
208
|
+
count_data(data_list,data_count)
|
209
|
+
update_assessments_progress(data_count, d)
|
215
210
|
end
|
216
211
|
end
|
217
212
|
|
@@ -247,20 +242,20 @@ module EducodeSales
|
|
247
242
|
def customer_and_busniness_visits
|
248
243
|
@staff_ids.each do |m|
|
249
244
|
customers = @customers.where(id: EducodeSales::CustomerExtension.where(customer_staff_id: m).pluck(:school_id))
|
250
|
-
|
251
|
-
|
245
|
+
data_list = []
|
246
|
+
data_count = []
|
252
247
|
CustomerFollow.joins(:school).where(school_id: customers.pluck(:id))
|
253
248
|
.where("Educode_Sales_customer_follows.created_at >= ? and Educode_Sales_customer_follows.created_at <= ?","#{@assessment_year}-01-01 ","#{@assessment_year}-12-31 23:59:59" )
|
254
249
|
.each do |d|
|
255
|
-
|
250
|
+
data_list << {value: 1, date: d.created_at.to_s[5..6].to_i}
|
256
251
|
end
|
257
252
|
FollowUp.joins(:business).where("Educode_Sales_businesses.id in (?)",EducodeSales::Business.where(school_id: customers.pluck(:id)).pluck(:id))
|
258
253
|
.where("Educode_Sales_follow_ups.created_at >= ? and Educode_Sales_follow_ups.created_at <= ?","#{@assessment_year}-01-01 00:00:00", "#{@assessment_year}-12-31 23:59:59").each do |d|
|
259
|
-
|
254
|
+
data_list << {date: d.created_at.to_s[5..6].to_i, value: 1}
|
260
255
|
end
|
261
|
-
count_data(
|
256
|
+
count_data(data_list,data_count)
|
262
257
|
assessment = @assessments.where(staff_id: m)
|
263
|
-
update_assessments_progress(
|
258
|
+
update_assessments_progress(data_count, assessment)
|
264
259
|
end
|
265
260
|
end
|
266
261
|
|
@@ -274,13 +269,12 @@ module EducodeSales
|
|
274
269
|
@businesses = @businesses.joins("JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id").where("educode_sales_follow_ups.clazz_id in (?) ",ids)
|
275
270
|
@staff_ids.each do |d|
|
276
271
|
businesses = @businesses.where(staff_id: d)
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
b << {date: m.created_at.to_s[5..6].to_i, value: 1}
|
272
|
+
data_count = []
|
273
|
+
data_list = businesses.map do |m|
|
274
|
+
{date: m.created_at.to_s[5..6].to_i, value: 1}
|
281
275
|
end
|
282
|
-
count_data(
|
283
|
-
update_assessments_progress(
|
276
|
+
count_data(data_list,data_count) # 统计数据
|
277
|
+
update_assessments_progress(data_count, d) # 批量更新assessment数据 事物 一个commit
|
284
278
|
end
|
285
279
|
end
|
286
280
|
|
@@ -309,27 +303,27 @@ module EducodeSales
|
|
309
303
|
|
310
304
|
|
311
305
|
# 更新assessments_settings表中数据
|
312
|
-
def update_assessments_progress(
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
306
|
+
def update_assessments_progress(data_count,staff_id)
|
307
|
+
data_count[12] = data_count[0].to_i + data_count[1].to_i + data_count[2].to_i
|
308
|
+
data_count[13] = data_count[3].to_i + data_count[4].to_i + data_count[5].to_i
|
309
|
+
data_count[14] = data_count[6].to_i + data_count[7].to_i + data_count[8].to_i
|
310
|
+
data_count[15] = data_count[9].to_i + data_count[10].to_i + data_count[11].to_i
|
311
|
+
data_count[16] = data_count[12].to_i + data_count[13].to_i + data_count[14].to_i + data_count[15].to_i
|
318
312
|
# 开启事物 处理 批量修改数据
|
319
313
|
assessments = @assessments.where(staff_id: staff_id)
|
320
|
-
assessments.update(annual_progress:
|
321
|
-
january_progress:
|
322
|
-
july_progress:
|
314
|
+
assessments.update(annual_progress: data_count[16], first_quarter_progress: data_count[12], second_quarter_progress: data_count[13], third_quarter_progress: data_count[14], fourth_quarter_progress: data_count[15],
|
315
|
+
january_progress: data_count[0], february_progress: data_count[1], march_progress: data_count[2], april_progress: data_count[3], may_progress: data_count[4], june_progress: data_count[5],
|
316
|
+
july_progress: data_count[6], august_progress: data_count[7], september_progress: data_count[8], october_progress: data_count[9], november_progress: data_count[10], december_progress: data_count[11])
|
323
317
|
|
324
318
|
end
|
325
319
|
|
326
320
|
# 将统计到的数据转入a中
|
327
|
-
def count_data(
|
328
|
-
|
329
|
-
if
|
330
|
-
|
321
|
+
def count_data(data_list,data_count)
|
322
|
+
data_list.each do |d|
|
323
|
+
if data_count[d[:date]-1].present?
|
324
|
+
data_count[d[:date]-1] = data_count[d[:date]-1] + d[:value]
|
331
325
|
else
|
332
|
-
|
326
|
+
data_count[d[:date]-1] = d[:value]
|
333
327
|
end
|
334
328
|
end
|
335
329
|
end
|
@@ -46,12 +46,11 @@ module EducodeSales
|
|
46
46
|
gon.export_menus << { title: '导出到Excel文件', event: 'export_excel' }
|
47
47
|
end
|
48
48
|
gon.export_menus << { title: '导出记录', event: 'export_records' }
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
gon.business_filter["#{m}"] = d[-1].to_i
|
49
|
+
filter = Filter.find_or_create_by(staff_id: @current_admin.id, clazz: "businesses_list")
|
50
|
+
if filter.extras.present?
|
51
|
+
gon.filter = filter.extras
|
52
|
+
else
|
53
|
+
gon.filter = {}
|
55
54
|
end
|
56
55
|
end
|
57
56
|
format.json do
|
@@ -324,6 +323,7 @@ module EducodeSales
|
|
324
323
|
@o_name = EducodeSales::Common.find_by(extras: EducodeSales::Common::OTYPE)&.name
|
325
324
|
@clazz = Common.where(clazz: 'business_type').order("position").pluck(:name, :id)
|
326
325
|
@stages = Common.where(clazz: 'business_step').order("position").pluck(:name, :id)
|
326
|
+
@deployment_type = EducodeSales::FollowUp::BUSINESS_DEPLOYMENT
|
327
327
|
@places = Place.order("created_at desc").pluck(:name, :id)
|
328
328
|
@last_follow_up = @business.last_follow_up
|
329
329
|
if @last_follow_up
|
@@ -350,6 +350,12 @@ module EducodeSales
|
|
350
350
|
size = ids.size
|
351
351
|
ids = ids.reverse
|
352
352
|
index = ids.index(id)
|
353
|
+
EducodeSales::FollowUp::BUSINESS_DEPLOYMENT[1..-1].each do |m|
|
354
|
+
if @follow_up.o_business_deployment == m[1]
|
355
|
+
@show_follow_recored_deployment = m[0]
|
356
|
+
break
|
357
|
+
end
|
358
|
+
end
|
353
359
|
@next_id = (index != size - 1 && size > 1) ? ids[index + 1] : 0
|
354
360
|
@pre_id = (index != 0 && size > 1) ? ids[index - 1] : 0
|
355
361
|
render layout: false
|
@@ -358,6 +364,7 @@ module EducodeSales
|
|
358
364
|
def edit_follow_record
|
359
365
|
@years = (2015..Time.now.year).to_a.reverse
|
360
366
|
@o_name = EducodeSales::Common.find_by(extras: EducodeSales::Common::OTYPE)&.name
|
367
|
+
@deployment_type = EducodeSales::FollowUp::BUSINESS_DEPLOYMENT
|
361
368
|
@follow_up = FollowUp.find(params[:follow_up_id])
|
362
369
|
@clazz = Common.where(clazz: 'business_type').order("position").pluck(:name, :id)
|
363
370
|
@stages = Common.where(clazz: 'business_step').order("position").pluck(:name, :id)
|
@@ -226,7 +226,7 @@ module EducodeSales
|
|
226
226
|
end
|
227
227
|
|
228
228
|
def follow_up_params
|
229
|
-
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)
|
229
|
+
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, :o_business_deployment)
|
230
230
|
end
|
231
231
|
|
232
232
|
def teacher_params
|
@@ -13,8 +13,6 @@ module EducodeSales
|
|
13
13
|
end
|
14
14
|
format.json do
|
15
15
|
x_id = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
|
16
|
-
p "================================================================================"
|
17
|
-
p x_id
|
18
16
|
if @current_admin.is_admin?
|
19
17
|
@money_plans = MoneyPlan.joins(:follow_up).where("educode_sales_follow_ups.clazz_id != ?", x_id).where(follow_up_id: follow_up_ids)
|
20
18
|
else
|
@@ -1,5 +1,13 @@
|
|
1
1
|
module EducodeSales
|
2
2
|
class FollowUp < ApplicationRecord
|
3
|
+
# todo O类商机特有字段-部署类型(因此不写入common表中)
|
4
|
+
BUSINESS_DEPLOYMENT =[
|
5
|
+
["请选择", nil],
|
6
|
+
["公有云", 1],
|
7
|
+
["私有云", 2],
|
8
|
+
["混合云", 3]
|
9
|
+
]
|
10
|
+
|
3
11
|
include ::Deletable
|
4
12
|
belongs_to :business, counter_cache: true # counter_cache(自动计算 business对应follow_up表中对应的个数)
|
5
13
|
belongs_to :place, optional: true
|