parent
c94b1758db
commit
6b49e92424
@ -0,0 +1,35 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
namespace :competition_notice do
|
||||||
|
require 'simple_xlsx_reader'
|
||||||
|
|
||||||
|
task :send_message => :environment do
|
||||||
|
puts "--------------------------------competition_notice send_message start"
|
||||||
|
attachment = Attachment.where(id: 230670).first
|
||||||
|
if attachment.present?
|
||||||
|
path = attachment.disk_directory
|
||||||
|
name = attachment.disk_filename
|
||||||
|
if name.split(".").last == "xlsx"
|
||||||
|
doc = SimpleXlsxReader.open("files/#{path}/#{name}")
|
||||||
|
sheet = doc.sheets.first
|
||||||
|
lists = sheet.rows
|
||||||
|
|
||||||
|
lists.each_with_index do |list, index|
|
||||||
|
if index > 0
|
||||||
|
puts "--------------------------------user_name:#{list[0]}, user_phone:#{list[1]}"
|
||||||
|
user_name = list[0]
|
||||||
|
user_phone = list[1]
|
||||||
|
if user_name.present? && user_phone.present?
|
||||||
|
begin
|
||||||
|
status = Trustie::Sms.send(mobile: user_phone, send_type:'competition_notice' , name: user_name)
|
||||||
|
rescue => e
|
||||||
|
puts "--------------------------------发送验证码出错: #{user_name}---#{user_phone}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts "--------------------------------只支持xlsx文件"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue