educode_sales 0.9.93 → 0.9.94
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b7b6e63bd6432ce355c059bed56cd08ec327575c300211edfdd7456b47f803e
|
4
|
+
data.tar.gz: 425005691f9b2a971c971468428dc4f4f48e269adba413531e0eafb3e744abcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef43f0359464d39687502f0e5ba43c01855f5c9d9a6c53dc5a360a0ea79d8cb2b916d103e0d99519ff491cd4deb7a2ac9456b2a250b0bcf6c0d884b643168c8e
|
7
|
+
data.tar.gz: 4397b3bef68f798255cccac646cb30f706d0161daa8596f55891b261c0ddd4b93c81c5b4f2b2966856ca970607e02bb6d7a8ba80f4237447967c905eb425b65f
|
@@ -166,7 +166,7 @@ module EducodeSales
|
|
166
166
|
respond_to do |format|
|
167
167
|
format.html do
|
168
168
|
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
169
|
-
@staffs = Staff.
|
169
|
+
@staffs = Staff.includes(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id] }
|
170
170
|
gon.school_tags = SchoolTag.where(for_missions: true).map { |d| {value: d.id, name: d.name } }
|
171
171
|
end
|
172
172
|
format.json do
|
@@ -199,7 +199,9 @@ module EducodeSales
|
|
199
199
|
schools.*,
|
200
200
|
s.major_count,
|
201
201
|
s.department_id,
|
202
|
-
departments.name AS department_name
|
202
|
+
departments.name AS department_name,
|
203
|
+
(SELECT COUNT(user_extensions.id) FROM user_extensions WHERE user_extensions.department_id = s.department_id AND user_extensions.identity = 0) AS teacher_count,
|
204
|
+
(SELECT COUNT(user_extensions.id) FROM user_extensions WHERE user_extensions.department_id = s.department_id AND user_extensions.identity = 1) AS student_count
|
203
205
|
").joins("
|
204
206
|
JOIN schools ON s.id = schools.id
|
205
207
|
LEFT JOIN departments ON s.department_id = departments.id
|
@@ -1,16 +1,28 @@
|
|
1
1
|
x = EducodeSales::Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
|
2
2
|
o = EducodeSales::Common.find_by(extras: EducodeSales::Common::OTYPE)&.id
|
3
|
+
business_ids_group_a = EducodeSales::Business.where(department_id: @customers.map(&:department_id)).group_by(&:department_id)
|
4
|
+
business_ids_group_b = EducodeSales::Business.where(school_id: @customers.map(&:id)).group_by(&:school_id)
|
5
|
+
all_follow_ups = EducodeSales::FollowUp.where(business_id: business_ids_group_a.values.flatten.map(&:id) + business_ids_group_b.values.flatten.map(&:id))
|
6
|
+
customer_follows_a = EducodeSales::CustomerFollow.where(department_id: @customers.map(&:department_id)).group_by(&:department_id)
|
7
|
+
customer_follows_b = EducodeSales::CustomerFollow.where(school_id: @customers.map(&:id)).group_by(&:school_id)
|
8
|
+
all_school_tags = SchoolTag.joins(:school_tag_middles).where(school_tag_middles: { school_id: @customers.map(&:id) }).select(:school_id, :name, :for_missions)
|
9
|
+
business_count_group_a = EducodeSales::Business.where(department_id: @customers.map(&:department_id)).group(:department_id).count
|
10
|
+
business_count_group_b = EducodeSales::Business.where(school_id: @customers.map(&:id)).group(:school_id).count
|
11
|
+
o_business_count_group_a = EducodeSales::Business.where(department_id: @customers.map(&:department_id)).where("educode_sales_businesses.clazz_id = ?", o).group(:department_id).count
|
12
|
+
o_business_count_group_b = EducodeSales::Business.where(school_id: @customers.map(&:id)).where("educode_sales_businesses.clazz_id = ?", o).group(:school_id).count
|
13
|
+
all_staffs_group = EducodeSales::CustomerExtension.where(school_id: @customers.map(&:id)).includes(customer_staff: :user).group_by(&:school_id)
|
14
|
+
|
3
15
|
json.data do
|
4
16
|
json.array! @customers do |d|
|
5
17
|
if d['department_id']
|
6
|
-
business_ids =
|
7
|
-
customer_follows =
|
18
|
+
business_ids = business_ids_group_a[d['department_id']]&.map(&:id) || []
|
19
|
+
customer_follows = customer_follows_a[d['department_id']] || []
|
8
20
|
else
|
9
|
-
business_ids =
|
10
|
-
customer_follows =
|
21
|
+
business_ids = business_ids_group_b[d.id]&.map(&:id) || []
|
22
|
+
customer_follows = customer_follows_b[d.id] || []
|
11
23
|
end
|
12
|
-
follow_ups =
|
13
|
-
|
24
|
+
follow_ups = all_follow_ups.select { |f| business_ids&.include?(f.business_id) }
|
25
|
+
|
14
26
|
a_last_follow_time = follow_ups.last&.created_at&.to_s
|
15
27
|
b_last_follow_time = customer_follows.last&.created_at&.to_s
|
16
28
|
if a_last_follow_time.present? && b_last_follow_time.present?
|
@@ -21,24 +33,23 @@ json.data do
|
|
21
33
|
json.id d.id
|
22
34
|
json.name d.name
|
23
35
|
json.area d.province
|
24
|
-
json.property d.
|
36
|
+
json.property all_school_tags.select { |t| t.school_id == d.id && t.for_missions? }.pluck(:name).join("、")
|
25
37
|
if d['department_id']
|
26
|
-
json.business
|
27
|
-
json.o_business
|
38
|
+
json.business business_count_group_a[d['department_id']] || 0
|
39
|
+
json.o_business o_business_count_group_a[d['department_id']] || 0
|
28
40
|
else
|
29
|
-
json.business
|
30
|
-
json.o_business
|
41
|
+
json.business business_count_group_b[d.id] || 0
|
42
|
+
json.o_business o_business_count_group_b[d.id] || 0
|
31
43
|
end
|
32
44
|
json.unit "#{d.name}---#{d['department_name']}"
|
33
|
-
|
34
|
-
# json.follow follow_ups.size + customer_follows.size
|
45
|
+
|
35
46
|
json.follow customer_follows.size
|
36
|
-
json.staff
|
47
|
+
json.staff all_staffs_group[d.id]&.map { |d| d.customer_staff&.user&.real_name }&.join("、")
|
37
48
|
json.department d['department_name'] || ''
|
38
49
|
json.major_count d['major_count']
|
39
50
|
json.department_id d['department_id'] || ''
|
40
|
-
json.teacher_counts
|
41
|
-
json.student_counts
|
51
|
+
json.teacher_counts d['teacher_count']
|
52
|
+
json.student_counts d['student_count']
|
42
53
|
end
|
43
54
|
end
|
44
55
|
|