Commit bef95b65 by ivan Lan

Fix meta & price & origin_pirce in snapshot

parent f1d44384
......@@ -4,4 +4,4 @@ json.extract! order, :id, :seq, :address,
:delivery_way, :delivery_cost,
:merchant_remark, :mark, :customer_remark,
:status, :status_zh, :meta
# json.snapshots order.snapshots, partial: 'shotengai/share/snapshot_simple', as: :snapshot
json.snapshots order.snapshots, partial: 'shotengai/share/snapshot_simple', as: :snapshot
......@@ -3,4 +3,4 @@ json.extract! order, :id, :seq, :total_price, :total_original_price,
:pay_time, :delivery_time, :receipt_time,
:delivery_way, :delivery_cost, :customer_remark,
:status, :status_zh, :meta
# json.snapshots order.snapshots, partial: 'shotengai/share/snapshot_simple', as: :snapshot
\ No newline at end of file
json.snapshots order.snapshots, partial: 'shotengai/share/snapshot_simple', as: :snapshot
\ No newline at end of file
......@@ -68,6 +68,10 @@ module Shotengai
self.stock.eql?(-1) || self.update!(stock: self.stock - count)
end
def original_price
read_attribute(:original_price) || price
end
private
# spec 字段
def check_spec_value
......
......@@ -74,11 +74,11 @@ module Shotengai
# QUESTION: spec 赋值是在 after pay 合理?
# 支付前 信息 delegate to series
[:original_price, :price, :spec, :banners, :cover_image, :detail].each do |column|
define_method(column) { read_attribute(column) || self.series.read_attribute(column) }
define_method(column) { read_attribute(column) || self.series.send(column) }
end
def meta
read_attribute(column) || series.product.meta.merge(series.meta)
read_attribute(:meta) || (series.product.meta || {} ).merge(series.meta || {})
end
# 订单支付后 存储当时信息快照
......@@ -91,7 +91,7 @@ module Shotengai
banners: series.banners,
cover_image: series.cover_image,
detail: series.detail,
meta: series.product.meta.merge(series.meta)
meta: (series.product.meta || {} ).merge(series.meta || {})
)
end
......@@ -99,13 +99,9 @@ module Shotengai
self.series.cut_stock(self.count)
end
def meta
read_attribute(:meta) || series.product.meta.merge(series.meta)
end
###### view
def total_price
revised_amount || count * price
revised_amount || count * self.price
end
def total_original_price
......
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