educode_sales 0.4.2 → 0.4.6
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/assets/images/educode_sales/1./351/224/200/345/224/256/346/264/273/345/212/250.png +0 -0
- data/app/assets/images/educode_sales/10./346/225/231/345/270/210/350/277/220/350/220/245.png +0 -0
- data/app/assets/images/educode_sales/11./346/264/273/345/212/250/350/277/220/350/220/245.png +0 -0
- data/app/assets/images/educode_sales/12./350/277/220/350/220/245/350/256/241/345/210/222.png +0 -0
- data/app/assets/images/educode_sales/13./347/263/273/347/273/237/350/256/276/347/275/256.png +0 -0
- data/app/assets/images/educode_sales/14./350/247/222/350/211/262/347/256/241/347/220/206.png +0 -0
- data/app/assets/images/educode_sales/15./344/272/272/345/221/230/347/256/241/347/220/206.png +0 -0
- data/app/assets/images/educode_sales/16./345/255/227/345/205/270/345/210/227/350/241/250.png +0 -0
- data/app/assets/images/educode_sales/2./345/270/202/345/234/272/346/200/201/345/212/277.png +0 -0
- data/app/assets/images/educode_sales/3./351/224/200/345/224/256/345/210/206/345/267/245.png +0 -0
- data/app/assets/images/educode_sales/4./345/225/206/346/234/272/347/256/241/347/220/206.png +0 -0
- data/app/assets/images/educode_sales/5./346/270/240/351/201/223/347/256/241/347/220/206.png +0 -0
- data/app/assets/images/educode_sales/6./351/224/200/345/224/256/350/256/241/345/210/222.png +0 -0
- data/app/assets/images/educode_sales/7./350/277/220/350/220/245/346/264/273/345/212/250.png +0 -0
- data/app/assets/images/educode_sales/8./350/277/220/350/220/245/346/200/201/345/212/277.png +0 -0
- data/app/assets/images/educode_sales/9./350/277/220/350/220/245/345/210/206/345/267/245.png +0 -0
- data/app/assets/images/educode_sales/a.png +0 -0
- data/app/assets/images/educode_sales/indexLogo.png +0 -0
- data/app/assets/images/educode_sales/logo.png +0 -0
- data/app/controllers/educode_sales/businesses_controller.rb +21 -3
- data/app/controllers/educode_sales/follow_ups_controller.rb +3 -3
- data/app/controllers/educode_sales/operation_plans_controller.rb +2 -2
- data/app/controllers/educode_sales/operation_reports_controller.rb +3 -3
- data/app/controllers/educode_sales/places_controller.rb +1 -1
- data/app/controllers/educode_sales/plans_controller.rb +8 -4
- data/app/controllers/educode_sales/sale_reports_controller.rb +3 -3
- data/app/controllers/educode_sales/sale_trends_controller.rb +3 -3
- data/app/controllers/educode_sales/sales_controller.rb +1 -1
- data/app/controllers/educode_sales/teacher_follows_controller.rb +1 -1
- data/app/models/educode_sales/common.rb +2 -0
- data/app/models/educode_sales/teacher.rb +12 -19
- data/app/views/educode_sales/activities/index.html.erb +4 -0
- data/app/views/educode_sales/activities/index.json.jbuilder +6 -0
- data/app/views/educode_sales/businesses/edit_follow_record.html.erb +7 -8
- data/app/views/educode_sales/businesses/index.html.erb +46 -6
- data/app/views/educode_sales/businesses/index.json.jbuilder +8 -1
- data/app/views/educode_sales/businesses/new_follow_record.html.erb +7 -8
- data/app/views/educode_sales/businesses/show_follow.html.erb +10 -10
- data/app/views/educode_sales/businesses/show_follow.json.jbuilder +2 -2
- data/app/views/educode_sales/businesses/show_follow_record.html.erb +16 -4
- data/app/views/educode_sales/home/index.html.erb +1 -1
- data/app/views/educode_sales/operation_plans/_monthPlan.html.erb +5 -1
- data/app/views/educode_sales/operation_plans/_monthly.html.erb +14 -0
- data/app/views/educode_sales/operation_plans/_weekPlan.html.erb +5 -1
- data/app/views/educode_sales/operation_plans/_weekly.html.erb +14 -0
- data/app/views/educode_sales/operation_plans/index.json.jbuilder +10 -2
- data/app/views/educode_sales/operation_plans/new_monthly.html.erb +4 -2
- data/app/views/educode_sales/operation_plans/new_weekly.html.erb +4 -2
- data/app/views/educode_sales/operation_reports/audit.html.erb +40 -13
- data/app/views/educode_sales/operation_reports/edit.html.erb +4 -2
- data/app/views/educode_sales/operation_reports/index.json.jbuilder +7 -0
- data/app/views/educode_sales/operation_reports/show.html.erb +46 -15
- data/app/views/educode_sales/places/index.html.erb +5 -0
- data/app/views/educode_sales/plans/_monthPlan.html.erb +3 -0
- data/app/views/educode_sales/plans/_monthly.html.erb +15 -0
- data/app/views/educode_sales/plans/_weekPlan.html.erb +4 -1
- data/app/views/educode_sales/plans/_weekly.html.erb +16 -0
- data/app/views/educode_sales/plans/index.json.jbuilder +4 -0
- data/app/views/educode_sales/plans/new_monthly.html.erb +4 -2
- data/app/views/educode_sales/plans/new_weekly.html.erb +4 -2
- data/app/views/educode_sales/sale_reports/audit.html.erb +40 -13
- data/app/views/educode_sales/sale_reports/edit.html.erb +4 -2
- data/app/views/educode_sales/sale_reports/index.json.jbuilder +7 -0
- data/app/views/educode_sales/sale_reports/show.html.erb +46 -21
- data/app/views/educode_sales/sales/index.html.erb +6 -0
- data/app/views/educode_sales/sales/index.json.jbuilder +20 -4
- data/app/views/educode_sales/sales/operations.html.erb +4 -4
- data/app/views/educode_sales/sales/operations.json.jbuilder +12 -3
- data/app/views/educode_sales/teachers/index.html.erb +19 -14
- data/app/views/educode_sales/teachers/index.json.jbuilder +12 -2
- data/app/views/layouts/educode_sales/application.html.erb +179 -41
- data/db/migrate/20211018054256_add_extras_to_commons.rb +6 -0
- data/db/migrate/20211022085324_add_teacher_used_to_teachers.rb +7 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +22 -3
- data/app/assets/images/educode_sales/indexlogo.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5ec520db3019e20ddbbd8615880ee3060fdd6d6e5f859130dfb0b0845be8f6d
|
4
|
+
data.tar.gz: 7f678fb5d8c6b9dd77dc8c002b49f1e7228d8ce30b3eddb77fb2e7717b93d1d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ffcbfc616f3ab9241834c9642dfc13e8d18a1ea7c5bc16edcb46398503f80456e2fee80a09da8fec8377a748f0f60a56e4fdf53640470a1e7521a160642a7b7
|
7
|
+
data.tar.gz: 3dd3605a2b1f4cd3469201c87dc7237bb76c01ea6da7cb968e81fd5702b57ab847c919a176a792cb3b7c47547bcc1dad06711cc38dda351935f7096d87001fc1
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -40,6 +40,16 @@ module EducodeSales
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
if params[:q].present? && params[:q][:all].present?
|
44
|
+
@businesses = @businesses
|
45
|
+
end
|
46
|
+
|
47
|
+
if params[:q].present? && params[:q][:mine].present?
|
48
|
+
ids = AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
|
49
|
+
ids1 = FollowUp.where(id: ids).pluck(:business_id)
|
50
|
+
@businesses =@businesses.where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", ids1, @current_admin.id)
|
51
|
+
end
|
52
|
+
|
43
53
|
@businesses = @businesses
|
44
54
|
if params[:q].present? && params[:q][:name].present?
|
45
55
|
@businesses = @businesses.where("educode_sales_businesses.name like ?", "%#{params[:q][:name]}%")
|
@@ -49,7 +59,12 @@ module EducodeSales
|
|
49
59
|
@businesses = @businesses.joins(:department).where("departments.id in (?)", departments_ids)
|
50
60
|
end
|
51
61
|
if params[:q].present? && params[:q][:staff_id].present?
|
52
|
-
|
62
|
+
part_a_ids = @businesses.where("educode_sales_businesses.last_follow_up_id is null AND staff_id = ?",params[:q][:staff_id]).ids
|
63
|
+
part_b_ids = @businesses.where("educode_sales_businesses.last_follow_up_id is not null").joins("
|
64
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
65
|
+
").where("educode_sales_follow_ups.staff_id = ?", params[:q][:staff_id]).pluck(:business_id)
|
66
|
+
business_ids = part_a_ids + part_b_ids
|
67
|
+
@businesses = EducodeSales::Business.where(id:business_ids)
|
53
68
|
end
|
54
69
|
if params[:q].present? && params[:q][:business_type].present?
|
55
70
|
@businesses = @businesses.joins("
|
@@ -80,7 +95,6 @@ module EducodeSales
|
|
80
95
|
@businesses = @businesses.where("educode_sales_businesses.created_at > ? AND educode_sales_businesses.created_at < ?", date[0], date[1])
|
81
96
|
end
|
82
97
|
|
83
|
-
|
84
98
|
if params[:sort].present? && params[:sort][:field]
|
85
99
|
@businesses = @businesses.order("#{params[:sort][:field]} #{params[:sort][:order]}")
|
86
100
|
else
|
@@ -89,6 +103,8 @@ module EducodeSales
|
|
89
103
|
|
90
104
|
@business_count = @businesses.count
|
91
105
|
|
106
|
+
|
107
|
+
|
92
108
|
@businesses = @businesses.select("
|
93
109
|
educode_sales_businesses.*,
|
94
110
|
last_follow.invitation_at,
|
@@ -177,6 +193,7 @@ module EducodeSales
|
|
177
193
|
|
178
194
|
def new_follow_record
|
179
195
|
load_business
|
196
|
+
@o_name = EducodeSales::Common.find_by(extras: EducodeSales::Common::OTYPE)&.name
|
180
197
|
@clazz = Common.where(clazz: 'business_type').order("position").pluck(:name, :id)
|
181
198
|
@stages = Common.where(clazz: 'business_step').order("position").pluck(:name, :id)
|
182
199
|
@places = Place.order("created_at desc").pluck(:name, :id)
|
@@ -201,6 +218,7 @@ module EducodeSales
|
|
201
218
|
end
|
202
219
|
|
203
220
|
def edit_follow_record
|
221
|
+
@o_name = EducodeSales::Common.find_by(extras: EducodeSales::Common::OTYPE)&.name
|
204
222
|
@follow_up = FollowUp.find(params[:follow_up_id])
|
205
223
|
@clazz = Common.where(clazz: 'business_type').order("position").pluck(:name, :id)
|
206
224
|
@stages = Common.where(clazz: 'business_step').order("position").pluck(:name, :id)
|
@@ -222,7 +240,7 @@ module EducodeSales
|
|
222
240
|
end
|
223
241
|
|
224
242
|
def follow_up_params
|
225
|
-
params.permit(:clazz_id, :stage_id, :invitation_at, :reception_at, :total_amount, :actual_amount, :
|
243
|
+
params.permit(:clazz_id, :stage_id, :invitation_at, :reception_at, :total_amount, :actual_amount, :divide_amount, :description, :advise, :place_id)
|
226
244
|
end
|
227
245
|
|
228
246
|
end
|
@@ -11,7 +11,7 @@ module EducodeSales
|
|
11
11
|
follow_up.assign_follow_ups.build(staff_id: d)
|
12
12
|
end
|
13
13
|
|
14
|
-
follow_up.profit_amount = follow_up.actual_amount
|
14
|
+
follow_up.profit_amount = follow_up.actual_amount - (follow_up.divide_amount.to_i) if follow_up.actual_amount
|
15
15
|
if follow_up.save
|
16
16
|
if @business.last_follow_up.present?
|
17
17
|
@business.last_follow_up.key_person.each do |d|
|
@@ -54,7 +54,7 @@ module EducodeSales
|
|
54
54
|
assign_follow_ups << follow_up.assign_follow_ups.find_or_initialize_by(staff_id: d)
|
55
55
|
end
|
56
56
|
follow_up.assign_follow_ups = assign_follow_ups
|
57
|
-
follow_up.profit_amount = follow_up.actual_amount
|
57
|
+
follow_up.profit_amount = follow_up.actual_amount - (follow_up.divide_amount.to_i) * 0.01 if follow_up.actual_amount
|
58
58
|
if follow_up.save
|
59
59
|
render_success
|
60
60
|
else
|
@@ -156,7 +156,7 @@ module EducodeSales
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def follow_up_params
|
159
|
-
params.permit(:clazz_id, :stage_id, :invitation_at, :reception_at, :total_amount, :actual_amount, :
|
159
|
+
params.permit(:clazz_id, :stage_id, :invitation_at, :reception_at, :total_amount, :actual_amount, :divide_amount, :description, :advise, :place_id)
|
160
160
|
end
|
161
161
|
|
162
162
|
def teacher_params
|
@@ -21,7 +21,7 @@ module EducodeSales
|
|
21
21
|
@sale_plans = OperationPlan.where(staff_id: @current_admin.id)
|
22
22
|
when '区域'
|
23
23
|
staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
|
24
|
-
@sale_plans = OperationPlan.where("staff_id in (?)", staff_ids)
|
24
|
+
@sale_plans = OperationPlan.where("staff_id in (?) OR educode_sales_operation_plans.staff_id = ?", staff_ids, @current_admin.id)
|
25
25
|
else
|
26
26
|
@sale_plans = OperationPlan
|
27
27
|
end
|
@@ -44,7 +44,7 @@ module EducodeSales
|
|
44
44
|
if params[:sort].present? && params[:sort][:field]
|
45
45
|
@sale_plans = @sale_plans.order("#{params[:sort][:field]} #{params[:sort][:order]}")
|
46
46
|
else
|
47
|
-
@sale_plans = @sale_plans.order("
|
47
|
+
@sale_plans = @sale_plans.order("created_at desc")
|
48
48
|
end
|
49
49
|
@sale_plans = @sale_plans.page(params[:page]).per(params[:limit])
|
50
50
|
end
|
@@ -18,7 +18,7 @@ module EducodeSales
|
|
18
18
|
@sale_reports = OperationReport.where(staff_id: @current_admin.id)
|
19
19
|
when '区域'
|
20
20
|
staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
|
21
|
-
@sale_reports = OperationReport.where("staff_id in (?)", staff_ids)
|
21
|
+
@sale_reports = OperationReport.where("staff_id in (?) OR educode_sales_operation_reports.staff_id = ?", staff_ids, @current_admin.id)
|
22
22
|
else
|
23
23
|
@sale_reports = OperationReport
|
24
24
|
end
|
@@ -40,7 +40,7 @@ module EducodeSales
|
|
40
40
|
if params[:sort].present? && params[:sort][:field]
|
41
41
|
@sale_reports = @sale_reports.order("#{params[:sort][:field]} #{params[:sort][:order]}")
|
42
42
|
else
|
43
|
-
@sale_reports = @sale_reports.order("
|
43
|
+
@sale_reports = @sale_reports.order("created_at desc")
|
44
44
|
end
|
45
45
|
@sale_reports = @sale_reports.page(params[:page]).per(params[:limit])
|
46
46
|
end
|
@@ -126,6 +126,6 @@ module EducodeSales
|
|
126
126
|
params.permit(:level1_opinion, :level2_opinion, :level3_opinion, :level1_score, :level2_score, :level3_score)
|
127
127
|
end
|
128
128
|
|
129
|
-
|
129
|
+
|
130
130
|
end
|
131
131
|
end
|
@@ -9,7 +9,7 @@ module EducodeSales
|
|
9
9
|
end
|
10
10
|
format.json do
|
11
11
|
@places = Place.page(params[:page]).per(params[:limit])
|
12
|
-
@x = Common.find_by(
|
12
|
+
@x = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
|
13
13
|
@stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
14
14
|
end
|
15
15
|
end
|
@@ -22,7 +22,7 @@ module EducodeSales
|
|
22
22
|
@sale_plans = SalePlan.where(staff_id: @current_admin.id)
|
23
23
|
when '区域'
|
24
24
|
staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
|
25
|
-
@sale_plans = SalePlan.where("staff_id in (?)", staff_ids)
|
25
|
+
@sale_plans = SalePlan.where("staff_id in (?) OR educode_sales_sale_plans.staff_id = ?", staff_ids, @current_admin.id)
|
26
26
|
else
|
27
27
|
@sale_plans = SalePlan
|
28
28
|
end
|
@@ -44,7 +44,7 @@ module EducodeSales
|
|
44
44
|
if params[:sort].present? && params[:sort][:field]
|
45
45
|
@sale_plans = @sale_plans.order("#{params[:sort][:field]} #{params[:sort][:order]}")
|
46
46
|
else
|
47
|
-
@sale_plans = @sale_plans.order("
|
47
|
+
@sale_plans = @sale_plans.order("created_at desc")
|
48
48
|
end
|
49
49
|
|
50
50
|
@sale_plans = @sale_plans.page(params[:page]).per(params[:limit])
|
@@ -78,7 +78,9 @@ module EducodeSales
|
|
78
78
|
else
|
79
79
|
@weeks = [week]
|
80
80
|
end
|
81
|
-
|
81
|
+
ids = AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
|
82
|
+
ids1 = FollowUp.where(id: ids).pluck(:business_id)
|
83
|
+
@businesses =Business.where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", ids1, @current_admin.id).pluck(:name, :id)
|
82
84
|
render layout: false
|
83
85
|
end
|
84
86
|
|
@@ -92,7 +94,9 @@ module EducodeSales
|
|
92
94
|
|
93
95
|
def new_month
|
94
96
|
@business = Business.find_by(id: params[:business_id])
|
95
|
-
|
97
|
+
ids = AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
|
98
|
+
ids1 = FollowUp.where(id: ids).pluck(:business_id)
|
99
|
+
@businesses =Business.where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", ids1, @current_admin.id).pluck(:name, :id)
|
96
100
|
render layout: false
|
97
101
|
end
|
98
102
|
|
@@ -9,7 +9,7 @@ module EducodeSales
|
|
9
9
|
else
|
10
10
|
sale_report = @current_admin.sale_reports.build(month: Date.today.beginning_of_month, weekly: Time.now.strftime('%W').to_i)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
sale_report.finish_rate = params[:finish_rate]
|
14
14
|
sale_report.client = params[:client]
|
15
15
|
sale_report.content = params[:content]
|
@@ -51,7 +51,7 @@ module EducodeSales
|
|
51
51
|
@sale_reports = SaleReport.where(staff_id: @current_admin.id)
|
52
52
|
when '区域'
|
53
53
|
staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
|
54
|
-
@sale_reports = SaleReport.where("staff_id in (?)", staff_ids)
|
54
|
+
@sale_reports = SaleReport.where("staff_id in (?) OR educode_sales_sale_reports.staff_id = ?", staff_ids, @current_admin.id)
|
55
55
|
else
|
56
56
|
@sale_reports = SaleReport
|
57
57
|
end
|
@@ -73,7 +73,7 @@ module EducodeSales
|
|
73
73
|
if params[:sort].present? && params[:sort][:field]
|
74
74
|
@sale_reports = @sale_reports.order("#{params[:sort][:field]} #{params[:sort][:order]}")
|
75
75
|
else
|
76
|
-
@sale_reports = @sale_reports.order("
|
76
|
+
@sale_reports = @sale_reports.order("created_at desc")
|
77
77
|
end
|
78
78
|
@sale_reports = @sale_reports.page(params[:page]).per(params[:limit])
|
79
79
|
end
|
@@ -9,15 +9,15 @@ module EducodeSales
|
|
9
9
|
@year = params[:year] ? params[:year] : Time.now.year
|
10
10
|
@years = (1..(Time.now.year - 2020)).map { |d| 2020 + d }
|
11
11
|
year_time = "#{@year}-01-01 00:00:00"
|
12
|
-
x = Common.find_by(
|
13
|
-
o = Common.find_by(
|
12
|
+
x = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
|
13
|
+
o = Common.find_by(extras: EducodeSales::Common::OTYPE)&.id
|
14
14
|
@sale_trend = SaleTrend.find_or_create_by(year: @year)
|
15
15
|
@business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.clazz_id != ?", x, o).where("educode_sales_follow_ups.created_at >= ?", year_time).sum(:total_amount).round(2)
|
16
16
|
stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
17
17
|
@goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.created_at >= ? AND educode_sales_follow_ups.stage_id IN (?)", year_time, stage_ids).sum(:total_amount).round(2)
|
18
18
|
s_stage_ids = Common.where(clazz: '商机阶段', name: ['已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
19
19
|
@service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.created_at >= ? AND educode_sales_follow_ups.stage_id IN (?)", year_time, s_stage_ids).sum(:total_amount).round(2)
|
20
|
-
@return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_money_plans.date_at >= ?", year_time).sum(:amount).round(2)
|
20
|
+
@return_amount = Business.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 >= ?", year_time).sum(:amount).round(2)
|
21
21
|
a = Common.where(clazz: '商机类型', name: 'A类').pluck(:id)
|
22
22
|
@a_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", a).sum(:total_amount).round(2)
|
23
23
|
b = Common.where(clazz: '商机类型', name: 'B类').pluck(:id)
|
@@ -14,7 +14,7 @@ module EducodeSales
|
|
14
14
|
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
15
15
|
@a_clazz = Common.find_by(clazz: 'business_type', name: 'A类')
|
16
16
|
@b_clazz = Common.find_by(clazz: 'business_type', name: 'B类')
|
17
|
-
@x = Common.find_by(
|
17
|
+
@x = Common.find_by(extras: EducodeSales::Common::XTYPE)
|
18
18
|
@step_ids = Common.where(name: %w(已中标 已签单 已验收 回款中 服务中 已结束), clazz: 'business_step').pluck(:id)
|
19
19
|
|
20
20
|
@staffs = Staff.where(job_type: common.id).page(params[:page]).per(params[:limit])
|
@@ -34,7 +34,7 @@ module EducodeSales
|
|
34
34
|
def update
|
35
35
|
follow_up = TeacherFollow.find(params[:id])
|
36
36
|
follow_up.assign_attributes(follow_up_params)
|
37
|
-
# follow_up.profit_amount = follow_up.actual_amount * (100-follow_up.
|
37
|
+
# follow_up.profit_amount = follow_up.actual_amount * (100-follow_up.divide_amount.to_i) * 0.01 if follow_up.actual_amount
|
38
38
|
if follow_up.save
|
39
39
|
render_success
|
40
40
|
else
|
@@ -13,29 +13,22 @@ module EducodeSales
|
|
13
13
|
belongs_to :follow_up, class_name: 'TeacherFollow', optional: true
|
14
14
|
validates :user_id, uniqueness: { allow_blank: true, message: '已存在老师列表'}
|
15
15
|
|
16
|
+
def cal_courses_count
|
17
|
+
if self.user_id.present?
|
18
|
+
Course.joins(:course_members).where(course_members: {user_id: self.user_id}).where("is_delete = 0 and role != 4 and excellent = 0 and is_hidden = 0").where("start_date is null or start_date <= '#{Date.today}'").distinct(:course_id).count
|
19
|
+
else
|
20
|
+
0
|
21
|
+
end
|
22
|
+
end
|
16
23
|
|
17
|
-
# def teacher_used_of_department
|
18
|
-
# if user_id.present?
|
19
|
-
# user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
|
20
|
-
# course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
|
21
|
-
# if course_ids.present?
|
22
|
-
# course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
|
23
|
-
# course_members.present? ? course_members[0]['count'] : 0
|
24
|
-
# else
|
25
|
-
# 0
|
26
|
-
# end
|
27
|
-
# else
|
28
|
-
# 0
|
29
|
-
# end
|
30
|
-
# end
|
31
24
|
def teacher_used_of_department
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
25
|
+
user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
|
26
|
+
course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
|
27
|
+
course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
|
28
|
+
course_members.present? ? course_members[0]['count'] : 0
|
36
29
|
end
|
37
30
|
|
38
|
-
def
|
31
|
+
def cal_students_count
|
39
32
|
if user_id.present?
|
40
33
|
course_ids = Course.joins(:course_members).where(course_members: {user_id: user_id}).where("is_delete = 0 and role != 4 and excellent = 0 and is_hidden = 0").where("start_date is null or start_date <= '#{Date.today}'").distinct("course_id").pluck(:course_id)
|
41
34
|
CourseMember.where(course_id: course_ids, role: "STUDENT").count
|
@@ -39,12 +39,14 @@
|
|
39
39
|
elem: '#activities_table',
|
40
40
|
url: '/missions/activities',
|
41
41
|
toolbar: '#activity_toolbar',
|
42
|
+
totalRow:true,
|
42
43
|
defaultToolbar: [],
|
43
44
|
cols: [
|
44
45
|
[
|
45
46
|
{
|
46
47
|
field: 'id',
|
47
48
|
title:'序号',type: 'numbers',
|
49
|
+
totalRowText:'合计',
|
48
50
|
width: 60
|
49
51
|
},
|
50
52
|
{
|
@@ -68,11 +70,13 @@
|
|
68
70
|
field: 'teachers_count',
|
69
71
|
title: '教师数',
|
70
72
|
width: 100,
|
73
|
+
totalRow:true,
|
71
74
|
templet: '#teachers_count'
|
72
75
|
},
|
73
76
|
{
|
74
77
|
field: 'students_count',
|
75
78
|
title: '学生数',
|
79
|
+
totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
|
76
80
|
width: 100
|
77
81
|
},
|
78
82
|
{
|
@@ -1,14 +1,20 @@
|
|
1
|
+
teachers_count = 0
|
1
2
|
json.data do
|
2
3
|
json.array! @activities do |d|
|
3
4
|
json.id d.id
|
4
5
|
json.name d.name
|
5
6
|
json.days d.days
|
6
7
|
json.teachers_count d.activity_teachers_count
|
8
|
+
teachers_count += d.activity_teachers_count
|
7
9
|
json.return_rate d.return_rate
|
8
10
|
json.students_count d.students_count || 0
|
9
11
|
json.course_rate d.course_rate
|
10
12
|
json.start_at d.start_at ? d.start_at.to_s(:date) : ''
|
11
13
|
end
|
12
14
|
end
|
15
|
+
|
16
|
+
json.totalRow do
|
17
|
+
json.teachers_count teachers_count.to_s
|
18
|
+
end
|
13
19
|
json.code 0
|
14
20
|
json.count @activities.total_count
|
@@ -17,9 +17,9 @@
|
|
17
17
|
<br>
|
18
18
|
<div class="layui-inline">
|
19
19
|
<label class="layui-form-label required">项目类型</label>
|
20
|
-
<%if EducodeSales::FollowUp.where(business_id: @follow_up.business.id,clazz_id: EducodeSales::Common.find_by(name:
|
20
|
+
<%if EducodeSales::FollowUp.where(business_id: @follow_up.business.id,clazz_id: EducodeSales::Common.find_by(name: @o_name).id).count >= 2 %>
|
21
21
|
<div class="layui-input-inline">
|
22
|
-
<%= select_tag "clazz_id", options_for_select([[
|
22
|
+
<%= select_tag "clazz_id", options_for_select([[@o_name,EducodeSales::Common.find_by(name: @o_name).id]]),:disabled => true, class: 'required' %>
|
23
23
|
</div>
|
24
24
|
<%else %>
|
25
25
|
<div class="layui-input-inline">
|
@@ -56,9 +56,9 @@
|
|
56
56
|
</div>
|
57
57
|
</div>
|
58
58
|
<div class="layui-inline">
|
59
|
-
<label class="layui-form-label"
|
59
|
+
<label class="layui-form-label">合同额</label>
|
60
60
|
<div class="layui-input-inline">
|
61
|
-
<input name="actual_amount" type="number" class="layui-input" value="<%= @follow_up.actual_amount %>">
|
61
|
+
<input name="actual_amount" type="number" class="layui-input" placeholder="本单位的签单金额" value="<%= @follow_up.actual_amount %>">
|
62
62
|
</div>
|
63
63
|
</div>
|
64
64
|
<br>
|
@@ -69,11 +69,10 @@
|
|
69
69
|
</div>
|
70
70
|
</div>
|
71
71
|
<div class="layui-inline">
|
72
|
-
<label class="layui-form-label"
|
72
|
+
<label class="layui-form-label">渠道分成</label>
|
73
73
|
<div class="layui-input-inline">
|
74
|
-
<input name="
|
74
|
+
<input name="divide_amount" class="layui-input" value="<%= @follow_up.divide_amount%>">
|
75
75
|
</div>
|
76
|
-
<span style="margin-top: 10px; float:left;">%</span>
|
77
76
|
</div>
|
78
77
|
<div class="layui-form-item">
|
79
78
|
<label class="layui-form-label">指定跟进人</label>
|
@@ -82,7 +81,7 @@
|
|
82
81
|
</div>
|
83
82
|
</div>
|
84
83
|
<div class="layui-form-item layui-form-text">
|
85
|
-
<label class="layui-form-label required"
|
84
|
+
<label class="layui-form-label required">最新进展</label>
|
86
85
|
<div class="layui-input-block">
|
87
86
|
<textarea name="description" lay-verify="required" placeholder="此处可以填写:
|
88
87
|
1、有无预算;
|
@@ -68,6 +68,8 @@
|
|
68
68
|
<% if can? :create, EducodeSales::Business %>
|
69
69
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加商机</button>
|
70
70
|
<% end %>
|
71
|
+
<button class="layui-btn layui-btn-primary layui-border-green layui-btn-sm pull-right" lay-event="mine"> 我的商机</button>
|
72
|
+
<button class="layui-btn layui-btn-primary layui-border-green layui-btn-sm pull-right" lay-event="all"> 全部商机</button>
|
71
73
|
</div>
|
72
74
|
</script>
|
73
75
|
<script type="text/html" id="currentTableBar">
|
@@ -113,6 +115,7 @@
|
|
113
115
|
url: '/missions/businesses',
|
114
116
|
where: {q: form.val('search_form')},
|
115
117
|
toolbar: '#bussinessBar',
|
118
|
+
totalRow: true,//开启合并行
|
116
119
|
defaultToolbar: [],
|
117
120
|
cols: [
|
118
121
|
[
|
@@ -120,6 +123,7 @@
|
|
120
123
|
field: 'id',
|
121
124
|
width: 60,
|
122
125
|
title:'序号',type: 'numbers',
|
126
|
+
totalRowText: '合计',
|
123
127
|
},
|
124
128
|
{
|
125
129
|
field: 'name',
|
@@ -139,8 +143,9 @@
|
|
139
143
|
{
|
140
144
|
field: 'follow_ups_count',
|
141
145
|
title: '跟进',
|
142
|
-
width:
|
143
|
-
templet: '#show_follow'
|
146
|
+
width: 100,
|
147
|
+
templet: '#show_follow',
|
148
|
+
totalRow: true,
|
144
149
|
},
|
145
150
|
// {
|
146
151
|
// field: 'teachers_count',
|
@@ -150,7 +155,7 @@
|
|
150
155
|
// },
|
151
156
|
{
|
152
157
|
field: 'clazz',
|
153
|
-
width:
|
158
|
+
width: 120,
|
154
159
|
title: '类型'
|
155
160
|
},
|
156
161
|
{
|
@@ -174,13 +179,15 @@
|
|
174
179
|
field: 'total_amount',
|
175
180
|
width: 100,
|
176
181
|
title: '总额',
|
182
|
+
totalRow: true,
|
177
183
|
sort: true
|
178
184
|
},
|
179
185
|
{
|
180
186
|
field: 'return_money',
|
181
187
|
width: 100,
|
182
188
|
title: '回款',
|
183
|
-
sort: true
|
189
|
+
sort: true,
|
190
|
+
totalRow: true
|
184
191
|
},
|
185
192
|
{
|
186
193
|
field: 'place',
|
@@ -195,7 +202,12 @@
|
|
195
202
|
{
|
196
203
|
field: 'last_follow_person',
|
197
204
|
width: 120,
|
198
|
-
title: '
|
205
|
+
title: '最新跟进人'
|
206
|
+
},
|
207
|
+
{
|
208
|
+
field: 'latest_time',
|
209
|
+
width: 200,
|
210
|
+
title: '最新跟进时间'
|
199
211
|
},
|
200
212
|
{
|
201
213
|
title: '操作',
|
@@ -361,7 +373,35 @@
|
|
361
373
|
$(window).on("resize", function () {
|
362
374
|
layer.full(index);
|
363
375
|
});
|
364
|
-
} else if (obj.event === '
|
376
|
+
} else if (obj.event === 'all') {
|
377
|
+
search = {"all":"1"}
|
378
|
+
table.reload('businesses_table', {
|
379
|
+
page: {
|
380
|
+
curr: 1
|
381
|
+
},
|
382
|
+
where: {q: search, sort: sort}
|
383
|
+
}, 'data');
|
384
|
+
form.val('search_form', {
|
385
|
+
name: '', department: '', staff_id: '', business_type: '', business_step: '',
|
386
|
+
place_id: '', date: '', area: ''
|
387
|
+
})
|
388
|
+
return false;
|
389
|
+
}
|
390
|
+
else if (obj.event === 'mine') {
|
391
|
+
search = {"mine":"1"}
|
392
|
+
table.reload('businesses_table', {
|
393
|
+
page: {
|
394
|
+
curr: 1
|
395
|
+
},
|
396
|
+
where: {q: search, sort: sort}
|
397
|
+
}, 'data');
|
398
|
+
form.val('search_form', {
|
399
|
+
name: '', department: '', staff_id: '', business_type: '', business_step: '',
|
400
|
+
place_id: '', date: '', area: ''
|
401
|
+
})
|
402
|
+
return false;
|
403
|
+
}
|
404
|
+
else if (obj.event === 'delete') {
|
365
405
|
var checkStatus = table.checkStatus('currentTableId'),
|
366
406
|
data = checkStatus.data;
|
367
407
|
layer.alert(JSON.stringify(data));
|
@@ -1,3 +1,4 @@
|
|
1
|
+
follow_ups_count = 0
|
1
2
|
json.data do
|
2
3
|
json.array! @businesses do |d|
|
3
4
|
json.id d.id
|
@@ -5,6 +6,7 @@ json.data do
|
|
5
6
|
json.department d.department.name
|
6
7
|
json.school d.department.school.name
|
7
8
|
json.follow_ups_count d.follow_ups_count
|
9
|
+
follow_ups_count += d.follow_ups_count
|
8
10
|
json.follow_up_id d.last_follow_up_id
|
9
11
|
# json.teachers_count d.follow_ups.sum(:key_people_count)
|
10
12
|
# json.teachers_count EducodeSales::FollowUp.order(created_at: :desc).find_by(business_id: d.id).present? ? EducodeSales::FollowUp.order(created_at: :desc).find_by(business_id: d.id).key_people_count : 0
|
@@ -15,13 +17,18 @@ json.data do
|
|
15
17
|
json.total_amount d.last_follow_up&.total_amount
|
16
18
|
json.return_money d.return_money
|
17
19
|
json.place d.last_follow_up&.place&.name
|
18
|
-
json.last_follow_person d.last_follow_up.present? ? d.last_follow_up.staff.user.real_name :
|
20
|
+
json.last_follow_person d.last_follow_up.present? ? d.last_follow_up.staff.user.real_name : EducodeSales::Staff.find(d.staff_id).user.real_name
|
19
21
|
json.source d.source
|
20
22
|
json.assign_follow_ups d.last_follow_up.present? ? d.last_follow_up.assign_follow_ups.pluck(:staff_id) : []
|
21
23
|
json.current_staff_id @current_admin.id
|
22
24
|
json.staff_id d.staff_id
|
25
|
+
json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
|
23
26
|
end
|
24
27
|
end
|
28
|
+
|
29
|
+
json.totalRow do
|
30
|
+
json.follow_ups_count follow_ups_count.to_s
|
31
|
+
end
|
25
32
|
json.code 0
|
26
33
|
json.count @businesses.total_count
|
27
34
|
json.msg 'succcess'
|