blsm-vd-core 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 240d6c8e38c044bf1aad23991ab7ee642677db58
4
- data.tar.gz: 6b7436ba1dbcbc3c4de9f5c551bd02c350cebe94
3
+ metadata.gz: a14598f3a42dfe34904abf376cce255e1f295494
4
+ data.tar.gz: 858bf0a1a8e02413217f8cc585b6de27807d4269
5
5
  SHA512:
6
- metadata.gz: c1e5bae2d12dfe7802bdb64f7df36cbff480c39e8215196a95ce3375dee7cb413b3a9b6f8e958fa8a3462d2b752c10e7544aefbeb4f2400119c3780d7f8a3ac3
7
- data.tar.gz: 9e508ece749fe38479b92ce3331d1711e55248524b76cd2945c8f45d15c52a2b3c1d243a3b2ef76e5a7c58aa315e845a1b6888bbd7bccce41299843df2a4dc92
6
+ metadata.gz: 54edac05c01753362d2720a44b456736d79458f13e1426776d4d6c750340b48177261a957fdb42449a75ecff97626a45da12d6981d579508dd4c3aaf202cb195
7
+ data.tar.gz: b97b0279512adbf0c1e178ce0e89801a630b4b2a1a2c991e4d6733a29ef0e3489a9c4c375039e52f37fa281ee21f660fa1873eeeee4566acdf1b3401cee0da6f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blsm-vd-core (0.6.9)
4
+ blsm-vd-core (0.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://ruby.taobao.org/
@@ -15,7 +15,6 @@ module BlsmVdCore
15
15
  'CU:TemplateMsg' => '模板消息'
16
16
  }
17
17
 
18
-
19
18
  # 店主:新订单通知
20
19
  def self.create_new_order_notify(user_id, order_id)
21
20
  user = BlsmVdCore::User.where(id: user_id).first
@@ -34,6 +33,38 @@ module BlsmVdCore
34
33
  body: "您好,客户#{order.ubox_order? ? '' : order.name}在您店里下了一个订单,请及时处理。"
35
34
  },
36
35
  items: [
36
+ "订单编号:#{order.number}",
37
+ "下单时间:#{order.created_at.to_s[0, 16]}",
38
+ "支付方式:#{order.pay_type.to_i==0 ? '在线支付' : '货到付款'}",
39
+ "客户信息:#{order.ubox_order? ? "售货机#{order.ubox_vmid}扫码用户" : "#{order.shipping_province} #{order.name} #{order.phone}"}",
40
+ "买家留言:#{order.comment}"
41
+ ],
42
+ url: "http://wunion.4007060700.com/mobile/jms_orders/#{order.to_param}"
43
+ }.to_json
44
+ })
45
+
46
+ end
47
+
48
+
49
+ # 店主:拆分订单通知
50
+ def self.create_split_order_notify(user_id, order_id)
51
+ user = BlsmVdCore::User.where(id: user_id).first
52
+ order = Order.where(id: order_id).first
53
+ return nil unless order && user && user.rc_user
54
+
55
+ BlsmVdCore::VdRcMsgNotify.create({
56
+ user_id: 3,
57
+ to_ids: user.username,
58
+ to_type: 'single',
59
+ msg_type: 'CU:TemplateMsg',
60
+ title: '拆分订单通知',
61
+ content: {
62
+ title: '拆分订单通知',
63
+ content: {
64
+ body: "您好,订单#{order.number}根据发货地不同拆分为多个订单,请及时处理。"
65
+ },
66
+ items: [
67
+ "订单编号:#{order.number}",
37
68
  "下单时间:#{order.created_at.to_s[0, 16]}",
38
69
  "支付方式:#{order.pay_type.to_i==0 ? '在线支付' : '货到付款'}",
39
70
  "客户信息:#{order.ubox_order? ? "售货机#{order.ubox_vmid}扫码用户" : "#{order.shipping_province} #{order.name} #{order.phone}"}",
@@ -46,16 +77,77 @@ module BlsmVdCore
46
77
  end
47
78
 
48
79
 
80
+ #黑带: 店主确认新订单通知
81
+ def self.create_distribute_notify(user_id, order_id, title, score)
82
+ user = BlsmVdCore::User.where(id: user_id).first
83
+ order = Order.where(id: order_id).first
84
+ return nil unless order && user && user.rc_user
85
+
86
+ BlsmVdCore::VdRcMsgNotify.create({
87
+ user_id: 3,
88
+ to_ids: user.username,
89
+ to_type: 'single',
90
+ msg_type: 'CU:TemplateMsg',
91
+ title: '店主确认订单通知',
92
+ content: {
93
+ title: '店主确认订单通知',
94
+ content: {
95
+ body: title
96
+ },
97
+ items: [
98
+ "订单编号:#{order.number}",
99
+ "下单时间:#{order.created_at.to_s[0, 16]}",
100
+ "订单金额:#{order.total_fee}",
101
+ "预收积分:#{score}",
102
+ "备注:订单签收后您会获取相应积分"
103
+ ],
104
+ url: "http://wunion.4007060700.com/mobile/jms_orders/#{order.to_param}/only_show"
105
+ }.to_json
106
+ })
107
+
108
+ end
109
+
110
+
111
+ #店主: 物流返款通知
112
+ def self.create_cashback_notify(user_id, order_id)
113
+ user = BlsmVdCore::User.where(id: user_id).first
114
+ order = Order.where(id: order_id).first
115
+ return nil unless order && user && user.rc_user
116
+
117
+ BlsmVdCore::VdRcMsgNotify.create({
118
+ user_id: 3,
119
+ to_ids: user.username,
120
+ to_type: 'single',
121
+ msg_type: 'CU:TemplateMsg',
122
+ title: '物流返款通知',
123
+ content: {
124
+ title: '物流返款通知',
125
+ content: {
126
+ title: '返款金额',
127
+ body: "#{order.pay_type.to_i==0 ? order.total_fee : order.actual_total}"
128
+ },
129
+ items: [
130
+ "订单编号:#{order.number}",
131
+ "下单时间:#{order.created_at.to_s[0, 16]}",
132
+ "订单金额:#{order.total_fee}",
133
+ "预计收入:#{order.jm_profit}元"
134
+ ],
135
+ url: "http://wunion.4007060700.com/mobile/jms_orders/#{order.to_param}/only_show?change=√"
136
+ }.to_json
137
+ })
138
+
139
+ end
140
+
141
+
49
142
  #创建结算通知
50
143
  # msg_content['content'] 标题内容
51
144
  # msg_content['change'] 结算金额
52
145
  # msg_content['account_type'] 账户类型
53
146
  # msg_content['total'] 账户总余额
54
- def self.create_account_change_notify(user_id, msg_content)
147
+ def self.create_account_change_notify(user_id, body, money, account_type, total, url='http://wunion.4007060700.com/mobile/my_clearings')
55
148
  user = BlsmVdCore::User.where(id: user_id).first
56
149
  return nil unless user && user.rc_user
57
150
 
58
- msg_content = msg_content.symbolize_keys
59
151
  BlsmVdCore::VdRcMsgNotify.create({
60
152
  user_id: 3,
61
153
  to_ids: user.username,
@@ -65,16 +157,47 @@ module BlsmVdCore
65
157
  content: {
66
158
  title: '结算通知',
67
159
  content: {
68
- body: msg_content[:content]
160
+ body: body
69
161
  },
70
162
  items: [
71
- "结算账户:#{user.phone}",
72
163
  "结算时间:#{Time.now.strftime('%F')}",
73
- "结算金额:#{msg_content[:change]}",
74
- "#{msg_content[:account_type]}余额:#{msg_content[:total]}",
164
+ "结算金额:#{money}",
165
+ "#{account_type}余额:#{total}",
75
166
  "备注:感谢您对首趣一如既往的支持,商城客户热线4007060700!"
76
167
  ],
77
- url: 'http://wunion.4007060700.com/mobile/jms_orders'
168
+ url: url
169
+ }.to_json
170
+ })
171
+
172
+ end
173
+
174
+
175
+ #创建积分变动通知
176
+ # msg_content['content'] 标题内容
177
+ # msg_content['change'] 结算金额
178
+ # msg_content['account_type'] 账户类型
179
+ # msg_content['total'] 账户总余额
180
+ def self.create_score_change_notify(user_id, body, change, account_type, total, url='http://wunion.4007060700.com/mobile/my_scores')
181
+ user = BlsmVdCore::User.where(id: user_id).first
182
+ return nil unless user && user.rc_user
183
+
184
+ BlsmVdCore::VdRcMsgNotify.create({
185
+ user_id: 3,
186
+ to_ids: user.username,
187
+ to_type: 'single',
188
+ msg_type: 'CU:TemplateMsg',
189
+ title: '积分变动通知',
190
+ content: {
191
+ title: '积分变动通知',
192
+ content: {
193
+ body: body
194
+ },
195
+ items: ["账户名称:#{user.phone}",
196
+ "增加积分:#{change}",
197
+ "#{account_type}余额:#{total}",
198
+ "备注:感谢您对首趣一如既往的支持,商城客户热线4007060700!"
199
+ ],
200
+ url: url
78
201
  }.to_json
79
202
  })
80
203
 
@@ -82,7 +205,7 @@ module BlsmVdCore
82
205
 
83
206
 
84
207
  #创建订单拒签通知
85
- def self.create_order_sign_fail_notify(user_id, score_change, order_number, content)
208
+ def self.create_order_sign_fail_notify(user_id, score_change, order_number, body)
86
209
  user = BlsmVdCore::User.where(id: user_id).first
87
210
  return nil unless user && user.rc_user
88
211
 
@@ -96,7 +219,7 @@ module BlsmVdCore
96
219
  content: {
97
220
  title: '订单拒签、签收通知',
98
221
  content: {
99
- body: content
222
+ body: body
100
223
  },
101
224
  items: [
102
225
  "订单编号:#{order_number}",
@@ -1,3 +1,3 @@
1
1
  module BlsmVdCore
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
data/lib/blsm-vd-core.rb CHANGED
@@ -93,8 +93,14 @@ module BlsmVdCore
93
93
  return ERROR_CODES[4045] unless seller
94
94
 
95
95
  #物流返款通知
96
- seller_notify = {touser: seller.openid, order_id: Order.encrypt(Order.encrypted_id_key, order.id.to_s), content: "【物流返款通知】"}
97
- BlsmMpWx.create_msg(wx_app_id, seller.openid, seller_notify, 'order')
96
+ if seller.rc_user
97
+ VdRcMsgNotify.create_cashback_notify(seller.id, order.id)
98
+ end
99
+
100
+ if seller.openid
101
+ seller_notify = {touser: seller.openid, order_id: Order.encrypt(Order.encrypted_id_key, order.id.to_s), content: "【物流返款通知】"}
102
+ BlsmMpWx.create_msg(wx_app_id, seller.openid, seller_notify, 'order')
103
+ end
98
104
 
99
105
  ERROR_CODES[200]
100
106
  end
@@ -198,13 +204,26 @@ module BlsmVdCore
198
204
 
199
205
  #订单确认提醒(黑带)
200
206
  leader_change = order.get_vd_score(leader_info.vd_role) if leader_info
201
- distribute_leader_notify = {touser: leader.openid,
202
- order_id: Order.encrypt(Order.encrypted_id_key, order.id.to_s),
203
- score_change: leader_change,
204
- money_change: (leader_change*VdUserScore::SCORES[:SCORE_TO_MONEY]).round(2),
205
- content: "首趣黑带#{leader.username},你好:你的队员【#{user.username}】已成功确认订单,"
206
- } if leader && leader_info && !order.ubox_order?
207
- BlsmMpWx.create_msg(nil, leader.openid, distribute_leader_notify, 'distribute') if distribute_leader_notify
207
+
208
+ if leader && leader_info && !order.ubox_order?
209
+ content = "首趣黑带#{leader.username},你好:你的队员【#{user.username}】已成功确认订单,"
210
+
211
+ #客户端通知
212
+ if leader.rc_user
213
+ VdRcMsgNotify.create_distribute_notify(leader.id, order.id, content, leader_change)
214
+ end
215
+
216
+ #微信通知
217
+ if leader.openid
218
+ distribute_leader_notify = {touser: leader.openid,
219
+ order_id: Order.encrypt(Order.encrypted_id_key, order.id.to_s),
220
+ score_change: leader_change,
221
+ money_change: (leader_change*VdUserScore::SCORES[:SCORE_TO_MONEY]).round(2),
222
+ content: content
223
+ }
224
+ BlsmMpWx.create_msg(nil, leader.openid, distribute_leader_notify, 'distribute')
225
+ end
226
+ end
208
227
 
209
228
  return ERROR_CODES[200]
210
229
  end
@@ -287,8 +306,16 @@ module BlsmVdCore
287
306
  if seller_change!=0 && !order.ubox_order?
288
307
  seller_info.change_score(seller_change)
289
308
 
290
- seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "您好,订单#{order.number}已成功签收,分销#{franchise_sum}元"}
291
- BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
309
+ #融云推送
310
+ if seller.rc_user
311
+ VdRcMsgNotify.create_score_change_notify(seller.id, "您好,订单#{order.number}已成功签收,分销#{franchise_sum}元", seller_change, '积分', seller_info.score)
312
+ end
313
+
314
+ #微信通知
315
+ if seller.openid
316
+ seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "您好,订单#{order.number}已成功签收,分销#{franchise_sum}元"}
317
+ BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
318
+ end
292
319
  end
293
320
 
294
321
  VdUserScore.create({
@@ -302,8 +329,18 @@ module BlsmVdCore
302
329
  if leader && leader_info && leader_change && leader_change!=0 && !order.ubox_order?
303
330
 
304
331
  leader_info.change_score(leader_change)
305
- leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "首趣黑带#{leader.username},你好,你的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元"}
306
- BlsmMpWx.create_msg(nil, leader.openid, leader_notify, 'score_change')
332
+
333
+ #融云推送
334
+ if leader.rc_user
335
+ VdRcMsgNotify.create_score_change_notify(leader.id, "首趣黑带#{leader.username},你好,你的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元", leader_change, '积分', leader_info.score)
336
+ end
337
+
338
+ #微信通知
339
+ if leader.openid
340
+ leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "首趣黑带#{leader.username},你好,你的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元"}
341
+ BlsmMpWx.create_msg(nil, leader.openid, leader_notify, 'score_change')
342
+ end
343
+
307
344
  VdUserScore.create({
308
345
  user_id: leader.id,
309
346
  score: leader_change,
@@ -316,9 +353,21 @@ module BlsmVdCore
316
353
  if org_leader && org_leader_info && org_leader_change && org_leader_change!=0 && !order.ubox_order?
317
354
  org_leader_info.change_score(org_leader_change)
318
355
 
319
- org_leader_notify = {touser: org_leader.openid, change: org_leader_change, total: org_leader_info.score,
320
- content: "首趣黑带#{org_leader.username},你好,你的附属黑带【#{leader.username}】的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元"}
321
- BlsmMpWx.create_msg(nil, org_leader.openid, org_leader_notify, 'score_change')
356
+ #融云推送
357
+ if org_leader.rc_user
358
+ VdRcMsgNotify.create_score_change_notify(org_leader.id,
359
+ "首趣黑带#{org_leader.username},你好,你的附属黑带【#{leader.username}】的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元",
360
+ org_leader_change, '积分',
361
+ org_leader_info.score)
362
+ end
363
+
364
+ #微信通知
365
+ if org_leader.openid
366
+ org_leader_notify = {touser: org_leader.openid, change: org_leader_change, total: org_leader_info.score,
367
+ content: "首趣黑带#{org_leader.username},你好,你的附属黑带【#{leader.username}】的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元"}
368
+ BlsmMpWx.create_msg(nil, org_leader.openid, org_leader_notify, 'score_change')
369
+ end
370
+
322
371
  VdUserScore.create({
323
372
  user_id: org_leader.id,
324
373
  score: org_leader_change,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blsm-vd-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-09-06 00:00:00.000000000 Z
12
+ date: 2016-09-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec