Explorar o código

product package function develop

abiao %!s(int64=4) %!d(string=hai) anos
pai
achega
5022dcf913

+ 39 - 0
app/models/order_base_detail.rb

@@ -0,0 +1,39 @@
+# encoding:utf-8
+class OrderBaseDetail < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "order_base_details"
+  validates :order_no,:order_dt_id,:product_id, presence: true
+
+  rails_admin do
+    navigation_label '订单基本明细'
+    weight -300
+    parent Order
+    list do
+      filters [:order_no,:product_id,:order_dt_id]
+      # include_all_fields
+      field :id
+      field :order_no
+      field :product_id
+      field :title
+      field :nums
+      field :order_dt_id
+    end
+    show do
+      field :id
+      field :order_no
+      field :product_id
+      field :title
+      field :nums
+      field :order_dt_id
+    end
+
+    edit do
+      field :id
+      field :order_no
+      field :product_id
+      field :title
+      field :nums
+      field :order_dt_id
+    end
+  end
+end

+ 54 - 0
app/models/product_item.rb

@@ -0,0 +1,54 @@
+# encoding:utf-8
+class ProductItem < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "product_items"
+  validates :product_id,:item_id,:nums, presence: true
+  validate :order_validation
+  def product_validation
+    if self.product_id > 0
+      prd = Product.where("id = ?", self.product_id).first
+      if prd.blank?
+        self.errors.add(:product_id,"商品不存在,请重新填写商品ID")
+      else
+        self.title=prd.name
+      end
+    end
+
+    if self.item_id > 0
+      prd = Product.where("id = ?", self.item_id).first
+      if prd.blank?
+        self.errors.add(:item_id,"商品不存在,请填写正确的明细ID")
+      else
+        self.item_title=prd.name
+      end
+    end
+
+  end
+
+  rails_admin do
+    navigation_label '套装商品明细'
+    weight -300
+    parent Product
+    list do
+      filters [:product_id,:item_id]
+      # include_all_fields
+      field :id
+      field :product_id
+      field :item_id
+      field :nums
+    end
+    show do
+      field :id
+      field :product_id
+      field :item_id
+      field :nums
+    end
+
+    edit do
+      field :id
+      field :product_id
+      field :item_id
+      field :nums
+    end
+  end
+end

+ 14 - 0
config/locales/models/order_base_detail.yml

@@ -0,0 +1,14 @@
+zh-CN:
+  activerecord:
+    models: 
+      order_base_detail: 订单基本明细
+    attributes:
+      order_base_detail:
+        id: ID
+        product_id: 商品id
+        product: 商品
+        title: 商品名称
+        order_id: 订单ID
+        order_no: 订单编号
+        order_dt_id: 订单明细ID
+        nums: 数量

+ 13 - 0
config/locales/models/product_item.yml

@@ -0,0 +1,13 @@
+zh-CN:
+  activerecord:
+    models: 
+      product_item: 商品套装明细
+    attributes:
+      product_item:
+        id: ID
+        product_id: 商品id
+        product: 商品
+        title: 商品名称
+        item_id: 明细商品ID
+        item_title: 明细商品名称
+        nums: 数量

+ 72 - 0
db/migrate/20210220114641_create_product_commend_biaozhuns.rb

@@ -0,0 +1,72 @@
+# encoding:utf-8
+class CreateProductCommends < ActiveRecord::Migration
+  def up
+    #商品评论管理
+    create_table :product_commends do |t|
+      #微信ID
+      t.column :wx_user_id, :integer,:null=>false, :default => 0
+      #商品ID
+      t.column :product_id, :integer,:null=>false, :default => 0
+      #订单号
+      t.column :order_id, :string,:limit => 256
+      # 文字
+      t.column :detail, :string,:limit => 256
+      #评分
+      t.column :score, :integer,:null=>false, :default => 0
+      # 状态
+      t.column :is_enable, :boolean, :default=>false
+      # 是否置顶
+      t.column :is_top, :boolean, :default=>false
+      # 推荐程度
+      t.column :recommend, :integer,:null=>false, :default => 0
+      # 备注
+      t.column :remark, :string,:limit => 256
+      t.timestamps
+    end
+
+    #单牛记录表
+    create_table :d5c_project_traces do |t|
+      #项目id
+      t.column :project_id, :integer, :null => false, :default=>0
+      # 同步追溯ID
+      t.column :sync_record_id, :integer, :default=>0
+      #所在棚栏
+      t.column :location, :string, :limit => 100
+      #头图
+      t.column :img_head, :string, :limit => 255
+      #图片一
+      t.column :img_one, :string, :limit => 255
+      #图片二
+      t.column :img_two, :string, :limit => 255
+      #视频链接
+      t.column :url, :string, :limit => 200
+      #记录内容
+      t.column :about, :string, :limit => 500
+      #上件文件
+      t.column :up_file, :string, :limit => 255
+      #状态:0项目成功,1采购中,2入栏
+      t.column :state, :tinyint, :limit => 4, :default => 0
+      #用户id
+      t.column :user_id, :integer, :null => false, :default=>0
+      # 排序
+      t.column :sort, :integer, :default=>0
+      #是否显示:0否,1是
+      t.column :audit, :boolean, :default => true
+      #编辑人
+      t.column :editor, :string, :limit => 100
+      #时间戳
+      t.timestamps
+    end
+
+    add_index :product_commends, :wx_user_id
+    add_index :product_commends, :product_id
+    add_column :order_details, :commend, :boolean, :default=>false
+
+  end
+
+  def down
+  	drop_table :product_commends
+  end
+end
+
+

+ 0 - 37
db/migrate/20210220114641_create_product_commends.rb

@@ -1,37 +0,0 @@
-# encoding:utf-8
-class CreateProductCommends < ActiveRecord::Migration
-  def up
-    #商品评论管理
-    create_table :product_commends do |t|
-      #微信ID
-      t.column :wx_user_id, :integer,:null=>false, :default => 0
-      #商品ID
-      t.column :product_id, :integer,:null=>false, :default => 0
-      #订单号
-      t.column :order_id, :string,:limit => 256
-      # 文字
-      t.column :detail, :string,:limit => 256
-      #评分
-      t.column :score, :integer,:null=>false, :default => 0
-      # 状态
-      t.column :is_enable, :boolean, :default=>false
-      # 是否置顶
-      t.column :is_top, :boolean, :default=>false
-      # 推荐程度
-      t.column :recommend, :integer,:null=>false, :default => 0
-      # 备注
-      t.column :remark, :string,:limit => 256
-      t.timestamps
-    end
-    add_index :product_commends, :wx_user_id
-    add_index :product_commends, :product_id
-    add_column :order_details, :commend, :boolean, :default=>false
-
-  end
-
-  def down
-  	drop_table :product_commends
-  end
-end
-
-

+ 46 - 0
db/migrate/20210305114641_create_product_items.rb

@@ -0,0 +1,46 @@
+# encoding:utf-8
+class CreateProductItems < ActiveRecord::Migration
+  def up
+    #套装明细
+    create_table :product_items do |t|
+      # 商品id
+      t.column :product_id, :integer, :limit => 11, :default => 0
+      # 商品名称
+      t.column :title, :string, :limit => 255
+      # 明细ID
+      t.column :item_id, :integer, :limit => 11, :default => 0
+      # 明细名称
+      t.column :item_title, :string, :limit => 255
+      # 数量
+      t.column :nums, :integer, :limit => 11, :default => 0
+      t.timestamps
+    end
+
+    #订单基本明细
+    create_table :order_base_details do |t|
+      # 商品id
+      t.column :order_id, :integer, :limit => 11, :default => 0
+      # 商品名称
+      t.column :order_no, :string, :limit => 255
+      # 明细ID
+      t.column :order_dt_id, :integer, :limit => 11, :default => 0
+      # 商品ID
+      t.column :product_id, :integer, :limit => 11, :default => 0
+      # 明细名称
+      t.column :title, :string, :limit => 255
+      # 数量
+      t.column :nums, :integer, :limit => 11, :default => 0
+      t.timestamps
+    end
+    add_column :products, :package,  :boolean, :default=>0
+
+  end
+
+  def down
+  	drop_table :product_items
+    drop_table :order_base_details
+    remove_column :products, :package
+  end
+end
+
+