Module: Model::Register
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/wechat/model/register.rb
Instance Method Summary collapse
- #bind_url ⇒ Object
- #compute_state ⇒ Object
- #email ⇒ Object
- #hello_code ⇒ Object
- #keyword1_code ⇒ Object
- #notify_auth ⇒ Object
- #notify_mobile_code ⇒ Object
- #notify_owner ⇒ Object
- #notify_promoter ⇒ Object
- #notify_qrcode ⇒ Object
- #organ_app ⇒ Object
- #promoter ⇒ Object
- #remark ⇒ Object
- #remark_code ⇒ Object
- #time ⇒ Object
Instance Method Details
#bind_url ⇒ Object
47 48 49 |
# File 'app/models/wechat/model/register.rb', line 47 def bind_url bind_qrcode.url end |
#compute_state ⇒ Object
67 68 69 70 71 72 73 |
# File 'app/models/wechat/model/register.rb', line 67 def compute_state if appid.present? self.state = 'done' else self.state = 'doing' end end |
#email ⇒ Object
75 76 77 |
# File 'app/models/wechat/model/register.rb', line 75 def email "#{mobile}@#{RailsWechat.config.email_domain}" end |
#hello_code ⇒ Object
55 56 57 |
# File 'app/models/wechat/model/register.rb', line 55 def hello_code '您好,我们正在协助您注册微信公众号' end |
#keyword1_code ⇒ Object
59 60 61 |
# File 'app/models/wechat/model/register.rb', line 59 def keyword1_code '手机号验证码' end |
#notify_auth ⇒ Object
121 122 123 124 125 126 127 128 129 |
# File 'app/models/wechat/model/register.rb', line 121 def notify_auth to_notification( user: user, code: 'auth', title: '授权服务', link: Platform.first.click_auth_url, organ_id: organ_id ) end |
#notify_mobile_code ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'app/models/wechat/model/register.rb', line 111 def notify_mobile_code to_notification( user: user, code: 'code', title: '手机验证码已下发,该验证码用于注册微信公众号', link: url_helpers.code_my_wechat_register_url(id, subdomain: organ_app&.subdomain), organ_id: organ_id ) end |
#notify_owner ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'app/models/wechat/model/register.rb', line 102 def notify_owner to_notification( user: user, title: '您好,这是您注册公众号绑定管理员的二维码', link: bind_url, organ_id: organ_id ) end |
#notify_promoter ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'app/models/wechat/model/register.rb', line 92 def notify_promoter return unless promoter to_notification( user: promoter.user, title: '管理员绑定二维码已生成,请邀请对方绑定', link: bind_url, organ_id: promoter.organ_id ) end |
#notify_qrcode ⇒ Object
131 132 133 134 |
# File 'app/models/wechat/model/register.rb', line 131 def notify_qrcode notify_owner notify_promoter end |
#organ_app ⇒ Object
79 80 81 |
# File 'app/models/wechat/model/register.rb', line 79 def organ_app organ.apps.default end |
#promoter ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'app/models/wechat/model/register.rb', line 83 def promoter open_id = user.wechat_users.find_by(appid: organ_app&.appid)&.uid if open_id wr = Request.where(open_id: open_id).default_where('body-ll': 'invite_member_').order(id: :desc).first member_id = wr&.body.to_s.delete_prefix('invite_member_') Member.find_by id: member_id end end |
#remark ⇒ Object
51 52 53 |
# File 'app/models/wechat/model/register.rb', line 51 def remark '此二维码不支持图片识别,可复制链接在电脑或其他手机上访问后再扫一扫!' end |
#remark_code ⇒ Object
63 64 65 |
# File 'app/models/wechat/model/register.rb', line 63 def remark_code '请点击链接,输入您收到的验证码。' end |
#time ⇒ Object
43 44 45 |
# File 'app/models/wechat/model/register.rb', line 43 def time Time.current.to_s end |