竞赛短信通知

dev_bj
cxt 6 years ago
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

@ -31,6 +31,8 @@ module Trustie
params['text'] = ""
if send_type.nil?
params['text'] = "【Edu实训】" + code + "(手机验证码)。如非本人操作,请忽略。"
elsif send_type == "competition_notice"
params['text'] = "【Edu实训】亲爱的#{name}你参与的全国绿色计算大赛2019于7月1日开始请及时完善信息详戳→http://opengcc.org.cn/"
elsif send_type == "teacher_register"
params['text'] = "【Edu实训】亲爱的#{user_name},有新的老师#{name}注册啦,请尽快处理"
elsif send_type == 'competition_start'

Loading…
Cancel
Save