unidom-order 1.4.1 → 1.4.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 +26 -5
- data/app/controllers/unidom/order/application_controller.rb +3 -0
- data/app/jobs/unidom/order/application_job.rb +3 -0
- data/app/mailers/unidom/order/application_mailer.rb +3 -0
- data/app/models/unidom/order/application_record.rb +3 -0
- data/app/models/unidom/order/order.rb +1 -1
- data/app/models/unidom/order/order_adjustment.rb +4 -1
- data/app/models/unidom/order/order_item.rb +4 -1
- data/app/views/layouts/unidom/order/application.html.erb +1 -1
- data/lib/unidom/order/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e091e23d5b3eb27ad6a15956f79901c6cc293127
|
4
|
+
data.tar.gz: 242b53a3e93e89b0ae87957c241acd016a15c572
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a1f3ca8d004687a472626259f5400dcaf8a2b5924c1eaf5cb0e5f1d4f15cf37cfbd53613ae2eb0b39908842f59b25704258b569a8f13edf112bde597d2c06a3
|
7
|
+
data.tar.gz: 389637997d93c82734639e617a805757b50f4263298fe241637422eb88749cc9a6fdc658fb03f956c7999d01980db3f35e5697cb336373ea6a9fba7888daa27d
|
data/README.md
CHANGED
@@ -112,19 +112,24 @@ include Unidom::Order::AsOrderTaker
|
|
112
112
|
|
113
113
|
### As Adjusted concern
|
114
114
|
|
115
|
-
The As Adjusted concern do the following tasks for the includer automatically:
|
116
|
-
|
117
|
-
|
115
|
+
The As Adjusted concern do the following tasks for the includer automatically:
|
116
|
+
|
117
|
+
1. Define the has_many :adjustments macro as: ``has_many :adjustments, class_name: 'Unidom::Order::OrderAdjustment', as: :adjusted``
|
118
|
+
|
119
|
+
2. Define the #is_adjusted! method as: ``is_adjusted!(amount, due_to: 'FRGT', at: Time.now)``
|
120
|
+
|
118
121
|
3. Define the #is_adjusted? method as: ``is_adjusted?(due_to: 'FRGT', at: Time.now)``
|
119
122
|
|
120
123
|
### As Order Placer concern
|
121
124
|
|
122
|
-
The As Order Placer concern do the following tasks for the includer automatically:
|
125
|
+
The As Order Placer concern do the following tasks for the includer automatically:
|
126
|
+
|
123
127
|
1. Define the has_many :placed_orders macro as: ``has_many :placed_orders, class_name: 'Unidom::Order::Order', as: :placer``
|
124
128
|
|
125
129
|
### As Order Taker concern
|
126
130
|
|
127
|
-
The As Order Taker concern do the following tasks for the includer automatically:
|
131
|
+
The As Order Taker concern do the following tasks for the includer automatically:
|
132
|
+
|
128
133
|
1. Define the has_many :taken_orders macro as: ``has_many :taken_orders, class_name: 'Unidom::Order::Order', as: :taker``
|
129
134
|
|
130
135
|
|
@@ -141,3 +146,19 @@ Unidom::Order::AdjustmentFactor::SHIPPING_AND_HANDLING_CHARGES # 装运和处理
|
|
141
146
|
Unidom::Order::AdjustmentFactor::FEE # 手续费
|
142
147
|
Unidom::Order::AdjustmentFactor::MISCELLANEOUS_CHARGE # 杂项收费
|
143
148
|
```
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
## Disable the Model & Migration
|
153
|
+
|
154
|
+
If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
|
155
|
+
```ruby
|
156
|
+
# config/initializers/unidom.rb
|
157
|
+
Unidom::Common.configure do |options|
|
158
|
+
|
159
|
+
options[:neglected_namespaces] = %w{
|
160
|
+
Unidom::Order
|
161
|
+
}
|
162
|
+
|
163
|
+
end
|
164
|
+
```
|
@@ -16,6 +16,9 @@ class Unidom::Order::OrderAdjustment < Unidom::Order::ApplicationRecord
|
|
16
16
|
|
17
17
|
code :adjustment_factor, Unidom::Order::AdjustmentFactor
|
18
18
|
|
19
|
+
##
|
20
|
+
# 对订单或者订单项 adjusted 进行调整。调整金额为 amount ,缺省为 0 。调整原因是 due_to ,缺省是 FRGT 。调整时间是 opened_at ,缺省为当前时间。如:
|
21
|
+
# Unidom::Order::OrderAdjustment.adjust! order, amount: 7.90, due_to: 'LTAX'
|
19
22
|
def self.adjust!(adjusted, amount: 0, due_to: 'FRGT', opened_at: Time.now)
|
20
23
|
query = adjusted_is(adjusted).adjustment_factor_coded_as(due_to).valid_at(now: opened_at).alive
|
21
24
|
adjustment = query.first
|
@@ -32,4 +35,4 @@ class Unidom::Order::OrderAdjustment < Unidom::Order::ApplicationRecord
|
|
32
35
|
adjustment
|
33
36
|
end
|
34
37
|
|
35
|
-
end
|
38
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::OrderAdjustment'
|
@@ -22,6 +22,9 @@ class Unidom::Order::OrderItem < Unidom::Order::ApplicationRecord
|
|
22
22
|
scope :ordered_is, ->(ordered) { where ordered: ordered }
|
23
23
|
scope :placed_by, ->(placer) { where placer: placer }
|
24
24
|
|
25
|
+
##
|
26
|
+
# 订购商品 ordered ,放入订单 of 。订购者为 by ,缺省为订单的下单者。单价为 unit_price ,缺省值为 0 。数量为 quantity ,缺省值为 1。如:
|
27
|
+
# Unidom::Order::OrderItem.order! coca_cola, of: order, by: current_person, unit_price: 3.50, quantity: 2
|
25
28
|
def self.order!(ordered, of: nil, by: of.placer, unit_price: 0, quantity: 1)
|
26
29
|
item = of.items.ordered_is(ordered).placed_by(by).valid_at.alive.first
|
27
30
|
if item.present?
|
@@ -36,4 +39,4 @@ class Unidom::Order::OrderItem < Unidom::Order::ApplicationRecord
|
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
|
-
end
|
42
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Order::OrderItem'
|
data/lib/unidom/order/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-order
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.9'
|
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: '1.
|
26
|
+
version: '1.9'
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
28
28
|
The Order domain model engine includes Order, Order Item, and Order Adjustment models.
|
29
29
|
Unidom (统一领域对象模型)是一系列的领域模型引擎。订单领域模型引擎包括订单、订单项和订单调整的模型。
|