@@ -24,7 +24,7 @@ def start_import
24
24
else
25
25
ActiveRecord ::Base . transaction do
26
26
begin
27
- is_valid , value = check_valid ( row )
27
+ is_valid , value = check_valid ( row )
28
28
if is_valid
29
29
attributes = value
30
30
column = column ( row )
@@ -39,7 +39,7 @@ def start_import
39
39
platform_id : Platform . manual_input . id ,
40
40
source_channel : 'manual' ,
41
41
owner_group_id : group_id )
42
- customer . update! ( cellphone : column . c_email ) if customer . id . present? && column . c_email . present?
42
+ customer . update! ( cellphone : column . c_cellphone ) if customer . id . present? && column . c_cellphone . present?
43
43
attributes . merge! ( { user_id : customer . id } )
44
44
end
45
45
ticket = Ticket . new ( attributes )
@@ -56,7 +56,6 @@ def start_import
56
56
@record . update! ( failure_count : @unsuccessful_data . size , treated_count : row_num - 1 )
57
57
end
58
58
save_unsuccessful_data_to_file
59
- Sidekiq . logger . info "==================#{ @unsuccessful_data } "
60
59
@record . update! ( completed : true )
61
60
end
62
61
@@ -156,14 +155,13 @@ def check_valid(row)
156
155
end
157
156
158
157
def validate_email_cellphone ( email , cellphone )
159
- customer_a_id = nil
160
- customer_b_id = nil
158
+ customer_a_id , customer_b_id = nil , nil
161
159
if email . present?
162
160
return [ false , "邮件格式错误" ] unless email =~ EMAIL_REGEXP
163
161
customer_a_id = @company . customers . find_in_emails ( email ) . try ( :id )
164
162
end
165
163
if cellphone . present?
166
- return [ false , "电话号码格式错误" ] unless PhoneNumber . new ( cellphone ) . valid?
164
+ return [ false , "电话号码格式错误" ] unless :: PhoneNumber . new ( cellphone ) . valid?
167
165
customer_b_id = @company . customers . find_in_cellphones ( cellphone ) . try ( :id )
168
166
end
169
167
if customer_a_id && customer_b_id
@@ -185,6 +183,7 @@ def validate_agent_and_owner_group(group_name, agent_email)
185
183
unless @company . user_groups . where ( name : group_name ) . exists?
186
184
return [ false , "受理客服组不存在" ]
187
185
end
186
+ user_group_id = @company . user_groups . find_by ( name : group_name ) . try ( :id )
188
187
end
189
188
if agent_email . present? && group_name . present?
190
189
user_id = @company . agents . find_by ( email : agent_email ) . try ( :id )
@@ -235,7 +234,7 @@ def validate_custom_fields(template_name, row)
235
234
import_fields . each_with_index do |custom_field , i |
236
235
title = custom_field . first
237
236
field = custom_field . last
238
- _index = field [ :index ] # field.index is not right
237
+ _index = field [ :index ]
239
238
column = row [ _index ]
240
239
return [ false , "#{ title } 为必填字段" ] if field . is_require && column . blank?
241
240
if field && column . present?
@@ -290,7 +289,7 @@ def get_index_value(values, options)
290
289
indexes . join ( "," )
291
290
end
292
291
293
- # 根据头部的命名,得到普通字段和列索引之间的map关系 ,用一个hash存储
292
+ # 根据头部的命名,得到普通字段和excel列索引之间的map关系 ,用一个hash存储
294
293
def column_map
295
294
column_hash = Hashie ::Mash . new
296
295
@head_data . each_with_index do |head , index |
0 commit comments