Bladeren bron

add balance promotion shop promotion

abiao 4 jaren geleden
bovenliggende
commit
612f407484

+ 41 - 3
app/models/balance_promotion.rb

@@ -1,6 +1,8 @@
 class BalancePromotion < ActiveRecord::Base
     has_paper_trail
     self.table_name = "balance_promotions"
+    belongs_to :depart_record, :foreign_key => :depart
+
     validates :begin_time,:end_time,:name, presence: true
     validate :product_validation
     def product_validation
@@ -55,10 +57,22 @@ class BalancePromotion < ActiveRecord::Base
       end
     end
 
+    def get_depart_enum
+      DEPART_ENUM.clear
+      if DEPART_ENUM.length ==0
+        departAttrs = DepartRecord.where("1 ").order("id desc")
+        departAttrs.each do |attr|
+            a=[attr.name,attr.id]
+            DEPART_ENUM.push(a)
+          end
+      end
+      return DEPART_ENUM
+    end
+
     
     rails_admin do 
 
-        navigation_label '系统配置'
+        navigation_label '促销管理'
         weight -100
 
         list do 
@@ -68,11 +82,20 @@ class BalancePromotion < ActiveRecord::Base
           field :begin_time
           field :end_time
           field :min_total do
-            label "充值最小金额(元)"
+            label "最小金额(元)"
+            formatted_value do # used in form views
+              value.to_f / 100
+            end
+          end
+          field :max_total do
+            label "最大金额(元)"
             formatted_value do # used in form views
               value.to_f / 100
             end
           end
+          field :is_more
+          field :depart_record
+          field :send_prodcut1
           field :send_prodcut1
           field :send_prodcut2
           field :send_prodcut3
@@ -100,11 +123,19 @@ class BalancePromotion < ActiveRecord::Base
           field :end_time
       
           field :min_total do
-            label "订单最小金额(元)"
+            label "最小金额(元)"
+            formatted_value do # used in form views
+              value.to_f / 100
+            end
+          end
+          field :max_total do
+            label "最大金额(元)"
             formatted_value do # used in form views
               value.to_f / 100
             end
           end
+          field :is_more
+          field :depart_record
           field :send_prodcut1
           field :send_prodcut2
           field :send_prodcut3
@@ -121,6 +152,13 @@ class BalancePromotion < ActiveRecord::Base
           field :begin_time
           field :end_time
           field :min_total
+          field :max_total
+          field :is_more
+          field :depart, :enum do
+            enum do
+              bindings[:object].get_depart_enum
+            end
+          end
           field :send_prod1
           field :send_nums1
           field :send_prod2

+ 1 - 1
app/models/promotion.rb

@@ -105,7 +105,7 @@ class Promotion < ActiveRecord::Base
 
     rails_admin do 
 
-        navigation_label '系统配置'
+        navigation_label '促销管理'
         weight -100
 
         list do 

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

@@ -7,7 +7,10 @@ zh-CN:
         name: 促销名称
         begin_time: 开始时间
         end_time:  结束时间
-        min_total: 充值最小金额(单位:分)
+        min_total: 最小金额(单位:分)
+        max_total: 最大金额(单位:分)
+        is_more: 多充多送
+        depart: 部门
         send_prod1: 赠品1ID
         send_nums1: 赠品1数量
         send_prod2: 赠品2ID

+ 1 - 1
config/locales/models/promotion.yml

@@ -1,7 +1,7 @@
 zh-CN:
   activerecord:
     models:
-      promotion: 促销管理
+      promotion: 订单促销配置
     attributes:
       promotion: 
         name: 促销名称

+ 91 - 0
db/migrate/20210325114688_create_recharge_promotions.rb

@@ -0,0 +1,91 @@
+# encoding:utf-8
+class CreateRechargePromotions < ActiveRecord::Migration
+  def up
+
+
+    #店长促销表
+    create_table :shop_promotions do |t|
+      # 促销名称
+      t.column :name, :string,:limit => 128
+      #开始时间
+      t.column :begin_time,:datetime
+      #结束时间
+      t.column :end_time,:datetime
+      # 部门
+      t.column :depart, :integer, :limit => 11, :default => 0
+      # 充值金额
+      t.column :total, :integer, :limit => 11, :default => 0
+      # 赠提货券
+      t.column :cash, :integer, :limit => 11, :default => 0
+      # 赠积分
+      t.column :cent, :integer, :limit => 11, :default => 0
+      # 赠品1
+      t.column :send_prod1, :integer, :limit => 11, :default => 0
+      # 数量1
+      t.column :send_nums1, :integer, :limit => 11, :default => 0
+      # 赠品2
+      t.column :send_prod2, :integer, :limit => 11, :default => 0
+      # 赠品数量2
+      t.column :send_nums2, :integer, :limit => 11, :default => 0
+      # 赠品3
+      t.column :send_prod3, :integer, :limit => 11, :default => 0
+      # 赠品数量3
+      t.column :send_nums3, :integer, :limit => 11, :default => 0
+      # 赠品4
+      t.column :send_prod4, :integer, :limit => 11, :default => 0
+      # 赠品数量4
+      t.column :send_nums4, :integer, :limit => 11, :default => 0
+      # 赠品5
+      t.column :send_prod5, :integer, :limit => 11, :default => 0
+      # 赠品数量5
+      t.column :send_nums5, :integer, :limit => 11, :default => 0
+      # 状态
+      t.column :is_enable, :boolean, :default=>1
+      t.timestamps
+    end
+
+    add_index :shop_promotions, :begin_time
+    add_index :shop_promotions, :end_time
+    add_index :shop_promotions, :min_total
+    add_index :shop_promotions, :max_total
+
+
+    #商城赠品
+    create_table :presents do |t|
+      # 微信ID
+      t.column :wx_user_id, :integer, :limit => 11, :default => 0
+      # 单价
+      t.column :price, :integer, :limit => 11, :default => 0
+      # 总价
+      t.column :total, :integer, :limit => 11, :default => 0
+      # 赠品1
+      t.column :send_prod1, :integer, :limit => 11, :default => 0
+      # 数量1
+      t.column :send_nums1, :integer, :limit => 11, :default => 0
+      # 状态
+      t.column :status, :boolean, :default=>1
+      # 订单号
+      t.column :order_id, :string, :limit => 255
+      #来源
+      t.column :source, :string, :limit => 255
+      #备注
+      t.column :remark, :string, :limit => 255
+      t.timestamps
+    end
+
+    add_index :presents, :begin_time
+    add_index :presents, :send_prod1
+
+    add_column :balance_promotions, :max_total, :integer, :default=>0,:limit => 11
+    add_column :balance_promotions, :depart, :integer, :default=>0,:limit => 11
+    add_column :balance_promotions, :is_more, :boolean, :default=>0,:limit => 11
+
+
+  end
+
+  def down
+    drop_table :shop_promotions
+    drop_table :presents
+  end
+
+end