educode_sales 0.9.43 → 0.9.45

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: 392c1371a9b0cb569b25de476461924555a2d8b077a2864f1bc33145ae65bc61
4
- data.tar.gz: 250898b5906ea9b92a41eb4bef8b9ecba8e254bcd574d37d4cdc8cdd11f25811
3
+ metadata.gz: 490547dd6002957fc97b49d5944e48b43476036a6f9090689c457ebdf0ad2167
4
+ data.tar.gz: e82a58a5dfdc42d2ad607f6c702a643ed3a91227a42771fdada0034b823340e9
5
5
  SHA512:
6
- metadata.gz: b66b2ee6d89ef9f63bd035843df5c6724bb34108320dbd9c2af6d3706ccc91e5a3af9940bd22eca06779e2f6ecebeb9e816beea8fb78c967cfb620666e45df9d
7
- data.tar.gz: 2d0f88851293f938355a04ed9c8c90dceaf126dd8df3b4cd8a18c675dbd158203132dbd9e3f504c2803c25c4bb3fc57c0086372871bd3b193fc4f3ddc55cba08
6
+ metadata.gz: 42827e0c0a5c605af5bd4ecd2dd4dd82faed892a6697d3c8c684c6d4dd4a3c96e9c67e94e7fe20eedd68c6545dad6ab5a8e66b02f39a3f2048fa8afa0b994f0c
7
+ data.tar.gz: 25005c073e6b4f7bf406d6950907a3fe2a95fb68a14d45ade420a663a31d29795292e168614e61501f48c08e53d8b888ba72adac3fffb05bd299b0121d7a7237
@@ -39,6 +39,7 @@ module EducodeSales
39
39
  format.html do
40
40
  common = Common.find_by(clazz: 'staff_type', name: '销售')
41
41
  @staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id] }
42
+ gon.school_tags = SchoolTag.where(for_missions: true).map { |d| {value: d.id, name: d.name } }
42
43
  end
43
44
  format.json do
44
45
  if @current_admin.is_admin?
@@ -73,34 +74,34 @@ module EducodeSales
73
74
  @customers = @customers.where(id: school_ids)
74
75
  end
75
76
  if params[:q].present? && params[:q][:property].present?
76
- school_property_ids = []
77
77
  property = params[:q][:property].split(",").map(&:to_i)
78
- property.each do |p|
79
- case p
80
- when 0
81
- school_property_ids += SchoolProperty.where(project_985: true).ids
82
- when 1
83
- school_property_ids += SchoolProperty.where(project_211: true).ids
84
- when 2
85
- school_property_ids += SchoolProperty.where(regular_college: true).ids
86
- when 3
87
- school_property_ids += SchoolProperty.where(junior_college: true).ids
88
- when 4
89
- school_property_ids += SchoolProperty.where(secondary_school: true).ids
90
- when 5
91
- school_property_ids += SchoolProperty.where(military_school: true).ids
92
- when 6
93
- school_property_ids += SchoolProperty.where(enterprise: true).ids
94
- when 7
95
- school_property_ids += SchoolProperty.where(mid_school: true).ids
96
- when 8
97
- school_property_ids += SchoolProperty.where(ele_school: true).ids
98
- when 9
99
- school_property_ids += SchoolProperty.where(other: true).ids
100
- else
101
- end
102
- end
103
- @customers = @customers.where(school_property_id: school_property_ids)
78
+ # property.each do |p|
79
+ # case p
80
+ # when 0
81
+ # school_property_ids += SchoolProperty.where(project_985: true).ids
82
+ # when 1
83
+ # school_property_ids += SchoolProperty.where(project_211: true).ids
84
+ # when 2
85
+ # school_property_ids += SchoolProperty.where(regular_college: true).ids
86
+ # when 3
87
+ # school_property_ids += SchoolProperty.where(junior_college: true).ids
88
+ # when 4
89
+ # school_property_ids += SchoolProperty.where(secondary_school: true).ids
90
+ # when 5
91
+ # school_property_ids += SchoolProperty.where(military_school: true).ids
92
+ # when 6
93
+ # school_property_ids += SchoolProperty.where(enterprise: true).ids
94
+ # when 7
95
+ # school_property_ids += SchoolProperty.where(mid_school: true).ids
96
+ # when 8
97
+ # school_property_ids += SchoolProperty.where(ele_school: true).ids
98
+ # when 9
99
+ # school_property_ids += SchoolProperty.where(other: true).ids
100
+ # else
101
+ # end
102
+ # end
103
+ @customers = @customers.joins(:school_tags).where("school_tags.id in (?)", property).distinct
104
+ # @customers = @customers.where(school_property_id: school_property_ids)
104
105
  end
105
106
 
106
107
  if params[:q].present? && params[:q][:date].present?
@@ -127,7 +128,11 @@ module EducodeSales
127
128
  @customers = @customers.where(id: school_ids)
128
129
  end
129
130
 
130
- @customers = @customers.order(id: :desc).page(params[:page]).per(params[:limit])
131
+ if params[:page].present?
132
+ @customers = @customers.order(id: :desc).page(params[:page]).per(params[:limit])
133
+ else
134
+ @customers = @customers.order(id: :desc)
135
+ end
131
136
  end
132
137
  end
133
138
  end
@@ -212,6 +217,36 @@ module EducodeSales
212
217
  render layout: false
213
218
  end
214
219
 
220
+ def batch_update_school_tags
221
+ xlsx = Roo::Spreadsheet.open(params[:file])
222
+ ods = xlsx.sheet(0)
223
+ rows = ods.last_row - 1
224
+ i = 0
225
+ school_tag_hash = SchoolTag.where(for_missions: true).pluck(:name, :id).to_h
226
+ rows.times do |r| #行数
227
+ i += 1
228
+ next unless ods.row(r+1)[0]
229
+ school = School.find_by(name: ods.row(r+1)[0].to_s.strip)
230
+ school_list = EducodeSales::CustomerAdd::SCHOOL_LIST.invert
231
+ if school
232
+ property_names = ods.row(r+1)[2].to_s.strip
233
+ tags = []
234
+ if property_names
235
+ property_names.gsub("、", " ").gsub(",", " ").split(" ").each do |tag|
236
+ if school_tag_hash[tag]
237
+ tags << SchoolTagMiddle.find_or_initialize_by(school_id: school.id, school_tag_id: school_tag_hash[tag])
238
+ end
239
+ end
240
+ end
241
+ school.school_tag_middles = tags
242
+ end
243
+ end
244
+
245
+ SchoolTagMiddle.where(school_id: nil).delete_all
246
+
247
+ render json: { succcess: true}
248
+ end
249
+
215
250
  def update
216
251
  @school = School.find(params[:id])
217
252
  ActiveRecord::Base.transaction do
@@ -235,20 +270,11 @@ module EducodeSales
235
270
  #保存学校标签
236
271
 
237
272
  keys = %w[regular_college junior_college secondary_school military_school other mid_school ele_school enterprise]
238
- names = {
239
- "regular_college" => "本科院校",
240
- "junior_college" => "高职院校",
241
- "secondary_school" => "中职院校",
242
- "military_school" => "军事院校",
243
- "other" => "其他",
244
- "mid_school" => "中学",
245
- "ele_school" => "小学",
246
- "enterprise" => "企业"
247
- }
273
+ names = EducodeSales::CustomerAdd::SCHOOL_LIST
248
274
  property.attributes.each do |key, value|
249
275
  next unless key.in?(keys)
250
276
  next unless value.to_s == "true"
251
- school_tag = SchoolTag.find_by_name(names[key])
277
+ school_tag = SchoolTag.find_by(name: names[key], for_missions: true)
252
278
  if school_tag.present?
253
279
  SchoolTagMiddle.create(school_id: @school.id, school_tag_id: school_tag.id)
254
280
  end
@@ -1,4 +1,15 @@
1
1
  module EducodeSales
2
2
  class CustomerAdd < ApplicationRecord
3
+
4
+ SCHOOL_LIST = {
5
+ "regular_college" => "本科院校",
6
+ "junior_college" => "高职院校",
7
+ "secondary_school" => "中职院校",
8
+ "military_school" => "军事院校",
9
+ "other" => "其他",
10
+ "mid_school" => "中学",
11
+ "ele_school" => "小学",
12
+ "enterprise" => "企业"
13
+ }
3
14
  end
4
15
  end
@@ -496,6 +496,7 @@
496
496
  field: 'budget_amount',
497
497
  width: 105,
498
498
  title: '预算金额',
499
+ totalRow: true,
499
500
  sort: true,
500
501
  hide: gon.filter.budget_amount
501
502
  },
@@ -28,16 +28,21 @@ json.data do
28
28
  json.divide_money d.divide_amount.to_f.round(2)
29
29
  json.budget_amount d.budget_amount.to_f.round(2) #d.follow_ups.where(stage_id: @budget_stage_ids).order("created_at desc").first&.total_amount&.round(2) || 0
30
30
  json.area d.department.school.province
31
- school_property = d.department.school.school_property
32
- property = []
31
+ # school_property = d.department.school.school_property
32
+ # property = []
33
33
 
34
- if school_property.present?
35
- property << '本科地方院校' if school_property.regular_college || school_property.project_985 || school_property.project_211
36
- property << '高职' if school_property.junior_college || school_property.secondary_school
37
- property << '本科军校' if school_property.military_school
38
- property << '企业' if school_property.enterprise
34
+ # if school_property.present?
35
+ # property << '本科地方院校' if school_property.regular_college || school_property.project_985 || school_property.project_211
36
+ # property << '高职' if school_property.junior_college || school_property.secondary_school
37
+ # property << '本科军校' if school_property.military_school
38
+ # property << '企业' if school_property.enterprise
39
+ # end
40
+ if d.department.school
41
+ json.property d.department.school.school_tags.where(for_missions: true).pluck(:name).join("、")
42
+ else
43
+ json.property ''
39
44
  end
40
- json.property property.join("、")
45
+ # json.property d.school.school_property.school_tags.where(for_missions: true).pluck(:name).join("、")#property.join("、")
41
46
  json.sale_way d.last_follow_up&.place&.name.present? ? '渠道' : '直销'
42
47
  json.year d.last_follow_up&.year.to_s
43
48
  json.total_amount d.last_follow_up&.total_amount.to_f.round(2)