blsm-vd-core 0.5.7 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile.lock +1 -1
- data/lib/blsm-vd-core.rb +22 -18
- data/lib/blsm-vd-core/model/order.rb +8 -2
- data/lib/blsm-vd-core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bc23518d04fe5711185d9ff221296bad389975b
|
4
|
+
data.tar.gz: 84e2e49660d867b1e9892478978f6cf71e4631bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1df46731003a908d359f2f9d7f9c010bd7ad6ece943a417e8bbb0ee9df4a542564c33e9acb6c454220d4294a198536c627dbe4063f66864eb8c799aecda724a7
|
7
|
+
data.tar.gz: b66f2605df6c74fe3ce56519e231061c324f08718a5b52468743fecbc89028299f74644c53e4922e65ff1a1a0fe00c688d595b7044656693d8a9aaac4f741a2a
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/blsm-vd-core.rb
CHANGED
@@ -62,10 +62,6 @@ module BlsmVdCore
|
|
62
62
|
return create_clearing_item(order_id)
|
63
63
|
end
|
64
64
|
|
65
|
-
#已发货,准备收货=>订单被售卖出去
|
66
|
-
# if order.state.to_s.include?('已发货,准备收货')
|
67
|
-
# return on_order_sale_out(order.application.user_id, order_id) if order.application
|
68
|
-
# end
|
69
65
|
|
70
66
|
#订单被取消=>删除结算项(扣除積分)
|
71
67
|
if order.state.to_s.include?('订单取消')
|
@@ -74,6 +70,9 @@ module BlsmVdCore
|
|
74
70
|
|
75
71
|
#在线支付(客户签收,订单完成)=>确认结算项
|
76
72
|
if order.state.to_s.include?('客户签收,订单完成')
|
73
|
+
create_clearing_item(order_id) if order.ubox_order?
|
74
|
+
clearing_item = ClearingItem.where(order_id: order.id).first if order.ubox_order?
|
75
|
+
|
77
76
|
on_order_sale_out(order.application.user_id, order_id) if order.application
|
78
77
|
clearing_item.update_attributes({earn_amount: order.jm_profit, state: 'CASH_BACK'}) if clearing_item && order.pay_on_line?
|
79
78
|
return ERROR_CODES[200]
|
@@ -169,21 +168,21 @@ module BlsmVdCore
|
|
169
168
|
|
170
169
|
#没有对应的结算项
|
171
170
|
if order.clearing_items.empty?
|
172
|
-
|
171
|
+
#线上订单(等待配货时创建结算项) 线下订单(客户签收时创建结算项)
|
172
|
+
if (!order.ubox_order? && order.state=='等待配货') || (order.ubox_order? && order.state=='客户签收,订单完成') || force
|
173
173
|
data = {}
|
174
174
|
data[:order_id] = order.id
|
175
175
|
data[:order_amount] = order.total_fee
|
176
176
|
data[:earn_amount] = order.jm_profit
|
177
177
|
data[:user_id] = user.id
|
178
178
|
data[:item_type] ='default'
|
179
|
-
data[:rate_of_profit] = user_info.profit_rate
|
179
|
+
data[:rate_of_profit] = order.ubox_order? ? 0.25 : user_info.profit_rate
|
180
180
|
data[:state] = 'WAIT_TO_SURE'
|
181
181
|
|
182
182
|
if order.pay_off_line?
|
183
183
|
data[:pay_type] = 'CODPAY'
|
184
184
|
else
|
185
185
|
data[:pay_type] = 'ZXZF'
|
186
|
-
# data[:state] = 'CASH_BACK'
|
187
186
|
data[:real_amount] = order.total_fee
|
188
187
|
end
|
189
188
|
|
@@ -201,7 +200,7 @@ module BlsmVdCore
|
|
201
200
|
score_change: leader_change,
|
202
201
|
money_change: (leader_change*VdUserScore::SCORES[:SCORE_TO_MONEY]).round(2),
|
203
202
|
content: "首趣黑带#{leader.username},你好:你的队员【#{user.username}】已成功确认订单,"
|
204
|
-
} if leader && leader_info
|
203
|
+
} if leader && leader_info && !order.ubox_order?
|
205
204
|
BlsmMpWx.create_msg(nil, leader.openid, distribute_leader_notify, 'distribute') if distribute_leader_notify
|
206
205
|
|
207
206
|
return ERROR_CODES[200]
|
@@ -215,7 +214,7 @@ module BlsmVdCore
|
|
215
214
|
data[:order_id] = order.id
|
216
215
|
data[:order_amount] = order.total_fee
|
217
216
|
data[:earn_amount] = order.jm_profit
|
218
|
-
data[:rate_of_profit] = user_info.profit_rate
|
217
|
+
data[:rate_of_profit] = order.ubox_order? ? 0.25 : user_info.profit_rate
|
219
218
|
if order.pay_off_line?
|
220
219
|
data[:pay_type] = 'CODPAY'
|
221
220
|
else
|
@@ -281,20 +280,22 @@ module BlsmVdCore
|
|
281
280
|
end
|
282
281
|
|
283
282
|
# 卖家信息变动
|
284
|
-
|
283
|
+
if seller_change!=0 && !order.ubox_order?
|
284
|
+
seller_info.change_score(seller_change)
|
285
|
+
|
286
|
+
seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "您好,订单#{order.number}已成功签收,分销#{franchise_sum}元"}
|
287
|
+
BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
|
288
|
+
end
|
285
289
|
|
286
|
-
seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "您好,订单#{order.number}已成功签收,分销#{franchise_sum}元"}
|
287
|
-
BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
|
288
290
|
VdUserScore.create({
|
289
291
|
user_id: seller_id,
|
290
292
|
score: seller_change,
|
291
|
-
notes: "订单#{order.number}
|
293
|
+
notes: "订单#{order.number}已#{order.ubox_order? ? '出货成功' : '成功签收'},分销#{franchise_sum}元",
|
292
294
|
score_type: vd_transaction
|
293
295
|
})
|
294
|
-
# end
|
295
296
|
|
296
297
|
#黑带信息变动
|
297
|
-
if leader && leader_info && leader_change && leader_change!=0
|
298
|
+
if leader && leader_info && leader_change && leader_change!=0 && !order.ubox_order?
|
298
299
|
|
299
300
|
leader_info.change_score(leader_change)
|
300
301
|
leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "首趣黑带#{leader.username},你好,你的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元"}
|
@@ -308,7 +309,7 @@ module BlsmVdCore
|
|
308
309
|
end
|
309
310
|
|
310
311
|
#原始黑带信息变动
|
311
|
-
if org_leader && org_leader_info && org_leader_change && org_leader_change!=0
|
312
|
+
if org_leader && org_leader_info && org_leader_change && org_leader_change!=0 && !order.ubox_order?
|
312
313
|
org_leader_info.change_score(org_leader_change)
|
313
314
|
|
314
315
|
org_leader_notify = {touser: org_leader.openid, change: org_leader_change, total: org_leader_info.score,
|
@@ -326,6 +327,9 @@ module BlsmVdCore
|
|
326
327
|
VdUserInfo.update_counters(seller_info.id, :distribute_sum => order.franchise_sum.to_f)
|
327
328
|
VdUserInfo.find_by_id(seller_info.id) { |info| info.sync_shop_state }
|
328
329
|
|
330
|
+
#分销额增加,更新未发出货物的(state=CREATE)分成比率
|
331
|
+
seller.clearing_items.where(:state => "WAIT_TO_SURE").update_all(:rate_of_profit => seller_info.profit_rate)
|
332
|
+
|
329
333
|
#安全库录入信息
|
330
334
|
VdInfoSec.committed(vd_transaction)
|
331
335
|
|
@@ -374,7 +378,7 @@ module BlsmVdCore
|
|
374
378
|
|
375
379
|
VdUserScore.where(score_type: score_type_str).each do |score|
|
376
380
|
score_change = -score.score
|
377
|
-
if score.user
|
381
|
+
if score.user && !order.ubox_order?
|
378
382
|
score.user.create_vd_user_info.change_score(score_change)
|
379
383
|
notify = {touser: score.user.openid, change: score_change, total: score.user.create_vd_user_info.score, content: "订单#{order_id}取消"}
|
380
384
|
BlsmMpWx.create_msg(nil, score.user.openid, notify, 'score_change')
|
@@ -418,7 +422,7 @@ module BlsmVdCore
|
|
418
422
|
|
419
423
|
VdUserScore.where(score_type: score_type_str).each do |score|
|
420
424
|
score_change = -score.score
|
421
|
-
if score.user
|
425
|
+
if score.user && !order.ubox_order?
|
422
426
|
score.user.create_vd_user_info.change_score(score_change)
|
423
427
|
notify = {touser: score.user.openid, change: score_change, total: score.user.create_vd_user_info.score, content: "订单#{order_id}拒签"}
|
424
428
|
BlsmMpWx.create_msg(nil, score.user.openid, notify, 'score_change')
|
@@ -20,7 +20,13 @@ module BlsmVdCore
|
|
20
20
|
fee += ((item.quantity * item.franchise_price.to_f) * rate)
|
21
21
|
end
|
22
22
|
sprintf('%0.2f', fee.to_f).to_f
|
23
|
-
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#是否是自动售货机的订单
|
26
|
+
def ubox_order?
|
27
|
+
!self.ubox_vmid.nil?
|
28
|
+
end
|
29
|
+
|
24
30
|
def pay_off_line?
|
25
31
|
self.pay_type == 1
|
26
32
|
end
|
@@ -44,7 +50,7 @@ module BlsmVdCore
|
|
44
50
|
jm_cost += item.quantity * (item.franchise_price.to_f)
|
45
51
|
end
|
46
52
|
end
|
47
|
-
sprintf('%0.2f', (self.total_fee - self.shipping_charge - jm_cost).to_f).to_f
|
53
|
+
ubox_order? ? sprintf('%0.2f', self.total_fee).to_f : sprintf('%0.2f', (self.total_fee - self.shipping_charge - jm_cost).to_f).to_f
|
48
54
|
end
|
49
55
|
|
50
56
|
#总的加盟费(供货价)
|
data/lib/blsm-vd-core/version.rb
CHANGED
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.
|
4
|
+
version: 0.6.2
|
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-
|
12
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|