Selaa lähdekoodia

fohow 订单统计功能

abiao 5 vuotta sitten
vanhempi
commit
d2d77727f0

+ 1 - 1
Rakefile

@@ -4,4 +4,4 @@
 
 require File.expand_path('../config/application', __FILE__)
 
-AdminD5ctCom::Application.load_tasks
+AdminFohowCom::Application.load_tasks

+ 56 - 0
app/models/order_static.rb

@@ -0,0 +1,56 @@
+# encoding: utf-8
+class OrderStatic < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "order_statics"
+  validates :begin_date,presence: true
+
+  STATUS_ENUM = [["未支付","unpay"],["已关闭","closed"],["待确认","unconfirmed"],["处理中","processing"],["已完成","complete"],["待收货","dispatch"],["已退款","refunded"]]
+  
+  rails_admin do
+    navigation_label '商品销售汇总'
+    weight -500
+    parent Order
+    list do
+      filters [:begin_date,:end_date, :state,:is_send]
+      field :id
+      field :begin_date
+      field :end_date
+      field :state, :enum do
+          enum do
+            STATUS_ENUM
+          end
+      end
+      field :is_send
+      field :created_at
+      field :updated_at
+    end
+
+    show do
+      field :id
+      field :begin_date
+      field :end_date
+      field :state, :enum do
+        enum do
+          STATUS_ENUM
+        end
+      end
+      field :is_send
+      field :created_at
+      field :updated_at
+    end
+
+    edit do
+      field :begin_date
+      field :end_date
+      field :state, :enum do
+        enum do
+          STATUS_ENUM
+        end
+      end
+      field :is_send
+      field :created_at
+      field :updated_at
+    end
+  end
+
+end

+ 68 - 0
app/models/order_static_detail.rb

@@ -0,0 +1,68 @@
+# encoding: utf-8
+class OrderStaticDetail < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "order_static_details"
+  validates :begin_date,presence: true
+
+  STATUS_ENUM = [["未支付","unpay"],["已关闭","closed"],["待确认","unconfirmed"],["处理中","processing"],["已完成","complete"],["待收货","dispatch"],["已退款","refunded"]]
+
+  rails_admin do
+    navigation_label '销售汇总明细'
+    weight -500
+    parent Order
+    list do
+      filters [:begin_date,:end_date, :state,:is_send]
+      field :id
+      field :begin_date
+      field :end_date
+      field :state, :enum do
+        enum do
+          STATUS_ENUM
+        end
+      end
+      field :product_id
+      field :product_name
+      field :nums
+      field :total
+      field :is_send
+      field :created_at
+      field :updated_at
+    end
+
+    show do
+      field :id
+      field :begin_date
+      field :end_date
+      field :state, :enum do
+        enum do
+          STATUS_ENUM
+        end
+      end
+      field :product_id
+      field :product_name
+      field :nums
+      field :total
+      field :is_send
+      field :created_at
+      field :updated_at
+    end
+
+    edit do
+      field :begin_date
+      field :end_date
+      field :state, :enum do
+        enum do
+          STATUS_ENUM
+        end
+      end
+      field :product_id
+      field :product_name
+      field :nums
+      field :total
+      field :is_send
+      field :created_at
+      field :updated_at
+    end
+  end
+
+end

+ 1 - 1
app/views/layouts/application.html.erb

@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
 <head>
-  <title>AdminD5ctCom</title>
+  <title>AdminFohowCom</title>
   <%= stylesheet_link_tag    "application", :media => "all" %>
   <%= javascript_include_tag "application" %>
   <%= javascript_include_tag 'ckeditor/ckeditor.js' %>

+ 1 - 1
config.ru

@@ -1,4 +1,4 @@
 # This file is used by Rack-based servers to start the application.
 
 require ::File.expand_path('../config/environment',  __FILE__)
-run AdminD5ctCom::Application
+run AdminFohowCom::Application

+ 1 - 1
config/application.rb

@@ -15,7 +15,7 @@ if defined?(Bundler)
   # Bundler.require(:default, :assets, Rails.env)
 end
 
-module AdminD5ctCom
+module AdminFohowCom
   class Application < Rails::Application
     # require 'active_record/connection_adapters/mysql2_adapter'
     # ActiveRecord::ConnectionAdapters::Mysql2Adapter.emulate_booleans = false

+ 1 - 1
config/environment.rb

@@ -3,5 +3,5 @@
 require File.expand_path('../application', __FILE__)
 
 # Initialize the rails application
-AdminD5ctCom::Application.initialize!
+AdminFohowCom::Application.initialize!
 Time::DATE_FORMATS[:format] = "%Y年%m月%d %H:%M:%S"

+ 1 - 1
config/environments/development.rb

@@ -1,4 +1,4 @@
-AdminD5ctCom::Application.configure do
+AdminFohowCom::Application.configure do
   # Settings specified here will take precedence over those in config/application.rb
 
   # In the development environment your application's code is reloaded on

+ 1 - 1
config/environments/production.rb

@@ -1,4 +1,4 @@
-AdminD5ctCom::Application.configure do
+AdminFohowCom::Application.configure do
   # Settings specified here will take precedence over those in config/application.rb
 
   # Code is not reloaded between requests

+ 1 - 1
config/environments/test.rb

@@ -1,4 +1,4 @@
-AdminD5ctCom::Application.configure do
+AdminFohowCom::Application.configure do
   # Settings specified here will take precedence over those in config/application.rb
 
   # The test environment is used exclusively to run your application's

+ 1 - 1
config/initializers/rails_admin.rb.example

@@ -7,7 +7,7 @@ RailsAdmin.config do |config|
   ################  Global configuration  ################
 
   # Set the admin name here (optional second array element will appear in red). For example:
-  config.main_app_name = ['Admin D5ct Com', 'Admin']
+  config.main_app_name = ['Admin Fohow', 'Admin']
   # or for a more dynamic name:
   # config.main_app_name = Proc.new { |controller| [Rails.application.engine_name.titleize, controller.params['action'].titleize] }
 

+ 2 - 2
config/initializers/secret_token.rb

@@ -4,5 +4,5 @@
 # If you change this key, all old signed cookies will become invalid!
 # Make sure the secret is at least 30 characters and all random,
 # no regular words or you'll be exposed to dictionary attacks.
-AdminD5ctCom::Application.config.secret_token = 'db679119f58b9e1cbb5d1700fc8b9586f2cfd6abb913ecc0a9965ecaae727a6a984996cc65865012e36e26d1d77a1324699b15f7cb092adf4bcd9212ac756912'
-AdminD5ctCom::Application.config.secret_key_base = '29013fad4844deb4d281cba61c64d1a42b98472681282031c63eecd60a7cd4d898f4689275788cf87b8baab2a38764bac436a115629258dce2bfe5e2f701ebe8'
+AdminFohowCom::Application.config.secret_token = 'db679119f58b9e1cbb5d1700fc8b9586f2cfd6abb913ecc0a9965ecaae727a6a984996cc65865012e36e26d1d77a1324699b15f7cb092adf4bcd9212ac756912'
+AdminFohowCom::Application.config.secret_key_base = '29013fad4844deb4d281cba61c64d1a42b98472681282031c63eecd60a7cd4d898f4689275788cf87b8baab2a38764bac436a115629258dce2bfe5e2f701ebe8'

+ 2 - 2
config/initializers/session_store.rb

@@ -1,8 +1,8 @@
 # Be sure to restart your server when you modify this file.
 
-AdminD5ctCom::Application.config.session_store :cookie_store, key: 'admin_d5ct_com_sid'
+AdminFohowCom::Application.config.session_store :cookie_store, key: 'admin_fohow_com_sid'
 
 # Use the database for sessions instead of the cookie-based default,
 # which shouldn't be used to store highly confidential information
 # (create the session table with "rails generate session_migration")
-# AdminD5ctCom::Application.config.session_store :active_record_store
+# AdminFohowCom::Application.config.session_store :active_record_store

+ 10 - 0
config/locales/models/order_static.yml

@@ -0,0 +1,10 @@
+zh-CN:
+  activerecord:
+    models:
+      order_static: 商品销售汇总
+    attributes:
+      order_static:
+        begin_date: 开始时间
+        end_date: 结束时间
+        state: 订单状态
+        is_send: 是否赠品

+ 15 - 0
config/locales/models/order_static_detail.yml

@@ -0,0 +1,15 @@
+zh-CN:
+  activerecord:
+    models:
+      order_static_detail: 商品销售汇总明细
+    attributes:
+      order_static_detail:
+        begin_date: 开始时间
+        end_date: 结束时间
+        state: 订单状态
+        is_send: 是否赠品
+        product_id: 商品ID
+        product_name: 商品名称
+        nums: 数量
+        total: 总金额
+        static_id: 汇总ID

+ 1 - 1
config/routes.rb

@@ -1,4 +1,4 @@
-AdminD5ctCom::Application.routes.draw do
+AdminFohowCom::Application.routes.draw do
   devise_for :admin_users
   mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'  
   mount Ckeditor::Engine => '/ckeditor'

+ 44 - 0
db/migrate/20201001114641_create_order_statics.rb

@@ -0,0 +1,44 @@
+# encoding:utf-8
+class CreateOrderStatics < ActiveRecord::Migration
+  def up
+    #创建商品销售汇总
+    create_table :order_statics do |t|
+      #开始时间
+      t.column :begin_date,:datetime
+      #结束时间
+      t.column :end_date,:datetime
+      #订单状态
+      t.column :state, :string,:limit => 256
+      # 是否赠品
+      t.column :is_send, :boolean, :default=>1
+      t.timestamps
+    end
+
+    #创建商品销售汇总明细
+    create_table :order_static_details do |t|
+      #开始时间
+      t.column :begin_date,:datetime
+      #结束时间
+      t.column :end_date,:datetime
+      #订单状态
+      t.column :state, :string,:limit => 256
+      # 是否赠品
+      t.column :is_send, :boolean, :default=>1
+      # 产品ID
+      t.column :product_id, :integer, :limit => 8, :default => 0
+      # 商品名称
+      t.column :product_name, :string,:limit => 256
+      # 数量
+      t.column :nums, :integer, :limit => 8, :default => 0
+      # 总金额
+      t.column :total, :integer, :limit => 11, :default => 0
+      t.timestamps
+    end
+  end
+
+  def down
+  	drop_table :order_statics
+    drop_table :order_static_details
+  end
+
+end