blsm-vd-core 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/blsm-vd-core.gemspec +2 -2
- data/lib/blsm-vd-core/model/order.rb +12 -0
- data/lib/blsm-vd-core/version.rb +1 -1
- data/lib/blsm-vd-core.rb +81 -11
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b57b906e7e5353bf1462b2ef2837017a0646b34f
|
4
|
+
data.tar.gz: b615efb55cc6ef16946ad27a18e29993019504fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1110f0ac05fe5a53d7c00d860583d282f7ab046cb04d374b2ef21f631cafc1e326e8ac2b13633eccbe55ee4d99ae60a1c536d6f2776b0da94a678552bf80272
|
7
|
+
data.tar.gz: 8cbb151b80a35bda57af73e6891d1269ecc1a691714d8afbf601690df7a5f006d8318004a896227c98d3a2eac3437b7355c75d0aba1c921b9ae380d90f079e14
|
data/Gemfile.lock
CHANGED
data/blsm-vd-core.gemspec
CHANGED
@@ -6,9 +6,9 @@ require 'blsm-vd-core/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "blsm-vd-core"
|
8
8
|
spec.version = BlsmVdCore::VERSION
|
9
|
-
spec.authors = ["saxer"]
|
9
|
+
spec.authors = ["saxer","sunyafei"]
|
10
10
|
spec.licenses = ['MIT']
|
11
|
-
spec.email = ["15201280641@qq.com"]
|
11
|
+
spec.email = ["15201280641@qq.com","1752709589@qq.com"]
|
12
12
|
|
13
13
|
spec.summary = %q{首趣微店核心模块}
|
14
14
|
spec.description = %q{首趣微店核心模块,包含结算项的创建、更新、删除,微店主积分的更改等信息}
|
@@ -9,6 +9,18 @@ module BlsmVdCore
|
|
9
9
|
encrypted_id key: 'bYqILlFMZn3xd8Cy'
|
10
10
|
|
11
11
|
public
|
12
|
+
def get_vd_score(role)
|
13
|
+
column = "black" == role ? "black_belt_rate" : "ordinary_rate"
|
14
|
+
fee = 0.0
|
15
|
+
self.line_items.each do |item|
|
16
|
+
next if item.product_prop.nil?
|
17
|
+
rate = item.product_prop.send(column)
|
18
|
+
rate = VdUserScore::SCORES[:SALE_OUT_DIRECT] if rate.nil? && "normal" == role
|
19
|
+
rate = VdUserScore::SCORES[:SALE_OUT_INDIRECT] if rate.nil? && "black" == role
|
20
|
+
fee += ((item.quantity * item.franchise_price.to_f) * rate)
|
21
|
+
end
|
22
|
+
fee
|
23
|
+
end
|
12
24
|
def pay_off_line?
|
13
25
|
self.pay_type == 1
|
14
26
|
end
|
data/lib/blsm-vd-core/version.rb
CHANGED
data/lib/blsm-vd-core.rb
CHANGED
@@ -109,6 +109,9 @@ module BlsmVdCore
|
|
109
109
|
#签收失败(拒签)
|
110
110
|
if sign_type =~ /sign_fail/
|
111
111
|
VdInfoSec.committed(vd_transaction)
|
112
|
+
user = order.application.user if order && order.application
|
113
|
+
#拒签删除积分
|
114
|
+
on_order_sign_fail(user.id,order_id) if user
|
112
115
|
if clearing_item.clearing && clearing_item.clearing.state == "BALANCED"
|
113
116
|
i_clearing = clearing_item.clone
|
114
117
|
i_clearing.clearing_id = nil
|
@@ -235,8 +238,8 @@ module BlsmVdCore
|
|
235
238
|
franchise_sum = order.franchise_sum
|
236
239
|
|
237
240
|
#积分获取
|
238
|
-
seller_change =
|
239
|
-
leader_change =
|
241
|
+
seller_change = order.get_vd_score(seller_info.vd_role)
|
242
|
+
leader_change = order.get_vd_score(leader_info.vd_role) if leader_info
|
240
243
|
seller_info.update_attributes({:score => seller_info.score.to_f+seller_change})
|
241
244
|
leader_info.update_attributes({:score => leader_info.score.to_f+leader_change}) if leader_info
|
242
245
|
|
@@ -250,12 +253,14 @@ module BlsmVdCore
|
|
250
253
|
VdUserScore.create({
|
251
254
|
user_id: seller_id,
|
252
255
|
score: seller_change,
|
253
|
-
notes: "分销#{franchise_sum}元,订单#{order_id}完成"
|
256
|
+
notes: "分销#{franchise_sum}元,订单#{order_id}完成",
|
257
|
+
score_type: vd_transaction
|
254
258
|
})
|
255
259
|
VdUserScore.create({
|
256
260
|
user_id: leader.id,
|
257
261
|
score: leader_change,
|
258
|
-
notes: "成员【#{seller.username}】分销#{franchise_sum}元,订单#{order_id}完成"
|
262
|
+
notes: "成员【#{seller.username}】分销#{franchise_sum}元,订单#{order_id}完成",
|
263
|
+
score_type: vd_transaction
|
259
264
|
}) if leader_info
|
260
265
|
|
261
266
|
#店主销售额、分销额增加
|
@@ -308,16 +313,17 @@ module BlsmVdCore
|
|
308
313
|
|
309
314
|
#供货价总和、应该扣取的积分总额
|
310
315
|
franchise_sum = order.franchise_sum
|
311
|
-
|
312
|
-
|
316
|
+
leader_order_score = VdUserScore.where(user_id: leader.id).where(score_type: sold_out) if leader && leader_info
|
317
|
+
seller_change = -VdUserScore.where(user_id: seller.id).where(score_type: sold_out).first.score
|
318
|
+
leader_change = -leader_order_score.score if leader_order_score
|
313
319
|
|
314
320
|
#扣取积分
|
315
321
|
seller_info.change_score(seller_change)
|
316
|
-
leader_info.change_score(leader_change) if
|
322
|
+
leader_info.change_score(leader_change) if leader_change
|
317
323
|
|
318
324
|
#积分变动通知
|
319
325
|
seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "订单#{order_id}取消"}
|
320
|
-
leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "成员【#{seller.username}】订单#{order_id}取消,积分扣取"} if
|
326
|
+
leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "成员【#{seller.username}】订单#{order_id}取消,积分扣取"} if leader_order_score
|
321
327
|
BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
|
322
328
|
BlsmMpWx.create_msg(nil, leader.openid, leader_notify, 'score_change') if leader_notify
|
323
329
|
|
@@ -325,13 +331,15 @@ module BlsmVdCore
|
|
325
331
|
VdUserScore.create({
|
326
332
|
user_id: seller_id,
|
327
333
|
score: seller_change,
|
328
|
-
notes: "订单#{order_id}取消,积分扣取"
|
334
|
+
notes: "订单#{order_id}取消,积分扣取",
|
335
|
+
score_type: vd_transaction
|
329
336
|
})
|
330
337
|
VdUserScore.create({
|
331
338
|
user_id: leader.id,
|
332
339
|
score: leader_change,
|
333
|
-
notes: "成员【#{seller.username}】订单#{order_id}取消,积分扣取"
|
334
|
-
|
340
|
+
notes: "成员【#{seller.username}】订单#{order_id}取消,积分扣取",
|
341
|
+
score_type: vd_transaction
|
342
|
+
}) if leader_order_score
|
335
343
|
|
336
344
|
#安全库录入信息
|
337
345
|
VdInfoSec.committed(vd_transaction)
|
@@ -339,4 +347,66 @@ module BlsmVdCore
|
|
339
347
|
ERROR_CODES[200]
|
340
348
|
|
341
349
|
end
|
350
|
+
|
351
|
+
# 什么时候调用此方法合适?当订单的状态变更为‘拒签’时
|
352
|
+
#==== Parameters
|
353
|
+
# * +seller_id+ - 销售员的id
|
354
|
+
# * +order_id+ - 订单id
|
355
|
+
def on_order_sign_fail(seller_id, order_id)
|
356
|
+
seller = User.where(id: seller_id).first
|
357
|
+
leader = User.where("id in(select supervisor_id from vd_user_infos where user_id=#{seller_id})").first
|
358
|
+
order = Order.where(id: order_id).first
|
359
|
+
|
360
|
+
return ERROR_CODES[4045] unless seller
|
361
|
+
return ERROR_CODES[401] if !order || !order.application || !(order.application.user_id==seller_id)
|
362
|
+
|
363
|
+
#安全校验(是否曾经被售出过)
|
364
|
+
sold_out = VdInfoSec.dangerous?("order_sale_out_#{seller_id}_#{order_id}")
|
365
|
+
return ERROR_CODES[200] unless sold_out
|
366
|
+
|
367
|
+
#安全校验(是否曾经此订单被取消,并且扣取积分)
|
368
|
+
vd_transaction = "order_sale_out_#{seller_id}_#{order_id}_then_sign_fail"
|
369
|
+
return ERROR_CODES[200] if VdInfoSec.dangerous?(vd_transaction)
|
370
|
+
|
371
|
+
#卖家和团队领导的信息
|
372
|
+
seller_info = seller.create_vd_user_info
|
373
|
+
leader_info = leader && leader.is_vd_black? ? leader.create_vd_user_info : nil
|
374
|
+
|
375
|
+
#供货价总和、应该扣取的积分总额
|
376
|
+
franchise_sum = order.franchise_sum
|
377
|
+
leader_order_score = VdUserScore.where(user_id: leader.id).where(score_type: sold_out) if leader && leader_info
|
378
|
+
seller_change = -VdUserScore.where(user_id: seller.id).where(score_type: sold_out).first.score
|
379
|
+
leader_change = -leader_order_score.score if leader_order_score
|
380
|
+
|
381
|
+
#扣取积分
|
382
|
+
seller_info.change_score(seller_change)
|
383
|
+
leader_info.change_score(leader_change) if leader_change
|
384
|
+
|
385
|
+
#积分变动通知
|
386
|
+
seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "订单#{order_id}拒签"}
|
387
|
+
leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "成员【#{seller.username}】订单#{order_id}拒签,积分扣取"} if leader_order_score
|
388
|
+
BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
|
389
|
+
BlsmMpWx.create_msg(nil, leader.openid, leader_notify, 'score_change') if leader_notify
|
390
|
+
|
391
|
+
#积分历史
|
392
|
+
VdUserScore.create({
|
393
|
+
user_id: seller_id,
|
394
|
+
score: seller_change,
|
395
|
+
notes: "订单#{order_id}拒签,积分扣取",
|
396
|
+
score_type: vd_transaction
|
397
|
+
})
|
398
|
+
VdUserScore.create({
|
399
|
+
user_id: leader.id,
|
400
|
+
score: leader_change,
|
401
|
+
notes: "成员【#{seller.username}】订单#{order_id}拒签,积分扣取",
|
402
|
+
score_type: vd_transaction
|
403
|
+
}) if leader_order_score
|
404
|
+
|
405
|
+
#安全库录入信息
|
406
|
+
VdInfoSec.committed(vd_transaction)
|
407
|
+
|
408
|
+
ERROR_CODES[200]
|
409
|
+
|
410
|
+
end
|
411
|
+
|
342
412
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blsm-vd-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saxer
|
8
|
+
- sunyafei
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
12
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rspec
|
@@ -153,6 +154,7 @@ dependencies:
|
|
153
154
|
description: 首趣微店核心模块,包含结算项的创建、更新、删除,微店主积分的更改等信息
|
154
155
|
email:
|
155
156
|
- 15201280641@qq.com
|
157
|
+
- 1752709589@qq.com
|
156
158
|
executables: []
|
157
159
|
extensions: []
|
158
160
|
extra_rdoc_files: []
|