Commit d508d3fa by ivan Lan

Improve order about amount & product_amount & product_original_amount

parent 1f2477a1
json.extract! order, :id, :seq, :address,
json.extract! order, :id, :seq, :address, :amount,
:product_amount, :product_original_amount,
:total_price, :total_original_price,
:pay_time, :delivery_time, :receipt_time,
:delivery_way, :delivery_cost,
......
json.extract! order, :id, :seq, :address,
:total_price, :total_original_price,
json.extract! order, :id, :seq, :address, :amount
:product_amount, :product_original_amount,
:pay_time, :delivery_time, :receipt_time,
:delivery_way, :delivery_cost,
:merchant_remark, :mark, :customer_remark,
......
json.extract! order, :id, :seq, :total_price, :total_original_price,
json.extract! order, :id, :seq, :amount,
:product_amount, :product_original_amount,
:status_zh, :address,
:pay_time, :delivery_time, :receipt_time,
:delivery_way, :delivery_cost, :customer_remark,
......
json.extract! order, :id, :seq, :address,
:total_price, :total_original_price,
json.extract! order, :id, :seq, :address, :amount,
:product_amount, :product_original_amount,
:pay_time, :delivery_time, :receipt_time,
:delivery_way, :delivery_cost, :customer_remark,
:status, :status_zh, :meta, :created_at
\ No newline at end of file
......@@ -98,10 +98,6 @@ module Shotengai
update!(receipt_time: Time.now)
end
def set_amount
self.update!(amount: product_amount + delivery_cost)
end
def set_seq
timestamp = Time.now.strftime("%Y%m%d-%H%M")
no_length = 4
......@@ -109,6 +105,14 @@ module Shotengai
self.update!(seq: "#{timestamp}-#{no}}")
end
def set_amount
self.update!(amount: product_amount + delivery_cost)
end
def amount
read_attribute(:amount) || product_amount + delivery_cost
end
def product_amount
snapshots.sum(&:total_price)
end
......@@ -116,6 +120,8 @@ module Shotengai
def product_original_amount
snapshots.sum(&:total_original_price)
end
# into order
def incr_snapshot_ids= ids
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment