|
|
|
@ -139,6 +139,38 @@ class WechatService
|
|
|
|
|
data
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def three_keys_template(openid, template_id, type, id, first, key1, key2, key3, remark="")
|
|
|
|
|
data = {
|
|
|
|
|
touser:openid,
|
|
|
|
|
template_id:template_id,
|
|
|
|
|
url:"#{Setting.protocol}://#{Setting.host_name}/assets/wechat/app.html#/#{type}/#{id}",
|
|
|
|
|
topcolor:"#FF0000",
|
|
|
|
|
data:{
|
|
|
|
|
first: {
|
|
|
|
|
value:first,
|
|
|
|
|
color:"#707070"
|
|
|
|
|
},
|
|
|
|
|
keyword1:{
|
|
|
|
|
value:key1,
|
|
|
|
|
color:"#707070"
|
|
|
|
|
},
|
|
|
|
|
keyword2:{
|
|
|
|
|
value:key2,
|
|
|
|
|
color:"#707070"
|
|
|
|
|
},
|
|
|
|
|
keyword3:{
|
|
|
|
|
value:key3,
|
|
|
|
|
color:"#707070"
|
|
|
|
|
},
|
|
|
|
|
remark:{
|
|
|
|
|
value:remark,
|
|
|
|
|
color:"#707070"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
data
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def four_keys_template(openid, template_id, type, id, first, key1, key2, key3, key4, remark="")
|
|
|
|
|
data = {
|
|
|
|
|
touser:openid,
|
|
|
|
@ -250,4 +282,17 @@ class WechatService
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create_class_notice(user_id, type, id, first, key1, key2, key3, remark="")
|
|
|
|
|
uw = UserWechat.where(user_id: user_id).first
|
|
|
|
|
unless uw.nil?
|
|
|
|
|
data = three_keys_template uw.openid,Wechat.config.create_class_notice, type, id, first, key1, key2, key3, remark
|
|
|
|
|
begin
|
|
|
|
|
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
Rails.logger.error "[wechat_create_class_notice] ===> #{e}"
|
|
|
|
|
end
|
|
|
|
|
Rails.logger.info "send over. #{req}"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|