Commit 9ec8f4c7 by ivan Lan

Add column title to snapshot

parent 4e007d9e
example_id | status | run_time |
------------------------------------------ | ------ | --------------- |
./spec/shotengai/models_spec.rb[1:1:1:1] | passed | 0.76841 seconds |
./spec/shotengai/models_spec.rb[1:1:1:2] | passed | 0.39895 seconds |
./spec/shotengai/models_spec.rb[1:1:2:1] | passed | 0.40877 seconds |
./spec/shotengai/models_spec.rb[1:1:2:2] | passed | 0.40292 seconds |
./spec/shotengai/models_spec.rb[1:1:2:3] | passed | 0.40936 seconds |
./spec/shotengai/models_spec.rb[1:1:2:4] | passed | 0.39549 seconds |
./spec/shotengai/models_spec.rb[1:1:3:1] | passed | 0.36859 seconds |
./spec/shotengai/models_spec.rb[1:1:3:2] | passed | 0.3979 seconds |
./spec/shotengai/models_spec.rb[1:1:3:3] | passed | 0.40805 seconds |
./spec/shotengai/models_spec.rb[1:1:4:1] | failed | 0.66932 seconds |
./spec/shotengai/models_spec.rb[1:1:5:1] | passed | 0.38994 seconds |
./spec/shotengai/models_spec.rb[1:1:5:2:1] | passed | 0.48448 seconds |
./spec/shotengai/models_spec.rb[1:1:5:2:2] | failed | 0.56715 seconds |
./spec/shotengai/models_spec.rb[1:2:1:1] | passed | 0.40297 seconds |
./spec/shotengai/models_spec.rb[1:2:1:2] | passed | 0.3698 seconds |
./spec/shotengai/models_spec.rb[1:2:2:1] | passed | 0.66138 seconds |
./spec/shotengai/models_spec.rb[1:2:2:2] | passed | 0.48194 seconds |
./spec/shotengai/models_spec.rb[1:3:1] | passed | 0.37498 seconds |
...@@ -77,6 +77,7 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1] ...@@ -77,6 +77,7 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1]
def create_snapshot def create_snapshot
create_table :shotengai_snapshots do |t| create_table :shotengai_snapshots do |t|
t.string :title
t.decimal :original_price, precision: 9, scale: 2 t.decimal :original_price, precision: 9, scale: 2
t.decimal :price, precision: 9, scale: 2 t.decimal :price, precision: 9, scale: 2
# Merchant can change the amount of snapshot # Merchant can change the amount of snapshot
......
json.extract! snapshot, :id, :shotengai_series_id, :original_price, :price, :count, json.extract! snapshot, :id, :title, :shotengai_series_id,
:original_price, :price, :count,
:product_status_zh, :order_status_zh, :product_status, :order_status, :product_status_zh, :order_status_zh, :product_status, :order_status,
:total_price, :total_original_price, :revised_amount, :total_price, :total_original_price, :revised_amount,
:spec, :cover_image, :banners, :detail, :meta, :is_in_cart :spec, :cover_image, :banners, :detail, :meta, :is_in_cart
\ No newline at end of file
json.extract! snapshot, :id, :shotengai_series_id, :original_price, :price, :count, json.extract! snapshot, :id, :title, :shotengai_series_id,
:original_price, :price, :count, :title,
:product_status_zh, :order_status_zh, :product_status, :order_status, :product_status_zh, :order_status_zh, :product_status, :order_status,
:total_price, :total_original_price, :revised_amount, :total_price, :total_original_price, :revised_amount,
:spec, :cover_image, :meta, :is_in_cart :spec, :cover_image, :meta, :is_in_cart
\ No newline at end of file
...@@ -75,7 +75,7 @@ module Shotengai ...@@ -75,7 +75,7 @@ module Shotengai
def meta def meta
super || {} super || {}
end end
private private
# spec 字段 # spec 字段
def check_spec_value def check_spec_value
......
...@@ -4,6 +4,7 @@ module Shotengai ...@@ -4,6 +4,7 @@ module Shotengai
# Table name: shotengai_snapshots # Table name: shotengai_snapshots
# #
# id :integer not null, primary key # id :integer not null, primary key
# title :string(255)
# original_price :decimal(9, 2) # original_price :decimal(9, 2)
# price :decimal(9, 2) # price :decimal(9, 2)
# revised_amount :decimal(9, 2) # revised_amount :decimal(9, 2)
...@@ -71,9 +72,11 @@ module Shotengai ...@@ -71,9 +72,11 @@ module Shotengai
end end
end end
# QUESTION: spec 赋值是在 after pay 合理?
# 支付前 信息 delegate to series # 支付前 信息 delegate to series
[:original_price, :price, :spec, :banners, :cover_image, :detail].each do |column| %i{
original_price price spec banners
cover_image detail title
}.each do |column|
define_method(column) { read_attribute(column) || self.series.send(column) } define_method(column) { read_attribute(column) || self.series.send(column) }
end end
...@@ -85,6 +88,7 @@ module Shotengai ...@@ -85,6 +88,7 @@ module Shotengai
def copy_info def copy_info
# cut_stock # cut_stock
self.update!( self.update!(
title: series.title,
original_price: series.original_price, original_price: series.original_price,
price: series.price, price: series.price,
spec: series.spec, spec: series.spec,
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# Table name: shotengai_snapshots # Table name: shotengai_snapshots
# #
# id :integer not null, primary key # id :integer not null, primary key
# title :string(255)
# original_price :decimal(9, 2) # original_price :decimal(9, 2)
# price :decimal(9, 2) # price :decimal(9, 2)
# revised_amount :decimal(9, 2) # revised_amount :decimal(9, 2)
...@@ -17,7 +18,14 @@ ...@@ -17,7 +18,14 @@
# shotengai_order_id :integer # shotengai_order_id :integer
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
#
# Indexes
# #
# index_shotengai_snapshots_on_shotengai_order_id (shotengai_order_id)
# index_shotengai_snapshots_on_shotengai_series_id (shotengai_series_id)
# index_shotengai_snapshots_on_type (type)
#
FactoryGirl.define do FactoryGirl.define do
factory :test_snapshot, class: 'TestGoodSnapshot' do factory :test_snapshot, class: 'TestGoodSnapshot' do
......
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