Explorar o código

add balance promotion shop promotion

abiao %!s(int64=4) %!d(string=hai) anos
pai
achega
207d3e75eb

+ 78 - 0
app/models/present.rb

@@ -0,0 +1,78 @@
+# encoding: utf-8
+class Present < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "presents"
+  validates :code,:name,:remark,presence: true
+
+  rails_admin do
+    navigation_label '促销管理'
+    weight -500
+    list do
+      filters [:wx_user_id,:send_prod1,:source]
+      field :id
+      field :wx_user_id
+      field :price do
+        label "单价(元)"
+        formatted_value do # used in form views
+          value.to_f / 100
+        end
+      end
+      field :total do
+        label "总价(元)"
+        formatted_value do # used in form views
+          value.to_f / 100
+        end
+      end
+      field :send_prod1
+      field :send_nums1
+      field :order_id
+      field :status
+      field :source
+      field :remark
+      field :created_at
+      # field :updated_at
+    end
+
+    show do
+      field :id
+      field :wx_user_id
+      field :price do
+        label "单价(元)"
+        formatted_value do # used in form views
+          value.to_f / 100
+        end
+      end
+      field :total do
+        label "总价(元)"
+        formatted_value do # used in form views
+          value.to_f / 100
+        end
+      end
+      field :send_prod1
+      field :send_nums1
+      field :order_id
+      field :status
+      field :source
+      field :remark
+      field :created_at
+      # field :updated_at
+    end
+
+    edit do
+      field :wx_user_id
+      field :price
+      field :total
+      field :send_prod1
+      field :send_nums1
+      field :order_id
+      field :status
+      field :source
+      field :remark
+      field :remark    
+    end
+
+  end
+
+end
+
+

+ 19 - 0
config/locales/models/present.yml

@@ -0,0 +1,19 @@
+zh-CN:
+  activerecord:
+    models:
+      present: 促销赠品明细
+    attributes:
+      present:
+        id: ID
+        wx_user_id: 微信ID
+        wx_user: 微信会员
+        price: 单价
+        total: 总价
+        send_prod1: 赠品ID
+        send_nums1: 赠品数量
+        order_id: 订单号
+        status: 状态
+        source: 来源
+        remark: 备注
+        created_at: 创建时间
+        updated_at: 更新时间

+ 2 - 2
db/migrate/20210325114688_create_recharge_promotions.rb

@@ -12,7 +12,7 @@ class CreateRechargePromotions < ActiveRecord::Migration
       #结束时间
       t.column :end_time,:datetime
       # 部门
-      t.column :depart, :integer, :limit => 11, :default => 0
+      t.column :depart, :integer, :limit => 11, :null => false, :default => 0
       # 充值金额
       t.column :total, :integer, :limit => 11, :default => 0
       # 赠提货券
@@ -76,7 +76,7 @@ class CreateRechargePromotions < ActiveRecord::Migration
     add_index :presents, :order_id
 
     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, :depart, :integer, :null => false, :default=>0,:limit => 11
     add_column :balance_promotions, :is_more, :boolean, :default=>0,:limit => 11