blsm-vd-core 0.4.6 → 0.4.8
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/lib/blsm-vd-core/version.rb +1 -1
- data/lib/blsm-vd-core.rb +148 -89
- 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: c2e4c393f9c216eaed675b271630dc4e3c510083
|
4
|
+
data.tar.gz: 102b4dbcb46114b6752f3f27bf2e5d201e049fb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df32d33db6fdae4dd501e0581285349da4b53f6c63b04e01d7a8acf24f5214c4fc690ed34f9333c242d2107307782142ab5a7b30ff5450a2406bb95da3ef8281
|
7
|
+
data.tar.gz: e0f73430145cc0ed6854552a3ed1276bc14393d5f73968775b8d7084433e5212d1f2f6425e914e8b574db9db40a166ae49df95b2b986aaedf2c32626b8332f19
|
data/Gemfile.lock
CHANGED
data/lib/blsm-vd-core/version.rb
CHANGED
data/lib/blsm-vd-core.rb
CHANGED
@@ -260,30 +260,60 @@ module BlsmVdCore
|
|
260
260
|
|
261
261
|
#积分获取
|
262
262
|
seller_change = order.get_vd_score(seller_info.vd_role)
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
263
|
+
if leader_info
|
264
|
+
leader_change = order.get_vd_score(leader_info.vd_role)
|
265
|
+
# - 卖家是黑带,但是从属于某个黑带名下
|
266
|
+
if seller_info.is_black?
|
267
|
+
seller_change = 0
|
268
|
+
leader_change = (order.get_vd_score(seller_info.vd_role)+order.get_vd_score(leader_info.vd_role))
|
269
|
+
# - 卖家所属的黑带,是某个黑带的附属黑带
|
270
|
+
elsif leader_info.supervisor_slave && leader_info.supervisor
|
271
|
+
org_leader = leader_info.supervisor
|
272
|
+
org_leader_info = org_leader.create_vd_user_info
|
273
|
+
leader_change = order.get_vd_score(leader_info.vd_role)*0.7
|
274
|
+
org_leader_change = order.get_vd_score(org_leader_info.vd_role)*0.3
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
# 卖家信息变动
|
279
|
+
if seller_change!=0
|
280
|
+
seller_info.update_attributes({:score => seller_info.score.to_f+seller_change})
|
281
|
+
seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "您好,订单#{order.number}已成功签收,分销#{franchise_sum}元"}
|
282
|
+
BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
|
283
|
+
VdUserScore.create({
|
284
|
+
user_id: seller_id,
|
285
|
+
score: seller_change,
|
286
|
+
notes: "订单#{order.number}已成功签收,分销#{franchise_sum}元",
|
287
|
+
score_type: vd_transaction
|
288
|
+
})
|
289
|
+
end
|
290
|
+
|
291
|
+
#黑带信息变动
|
292
|
+
if leader && leader_info && leader_change && leader_change!=0
|
293
|
+
leader_info.update_attributes({:score => leader_info.score.to_f+leader_change})
|
294
|
+
leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "首趣黑带#{leader.username},你好,你的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元"}
|
295
|
+
BlsmMpWx.create_msg(nil, leader.openid, leader_notify, 'score_change')
|
296
|
+
VdUserScore.create({
|
297
|
+
user_id: leader.id,
|
298
|
+
score: leader_change,
|
299
|
+
notes: "队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元",
|
300
|
+
score_type: vd_transaction
|
301
|
+
})
|
302
|
+
end
|
286
303
|
|
304
|
+
#原始黑带信息变动
|
305
|
+
if org_leader && org_leader_info && org_leader_change && org_leader_change!=0
|
306
|
+
org_leader_info.update_attributes({:score => org_leader_info.score.to_f+org_leader_change})
|
307
|
+
org_leader_notify = {touser: org_leader.openid, change: org_leader_change, total: org_leader_info.score,
|
308
|
+
content: "首趣黑带#{org_leader.username},你好,你的附属黑带【#{leader.username}】的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元"}
|
309
|
+
BlsmMpWx.create_msg(nil, org_leader.openid, org_leader_notify, 'score_change')
|
310
|
+
VdUserScore.create({
|
311
|
+
user_id: org_leader.id,
|
312
|
+
score: org_leader_change,
|
313
|
+
notes: "下属黑带【#{leader.username}】的队员【#{seller.username}】订单#{order.number}已成功签收,分销#{franchise_sum}元",
|
314
|
+
score_type: vd_transaction
|
315
|
+
})
|
316
|
+
end
|
287
317
|
#店主销售额、分销额增加
|
288
318
|
seller_info.update_attributes({:sale_sum => seller_info.sale_sum.to_f + order.total_fee.to_f})
|
289
319
|
seller_info.update_attributes({:distribute_sum => seller_info.distribute_sum.to_f + order.franchise_sum.to_f})
|
@@ -306,7 +336,7 @@ module BlsmVdCore
|
|
306
336
|
# * +order_id+ - 订单id
|
307
337
|
def on_order_canceled(seller_id, order_id)
|
308
338
|
seller = User.where(id: seller_id).first
|
309
|
-
leader = User.where("id in(select supervisor_id from vd_user_infos where user_id=#{seller_id})").first
|
339
|
+
# leader = User.where("id in(select supervisor_id from vd_user_infos where user_id=#{seller_id})").first
|
310
340
|
order = Order.where(id: order_id).first
|
311
341
|
|
312
342
|
return ERROR_CODES[4045] unless seller
|
@@ -327,41 +357,55 @@ module BlsmVdCore
|
|
327
357
|
|
328
358
|
#安全校验(是否曾经此订单被取消,并且扣取积分)
|
329
359
|
vd_transaction = "order_sale_out_#{seller_id}_#{order_id}_then_cancel"
|
330
|
-
|
360
|
+
danger = VdInfoSec.dangerous?(vd_transaction)
|
361
|
+
return danger if danger
|
331
362
|
|
332
363
|
#卖家和团队领导的信息
|
333
|
-
seller_info = seller.create_vd_user_info
|
334
|
-
leader_info = leader && leader.is_vd_black? ? leader.create_vd_user_info : nil
|
364
|
+
# seller_info = seller.create_vd_user_info
|
365
|
+
# leader_info = leader && leader.is_vd_black? ? leader.create_vd_user_info : nil
|
366
|
+
|
367
|
+
VdUserScore.where(score_type: score_type_str).each do |score|
|
368
|
+
score_change = -score.score
|
369
|
+
if score.user
|
370
|
+
score.user.create_vd_user_info.change_score(score_change)
|
371
|
+
notify = {touser: score.user.openid, change: score_change, total: score.user.create_vd_user_info.score, content: "订单#{order_id}取消"}
|
372
|
+
BlsmMpWx.create_msg(nil, score.user.openid, notify, 'score_change')
|
373
|
+
VdUserScore.create({
|
374
|
+
user_id: score.user_id,
|
375
|
+
score: score_change,
|
376
|
+
notes: "订单#{order.number}取消,积分扣取",
|
377
|
+
score_type: vd_transaction
|
378
|
+
})
|
379
|
+
end
|
380
|
+
end
|
335
381
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
score_type: vd_transaction
|
364
|
-
}) if leader_order_score
|
382
|
+
# leader_order_score = VdUserScore.where(user_id: leader.id).where(score_type: score_type_str).first if leader && leader_info
|
383
|
+
# seller_change = -VdUserScore.where(user_id: seller.id).where(score_type: score_type_str).first.score
|
384
|
+
# leader_change = -leader_order_score.score if leader_order_score
|
385
|
+
#
|
386
|
+
# #扣取积分
|
387
|
+
# seller_info.change_score(seller_change)
|
388
|
+
# leader_info.change_score(leader_change) if leader_change
|
389
|
+
#
|
390
|
+
# #积分变动通知
|
391
|
+
# seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "订单#{order_id}取消"}
|
392
|
+
# leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "成员【#{seller.username}】订单#{order_id}取消,积分扣取"} if leader_order_score
|
393
|
+
# BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
|
394
|
+
# BlsmMpWx.create_msg(nil, leader.openid, leader_notify, 'score_change') if leader_notify
|
395
|
+
#
|
396
|
+
# #积分历史
|
397
|
+
# VdUserScore.create({
|
398
|
+
# user_id: seller_id,
|
399
|
+
# score: seller_change,
|
400
|
+
# notes: "订单#{order_id}取消,积分扣取",
|
401
|
+
# score_type: vd_transaction
|
402
|
+
# })
|
403
|
+
# VdUserScore.create({
|
404
|
+
# user_id: leader.id,
|
405
|
+
# score: leader_change,
|
406
|
+
# notes: "成员【#{seller.username}】订单#{order_id}取消,积分扣取",
|
407
|
+
# score_type: vd_transaction
|
408
|
+
# }) if leader_order_score
|
365
409
|
|
366
410
|
#安全库录入信息
|
367
411
|
VdInfoSec.committed(vd_transaction)
|
@@ -376,7 +420,7 @@ module BlsmVdCore
|
|
376
420
|
# * +order_id+ - 订单id
|
377
421
|
def on_order_sign_fail(seller_id, order_id)
|
378
422
|
seller = User.where(id: seller_id).first
|
379
|
-
leader = User.where("id in(select supervisor_id from vd_user_infos where user_id=#{seller_id})").first
|
423
|
+
# leader = User.where("id in(select supervisor_id from vd_user_infos where user_id=#{seller_id})").first
|
380
424
|
order = Order.where(id: order_id).first
|
381
425
|
|
382
426
|
return ERROR_CODES[4045] unless seller
|
@@ -391,39 +435,54 @@ module BlsmVdCore
|
|
391
435
|
vd_transaction = "order_sale_out_#{seller_id}_#{order_id}_then_sign_fail"
|
392
436
|
return ERROR_CODES[200] if VdInfoSec.dangerous?(vd_transaction)
|
393
437
|
|
394
|
-
|
395
|
-
|
396
|
-
|
438
|
+
VdUserScore.where(score_type: score_type_str).each do |score|
|
439
|
+
score_change = -score.score
|
440
|
+
if score.user
|
441
|
+
score.user.create_vd_user_info.change_score(score_change)
|
442
|
+
notify = {touser: score.user.openid, change: score_change, total: score.user.create_vd_user_info.score, content: "订单#{order_id}拒签"}
|
443
|
+
BlsmMpWx.create_msg(nil, score.user.openid, notify, 'score_change')
|
444
|
+
VdUserScore.create({
|
445
|
+
user_id: score.user_id,
|
446
|
+
score: score_change,
|
447
|
+
notes: "订单#{order.number}拒签,积分扣取",
|
448
|
+
score_type: vd_transaction
|
449
|
+
})
|
450
|
+
end
|
451
|
+
end
|
397
452
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
453
|
+
#卖家和团队领导的信息
|
454
|
+
# seller_info = seller.create_vd_user_info
|
455
|
+
# leader_info = leader && leader.is_vd_black? ? leader.create_vd_user_info : nil
|
456
|
+
#
|
457
|
+
# #供货价总和、应该扣取的积分总额
|
458
|
+
# franchise_sum = order.franchise_sum
|
459
|
+
# leader_order_score = VdUserScore.where(user_id: leader.id).where(score_type: score_type_str).first if leader && leader_info
|
460
|
+
# seller_change = -VdUserScore.where(user_id: seller.id).where(score_type: score_type_str).first.score
|
461
|
+
# leader_change = -leader_order_score.score if leader_order_score
|
462
|
+
#
|
463
|
+
# #扣取积分
|
464
|
+
# seller_info.change_score(seller_change)
|
465
|
+
# leader_info.change_score(leader_change) if leader_change
|
466
|
+
#
|
467
|
+
# #积分变动通知
|
468
|
+
# seller_notify = {touser: seller.openid, change: seller_change, total: seller_info.score, content: "订单#{order_id}拒签"}
|
469
|
+
# leader_notify = {touser: leader.openid, change: leader_change, total: leader_info.score, content: "成员【#{seller.username}】订单#{order_id}拒签,积分扣取"} if leader_order_score
|
470
|
+
# BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
|
471
|
+
# BlsmMpWx.create_msg(nil, leader.openid, leader_notify, 'score_change') if leader_notify
|
472
|
+
#
|
473
|
+
# #积分历史
|
474
|
+
# VdUserScore.create({
|
475
|
+
# user_id: seller_id,
|
476
|
+
# score: seller_change,
|
477
|
+
# notes: "订单#{order_id}拒签,积分扣取",
|
478
|
+
# score_type: vd_transaction
|
479
|
+
# })
|
480
|
+
# VdUserScore.create({
|
481
|
+
# user_id: leader.id,
|
482
|
+
# score: leader_change,
|
483
|
+
# notes: "成员【#{seller.username}】订单#{order_id}拒签,积分扣取",
|
484
|
+
# score_type: vd_transaction
|
485
|
+
# }) if leader_order_score
|
427
486
|
|
428
487
|
#安全库录入信息
|
429
488
|
VdInfoSec.committed(vd_transaction)
|
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.
|
4
|
+
version: 0.4.8
|
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-01-
|
12
|
+
date: 2016-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|