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]
def create_snapshot
create_table :shotengai_snapshots do |t|
t.string :title
t.decimal :original_price, precision: 9, scale: 2
t.decimal :price, precision: 9, scale: 2
# 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,
:total_price, :total_original_price, :revised_amount,
: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,
:total_price, :total_original_price, :revised_amount,
:spec, :cover_image, :meta, :is_in_cart
\ No newline at end of file
......@@ -75,7 +75,7 @@ module Shotengai
def meta
super || {}
end
private
# spec 字段
def check_spec_value
......
......@@ -4,6 +4,7 @@ module Shotengai
# Table name: shotengai_snapshots
#
# id :integer not null, primary key
# title :string(255)
# original_price :decimal(9, 2)
# price :decimal(9, 2)
# revised_amount :decimal(9, 2)
......@@ -71,9 +72,11 @@ module Shotengai
end
end
# QUESTION: spec 赋值是在 after pay 合理?
# 支付前 信息 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) }
end
......@@ -85,6 +88,7 @@ module Shotengai
def copy_info
# cut_stock
self.update!(
title: series.title,
original_price: series.original_price,
price: series.price,
spec: series.spec,
......
......@@ -3,6 +3,7 @@
# Table name: shotengai_snapshots
#
# id :integer not null, primary key
# title :string(255)
# original_price :decimal(9, 2)
# price :decimal(9, 2)
# revised_amount :decimal(9, 2)
......@@ -17,7 +18,14 @@
# shotengai_order_id :integer
# created_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
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