wechat_payment 0.2.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/app/controllers/wechat_payment/payment_orders_controller.rb +9 -0
- data/app/models/wechat_payment/payment_order.rb +6 -2
- data/db/migrate/20210706075217_create_wechat_payment_payment_orders.rb +2 -2
- data/lib/generators/wechat_payment/install/install_generator.rb +7 -2
- data/lib/wechat_payment/concern/goods.rb +3 -3
- data/lib/wechat_payment/concern/user.rb +2 -2
- data/lib/wechat_payment/version.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c61c4ab32413e5389896bde1f772149d3df02e74c4cdcd76973ed942c6e25009
|
4
|
+
data.tar.gz: b5d53616d2f40fa7c112ca57319f5d4c29606053ae291fb09aee8a8280674ea5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9265a884ffd5b9a544644400bac0e2c89c75b87803fb95d9542e8e0cbfce76c8688928b9aad3aeaf54c67b261a0c7cb99d0f2021a749a7207cd4a35a40380c0c
|
7
|
+
data.tar.gz: 95e24b9a3941112ad5698a3cbbdf313c38f4755d0a2ecc0dcaca0c2ce4ddf62b4045bddac81b7fcdf24b394a4ede23d512b5db232436975f0165c60c08490df8
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
## Convention
|
6
|
-
在使用该 Engine 之前,需要先建立`用户模型`,`商品模型`,`用户商品关联模型`,用户表需要有
|
6
|
+
在使用该 Engine 之前,需要先建立`用户模型`,`商品模型`,`用户商品关联模型`,用户表需要有 openid 字段,
|
7
7
|
商品表需要有 price 和 name 字段。假设`商品模型`为`Product`,则用户和商品之间的关联模型为`UserProduct`,
|
8
8
|
关联模型属于`user`和`product`。
|
9
9
|
|
@@ -17,8 +17,8 @@
|
|
17
17
|
|
18
18
|
3. 初始化
|
19
19
|
```bash
|
20
|
-
# rails g wechat_payment:install [GoodsModel] [UserModel]
|
21
|
-
$ rails g wechat_payment:install Product User
|
20
|
+
# rails g wechat_payment:install [GoodsModel] [UserGoodRelationModel] [UserModel]
|
21
|
+
$ rails g wechat_payment:install Product UserProduct User
|
22
22
|
$ rails db:migrate
|
23
23
|
```
|
24
24
|
|
@@ -227,4 +227,4 @@ TODO 待补充
|
|
227
227
|
Contribution directions go here.
|
228
228
|
|
229
229
|
## License
|
230
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
230
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -8,6 +8,10 @@ module WechatPayment
|
|
8
8
|
before_create :gen_out_trade_no
|
9
9
|
belongs_to :goods, polymorphic: true
|
10
10
|
|
11
|
+
scope :by_state, ->(state)do
|
12
|
+
where(state: state) if state.present?
|
13
|
+
end
|
14
|
+
|
11
15
|
enum state: {
|
12
16
|
paid: "paid",
|
13
17
|
pending: "pending",
|
@@ -17,7 +21,7 @@ module WechatPayment
|
|
17
21
|
|
18
22
|
# 将部分用户信息保存至订单
|
19
23
|
def set_customer_info
|
20
|
-
self.
|
24
|
+
self.openid = customer.openid if openid.blank?
|
21
25
|
self.spbill_create_ip = customer.spbill_create_ip
|
22
26
|
end
|
23
27
|
|
@@ -50,7 +54,7 @@ module WechatPayment
|
|
50
54
|
spbill_create_ip: spbill_create_ip,
|
51
55
|
total_fee: total_fee,
|
52
56
|
body: body,
|
53
|
-
openid:
|
57
|
+
openid: openid
|
54
58
|
}
|
55
59
|
end
|
56
60
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CreateWechatPaymentPaymentOrders < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
3
|
create_table :wechat_payment_payment_orders do |t|
|
4
|
-
t.string :
|
4
|
+
t.string :openid
|
5
5
|
t.string :out_trade_no
|
6
6
|
t.references :goods, polymorphic: true, null: false
|
7
7
|
t.references :customer, polymorphic: true, null: false
|
@@ -17,6 +17,6 @@ class CreateWechatPaymentPaymentOrders < ActiveRecord::Migration[6.1]
|
|
17
17
|
|
18
18
|
t.timestamps
|
19
19
|
end
|
20
|
-
add_index :wechat_payment_payment_orders, :
|
20
|
+
add_index :wechat_payment_payment_orders, :openid
|
21
21
|
end
|
22
22
|
end
|
@@ -2,6 +2,7 @@ class WechatPayment::InstallGenerator < Rails::Generators::Base
|
|
2
2
|
source_root File.expand_path('templates', __dir__)
|
3
3
|
|
4
4
|
argument :goods, type: :string
|
5
|
+
argument :relation_model, type: :string
|
5
6
|
argument :user, type: :string, default: :User
|
6
7
|
|
7
8
|
|
@@ -59,7 +60,11 @@ class WechatPayment::InstallGenerator < Rails::Generators::Base
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def user_goods_model_file
|
62
|
-
|
63
|
+
if relation_model
|
64
|
+
"app/models/#{relation_model.underscore}.rb"
|
65
|
+
else
|
66
|
+
"app/models/#{user.to_s.underscore}_#{goods.to_s.underscore}.rb"
|
67
|
+
end
|
63
68
|
end
|
64
69
|
|
65
70
|
def goods_model_name
|
@@ -71,7 +76,7 @@ class WechatPayment::InstallGenerator < Rails::Generators::Base
|
|
71
76
|
end
|
72
77
|
|
73
78
|
def user_goods_model_name
|
74
|
-
user_model_name + goods_model_name
|
79
|
+
(relation_model&.camelize) || (user_model_name + goods_model_name)
|
75
80
|
end
|
76
81
|
|
77
82
|
def def_custom_user_model
|
@@ -25,8 +25,7 @@ module WechatPayment
|
|
25
25
|
# 售出
|
26
26
|
# @param [User] user
|
27
27
|
# @return [WechatPaymentOrder]
|
28
|
-
def sell_to(user)
|
29
|
-
|
28
|
+
def sell_to(user, with_info = {})
|
30
29
|
persist_goods_data = {}.tap do |h|
|
31
30
|
self.class.persist_goods_attrs.each do |attr|
|
32
31
|
h[attr] = send(attr)
|
@@ -36,7 +35,8 @@ module WechatPayment
|
|
36
35
|
user_goods = self.class.user_goods_model.constantize.create(
|
37
36
|
self.class.goods_ref_field => self,
|
38
37
|
self.class.user_ref_field => user,
|
39
|
-
**
|
38
|
+
**with_info,
|
39
|
+
**persist_goods_data,
|
40
40
|
)
|
41
41
|
|
42
42
|
user_goods.payment_orders.create(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wechat_payment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 7.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 7.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: wx_pay
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- app/assets/stylesheets/wechat_payment/application.css
|
67
67
|
- app/controllers/wechat_payment/application_controller.rb
|
68
68
|
- app/controllers/wechat_payment/callback_controller.rb
|
69
|
+
- app/controllers/wechat_payment/payment_orders_controller.rb
|
69
70
|
- app/helpers/wechat_payment/application_helper.rb
|
70
71
|
- app/jobs/wechat_payment/application_job.rb
|
71
72
|
- app/mailers/wechat_payment/application_mailer.rb
|
@@ -97,13 +98,13 @@ files:
|
|
97
98
|
- lib/wechat_payment/service_result.rb
|
98
99
|
- lib/wechat_payment/sign.rb
|
99
100
|
- lib/wechat_payment/version.rb
|
100
|
-
homepage:
|
101
|
+
homepage: http://dev.com
|
101
102
|
licenses:
|
102
103
|
- MIT
|
103
104
|
metadata:
|
104
|
-
homepage_uri:
|
105
|
-
source_code_uri:
|
106
|
-
changelog_uri:
|
105
|
+
homepage_uri: http://dev.com
|
106
|
+
source_code_uri: http://dev.com
|
107
|
+
changelog_uri: http://dev.com/CHANGELOG.md
|
107
108
|
post_install_message:
|
108
109
|
rdoc_options: []
|
109
110
|
require_paths:
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.3.3
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: Summary of WechatPayment.
|