educode_sales 0.6.0 → 0.6.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/educode_sales/money_plans.png +0 -0
  3. data/app/controllers/educode_sales/businesses_controller.rb +7 -4
  4. data/app/controllers/educode_sales/customers_controller.rb +45 -34
  5. data/app/controllers/educode_sales/follow_ups_controller.rb +1 -1
  6. data/app/controllers/educode_sales/money_plans_controller.rb +64 -0
  7. data/app/controllers/educode_sales/places_controller.rb +5 -1
  8. data/app/controllers/educode_sales/roles_controller.rb +4 -1
  9. data/app/controllers/educode_sales/sale_trends_controller.rb +44 -1
  10. data/app/controllers/educode_sales/staffs_controller.rb +3 -4
  11. data/app/controllers/educode_sales/teachers_controller.rb +13 -2
  12. data/app/models/educode_sales/permission.rb +3 -2
  13. data/app/models/educode_sales/role_area.rb +1 -0
  14. data/app/views/educode_sales/businesses/_follows.html.erb +18 -15
  15. data/app/views/educode_sales/businesses/edit.html.erb +3 -0
  16. data/app/views/educode_sales/businesses/index.html.erb +28 -18
  17. data/app/views/educode_sales/businesses/index.json.jbuilder +1 -0
  18. data/app/views/educode_sales/businesses/show_follow.html.erb +2 -1
  19. data/app/views/educode_sales/businesses/time_line.html.erb +1 -1
  20. data/app/views/educode_sales/customers/edit.html.erb +732 -22
  21. data/app/views/educode_sales/customers/index.html.erb +19 -19
  22. data/app/views/educode_sales/customers/index.json.jbuilder +3 -3
  23. data/app/views/educode_sales/customers/new.html.erb +710 -27
  24. data/app/views/educode_sales/customers/new_department.html.erb +1 -0
  25. data/app/views/educode_sales/customers/show_follow.html.erb +5 -2
  26. data/app/views/educode_sales/customers/show_follow_record.html.erb +5 -4
  27. data/app/views/educode_sales/follow_ups/index.json.jbuilder +1 -0
  28. data/app/views/educode_sales/money_plans/index.html.erb +183 -0
  29. data/app/views/educode_sales/money_plans/index.json.jbuilder +20 -0
  30. data/app/views/educode_sales/places/index.html.erb +64 -0
  31. data/app/views/educode_sales/plans/_monthPlan.html.erb +2 -1
  32. data/app/views/educode_sales/plans/_weekPlan.html.erb +2 -1
  33. data/app/views/educode_sales/roles/edit.html.erb +9 -1
  34. data/app/views/educode_sales/sale_trends/trends.html.erb +93 -13
  35. data/app/views/educode_sales/sale_trends/trends.json.jbuilder +3 -14
  36. data/app/views/educode_sales/sales/index.html.erb +25 -17
  37. data/app/views/educode_sales/sales/index.json.jbuilder +20 -2
  38. data/app/views/educode_sales/sales/operations.json.jbuilder +2 -2
  39. data/app/views/educode_sales/teachers/index.html.erb +4 -11
  40. data/app/views/educode_sales/teachers/index.json.jbuilder +1 -1
  41. data/app/views/layouts/educode_sales/application.html.erb +13 -2
  42. data/config/routes.rb +2 -0
  43. data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +3 -0
  44. data/db/migrate/20211220102720_add_position_to_commons.rb +12 -0
  45. data/db/migrate/20211221075146_add_school_id_to_educode_sales_businesses.rb +8 -0
  46. data/lib/educode_sales/version.rb +1 -1
  47. metadata +8 -2
@@ -5,6 +5,8 @@ businesses_d_count = 0
5
5
  businesses_e_count = 0
6
6
  businesses_o_count = 0
7
7
  school_counts = 0
8
+ follow_school_rates = 0
9
+ follow_department_rates = 0
8
10
  area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
9
11
  json.data do
10
12
  json.array! @staffs do |d|
@@ -38,7 +40,13 @@ json.data do
38
40
  json.goal @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.stage_id in (?)", @x, @step_ids).sum(:total_amount).round(2)
39
41
  json.return_money @businesses.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", @x).where.not("educode_sales_money_plans.clazz!= ?", 1).sum(:amount).round(2)
40
42
  json.school_count school_count
41
- # json.follow_school_counts EducodeSales::CustomerFollow.where(staff_id: d.id).size + EducodeSales::FollowUp.where(staff_id: d.id).size
43
+ follow_school_count = (EducodeSales::CustomerFollow.where(staff_id: d.id).pluck(:school_id) + EducodeSales::Business.where(id: EducodeSales::FollowUp.where(staff_id: d.id).pluck(:business_id).uniq).pluck(:school_id)).uniq.size
44
+ json.follow_school_count follow_school_count
45
+ json.follow_school_counts EducodeSales::CustomerFollow.where(staff_id: d.id).size + EducodeSales::FollowUp.where(staff_id: d.id).size
46
+ follow_school_rate = (follow_school_count!=0 ? school_count.to_f * 100 / follow_school_count : 0).round(2)
47
+ json.follow_school_rate follow_school_rate.to_s + '%'
48
+ follow_department_rate = (follow_school_count!=0 ? school_count.to_f * 110 / follow_school_count : 0).round(2)
49
+ json.follow_department_rate follow_department_rate.to_s + '%'
42
50
  else
43
51
  business_a = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @a_clazz&.id).where("educode_sales_follow_ups.year = ?", @year).count
44
52
  business_b = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @b_clazz&.id).where("educode_sales_follow_ups.year = ?", @year).count
@@ -50,7 +58,13 @@ json.data do
50
58
  json.goal @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.stage_id in (?)", @x, @step_ids).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ?", "#{@year}-01-01", "#{@year}-12-31").sum(:total_amount).round(2)
51
59
  json.return_money @businesses.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", @x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").sum(:amount).round(2)
52
60
  json.school_count school_count
53
- # json.follow_school_counts EducodeSales::CustomerFollow.where(staff_id: d.id).size + EducodeSales::FollowUp.where(staff_id: d.id).size
61
+ follow_school_count = (EducodeSales::CustomerFollow.where(staff_id: d.id).where("created_at >= ? AND created_at <= ?", "#{@year}-01-01", "#{@year}-12-31").pluck(:school_id) + EducodeSales::Business.where(id: EducodeSales::FollowUp.where("created_at >= ? AND created_at <= ?", "#{@year}-01-01", "#{@year}-12-31").where(staff_id: d.id).pluck(:business_id).uniq).pluck(:school_id)).uniq.size
62
+ json.follow_school_count follow_school_count
63
+ json.follow_school_counts EducodeSales::CustomerFollow.where(staff_id: d.id).where("created_at >= ? AND created_at <= ?", "#{@year}-01-01", "#{@year}-12-31").size + EducodeSales::FollowUp.where(staff_id: d.id).where("created_at >= ? AND created_at <= ?", "#{@year}-01-01", "#{@year}-12-31").size
64
+ follow_school_rate = (follow_school_count!=0 ? school_count.to_f * 100 / follow_school_count : 0).round(2)
65
+ json.follow_school_rate follow_school_rate.to_s + '%'
66
+ follow_department_rate = (follow_school_count!=0 ? school_count.to_f * 110 / follow_school_count : 0).round(2)
67
+ json.follow_department_rate follow_department_rate.to_s + '%'
54
68
  end
55
69
 
56
70
  json.business_a business_a
@@ -73,6 +87,8 @@ json.data do
73
87
  businesses_e_count += business_e
74
88
  businesses_o_count += business_o
75
89
  school_counts += school_count
90
+ follow_school_rates += follow_school_rate
91
+ follow_department_rates += follow_department_rate
76
92
  end
77
93
  end
78
94
 
@@ -84,6 +100,8 @@ json.totalRow do
84
100
  json.business_e businesses_e_count.to_s
85
101
  json.business_o businesses_o_count.to_s
86
102
  json.school_count school_counts.to_s
103
+ json.follow_school_rate (follow_school_rates.to_f / @staffs.size).round(2).to_s + '%'
104
+ json.follow_department_rate (follow_department_rates.to_f / @staffs.size).round(2).to_s + '%'
87
105
  end
88
106
  json.code 0
89
107
  json.count @staffs.total_count
@@ -17,9 +17,9 @@ json.data do
17
17
  else
18
18
  json.area ''
19
19
  end
20
- departments = EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.staff_id = #{d.id}").select("COUNT(educode_sales_follow_ups.staff_id) AS count")[0]&.send('count') + EducodeSales::Teacher.joins(:follow_up).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("COUNT(educode_sales_teacher_follows.staff_id) AS count")[0]&.send('count') || 0
20
+ departments = (EducodeSales::Business.joins(:follow_ups, [department: :school]).where("educode_sales_follow_ups.staff_id = #{d.id}").select("departments.id, departments.name, schools.name AS school, educode_sales_follow_ups.updated_at") + EducodeSales::Teacher.joins(:follow_up, [department: :school]).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("departments.id, departments.name, schools.name AS school, educode_sales_teacher_follows.updated_at")).uniq{|s| s.id}.size
21
21
  json.departments departments
22
- schools = EducodeSales::Business.joins(:last_follow_up, :department).where("educode_sales_follow_ups.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count'] + EducodeSales::Teacher.joins(:follow_up, :department).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count']
22
+ schools = EducodeSales::Business.joins(:follow_ups, :department).where("educode_sales_follow_ups.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count'] + EducodeSales::Teacher.joins(:follow_up, :department).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count']
23
23
  json.schools schools
24
24
  departments_count += departments
25
25
  schools_count += schools
@@ -88,16 +88,6 @@
88
88
  <table class="layui-hide" id="teachers_table" style="min-height: 300px;" lay-filter="teachers_table"></table>
89
89
  </div>
90
90
  <script type="text/html" id="currentTableBar">
91
- <%# if can? :create, EducodeSales::OperationPlan %>
92
- <!-- <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="addWeek">添加周计划</a>-->
93
- <!-- <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="addMonth">添加月计划</a>-->
94
- <%# end %>
95
- <%# if can? :update, EducodeSales::Teacher %>
96
- <!-- <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>-->
97
- <%# end %>
98
- <%# if can? :destroy, EducodeSales::Teacher %>
99
- <!-- <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>-->
100
- <%# end %>
101
91
  <% if can? :create, EducodeSales::TeacherFollow %>
102
92
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_event">添加跟进记录</a>
103
93
  <% end %>
@@ -243,19 +233,22 @@
243
233
  templet: "#event"
244
234
  },
245
235
  {
246
- field: 'regist_at',
236
+ field: 'created_on',
247
237
  width: 120,
248
238
  title: '注册时间',
239
+ sort: true,
249
240
  },
250
241
  {
251
242
  field: 'last_login_on',
252
243
  width: 120,
253
244
  title: '最近登录',
245
+ sort: true,
254
246
  },
255
247
  {
256
248
  field: 'created_at',
257
249
  width: 120,
258
250
  title: '添加时间',
251
+ sort: true,
259
252
  },
260
253
  {
261
254
  field: 'wechat',
@@ -18,7 +18,7 @@ json.data do
18
18
  json.courses_count d.courses_count
19
19
  json.actives d.actives
20
20
  json.students d.students_count
21
- json.regist_at d.user.present? ? d.user.created_on.to_s(:date) : ''
21
+ json.created_on d.user.present? ? d.user.created_on.to_s(:date) : ''
22
22
  json.last_login_on (d.user.present? && d.user.last_login_on.present?) ? d.user.last_login_on.to_s(:date) : ''
23
23
  json.teacher_used d.teacher_used
24
24
  json.wechat d.wechat
@@ -9,12 +9,15 @@
9
9
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
10
10
  <%= stylesheet_link_tag "educode_sales/application", media: "all" %>
11
11
  <%= javascript_include_tag "educode_sales/application" %>
12
+ <script src="https://cdn.jsdelivr.net/npm/cxselect@1.4.0/js/jquery.cxselect.js"></script>
13
+ <script src="https://cdn.jsdelivr.net/npm/cxselect@1.4.0/js/jquery.cxselect.min.js"></script>
14
+ <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.js"></script>
12
15
  </head>
13
16
  <body class="" id="body">
14
17
  <div class="layui-layout layui-layout-admin " >
15
18
  <div class="layui-header">
16
19
  <a href="/missions">
17
- <div class="layui-hide-xs layui-bg-black layuimini-logo layui-logo">
20
+ <div class="layui-bg-black layuimini-logo layui-logo" id="head_a">
18
21
  <%= image_tag "educode_sales/logo.png", class: 'header-logo' %>
19
22
  <span class="app-title">营销系统</span>
20
23
  </div>
@@ -45,7 +48,7 @@
45
48
  </ul>
46
49
  </div>
47
50
 
48
- <div class="layui-side layui-bg-black">
51
+ <div class="layui-side layui-bg-black" id="head_b">
49
52
  <div class="layui-side-scroll ">
50
53
  <!-- 左侧导航区域(可配合layui已有的垂直导航) -->
51
54
  <ul class="layui-nav layui-nav-tree ul"
@@ -66,6 +69,10 @@
66
69
  <dd><a href="/missions/businesses" class="<%= current?('layui-this', businesses_path) %>"><i style="padding-right: 35px"></i><%= image_tag "educode_sales/4.商机管理.png",size:"15"%><i style="font-size: 25px; padding-right: 15px"></i>商机管理</a>
67
70
  </dd>
68
71
  <% end %>
72
+ <% if can? :read, EducodeSales::MoneyPlan %>
73
+ <dd><a href="/missions/money_plans" class="<%= current?('layui-this', money_plans_path) %>"><i style="padding-right: 35px"></i><%= image_tag "educode_sales/money_plans.png",size:"15"%><i style="font-size: 25px; padding-right: 15px"></i>回款管理</a>
74
+ </dd>
75
+ <% end %>
69
76
  <% if can? :read, EducodeSales::Customer %>
70
77
  <dd><a href="/missions/customers" class="<%= current?('layui-this', customers_path) %>"><i style="padding-right: 35px"></i><%= image_tag "educode_sales/客户管理.png",size:"15"%><i style="font-size: 25px; padding-right: 15px"></i>客户管理</a>
71
78
  </dd>
@@ -205,6 +212,8 @@
205
212
  $(".i_class").animate({left: '200px'},"fast");
206
213
  $(".layui-nav-item").addClass('layui-nav-itemed')
207
214
  $("#logout").removeClass('layui-nav-itemed')
215
+ $("#head_b").removeClass('layui-hide-xs')
216
+ $("#head_a").removeClass('layui-hide-xs')
208
217
  }
209
218
 
210
219
  function menuHide(btn) {
@@ -212,6 +221,8 @@
212
221
  btn.removeClass('layui-icon-shrink-right').addClass('layui-icon-spread-left');
213
222
  body.addClass('layuimini-mini');
214
223
  $(".i_class").animate({left: '60px'});
224
+ $("#head_b").addClass('layui-hide-xs')
225
+ $("#head_a").addClass('layui-hide-xs')
215
226
  }
216
227
  }
217
228
  });
data/config/routes.rb CHANGED
@@ -20,6 +20,8 @@ EducodeSales::Engine.routes.draw do
20
20
  end
21
21
  resources :customer_follows do
22
22
  end
23
+ resources :money_plans do
24
+ end
23
25
 
24
26
  resources :customers do
25
27
  collection do
@@ -8,6 +8,9 @@ class CreateEducodeSalesRolePermissions < ActiveRecord::Migration[5.2]
8
8
  end
9
9
  if EducodeSales::Permission.last.nil?
10
10
 
11
+ #回款管理权限
12
+ EducodeSales::Permission.create(name: '查看回款列表', subject: 'MoneyPlan', action: 'read', clazz: 'money_plan', position: '15')
13
+
11
14
  #客户管理权限
12
15
  EducodeSales::Permission.create(name: '查看客户', subject: 'Customer', action: 'read', clazz: 'customer')
13
16
  EducodeSales::Permission.create(name: '添加客户', subject: 'Customer', action: 'create', clazz: 'customer')
@@ -0,0 +1,12 @@
1
+ class AddPositionToCommons < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :educode_sales_permissions, :position, :integer
4
+ EducodeSales::Permission.all.each_with_index do |d,index|
5
+ if d.clazz == '销售态势' || d.clazz == '销售分工' || d.clazz == '商机管理' || d.clazz == '客户管理'
6
+ d.update(position: index)
7
+ else
8
+ d.update(position: index * 10)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ class AddSchoolIdToEducodeSalesBusinesses < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :educode_sales_businesses, :school_id, :integer
4
+ EducodeSales::Business.all.each do |business|
5
+ business.update(school_id: business.department.school.id)
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: educode_sales
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-17 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -109,6 +109,7 @@ files:
109
109
  - app/assets/images/educode_sales/loading-2.gif
110
110
  - app/assets/images/educode_sales/loginbg.png
111
111
  - app/assets/images/educode_sales/logo.png
112
+ - app/assets/images/educode_sales/money_plans.png
112
113
  - app/assets/images/educode_sales/回收站.png
113
114
  - app/assets/images/educode_sales/客户管理.png
114
115
  - app/assets/javascripts/educode_sales/application.js
@@ -145,6 +146,7 @@ files:
145
146
  - app/controllers/educode_sales/home_controller.rb
146
147
  - app/controllers/educode_sales/import_teachers_controller.rb
147
148
  - app/controllers/educode_sales/key_person_controller.rb
149
+ - app/controllers/educode_sales/money_plans_controller.rb
148
150
  - app/controllers/educode_sales/operation_plans_controller.rb
149
151
  - app/controllers/educode_sales/operation_reports_controller.rb
150
152
  - app/controllers/educode_sales/operations_controller.rb
@@ -253,6 +255,8 @@ files:
253
255
  - app/views/educode_sales/home/search_teacher.json.jbuilder
254
256
  - app/views/educode_sales/home/search_users.json.jbuilder
255
257
  - app/views/educode_sales/home/statistics.html.erb
258
+ - app/views/educode_sales/money_plans/index.html.erb
259
+ - app/views/educode_sales/money_plans/index.json.jbuilder
256
260
  - app/views/educode_sales/operation_plans/_monthPlan.html.erb
257
261
  - app/views/educode_sales/operation_plans/_monthly.html.erb
258
262
  - app/views/educode_sales/operation_plans/_weekPlan.html.erb
@@ -405,6 +409,8 @@ files:
405
409
  - db/migrate/20211206054756_add_year_to_follow_ups.rb
406
410
  - db/migrate/20211214100803_create_customer_extensions.rb
407
411
  - db/migrate/20211215025029_create_educode_sales_customer_follows.rb
412
+ - db/migrate/20211220102720_add_position_to_commons.rb
413
+ - db/migrate/20211221075146_add_school_id_to_educode_sales_businesses.rb
408
414
  - lib/educode_sales.rb
409
415
  - lib/educode_sales/engine.rb
410
416
  - lib/educode_sales/version.rb