blsm-vd-core 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/Gemfile.lock +1 -1
- data/lib/blsm-vd-core/model/vd_user_info.rb +5 -0
- data/lib/blsm-vd-core/version.rb +1 -1
- data/lib/blsm-vd-core.rb +72 -5
- metadata +25 -25
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
N2IzMTgwMWI3YzdhOTRkMzIxMjMzOGJiYjU2MmQyNjc1OTlmODA0MA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTYxNmEyM2Y0ZDVjY2JhM2EwODgwMWE2NzM0NTEwMTY5ZmU1OGE2MQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZGYxNjRiODRiZjQwMjg0MzFjMWVhNDI4N2UzOThlYzEzNmExNDYwYTNlNTM5
|
10
|
+
MjEyMDg4NTBkNTEyMjc2ZjQ2N2FjY2EyMDQzZjQwZWUxMjQwMjY3ZDg4MGI3
|
11
|
+
ZDI3MDNhMjNjZGI3M2IwNjBhN2YzZjFhNmJiMmMwZjUzOWU0ZjU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NGM4ZDUzYzE5NWZlM2I0YTczODRlMDZjNDEwZjU4NjIxYmIwNzdiOTYwMDBh
|
14
|
+
ZmY0MjA1N2YzNTEzOTU4OWQwMWU3MzVkZmIwMDc4YzdjYzA5NWYxYzBjYjNk
|
15
|
+
ODdkNDRmZjI3YjY2MTg1MGIyODFlNGI1OTljMGY2MDJmYzI3ZmE=
|
data/Gemfile.lock
CHANGED
@@ -6,6 +6,11 @@ module BlsmVdCore
|
|
6
6
|
belongs_to :user, class_name: '::BlsmVdCore::User'
|
7
7
|
belongs_to :supervisor, class_name: '::BlsmVdCore::User'
|
8
8
|
|
9
|
+
#變化積分
|
10
|
+
def change_score(changed_score)
|
11
|
+
self.update_attributes({score: self.score+changed_score})
|
12
|
+
end
|
13
|
+
|
9
14
|
#是否是黑带
|
10
15
|
def is_black?
|
11
16
|
self.vd_role == 'black'
|
data/lib/blsm-vd-core/version.rb
CHANGED
data/lib/blsm-vd-core.rb
CHANGED
@@ -65,12 +65,9 @@ module BlsmVdCore
|
|
65
65
|
return on_order_sale_out(order.application.user_id, order_id) if order.application
|
66
66
|
end
|
67
67
|
|
68
|
-
#订单被取消=>删除结算项
|
68
|
+
#订单被取消=>删除结算项(扣除積分)
|
69
69
|
if order.state.to_s.include?('订单取消')
|
70
|
-
order.
|
71
|
-
item.destroy unless item.state == 'CASH_BACK'
|
72
|
-
} if order.clearing_items
|
73
|
-
return ERROR_CODES[200]
|
70
|
+
return on_order_canceled(order.application.user_id, order_id) if order.application
|
74
71
|
end
|
75
72
|
|
76
73
|
#在线支付(客户签收,订单完成)=>确认结算项
|
@@ -255,4 +252,74 @@ module BlsmVdCore
|
|
255
252
|
|
256
253
|
end
|
257
254
|
|
255
|
+
|
256
|
+
#【積分消耗】商品售卖出去
|
257
|
+
# 什么时候调用此方法合适?当订单的状态变更为‘已取消’时
|
258
|
+
#微店主的积分会根据商品总的供货价的
|
259
|
+
#订单取消,微店主会被扣直接的 订单供货价 * +SCORES[:SALE_OUT_DIRECT]+ 积分
|
260
|
+
# 微店主所属的队长(直接上级)被扣 订单供货价 * +SCORES[:SALE_OUT_INDIRECT]+ 积分
|
261
|
+
#==== Parameters
|
262
|
+
# * +seller_id+ - 销售员的id
|
263
|
+
# * +order_id+ - 订单id
|
264
|
+
def on_order_canceled(seller_id, order_id)
|
265
|
+
seller = User.where(id: seller_id).first
|
266
|
+
leader = User.where("id in(select supervisor_id from vd_user_infos where user_id=#{seller_id})").first
|
267
|
+
order = Order.where(id: order_id).first
|
268
|
+
|
269
|
+
return ERROR_CODES[4045] unless seller
|
270
|
+
return ERROR_CODES[401] if !order || !order.application || !(order.application.user_id==seller_id)
|
271
|
+
|
272
|
+
|
273
|
+
return ERROR_CODES[0] unless order.clearing_items
|
274
|
+
|
275
|
+
#删除结算项
|
276
|
+
order.clearing_items.each { |item|
|
277
|
+
item.destroy unless item.state == 'CASH_BACK'
|
278
|
+
}
|
279
|
+
|
280
|
+
#安全校验(是否曾经被售出过)
|
281
|
+
sold_out = VdInfoSec.dangerous?("order_sale_out_#{seller_id}_#{order_id}")
|
282
|
+
return ERROR_CODES[200] unless sold_out
|
283
|
+
|
284
|
+
#安全校验(是否曾经此订单被取消,并且扣取积分)
|
285
|
+
vd_transaction = "order_sale_out_#{seller_id}_#{order_id}_then_cancel"
|
286
|
+
return ERROR_CODES[200] if VdInfoSec.dangerous?(vd_transaction)
|
287
|
+
|
288
|
+
#卖家和团队领导的信息
|
289
|
+
seller_info = seller.create_vd_user_info
|
290
|
+
leader_info = leader && leader.is_vd_black? ? leader.create_vd_user_info : nil
|
291
|
+
|
292
|
+
#供货价总和、应该扣取的积分总额
|
293
|
+
franchise_sum = order.franchise_sum
|
294
|
+
seller_change = -franchise_sum.to_f*VdUserScore::SCORES[:SALE_OUT_DIRECT]
|
295
|
+
leader_change = -franchise_sum.to_f*VdUserScore::SCORES[:SALE_OUT_INDIRECT]
|
296
|
+
|
297
|
+
#扣取积分
|
298
|
+
seller_info.change_score(seller_change)
|
299
|
+
leader_info.change_score(leader_change) if leader_info
|
300
|
+
|
301
|
+
#积分变动通知
|
302
|
+
seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "订单#{order_id}取消"}
|
303
|
+
leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "成员【#{seller.username}】订单#{order_id}取消,积分扣取"} if leader && leader_info
|
304
|
+
BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
|
305
|
+
BlsmMpWx.create_msg(nil, leader.openid, leader_notify, 'score_change') if leader_notify
|
306
|
+
|
307
|
+
#积分历史
|
308
|
+
VdUserScore.create({
|
309
|
+
user_id: seller_id,
|
310
|
+
score: seller_change,
|
311
|
+
notes: "订单#{order_id}取消,积分扣取"
|
312
|
+
})
|
313
|
+
VdUserScore.create({
|
314
|
+
user_id: leader.id,
|
315
|
+
score: leader_change,
|
316
|
+
notes: "成员【#{seller.username}】订单#{order_id}取消,积分扣取"
|
317
|
+
}) if leader_info
|
318
|
+
|
319
|
+
#安全库录入信息
|
320
|
+
VdInfoSec.committed(vd_transaction)
|
321
|
+
|
322
|
+
ERROR_CODES[200]
|
323
|
+
|
324
|
+
end
|
258
325
|
end
|
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.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saxer
|
@@ -14,140 +14,140 @@ dependencies:
|
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.9'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.9'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.2'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mysql2
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.3.16
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.3.16
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: activemodel
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '3.2'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.2'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: activerecord
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '3.2'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.2'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: activesupport
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '3.2'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ~>
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '3.2'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: faraday
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ~>
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0.9'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ~>
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0.9'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: blsm-mp-wx
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ~>
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: 0.1.8
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ~>
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.1.8
|
153
153
|
description: 首趣微店核心模块,包含结算项的创建、更新、删除,微店主积分的更改等信息
|
@@ -157,8 +157,8 @@ executables: []
|
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
|
-
-
|
161
|
-
-
|
160
|
+
- .gitignore
|
161
|
+
- .travis.yml
|
162
162
|
- Gemfile
|
163
163
|
- Gemfile.lock
|
164
164
|
- README.md
|
@@ -191,12 +191,12 @@ require_paths:
|
|
191
191
|
- lib
|
192
192
|
required_ruby_version: !ruby/object:Gem::Requirement
|
193
193
|
requirements:
|
194
|
-
- -
|
194
|
+
- - ! '>='
|
195
195
|
- !ruby/object:Gem::Version
|
196
196
|
version: '0'
|
197
197
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- -
|
199
|
+
- - ! '>='
|
200
200
|
- !ruby/object:Gem::Version
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|