educode_sales 0.9.31 → 0.9.32

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: e90cfebc689f75a8729f824db95f6dd3fe8a6c1c2f97edfec4d7d8ac8c6ad17d
4
- data.tar.gz: b517a994b1be4ac595f8c8664526d1ba0eb7785c60df9ddb0373348cde0b4a5f
3
+ metadata.gz: baf1f64ce29343ba494bc426661bff113268f32056597273f67fb103c6d4800d
4
+ data.tar.gz: 50630bc44ae41626f2d7a6fe62307c7a890366ff28dac4fb8cf9f42a3f9b9b03
5
5
  SHA512:
6
- metadata.gz: 4169878b95d9f6ab1f53165587e783b7a85f8be05295187b7f070466bad23645b5c2801d49827265337004a60fa8380bf2fae9f15a345e2a7f188cfc3bc46c7c
7
- data.tar.gz: 7050ecd4233c2ae9b835542187b57f82a3ad305fb008f0e6ef31fc3beeab367862fcad099b8c6c7b108f4b708863dfed3dea5c1d3238cd6390dd84474becaae2
6
+ metadata.gz: 9321b37e3c51aaa2304ecf8b68b3b9c9e78317a08b506d4792792c8d90640ebe8b146038fe15f9163afdd688b670b09d10abc624602dc24ff45f8c27a3a5dbe0
7
+ data.tar.gz: c688c3e5c06fea4cb77ff221f8db5cb9f6cdb2118ef7da812fd264f7075da755ed24792799a18d51a684ad1b745619cd56990bdda5bc87ad0ed78059e271b3be
@@ -233,6 +233,12 @@ module EducodeSales
233
233
  end
234
234
  end
235
235
 
236
+ # 商机变化
237
+ if params[:q][:clazz_changes].present?
238
+ clazz_changes = EducodeSales::BusinessClazzChange.clazz_changes_value[params[:q][:clazz_changes].to_s]
239
+ @businesses = @businesses.joins("JOIN educode_sales_business_clazz_changes ON educode_sales_business_clazz_changes.business_id = educode_sales_businesses.id").where("educode_sales_business_clazz_changes.clazz_changed in (?)", clazz_changes)
240
+ end
241
+
236
242
  if params[:sort].present? && params[:sort][:field]
237
243
  if params[:sort][:field] == "service_end_time"
238
244
  @businesses = @businesses.order("service_time_long #{params[:sort][:order]}")
@@ -243,9 +249,10 @@ module EducodeSales
243
249
  @businesses = @businesses.order("educode_sales_businesses.created_at desc")
244
250
  end
245
251
 
246
- @business_count = @businesses.count
252
+ @business_count = @businesses.distinct.count
247
253
  # mysql -select
248
254
  @businesses = @businesses.select("
255
+ distinct
249
256
  educode_sales_businesses.*,
250
257
  last_follow.invitation_at,
251
258
  last_follow.budget_amount,
@@ -84,7 +84,14 @@ module EducodeSales
84
84
 
85
85
  follow_up.profit_amount = follow_up.actual_amount - (follow_up.divide_amount.to_i) if follow_up.actual_amount
86
86
  last_follow_up = @business.last_follow_up
87
- follow_up.clazz_changed = last_follow_up.clazz_id != follow_up.clazz_id if last_follow_up.present?
87
+ if last_follow_up.present?
88
+ follow_up.clazz_changed = last_follow_up.clazz_id != follow_up.clazz_id
89
+ if follow_up.clazz_changed
90
+ clazz_changes = "#{last_follow_up.clazz.extras.split('_')[0]}-#{follow_up.clazz.extras.split('_')[0]}"
91
+ business_clazz_change = @business.business_clazz_changes.find_or_initialize_by clazz_changed: clazz_changes
92
+ business_clazz_change.save unless business_clazz_change.persisted?
93
+ end
94
+ end
88
95
  if follow_up.save
89
96
  if last_follow_up.present?
90
97
  last_follow_up.key_person.each do |d|
@@ -9,11 +9,11 @@ module EducodeSales
9
9
 
10
10
  has_many :sale_plans
11
11
  has_many :follow_ups
12
+ has_many :business_clazz_changes
12
13
 
13
14
  #关联关注
14
15
  has_many :users,:class_name => 'EducodeSales::BusinessRelationShip',foreign_key: 'business_id',:dependent => :destroy
15
16
 
16
-
17
17
  #每次查询时 默认的查询条件
18
18
  default_scope -> {where(deleted_at: nil)}
19
19
 
@@ -43,4 +43,5 @@ module EducodeSales
43
43
  }[type]
44
44
  end
45
45
  end
46
+
46
47
  end
@@ -0,0 +1,21 @@
1
+ module EducodeSales
2
+ class BusinessClazzChange < ApplicationRecord
3
+ belongs_to :business
4
+ validates :clazz_changed, uniqueness: { message: '已存在' }
5
+
6
+
7
+
8
+ def self.clazz_changes_value
9
+ {
10
+ '1' => ['a-x', 'b-x', 'c-x'],
11
+ '2' => ['b-a', 'c-a', 'd-a'],
12
+ '3' => ['a-x'],
13
+ '4' => ['a-x', 'b-x'],
14
+ '5' => ['a-x', 'b-x', 'c-x'],
15
+ '6' => ['b-a'],
16
+ '7' => ['b-a', 'c-a'],
17
+ '8' => ['b-a', 'c-a', 'd-a']
18
+ }
19
+ end
20
+ end
21
+ end
@@ -33,6 +33,22 @@
33
33
  <%= select_tag "staff_id", options_for_select(@staffs, params[:staff_id]), { 'lay-filter': 'staff_id', include_blank: true } %>
34
34
  </div>
35
35
  </div>
36
+ <div class="layui-inline">
37
+ <label class="layui-form-label">商机变化</label>
38
+ <div class="layui-input-inline">
39
+ <select name="clazz_changes">
40
+ <option value=""></option>
41
+ <option value="1">商机降级</option>
42
+ <option value="2">商机晋级</option>
43
+ <option value="3">商机降级 A-X</option>
44
+ <option value="4">商机降级 AB-X</option>
45
+ <option value="5">商机降级 ABC-X</option>
46
+ <option value="6">商机晋级 B-A</option>
47
+ <option value="7">商机晋级 BC-A</option>
48
+ <option value="8">商机晋级 BCD-A</option>
49
+ </select>
50
+ </div>
51
+ </div>
36
52
  <div class="layui-inline show_item" style="<%= params[:name] || params[:type] ? '' : 'display:none;' %>">
37
53
  <label class="layui-form-label">项目类型</label>
38
54
  <div class="layui-input-inline">
@@ -0,0 +1,10 @@
1
+ class CreateEducodeSalesBusinessClazzChanges < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :educode_sales_business_clazz_changes do |t|
4
+ t.references :business
5
+ t.string :clazz_changed
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.9.31'
2
+ VERSION = '0.9.32'
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.9.31
4
+ version: 0.9.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-15 00:00:00.000000000 Z
11
+ date: 2023-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -186,6 +186,7 @@ files:
186
186
  - app/models/educode_sales/assessments_setting.rb
187
187
  - app/models/educode_sales/assign_follow_up.rb
188
188
  - app/models/educode_sales/business.rb
189
+ - app/models/educode_sales/business_clazz_change.rb
189
190
  - app/models/educode_sales/business_export_record.rb
190
191
  - app/models/educode_sales/business_number_record.rb
191
192
  - app/models/educode_sales/business_relation_ship.rb
@@ -484,6 +485,7 @@ files:
484
485
  - db/migrate/20221025094655_delete_business_number.rb
485
486
  - db/migrate/20221107122147_change_divide_rate_follow_ups.rb
486
487
  - db/migrate/20230115080730_add_origin_business_id_to_follow_ups.rb
488
+ - db/migrate/20230117144025_create_educode_sales_business_clazz_changes.rb
487
489
  - lib/educode_sales.rb
488
490
  - lib/educode_sales/engine.rb
489
491
  - lib/educode_sales/version.rb