From 998a27f55f81a498830ca7cbf62d5d4fbf5bbb73 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 31 Jul 2019 17:09:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E5=90=8D=E3=80=81=E8=81=8C=E4=B8=9A?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E5=92=8C=E8=80=81=E5=B8=88=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E7=9A=84=E7=9F=AD=E4=BF=A1=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 2 +- app/services/discusses_service.rb | 2 +- app/services/users/update_account_service.rb | 8 ++++++++ lib/educoder/sms.rb | 4 +++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index bc5b0a607..396c0900e 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -222,7 +222,7 @@ class SubjectsController < ApplicationController @subject.update_attributes(status: 1) ApplyAction.create(container_type: "ApplySubject", container_id: @subject.id, user_id: current_user.id, status: 0) begin - status = Trustie::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员') + status = Educoder::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员') rescue => e uid_logger_error("发送验证码出错: #{e}") end diff --git a/app/services/discusses_service.rb b/app/services/discusses_service.rb index c14850a4c..81ac1eb33 100644 --- a/app/services/discusses_service.rb +++ b/app/services/discusses_service.rb @@ -58,7 +58,7 @@ class DiscussesService praise_count: 0, position: params[:position], challenge_id: params[:challenge_id], hidden: !current_user.admin? ) # 发送手机通知 - Trustie::Sms.send(mobile:'18173242757', send_type:'discuss', name:'管理员') + Educoder::Sms.send(mobile:'18173242757', send_type:'discuss', name:'管理员') rescue Exception => e raise(e.message) end diff --git a/app/services/users/update_account_service.rb b/app/services/users/update_account_service.rb index d603cec8c..603f9beaa 100644 --- a/app/services/users/update_account_service.rb +++ b/app/services/users/update_account_service.rb @@ -51,6 +51,8 @@ class Users::UpdateAccountService < ApplicationService if first_full_reward RewardGradeService.call(user, container_id: user.id, container_type: 'Account', score: 500) + + sms_notify_admin if extension.teacher? end user @@ -65,4 +67,10 @@ class Users::UpdateAccountService < ApplicationService def user_extension_attributes params.slice(*%i[location location_city identity student_id technical_title school_id department_id]) end + + def sms_notify_admin + Educoder::Sms.send(mobile:'18175896138', send_type:'teacher_register', name:'管理员') + rescue => ex + Util.logger_error(ex) + end end \ No newline at end of file diff --git a/lib/educoder/sms.rb b/lib/educoder/sms.rb index 7fa1c0edb..63287301d 100644 --- a/lib/educoder/sms.rb +++ b/lib/educoder/sms.rb @@ -21,7 +21,7 @@ module Educoder def self.notify_admin(opt) opt[:name] = '管理员' - opt[:mobile] = ENV['NOTIFY_ADMIN_PHONE'] || EduSetting.get('notify_admin_phone') || '17680641960' + opt[:mobile] = ENV['NOTIFY_ADMIN_PHONE'] || EduSetting.get('notify_admin_phone') || '18711085785' send(opt) end @@ -40,6 +40,8 @@ module Educoder elsif send_type == 'competition_start' params['text'] = "【Edu实训】亲爱的#{user_name},你参与的#{name}将于#{result}开始,请及时参赛" Rails.logger.info "#{params['text']}" + elsif send_type == "teacher_register" + params['text'] = "【Edu实训】亲爱的#{user_name},有新的老师#{name}注册啦,请尽快处理" elsif send_type == 'subject_authorization' || send_type == 'shixun_authorization' params['text'] = "【Edu实训】亲爱的#{user_name},您提交的#{name}#{send_type=='subject_authorization'?'实训路径':'实训'}发布申请#{result},请登录平台查看详情" Rails.logger.info "#{params['text']}"