Selaa lähdekoodia

Merge branch 'master' into feature/docker_branch

* master:
  add promotion products
  add promotion products
  add promotion products
  add promotion products

# Conflicts:
#	.gitignore
abiao 4 vuotta sitten
vanhempi
commit
2c8038ca7e

+ 2 - 0
.gitignore

@@ -9,4 +9,6 @@
 /Dockerfile
 /run_unicorn_docker.sh
 /config/version.json
+/docker-compose.yml
+./log/
 

+ 1 - 1
app/models/ability.rb

@@ -29,7 +29,7 @@ class Ability
         # can :update, :all
       else
         user.permissions.each do |permission|
-          if permission.model=="Order"
+          if permission.model=="Order111"
             D_ENUM.clear
               departs = DepartRecord.find_by_sql("select id from depart_records ")
               departs.each do |dep|

+ 57 - 0
app/models/promotion.rb

@@ -32,6 +32,25 @@ class Promotion < ActiveRecord::Base
     end
 
 
+    def prodcut4
+      prd1 = Product.where("id = ?", self.prod4).first
+      if !prd1.blank?
+        return format("%s-%d",prd1.name,self.nums4)
+      else
+        return "不存在"
+      end
+    end
+
+
+    def prodcut5
+      prd1 = Product.where("id = ?", self.prod5).first
+      if !prd1.blank?
+        return format("%s-%d",prd1.name,self.nums5)
+      else
+        return "不存在"
+      end
+    end
+
     def send_prodcut1
       prd1 = Product.where("id = ?", self.send_prod1).first
       if !prd1.blank?
@@ -60,6 +79,27 @@ class Promotion < ActiveRecord::Base
       end
     end
 
+
+
+    def send_prodcut4
+      prd1 = Product.where("id = ?", self.send_prod4).first
+      if !prd1.blank?
+        return format("%s-%d",prd1.name,self.send_nums4)
+      else
+        return "不存在"
+      end
+    end
+
+
+    def send_prodcut5
+      prd1 = Product.where("id = ?", self.send_prod5).first
+      if !prd1.blank?
+        return format("%s-%d",prd1.name,self.send_nums5)
+      else
+        return "不存在"
+      end
+    end
+
     TYPE_ENUM = [["普通",0],["秒杀",1],["店长",2]]
 
 
@@ -97,9 +137,14 @@ class Promotion < ActiveRecord::Base
           field :prodcut1
           field :prodcut2
           field :prodcut3
+          field :prodcut4
+          field :prodcut5
           field :send_prodcut1
           field :send_prodcut2
           field :send_prodcut3
+          field :send_prodcut4
+          field :send_prodcut5
+
           field :cash do
             label "代办金(元)"
             formatted_value do # used in form views
@@ -145,9 +190,13 @@ class Promotion < ActiveRecord::Base
           field :prodcut1
           field :prodcut2
           field :prodcut3
+          field :prodcut4
+          field :prodcut5
           field :send_prodcut1
           field :send_prodcut2
           field :send_prodcut3
+          field :send_prodcut4
+          field :send_prodcut5
           field :is_enable
           field :cash
           field :cent
@@ -176,12 +225,20 @@ class Promotion < ActiveRecord::Base
           field :nums2
           field :prod3
           field :nums3
+          field :prod4
+          field :nums4
+          field :prod5
+          field :nums5
           field :send_prod1
           field :send_nums1
           field :send_prod2
           field :send_nums2
           field :send_prod3
           field :send_nums3
+          field :send_prod4
+          field :send_nums4
+          field :send_prod5
+          field :send_nums5
           field :cash
           field :cent
           field :is_enable

+ 12 - 0
config/locales/models/promotion.yml

@@ -18,19 +18,31 @@ zh-CN:
         nums2: 买品2数量
         prod3: 买品3ID3
         nums3: 买品3数量
+        prod4: 买品4ID3
+        nums4: 买品4数量
+        prod5: 买品5ID3
+        nums5: 买品5数量
         send_prod1: 赠品1ID
         send_nums1: 赠品1数量
         send_prod2: 赠品2ID
         send_nums2: 赠品2数量
         send_prod3: 赠品3ID
         send_nums3: 赠品3数量
+        send_prod4: 赠品4ID
+        send_nums4: 赠品4数量
+        send_prod5: 赠品5ID
+        send_nums5: 赠品5数量
         is_enable: 是否启用
         prodcut1: 买品1
         prodcut2: 买品2
         prodcut3: 买品3
+        prodcut4: 买品4
+        prodcut5: 买品5
         send_prodcut1: 赠品1
         send_prodcut2: 赠品2
         send_prodcut3: 赠品3
+        send_prodcut4: 赠品4
+        send_prodcut5: 赠品5
         cash: 赠代办费(分)
         cent: 赠积分(分)
         created_at: 创建时间

+ 26 - 0
db/migrate/20210203114699_add_products.rb

@@ -0,0 +1,26 @@
+# This migration and CreateVersionAssociations provide the necessary
+# schema for tracking associations.
+class AddProducts < ActiveRecord::Migration
+  def up
+    add_column :promotions, :prod4, :integer
+    add_column :promotions, :nums4, :integer
+    add_column :promotions, :prod5, :integer
+    add_column :promotions, :nums5, :integer
+    add_column :promotions, :send_prod4, :integer
+    add_column :promotions, :send_nums4, :integer
+    add_column :promotions, :send_prod5, :integer
+    add_column :promotions, :send_nums5, :integer
+
+  end
+
+  def down
+    remove_column :promotions, :prod4
+    remove_column :promotions, :nums4
+    remove_column :promotions, :prod5
+    remove_column :promotions, :nums5
+    remove_column :promotions, :send_prod4
+    remove_column :promotions, :send_nums4
+    remove_column :promotions, :send_prod5
+    remove_column :promotions, :send_nums5
+  end
+end