Quellcode durchsuchen

商品增加销售部门

abiao vor 3 Jahren
Ursprung
Commit
84f2b7759a

+ 5 - 0
app/models/product.rb

@@ -9,6 +9,8 @@ class Product < ActiveRecord::Base
     belongs_to :product_sale_type, :foreign_key => :sale_zone
 
     belongs_to :merchant, :foreign_key => :merchant_id
+    has_and_belongs_to_many :depart_record
+
     validates  :product_no,:name,:buy_price,:price,:category_id,:count,:robo_balance_price,:relate_product_id, presence: true
     validate :product_validation
     validates :id, presence: true, uniqueness: true
@@ -231,6 +233,7 @@ class Product < ActiveRecord::Base
             end
             field :out_nums
             field :key_words
+            #field :depart_record
             field :created_at
             field :updated_at
         end
@@ -309,6 +312,7 @@ class Product < ActiveRecord::Base
             field :silver
             field :use_quan
             field :key_words
+            field :depart_record
             field :created_at
             field :updated_at
         end
@@ -387,6 +391,7 @@ class Product < ActiveRecord::Base
             field :key_words
             field :silver
             field :use_quan
+            field :depart_record
         end
 
     end

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

@@ -65,4 +65,5 @@ zh-CN:
         silver: 抵扣银豆金额
         use_quan: 可用提货券
         sale_zone: 专区ID
-        product_sale_type: 专区名称
+        product_sale_type: 专区名称
+        depart_record: 部门

+ 0 - 2
db/migrate/20210419114688_create_live_broad_relateds.rb

@@ -15,8 +15,6 @@ class CreateLiveBroadRelateds < ActiveRecord::Migration
 
   def down
     drop_table :depart_records_live_broads
-    drop_table :depart_records_shop_promotions
-    drop_table :depart_records_balance_promotions
   end
 
 end

+ 20 - 0
db/migrate/20220616114688_create_product_relateds.rb

@@ -0,0 +1,20 @@
+# encoding:utf-8
+class CreateProductRelateds < ActiveRecord::Migration
+  def up
+
+    create_table :depart_records_products do |t|
+      t.integer :product_id
+      t.integer :depart_record_id
+    end
+
+
+    add_index :depart_records_products,
+              [:product_id, :depart_record_id],
+              :name => "idx_product_id"
+  end
+
+  def down
+    drop_table :depart_records_products
+  end
+
+end