lib/blsm-mp-wx.rb in blsm-mp-wx-0.2.4 vs lib/blsm-mp-wx.rb in blsm-mp-wx-0.2.5

- old
+ new

@@ -18,11 +18,11 @@ class << self attr_accessor :APP_ID attr_accessor :APP_ID_2 - MP_MSG_TYPES = %w(new_order balance score_change distribute custom split_order order todo) #微信公众号消息类型 + # MP_MSG_TYPES = %w(new_order balance score_change account_change distribute custom split_order order todo) #微信公众号消息类型 #根据app_id获取access_token #系统会根据当前的access_token即过期时间,自动更新并返回 #开发者无需关心这里的access_token怎么更新 #===Parameters @@ -216,33 +216,33 @@ # * +content+ - 消息内容 # * +msg_name+ - 消息种类:new_order(新订单通知)、balance(结算通知)、score_change(积分变动通知)、order(订单通知)、todo(待处理)、split_order(分单)、custom(普通消息) # new_order => content: {touser:'openid',order_id:''} 系统自动优先使用模板消息发送通知 # balance => content: {touser:'openid',clearing_id} 系统自动优先使用模板消息发送通知 # score_change => content: {touser:'',change:5,total:25,content:'邀请他人。。。。'} - def create_msg(app_id=nil, openid, content, msg_name) + def create_msg(app_id=nil, openid, content, msg_name, template_msg=false) app_id ||= self.APP_ID return nil unless openid return nil unless content[:touser]==openid - return nil unless MP_MSG_TYPES.include?(msg_name) + # return nil unless MP_MSG_TYPES.include?(msg_name) VdMpMsg.create({ app_id: app_id, openid: openid, content: content.to_json, msg_name: msg_name, - template_msg: MP_MSG_TYPES.include?(msg_name), + template_msg: template_msg, status: 'none' }) end - def create_msg!(app_id=nil, openid, content, msg_name) + def create_msg!(app_id=nil, openid, content, msg_name, template_msg=false) app_id ||= self.APP_ID VdMpMsg.create!({ app_id: app_id, openid: openid, content: content.to_json, msg_name: msg_name, - template_msg: MP_MSG_TYPES.include?(msg_name), + template_msg: template_msg, status: 'none' }) end #批量获取公众号的素材列表