blsm-mp-wx 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmRjNmMzOTQxNzc3NzczY2ZjZWQ1MmY2MDc0ODVhMWRiNjU5Y2Q2NQ==
4
+ MDJmYWNiNzAwZmNlMmM2YmQwNDEwNTBiM2M2ZmJkZTQxNjc2MWE0MA==
5
5
  data.tar.gz: !binary |-
6
- YzM0MmRlNTcyZTYzNzI5NGNkYmU5YzNiZmIyNzU2NjE2YTBlYWNiMQ==
6
+ ZDNiMWQzZTgwMWE4ZjM2ZjA4MDJlOTU1YWVmOTNmMmE4YmI1OTc1Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2ZmMzE3MTM2Nzc2MzBjNmFlZjk1MzdlNjQ2NjhiNjRjZWE1MjI5MzEwMjA1
10
- OTAyODBlMGZjZmM5MzljMzYzNDI3MGE5YjY5NjUwYWE3ZWU3M2I0NWY1Y2Zj
11
- MmU4MWJiY2ViMWE4NGNhYzY1MmY5OTQ2YzIzYjUwMTBlNTIwODg=
9
+ MzZiM2VlMzViMDI0NzdkYzVhZjRjNzg5OGJkNDEyNjhmYTU2ZjAzNmFjOWUx
10
+ NTk3ODRhNmMyOTc4NDM5ZWExNjEzOTM5NGMxOGI0NTBhY2I0NDFmNGMwODM5
11
+ ZTE0ZWM1YzZhMTIyOWY2M2M4NDhjYTczNDVjZjVmZWNjOTI5NTc=
12
12
  data.tar.gz: !binary |-
13
- N2FlZmQxNDlkYjA2OWJmZmY0M2NkYWY2MjRmYTY3OWNjNDg3M2M1MThiZWE3
14
- ZmY3Mzg0M2I0ODUwNDY0NjQ5ZWI1ZjhiOWIwN2Y0MmMzYjk4NzVjNzE0M2Q0
15
- ZTYyNDFiMjgxOGIzY2VkYjE4ZTQ5NTRjOGI5ZmNkNWM2MjdjZGI=
13
+ N2FiNzIxOTAxMTIyNGYwOGU5ZTcwMWVkMDI3ODhkYzUwNjYxMWI1ZDYyMzEw
14
+ Y2YxZWI2Nzc1NTBmZDViMThhNzdjNDJjMjc1MGU0M2I3ZDEwMTgxM2M4MzZl
15
+ NDFkYTk2ZWMwNTFiOWY5MDMzMTM0Nzk4MjU5NjcwMmFlNjMxMWE=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blsm-mp-wx (0.1.4)
4
+ blsm-mp-wx (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://ruby.taobao.org/
@@ -0,0 +1,7 @@
1
+ # coding: utf-8
2
+ module BlsmMpWx
3
+ class VdMpMsg < BaseRecord
4
+ self.table_name='vd_mp_msgs'
5
+
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module BlsmMpWx
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
data/lib/blsm-mp-wx.rb CHANGED
@@ -7,6 +7,7 @@ require 'active_support'
7
7
  require 'blsm-mp-wx/version'
8
8
  require 'blsm-mp-wx/model/active_record'
9
9
  require 'blsm-mp-wx/model/vd_mp_wx'
10
+ require 'blsm-mp-wx/model/vd_mp_msg'
10
11
  require 'json'
11
12
  require 'faraday'
12
13
 
@@ -206,6 +207,30 @@ module BlsmMpWx
206
207
  json_obj['short_url']
207
208
  end
208
209
 
210
+ #创建消息,存储到消息队列中
211
+ #====Parameters
212
+ # * +app_id+ - 公众号的唯一标识
213
+ # * +openid+ - 发送给用户的openid
214
+ # * +content+ - 消息内容
215
+ # * +msg_name+ - 消息种类:new_order(新订单通知)、balance(结算通知)、score_change(积分变动通知)、custom(普通消息)
216
+ # new_order => content: {touser:'openid',order_id:''} 系统自动优先使用模板消息发送通知
217
+ # balance => content: {touser:'openid',clearing_id} 系统自动优先使用模板消息发送通知
218
+ # score_change => content: {touser:'',change:5,total:25,content:'邀请他人。。。。'}
219
+ def create_msg(app_id=nil, openid, content, msg_name)
220
+ app_id ||= self.APP_ID
221
+ return nil unless openid
222
+ return nil unless content[:touser]==openid
223
+ return nil unless %w(new_order balance score_change custom).include?(msg_name)
224
+ VdMpMsg.create({
225
+ app_id: app_id,
226
+ openid: openid,
227
+ content: content,
228
+ msg_name: msg_name,
229
+ template: %w(new_order balance score_change).include?(msg_name),
230
+ status: 'none'
231
+ })
232
+ end
233
+
209
234
  private
210
235
  #解析json类型的数据,并将最后的数据转为hash或array
211
236
  # +json_data_str+ 要转换的json数据
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blsm-mp-wx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-13 00:00:00.000000000 Z
11
+ date: 2015-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -155,6 +155,7 @@ files:
155
155
  - blsm-mp-wx.gemspec
156
156
  - lib/blsm-mp-wx.rb
157
157
  - lib/blsm-mp-wx/model/active_record.rb
158
+ - lib/blsm-mp-wx/model/vd_mp_msg.rb
158
159
  - lib/blsm-mp-wx/model/vd_mp_wx.rb
159
160
  - lib/blsm-mp-wx/version.rb
160
161
  homepage: https://bitbucket.org/liuxi/blsm-mp-wx/