blsm-vd-core 0.1.6 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +0 -1
- data/Gemfile.lock +120 -0
- data/blsm-vd-core.gemspec +1 -0
- data/build.py +7 -0
- data/build.rb +4 -0
- data/lib/blsm-vd-core/model/active_record.rb +1 -6
- data/lib/blsm-vd-core/model/clearing.rb +8 -0
- data/lib/blsm-vd-core/model/clearing_item.rb +44 -0
- data/lib/blsm-vd-core/model/line_item.rb +9 -0
- data/lib/blsm-vd-core/model/order.rb +71 -4
- data/lib/blsm-vd-core/model/product.rb +8 -0
- data/lib/blsm-vd-core/model/product_prop.rb +8 -0
- data/lib/blsm-vd-core/model/user.rb +24 -0
- data/lib/blsm-vd-core/model/vd_user_info.rb +22 -0
- data/lib/blsm-vd-core/model/vd_user_score.rb +14 -0
- data/lib/blsm-vd-core/version.rb +1 -1
- data/lib/blsm-vd-core.rb +110 -1
- metadata +47 -22
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWU0YmY2YmQ4MjM2Y2ZhZjYyZmQ4ZWUzNDIzNmJkMGY0YzY1MDk1MA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZWMyNmQ1NzMyMGM0ZmJjYjFjOTIxNTMzNDVkZTgzYmU3NDA5ZTJlNQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MzU0YTkxOGU3MTFiMjRmMTA2ZmE2YWQ3Y2M3NmZjYmNhYzI3N2U4ZDlhODA1
|
10
|
+
MmNkOTRlNGNjMDIwOWE2YjFjNDM2ZDU3ODI5OGEzNjFhOTM5OGExMzI4ZWYz
|
11
|
+
MTYyMmI0ZGJkMzQ1ZTVhZGQ0YWZlMzUwMWZlZTU2ZDE5MzMxZjE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2VmNjZiNzViMmRiYzQ5ODg2ZjUyYjcwYTVjMjliM2Q4MDI0Y2QxODg3NmZk
|
14
|
+
N2RjZjA3MTYzN2U4NjBjYzc0NzAzNWViNDRjYWJmMDQ2MmM1NGNkMDU1NWQ3
|
15
|
+
NzU5MTkyZTFkZTQzMGNhNjdiNTJhNzgzMGFmNTZkZDNkZWFiMmI=
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
blsm-vd-core (0.1.8)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://ruby.taobao.org/
|
8
|
+
specs:
|
9
|
+
actionmailer (3.2.7)
|
10
|
+
actionpack (= 3.2.7)
|
11
|
+
mail (~> 2.4.4)
|
12
|
+
actionpack (3.2.7)
|
13
|
+
activemodel (= 3.2.7)
|
14
|
+
activesupport (= 3.2.7)
|
15
|
+
builder (~> 3.0.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
journey (~> 1.0.4)
|
18
|
+
rack (~> 1.4.0)
|
19
|
+
rack-cache (~> 1.2)
|
20
|
+
rack-test (~> 0.6.1)
|
21
|
+
sprockets (~> 2.1.3)
|
22
|
+
activemodel (3.2.7)
|
23
|
+
activesupport (= 3.2.7)
|
24
|
+
builder (~> 3.0.0)
|
25
|
+
activerecord (3.2.7)
|
26
|
+
activemodel (= 3.2.7)
|
27
|
+
activesupport (= 3.2.7)
|
28
|
+
arel (~> 3.0.2)
|
29
|
+
tzinfo (~> 0.3.29)
|
30
|
+
activeresource (3.2.7)
|
31
|
+
activemodel (= 3.2.7)
|
32
|
+
activesupport (= 3.2.7)
|
33
|
+
activesupport (3.2.7)
|
34
|
+
i18n (~> 0.6)
|
35
|
+
multi_json (~> 1.0)
|
36
|
+
arel (3.0.2)
|
37
|
+
builder (3.0.0)
|
38
|
+
diff-lcs (1.2.5)
|
39
|
+
erubis (2.7.0)
|
40
|
+
faraday (0.9.1)
|
41
|
+
multipart-post (>= 1.2, < 3)
|
42
|
+
hike (1.2.3)
|
43
|
+
i18n (0.7.0)
|
44
|
+
journey (1.0.4)
|
45
|
+
json (1.8.3)
|
46
|
+
mail (2.4.4)
|
47
|
+
i18n (>= 0.4.0)
|
48
|
+
mime-types (~> 1.16)
|
49
|
+
treetop (~> 1.4.8)
|
50
|
+
mime-types (1.19)
|
51
|
+
multi_json (1.11.0)
|
52
|
+
multipart-post (2.0.0)
|
53
|
+
mysql2 (0.3.17)
|
54
|
+
polyglot (0.3.3)
|
55
|
+
rack (1.4.1)
|
56
|
+
rack-cache (1.2)
|
57
|
+
rack (>= 0.4)
|
58
|
+
rack-ssl (1.3.2)
|
59
|
+
rack
|
60
|
+
rack-test (0.6.3)
|
61
|
+
rack (>= 1.0)
|
62
|
+
rails (3.2.7)
|
63
|
+
actionmailer (= 3.2.7)
|
64
|
+
actionpack (= 3.2.7)
|
65
|
+
activerecord (= 3.2.7)
|
66
|
+
activeresource (= 3.2.7)
|
67
|
+
activesupport (= 3.2.7)
|
68
|
+
bundler (~> 1.0)
|
69
|
+
railties (= 3.2.7)
|
70
|
+
railties (3.2.7)
|
71
|
+
actionpack (= 3.2.7)
|
72
|
+
activesupport (= 3.2.7)
|
73
|
+
rack-ssl (~> 1.3.2)
|
74
|
+
rake (>= 0.8.7)
|
75
|
+
rdoc (~> 3.4)
|
76
|
+
thor (>= 0.14.6, < 2.0)
|
77
|
+
rake (10.4.2)
|
78
|
+
rdoc (3.12)
|
79
|
+
json (~> 1.4)
|
80
|
+
rspec (3.2.0)
|
81
|
+
rspec-core (~> 3.2.0)
|
82
|
+
rspec-expectations (~> 3.2.0)
|
83
|
+
rspec-mocks (~> 3.2.0)
|
84
|
+
rspec-core (3.2.3)
|
85
|
+
rspec-support (~> 3.2.0)
|
86
|
+
rspec-expectations (3.2.1)
|
87
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
+
rspec-support (~> 3.2.0)
|
89
|
+
rspec-mocks (3.2.1)
|
90
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
91
|
+
rspec-support (~> 3.2.0)
|
92
|
+
rspec-support (3.2.2)
|
93
|
+
sprockets (2.1.3)
|
94
|
+
hike (~> 1.2)
|
95
|
+
rack (~> 1.0)
|
96
|
+
tilt (~> 1.1, != 1.3.0)
|
97
|
+
thor (0.19.1)
|
98
|
+
tilt (1.4.1)
|
99
|
+
treetop (1.4.10)
|
100
|
+
polyglot
|
101
|
+
polyglot (>= 0.3.1)
|
102
|
+
tzinfo (0.3.33)
|
103
|
+
|
104
|
+
PLATFORMS
|
105
|
+
ruby
|
106
|
+
|
107
|
+
DEPENDENCIES
|
108
|
+
activemodel (~> 3.2)
|
109
|
+
activerecord (~> 3.2)
|
110
|
+
activesupport (~> 3.2)
|
111
|
+
blsm-vd-core!
|
112
|
+
bundler (~> 1.9)
|
113
|
+
faraday (~> 0.9)
|
114
|
+
mysql2 (~> 0.3.16)
|
115
|
+
rails (~> 3.2)
|
116
|
+
rake (~> 10.0)
|
117
|
+
rspec (~> 3.2)
|
118
|
+
|
119
|
+
BUNDLED WITH
|
120
|
+
1.10.3
|
data/blsm-vd-core.gemspec
CHANGED
@@ -36,4 +36,5 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency "activemodel", "~> 3.2"
|
37
37
|
spec.add_development_dependency "activerecord", "~> 3.2"
|
38
38
|
spec.add_development_dependency "activesupport", "~> 3.2"
|
39
|
+
spec.add_development_dependency "faraday", "~> 0.9"
|
39
40
|
end
|
data/build.py
ADDED
data/build.rb
ADDED
@@ -2,12 +2,7 @@ module BlsmVdCore
|
|
2
2
|
|
3
3
|
def self.load_config
|
4
4
|
config_path = Rails.root ? File.join(Rails.root, "config", "database.yml") : './config/database.yml'
|
5
|
-
|
6
|
-
conf = ''
|
7
|
-
yaml.each do |line|
|
8
|
-
conf +=line
|
9
|
-
end
|
10
|
-
conf
|
5
|
+
File.open(config_path).inject('') { |text, line| text+line }
|
11
6
|
end
|
12
7
|
|
13
8
|
class BaseRecord < ActiveRecord::Base
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module BlsmVdCore
|
3
|
+
class ClearingItem < BlsmVdCore::BaseRecord
|
4
|
+
self.table_name='clearing_items'
|
5
|
+
belongs_to :user, class_name: "::BlsmVdCore::User"
|
6
|
+
belongs_to :order, class_name: "::BlsmVdCore::Order"
|
7
|
+
belongs_to :clearing, class_name: "::BlsmVdCore::Clearing"
|
8
|
+
|
9
|
+
#物流服务费
|
10
|
+
def express_service_fee
|
11
|
+
if self.pay_type=='CODPAY'
|
12
|
+
return 5
|
13
|
+
end
|
14
|
+
0
|
15
|
+
end
|
16
|
+
#可能的(预计)收入
|
17
|
+
def possible_profit
|
18
|
+
if self.state=='CASH_BACK'
|
19
|
+
return sprintf('%0.2f', (self.real_amount - self.order_amount + self.earn_amount)* self.rate_of_profit - self.express_service_fee).to_f
|
20
|
+
end
|
21
|
+
sprintf('%0.2f', self.earn_amount * self.rate_of_profit - self.express_service_fee).to_f
|
22
|
+
end
|
23
|
+
|
24
|
+
def marking_refuse(note, reduce_real_amount = 0)
|
25
|
+
update_params = {}
|
26
|
+
update_params[:notes] = note
|
27
|
+
update_params[:state] = 'CASH_BACK'
|
28
|
+
update_params[:real_amount] = self.express_service_fee - (self.earn_amount - self.order_amount + self.order.real_shipping_charge * 2) - reduce_real_amount
|
29
|
+
#here to avoid muliti time making refuse
|
30
|
+
update_params.delete(:real_amount) if self.possible_profit < 0.0
|
31
|
+
update_params[:rate_of_profit] = 1
|
32
|
+
self.update_attributes(update_params)
|
33
|
+
end
|
34
|
+
|
35
|
+
def marking_confirm(note)
|
36
|
+
update_params = Hash.new
|
37
|
+
update_params[:notes] = note
|
38
|
+
update_params[:state] = 'CASH_BACK'
|
39
|
+
update_params[:earn_amount] = self.order.jm_profit
|
40
|
+
update_params[:real_amount] = self.order.actual_total
|
41
|
+
self.update_attributes(update_params)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module BlsmVdCore
|
3
|
+
class LineItem < BlsmVdCore::BaseRecord
|
4
|
+
self.table_name='line_items'
|
5
|
+
belongs_to :order, class_name: "::BlsmVdCore::Order"
|
6
|
+
belongs_to :product_prop, class_name: "::BlsmVdCore::ProductProp"
|
7
|
+
belongs_to :product, class_name: "::BlsmVdCore::Product"
|
8
|
+
end
|
9
|
+
end
|
@@ -2,11 +2,78 @@
|
|
2
2
|
module BlsmVdCore
|
3
3
|
class Order < BlsmVdCore::BaseRecord
|
4
4
|
self.table_name='orders'
|
5
|
+
has_many :clearing_items, class_name: "::BlsmVdCore::ClearingItem"
|
6
|
+
has_many :line_items, class_name: "::BlsmVdCore::LineItem"
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
public
|
9
|
+
#加盟商(微店主)赚取的利润(直接利润)
|
10
|
+
def jm_profit
|
11
|
+
jm_cost = 0
|
12
|
+
if self.line_items
|
13
|
+
self.line_items.each do |item|
|
14
|
+
unless item.product_prop && item.product_prop.franchise_price
|
15
|
+
next
|
16
|
+
end
|
17
|
+
jm_cost += item.quantity * (item.product_prop.franchise_price.to_f)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
sprintf('%0.2f', (self.total_fee - self.shipping_charge - jm_cost).to_f).to_f
|
10
21
|
end
|
22
|
+
|
23
|
+
#总的加盟费(供货价)
|
24
|
+
def jm_fee
|
25
|
+
fee = 0
|
26
|
+
if self.line_items
|
27
|
+
self.line_items.each do |item|
|
28
|
+
fee += item.quantity * item.franchise_price.to_f
|
29
|
+
end
|
30
|
+
end
|
31
|
+
sprintf('%0.2f', fee.to_f).to_f
|
32
|
+
end
|
33
|
+
|
34
|
+
#订单总金额
|
35
|
+
def total_fee
|
36
|
+
sprintf('%0.2f', (self.item_total + self.shipping_charge).to_f).to_f
|
37
|
+
end
|
38
|
+
#真实的运费
|
39
|
+
def real_shipping_charge
|
40
|
+
if self.shipping_charge > 0
|
41
|
+
return self.shipping_charge
|
42
|
+
end
|
43
|
+
|
44
|
+
conn = Faraday.new(:url => 'http://'+"api.aihuo360.com")
|
45
|
+
response = conn.get do |req|
|
46
|
+
req.url '/v2/shipping_charges'
|
47
|
+
req.params[:province] = self.shipping_province
|
48
|
+
req.params[:city] = self.shipping_city
|
49
|
+
req.params[:district] = self.shipping_district
|
50
|
+
end
|
51
|
+
begin
|
52
|
+
result = JSON.parse(response.body)
|
53
|
+
if self.pay_type==1
|
54
|
+
result['shipping_charges'][0]['cash_on_delivery'].to_f
|
55
|
+
else
|
56
|
+
result['shipping_charges'][0]['pay_online'].to_f
|
57
|
+
end
|
58
|
+
rescue
|
59
|
+
15
|
60
|
+
end
|
61
|
+
end
|
62
|
+
private
|
63
|
+
|
64
|
+
def self.valid_update?(clearing_item)
|
65
|
+
if clearing_item[:state] == 'CASH_BACK'
|
66
|
+
return false
|
67
|
+
end
|
68
|
+
return true
|
69
|
+
end
|
70
|
+
def self.latest_notes(clearing_item, user, action)
|
71
|
+
notes = "#{user[:username] if user}"
|
72
|
+
date_now = DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d %H:%M:%S').to_s
|
73
|
+
notes = (clearing_item[:notes] ? clearing_item[:notes]+'<br>' : '')+"#{date_now} #{notes} #{action}"
|
74
|
+
return notes
|
75
|
+
end
|
76
|
+
|
77
|
+
alias :franchise_sum :jm_fee
|
11
78
|
end
|
12
79
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module BlsmVdCore
|
3
|
+
class User < BlsmVdCore::BaseRecord
|
4
|
+
self.table_name='users'
|
5
|
+
has_many :clearing_items, class_name: "::BlsmVdCore::LineItem"
|
6
|
+
has_many :clearings, class_name: "::BlsmVdCore::Clearing"
|
7
|
+
has_one :vd_user_info, class_name: "::BlsmVdCore::VdUserInfo"
|
8
|
+
|
9
|
+
def create_vd_user_info
|
10
|
+
unless self.vd_user_info
|
11
|
+
return VdUserInfo.create({
|
12
|
+
user_id: self.id
|
13
|
+
})
|
14
|
+
end
|
15
|
+
self.vd_user_info
|
16
|
+
end
|
17
|
+
|
18
|
+
#是否是黑带微店主
|
19
|
+
def is_vd_black?
|
20
|
+
info = self.vd_user_info || self.create_vd_user_info
|
21
|
+
info.is_black?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module BlsmVdCore
|
3
|
+
class VdUserInfo < BlsmVdCore::BaseRecord
|
4
|
+
self.table_name='vd_user_infos'
|
5
|
+
validates_uniqueness_of :user_id
|
6
|
+
belongs_to :user, class_name: '::BlsmVdCore::User'
|
7
|
+
belongs_to :supervisor, class_name: '::BlsmVdCore::User'
|
8
|
+
|
9
|
+
#是否是黑带
|
10
|
+
def is_black?
|
11
|
+
self.vd_role == 'black'
|
12
|
+
end
|
13
|
+
|
14
|
+
#利润率,跟销售额有关系
|
15
|
+
def profit_rate
|
16
|
+
return 0.5 if self.sale_sum.to_f<1500
|
17
|
+
return 0.7 if self.sale_sum.to_f<3000
|
18
|
+
1
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
module BlsmVdCore
|
3
|
+
class VdUserScore < BlsmVdCore::BaseRecord
|
4
|
+
self.table_name='vd_user_scores'
|
5
|
+
belongs_to :user, class_name: '::BlsmVdCore::User'
|
6
|
+
SCORES = {
|
7
|
+
INVITE: 5, #邀请他人,邀请者获取的积分数
|
8
|
+
BE_INVITED: 5, #被人邀请,被邀请者获取的积分数
|
9
|
+
SALE_OUT_DIRECT: 5/100.0, #订单完成,微店主直接获取的积分比
|
10
|
+
SALE_OUT_INDIRECT: 20/100.0, #订单完成,微店主的队长获取的积分比
|
11
|
+
SCORE_TO_MONEY: 1.1/1 #积分变现(积分抵货款的比例)
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
data/lib/blsm-vd-core/version.rb
CHANGED
data/lib/blsm-vd-core.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require 'cgi'
|
2
3
|
require 'rails'
|
3
4
|
require 'active_model'
|
@@ -6,9 +7,117 @@ require 'active_support'
|
|
6
7
|
require 'blsm-vd-core/version'
|
7
8
|
require 'blsm-vd-core/model/active_record'
|
8
9
|
require 'blsm-vd-core/model/order'
|
9
|
-
|
10
|
+
require 'blsm-vd-core/model/clearing_item'
|
11
|
+
require 'blsm-vd-core/model/line_item'
|
12
|
+
require 'blsm-vd-core/model/clearing'
|
13
|
+
require 'blsm-vd-core/model/product'
|
14
|
+
require 'blsm-vd-core/model/product_prop'
|
15
|
+
require 'blsm-vd-core/model/vd_user_info'
|
16
|
+
require 'blsm-vd-core/model/vd_user_score'
|
17
|
+
require 'blsm-vd-core/model/user'
|
18
|
+
require 'faraday'
|
10
19
|
module BlsmVdCore
|
11
20
|
class << self
|
12
21
|
attr_accessor :db_config
|
13
22
|
end
|
23
|
+
module_function
|
24
|
+
#订单状态发生变化
|
25
|
+
def order_state_change(order_id)
|
26
|
+
order = Order.find_by_id(order_id)
|
27
|
+
return "404-order" if order.nil?
|
28
|
+
clearing_item = ClearingItem.find_by_order_id(order.id)
|
29
|
+
return "404-clearing-item" if clearing_item.nil?
|
30
|
+
#在线支付,客户签收,订单完成
|
31
|
+
if order.pay_type == 0 && order.state=='客户签收,订单完成'
|
32
|
+
clearing_item.update_attributes({earn_amount: order.jm_profit, state: 'CASH_BACK'})
|
33
|
+
return "200-zxzf-clearing-item"
|
34
|
+
end
|
35
|
+
if order.state.to_s.include?('订单取消')
|
36
|
+
clearing_items = order.clearing_items
|
37
|
+
if clearing_items
|
38
|
+
clearing_items.each { |item|
|
39
|
+
if item.state != 'CASH_BACK'
|
40
|
+
item.destroy
|
41
|
+
end
|
42
|
+
}
|
43
|
+
return "200-delete-clearing-item"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
#物流返款
|
48
|
+
def order_sign_handle(order_id,sign_type)
|
49
|
+
order = Order.find_by_id(order_id)
|
50
|
+
return "404-order" if order.nil?
|
51
|
+
begin
|
52
|
+
clearing_item = ClearingItem.find_by_order_id(order.id)
|
53
|
+
return "404-clearing-item" if clearing_item.nil?
|
54
|
+
if sign_type == "sign_ok" && !Order.valid_update?(clearing_item)
|
55
|
+
return "already-cash-back"
|
56
|
+
end
|
57
|
+
rescue Exception, e
|
58
|
+
return "500-error"
|
59
|
+
end
|
60
|
+
|
61
|
+
result = if sign_type == "sign_ok"
|
62
|
+
if clearing_item.pay_type == 'ZXZF'
|
63
|
+
puts "非货到付款订单,不需要做啥操作"
|
64
|
+
return "zxzf-not-need-handle"
|
65
|
+
end
|
66
|
+
note = Order.latest_notes(clearing_item, {username: '首趣'}, '标记物流返款')
|
67
|
+
clearing_item.marking_confirm(note)
|
68
|
+
elsif sign_type == "sign_fail"
|
69
|
+
if clearing_item.clearing && clearing_item.clearing.state == "BALANCED"
|
70
|
+
i_clearing = clearing_item.dup
|
71
|
+
i_clearing.clearing_id = nil
|
72
|
+
i_clearing.save
|
73
|
+
note = Order.latest_notes(clearing_item, {username: '首趣'}, '标记签收失败')
|
74
|
+
i_clearing.marking_refuse(note, clearing_item.possible_profit)
|
75
|
+
else
|
76
|
+
note = Order.latest_notes(clearing_item, {username: '首趣'}, '标记签收失败')
|
77
|
+
clearing_item.marking_refuse(note)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
sign_column = (sign_type == "sign_ok") ? "sign_ok" : "sign_fail"
|
81
|
+
if result
|
82
|
+
"sign-#{sign_column}-success"
|
83
|
+
else
|
84
|
+
"sign-#{sign_column}-error"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
#【积分获取】商品售卖出去
|
89
|
+
#微店主的积分会根据商品总的供货价的
|
90
|
+
#商品卖出,微店主会获取直接的 订单供货价 * +SCORES[:SALE_OUT_DIRECT]+ 积分
|
91
|
+
# 微店主所属的队长(直接上级)获取 订单供货价 * +SCORES[:SALE_OUT_INDIRECT]+ 积分
|
92
|
+
#==== Parameters
|
93
|
+
# * +seller_id+ - 销售员的id
|
94
|
+
# * +order_id+ - 订单id
|
95
|
+
def product_sale_out(seller_id, order_id)
|
96
|
+
seller = User.where(id: seller_id).first
|
97
|
+
leader = User.where("id in(select supervisor_id from vd_user_infos where user_id=#{seller_id})").first
|
98
|
+
order = Order.where(id: order_id).first
|
99
|
+
|
100
|
+
seller_info = seller.create_vd_user_info
|
101
|
+
leader_info = leader && leader.is_vd_black? ? leader.create_vd_user_info : nil
|
102
|
+
|
103
|
+
franchise_sum = order.franchise_sum #供货价总和
|
104
|
+
|
105
|
+
#积分获取
|
106
|
+
seller_info.update_attributes({:score => seller_info.score.to_f+franchise_sum.to_f*VdUserScore::SCORES[:SALE_OUT_DIRECT]})
|
107
|
+
leader_info.update_attributes({:score => leader_info.score.to_f+franchise_sum.to_f*VdUserScore::SCORES[:SALE_OUT_INDIRECT]}) if leader_info
|
108
|
+
|
109
|
+
#积分历史
|
110
|
+
VdUserScore.create({
|
111
|
+
user_id: seller_id,
|
112
|
+
score: franchise_sum.to_f*VdUserScore::SCORES[:SALE_OUT_DIRECT],
|
113
|
+
notes: "分销#{franchise_sum}元,订单#{order_id}完成"
|
114
|
+
})
|
115
|
+
VdUserScore.create({
|
116
|
+
user_id: leader.id,
|
117
|
+
score: franchise_sum.to_f*VdUserScore::SCORES[:SALE_OUT_INDIRECT],
|
118
|
+
notes: "成员【#{seller.username}】分销#{franchise_sum}元,订单#{order_id}完成"
|
119
|
+
}) if leader_info
|
120
|
+
|
121
|
+
#TODO:销售额、分销额增加
|
122
|
+
end
|
14
123
|
end
|
metadata
CHANGED
@@ -1,127 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blsm-vd-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saxer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
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
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: faraday
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.9'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.9'
|
125
139
|
description: 首趣微店核心模块,包含结算项的创建、更新、删除,微店主积分的更改等信息
|
126
140
|
email:
|
127
141
|
- 15201280641@qq.com
|
@@ -129,18 +143,29 @@ executables: []
|
|
129
143
|
extensions: []
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
132
|
-
-
|
133
|
-
-
|
146
|
+
- .gitignore
|
147
|
+
- .travis.yml
|
134
148
|
- Gemfile
|
149
|
+
- Gemfile.lock
|
135
150
|
- README.md
|
136
151
|
- Rakefile
|
137
152
|
- bin/console
|
138
153
|
- bin/setup
|
139
154
|
- blsm-vd-core.gemspec
|
155
|
+
- build.py
|
156
|
+
- build.rb
|
140
157
|
- config/database.yml
|
141
158
|
- lib/blsm-vd-core.rb
|
142
159
|
- lib/blsm-vd-core/model/active_record.rb
|
160
|
+
- lib/blsm-vd-core/model/clearing.rb
|
161
|
+
- lib/blsm-vd-core/model/clearing_item.rb
|
162
|
+
- lib/blsm-vd-core/model/line_item.rb
|
143
163
|
- lib/blsm-vd-core/model/order.rb
|
164
|
+
- lib/blsm-vd-core/model/product.rb
|
165
|
+
- lib/blsm-vd-core/model/product_prop.rb
|
166
|
+
- lib/blsm-vd-core/model/user.rb
|
167
|
+
- lib/blsm-vd-core/model/vd_user_info.rb
|
168
|
+
- lib/blsm-vd-core/model/vd_user_score.rb
|
144
169
|
- lib/blsm-vd-core/version.rb
|
145
170
|
homepage: https://bitbucket.org/Xiaopuzhu/blsm-vd-core
|
146
171
|
licenses:
|
@@ -153,12 +178,12 @@ require_paths:
|
|
153
178
|
- lib
|
154
179
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
180
|
requirements:
|
156
|
-
- -
|
181
|
+
- - ! '>='
|
157
182
|
- !ruby/object:Gem::Version
|
158
183
|
version: '0'
|
159
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
185
|
requirements:
|
161
|
-
- -
|
186
|
+
- - ! '>='
|
162
187
|
- !ruby/object:Gem::Version
|
163
188
|
version: '0'
|
164
189
|
requirements: []
|