blsm-vd-core 0.2.9 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/Gemfile.lock +3 -3
- data/blsm-vd-core.gemspec +1 -1
- data/lib/blsm-vd-core.rb +9 -0
- data/lib/blsm-vd-core/model/encrypted_id.rb +84 -0
- data/lib/blsm-vd-core/model/order.rb +2 -0
- data/lib/blsm-vd-core/version.rb +1 -1
- metadata +29 -28
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDY0OGFiZTI1ZWQyNjE1OWU3MzhlMWFlYzc2N2Q4OGM4ZWEyNmNhMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDhhODgzMzM4MjEzOTgyOWRlNDM3NWQyNzY0NzkxMTEyMDhhZmJjOQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzU2ZTFlMjJjODRmZjAxOThjOTg1NGVhY2Y0MzdiYTZjNmFiNjBjMzJjYmI3
|
10
|
+
Mjg0YmRhNTg5YTcxZTdiMGNhNTU3MWY3NTM2Y2M2MWM2MzllZjJkNWNjZGQx
|
11
|
+
YWJiNjE0ZTllMzE5NmE0YmM4ZmRiMjE5MWY4NWZhNmZjOTEwNWE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWVhOGQ4NjMyNjU4N2Q0MzczYTY3Y2QzMmI3ZmNlODU0MzllMjUyZDk1N2Y5
|
14
|
+
OTM0ODVjYjU3YjliMTUwYWRhYjNjMmMwNDljZTQwOTFmOWE2MjBkMGNkMWYx
|
15
|
+
NDQ0MDMzMzY3YThhNjc5MmE4ZGM5ZjA2ZDdlZThhMmYzZDMzNmU=
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
blsm-vd-core (0.
|
4
|
+
blsm-vd-core (0.3.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://ruby.taobao.org/
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
i18n (~> 0.6)
|
35
35
|
multi_json (~> 1.0)
|
36
36
|
arel (3.0.2)
|
37
|
-
blsm-mp-wx (0.1.
|
37
|
+
blsm-mp-wx (0.1.9)
|
38
38
|
builder (3.0.0)
|
39
39
|
diff-lcs (1.2.5)
|
40
40
|
erubis (2.7.0)
|
@@ -109,7 +109,7 @@ DEPENDENCIES
|
|
109
109
|
activemodel (~> 3.2)
|
110
110
|
activerecord (~> 3.2)
|
111
111
|
activesupport (~> 3.2)
|
112
|
-
blsm-mp-wx (~> 0.1.
|
112
|
+
blsm-mp-wx (~> 0.1.9)
|
113
113
|
blsm-vd-core!
|
114
114
|
bundler (~> 1.9)
|
115
115
|
faraday (~> 0.9)
|
data/blsm-vd-core.gemspec
CHANGED
@@ -37,5 +37,5 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_development_dependency "activerecord", "~> 3.2"
|
38
38
|
spec.add_development_dependency "activesupport", "~> 3.2"
|
39
39
|
spec.add_development_dependency "faraday", "~> 0.9"
|
40
|
-
spec.add_development_dependency "blsm-mp-wx", "~> 0.1.
|
40
|
+
spec.add_development_dependency "blsm-mp-wx", "~> 0.1.9"
|
41
41
|
end
|
data/lib/blsm-vd-core.rb
CHANGED
@@ -6,6 +6,7 @@ require 'active_record'
|
|
6
6
|
require 'active_support'
|
7
7
|
require 'blsm-vd-core/version'
|
8
8
|
require 'blsm-vd-core/model/active_record'
|
9
|
+
require 'blsm-vd-core/model/encrypted_id'
|
9
10
|
require 'blsm-vd-core/model/order'
|
10
11
|
require 'blsm-vd-core/model/clearing_item'
|
11
12
|
require 'blsm-vd-core/model/line_item'
|
@@ -229,6 +230,14 @@ module BlsmVdCore
|
|
229
230
|
BlsmMpWx.create_msg(nil, seller.openid, seller_notify, 'score_change')
|
230
231
|
BlsmMpWx.create_msg(nil, leader.openid, leader_notify, 'score_change') if leader_notify
|
231
232
|
|
233
|
+
#订单确认提醒(黑带)
|
234
|
+
distribute_leader_notify = {touser: leader.openid,
|
235
|
+
order_id: Order.encrypt(Order.encrypted_id_key, order.id.to_s),
|
236
|
+
score_change: leader_change,
|
237
|
+
money_change: leader_change*VdUserScore::SCORES[:SCORE_TO_MONEY],
|
238
|
+
content: "首趣黑带#{leader.username},你好:成员【#{seller.username}】确认订单成功。"
|
239
|
+
} if leader && leader_info
|
240
|
+
BlsmMpWx.create_msg(nil, leader.openid, distribute_leader_notify, 'distribute') if distribute_leader_notify
|
232
241
|
|
233
242
|
#积分历史
|
234
243
|
VdUserScore.create({
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module BlsmVdCore
|
2
|
+
module EncryptedId
|
3
|
+
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
CIPHER_NAME = 'aes-256-cbc'
|
7
|
+
CIPHER_IV = ['1e5673b2572af26a8364a50af84c7d2a'].pack('H*')
|
8
|
+
|
9
|
+
included do
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
|
14
|
+
def encrypted_id(options = {})
|
15
|
+
cattr_accessor :encrypted_id_key
|
16
|
+
self.encrypted_id_key = Digest::SHA256.digest(options[:key] || encrypted_id_default_key)
|
17
|
+
self.define_singleton_method(:find_single, lambda { puts "foo" })
|
18
|
+
end
|
19
|
+
|
20
|
+
def find(*args)
|
21
|
+
scope = args.slice!(0)
|
22
|
+
options = args.slice!(0) || {}
|
23
|
+
if !(scope.is_a? Symbol) && has_encrypted_id? && !options[:no_encrypted_id]
|
24
|
+
begin
|
25
|
+
scope =
|
26
|
+
if scope.is_a? Array
|
27
|
+
scope.map! { |encrypted_id| decrypt(encrypted_id_key, encrypted_id) }
|
28
|
+
else
|
29
|
+
decrypt(encrypted_id_key, "#{scope}")
|
30
|
+
end
|
31
|
+
rescue OpenSSL::Cipher::CipherError
|
32
|
+
raise ActiveRecord::RecordNotFound.new("Could not decrypt ID #{args[0]}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
options.delete(:no_encrypted_id)
|
36
|
+
super(scope)
|
37
|
+
end
|
38
|
+
|
39
|
+
def find_by_encrypted_id(*args)
|
40
|
+
self.find(*args)
|
41
|
+
end
|
42
|
+
|
43
|
+
def has_encrypted_id?
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
def encrypted_id_default_key
|
48
|
+
name
|
49
|
+
end
|
50
|
+
|
51
|
+
def decrypt(key, id)
|
52
|
+
c = OpenSSL::Cipher::Cipher.new(CIPHER_NAME).decrypt
|
53
|
+
c.iv = CIPHER_IV
|
54
|
+
c.key = key
|
55
|
+
c.update([id].pack('H*')) + c.final
|
56
|
+
end
|
57
|
+
|
58
|
+
def encrypt(key, id)
|
59
|
+
c = OpenSSL::Cipher::Cipher.new(CIPHER_NAME).encrypt
|
60
|
+
c.iv = CIPHER_IV
|
61
|
+
c.key = key
|
62
|
+
(c.update("#{id}") + c.final).unpack('H*')[0]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_param
|
67
|
+
self.class.encrypt(self.class.encrypted_id_key, self.id)
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_key
|
71
|
+
key = self.id or nil
|
72
|
+
if key
|
73
|
+
key = [self.class.encrypt(self.class.encrypted_id_key, self.id)]
|
74
|
+
end
|
75
|
+
key
|
76
|
+
end
|
77
|
+
|
78
|
+
def reload(options = nil)
|
79
|
+
options = (options || {}).merge(:no_encrypted_id => true)
|
80
|
+
super(options)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
module BlsmVdCore
|
3
3
|
class Order < BlsmVdCore::BaseRecord
|
4
|
+
include BlsmVdCore::EncryptedId
|
4
5
|
self.table_name='orders'
|
5
6
|
has_many :clearing_items, class_name: "::BlsmVdCore::ClearingItem"
|
6
7
|
has_many :line_items, class_name: "::BlsmVdCore::LineItem"
|
7
8
|
belongs_to :application, class_name: "::BlsmVdCore::Application", foreign_key: "application_id"
|
9
|
+
encrypted_id key: 'bYqILlFMZn3xd8Cy'
|
8
10
|
|
9
11
|
public
|
10
12
|
def pay_off_line?
|
data/lib/blsm-vd-core/version.rb
CHANGED
metadata
CHANGED
@@ -1,155 +1,155 @@
|
|
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.3.2
|
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-26 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
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
|
-
version: 0.1.
|
145
|
+
version: 0.1.9
|
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
|
-
version: 0.1.
|
152
|
+
version: 0.1.9
|
153
153
|
description: 首趣微店核心模块,包含结算项的创建、更新、删除,微店主积分的更改等信息
|
154
154
|
email:
|
155
155
|
- 15201280641@qq.com
|
@@ -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
|
@@ -171,6 +171,7 @@ files:
|
|
171
171
|
- lib/blsm-vd-core/model/application.rb
|
172
172
|
- lib/blsm-vd-core/model/clearing.rb
|
173
173
|
- lib/blsm-vd-core/model/clearing_item.rb
|
174
|
+
- lib/blsm-vd-core/model/encrypted_id.rb
|
174
175
|
- lib/blsm-vd-core/model/line_item.rb
|
175
176
|
- lib/blsm-vd-core/model/order.rb
|
176
177
|
- lib/blsm-vd-core/model/product.rb
|
@@ -191,12 +192,12 @@ require_paths:
|
|
191
192
|
- lib
|
192
193
|
required_ruby_version: !ruby/object:Gem::Requirement
|
193
194
|
requirements:
|
194
|
-
- -
|
195
|
+
- - ! '>='
|
195
196
|
- !ruby/object:Gem::Version
|
196
197
|
version: '0'
|
197
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
199
|
requirements:
|
199
|
-
- -
|
200
|
+
- - ! '>='
|
200
201
|
- !ruby/object:Gem::Version
|
201
202
|
version: '0'
|
202
203
|
requirements: []
|