abiao 4 роки тому
батько
коміт
dedbfe7cf6

+ 6 - 0
app/models/product.rb

@@ -278,6 +278,9 @@ class Product < ActiveRecord::Base
             field :live
             field :single_purch_limit
             field :package
+            field :product_cycle
+            field :stock_cycle
+            field :min_purchase
             field :created_at
             field :updated_at
         end
@@ -338,6 +341,9 @@ class Product < ActiveRecord::Base
             field :live
             field :single_purch_limit
             field :package
+            field :product_cycle
+            field :stock_cycle
+            field :min_purchase
         end
 
     end

+ 63 - 0
app/models/product_warn.rb

@@ -0,0 +1,63 @@
+# encoding: utf-8
+class ProductWarn < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "product_warns"
+  validates :happen_time,:product_id,:sale_90,presence: true
+
+  rails_admin do
+    navigation_label '商品管理'
+    parent Product
+    weight -500
+    list do
+      filters [:happen_time,:product_id]
+      field :id
+      field :happen_time
+      field :product_id
+      field :product_name
+      field :sale_90
+      field :sale_30
+      field :sale_10
+      field :now_count
+      field :product_cycle
+      field :stock_cycle
+      field :min_purchase
+      field :history_day_sales
+      field :recommend_count
+      field :created_at
+      # field :updated_at
+    end
+    show do
+      field :id
+      field :happen_time
+      field :product_id
+      field :product_name
+      field :sale_90
+      field :sale_30
+      field :sale_10
+      field :now_count
+      field :product_cycle
+      field :stock_cycle
+      field :min_purchase
+      field :history_day_sales
+      field :recommend_count
+      field :created_at
+      # field :updated_at
+    end
+    edit do
+      field :happen_time
+      field :product_id
+      field :product_name
+      field :sale_90
+      field :sale_30
+      field :sale_10
+      field :now_count
+      field :product_cycle
+      field :stock_cycle
+      field :min_purchase
+      field :history_day_sales
+      field :recommend_count
+    end
+
+  end
+
+end

+ 4 - 1
config/locales/models/product.yml

@@ -54,4 +54,7 @@ zh-CN:
         show_flag: 主商品标记
         live: 是否直播
         single_purch_limit: 单次限购量
-        package: 是否套装
+        package: 是否套装
+        product_cycle: 生产周期
+        stock_cycle: 备货周期
+        min_purchase: 最低进货量

+ 21 - 0
config/locales/models/product_warn.yml

@@ -0,0 +1,21 @@
+zh-CN:
+  activerecord:
+    models:
+      product_warn: 商品销售预警
+    attributes:
+      product_warn:
+        id: ID
+        happen_time: 统计时间
+        product_id: 商品ID
+        product_name: 商品名称
+        sale_90: 近90日销售
+        sale_30: 近30日销售
+        sale_10: 近10日销售
+        now_count: 现有库存数
+        product_cycle:  生产周期
+        stock_cycle: 备货周期
+        min_purchase: 最低进货量
+        history_day_sales: 历史日均销量
+        recommend_count: 建议生产数
+        created_at: 创建时间
+        updated_at: 更新时间

+ 46 - 0
db/migrate/20210415114688_create_product_warns.rb

@@ -0,0 +1,46 @@
+# encoding:utf-8
+class CreateProductWarns < ActiveRecord::Migration
+  def up
+    #商品生产预警
+    create_table :product_warns do |t|
+      # 统计时间
+      t.column :happen_time,:datetime
+      # 商品ID
+      t.column :product_id, :integer, :limit => 4, :null => false, :default => 0
+      # 商品名称
+      t.column :product_name, :string, :limit => 128,  :null => false,:default => ""
+      # 近90日销售
+      t.column :sale_90, :integer, :limit => 11, :null => false, :default => 0
+      # 近30日销售
+      t.column :sale_30, :integer, :limit => 11, :null => false, :default => 0
+      # 近10日销售
+      t.column :sale_10, :integer, :limit => 11, :null => false, :default => 0
+      # 现有库存数
+      t.column :now_count, :integer, :limit => 11, :null => false, :default => 0
+      # 生产周期
+      t.column :product_cycle, :integer, :limit => 11, :null => false, :default => 0
+      # 备货周期
+      t.column :stock_cycle, :integer, :limit => 11, :null => false, :default => 0
+      # 最低进货量
+      t.column :min_purchase, :integer, :limit => 11, :null => false, :default => 0
+      # 历史日均销量
+      t.column :history_day_sales, :integer, :limit => 11, :null => false, :default => 0
+      # 建议生产数
+      t.column :recommend_count, :integer, :limit => 11, :null => false, :default => 0
+      t.timestamps
+    end
+
+    add_column :products, :product_cycle, :integer, :limit => 11, :null => false, :default => 0
+    add_column :products, :stock_cycle, :integer, :limit => 11, :null => false, :default => 0
+    add_column :products, :min_purchase, :integer, :limit => 11, :null => false, :default => 0
+
+  end
+
+  def down
+    drop_table :product_warns
+  end
+end
+
+
+
+