Procházet zdrojové kódy

Merge branch 'feature/#1002--import' into develop

* feature/#1002--import:
  更新物流信息
  更新物流信息
  增加导入翻译文件
  增加导入翻译文件
  增加导入翻译文件
  增加导入翻译文件
  增加导入翻译文件
  增加订单物流状态修改功能

# Conflicts:
#	config/initializers/rails_admin.rb
abiao před 5 roky
rodič
revize
f1d3ee7696

+ 49 - 0
app/models/update_order.rb

@@ -0,0 +1,49 @@
+# encoding:utf-8
+class UpdateOrder < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "update_orders"
+  after_create :update_order_express
+
+  def update_order_express
+    # 复制商品图片
+    orders = Order.find_by_sql("select * from orders where order_id = '#{self.order_id} ' limit 1")
+    # 创建商品图片
+    orders.each do |order|
+      order.express_company=self.express_company
+      order.express_order_no=self.express_order_no
+      order.save
+      self.status=1
+      self.save
+    end
+
+  end
+  rails_admin do
+    navigation_label '商品管理'
+    weight -240
+    parent Order
+    list do
+      filters [:order_id,:express_order_no]
+      # include_all_fields
+      field :id
+      field :order_id
+      field :express_order_no
+      field :express_company
+      field :status
+    end
+    show do
+      field :id
+      field :order_id
+      field :express_order_no
+      field :express_company
+      field :status
+    end
+
+    edit do
+      field :id
+      field :order_id
+      field :express_order_no
+      field :express_company
+      field :status
+    end
+  end
+end

+ 3 - 1
config/initializers/rails_admin.rb

@@ -82,7 +82,9 @@ RailsAdmin.config do |config|
       # except ['Address','WxUser', 'User','BalanceHistory', 'ProjectFollow', 'BalanceOrder', 'TakeCashOrder', 'UserBankcard', 'ProjectJoin']
     end
     export
-    #import
+    import do
+      only ["UpdateOrder"]
+    end
     history_index do
       # PAPER_TRAIL_AUDIT_MODEL
     end

+ 50 - 0
config/locales/import.cn.yml

@@ -0,0 +1,50 @@
+
+en:
+  admin:
+    actions:
+      import:
+        title: "Import"
+        menu: "Import"
+        breadcrumb: "Import"
+        link: "Import"
+        bulk_link: "Import"
+        done: "Imported"
+    import:
+      model_fields: "Model fields"
+      association_fields: "Association fields"
+
+      file: "Data file"
+      missing_file: "You must select a file"
+      format: "File format"
+      invalid_format: "Invalid import format."
+      missing_update_lookup: "Your file must contain a column for the 'Update lookup field' you selected."
+      invalid_json: "The JSON data should be an array of records or an object with a key '%{root_key}' set to an array of records"
+      update_if_exists: "Update if exists"
+      update_lookup: "Update lookup field(s)"
+      mapping: "mapping"
+      encoding: "Encoding"
+      legend:
+        fields: "Fields to import"
+        upload: "Upload file"
+        mapping: "Related fields mapping"
+      import_success:
+        create: "Created %{name}"
+        update: "Updated %{name}"
+      import_error:
+        create: "Failed to create %{name}: %{error}"
+        update: "Failed to update %{name}: %{error}"
+        general: "Error during import: %{error}"
+        line_item_limit: "Please limit upload file to %{limit} line items."
+        old_import_hook: >
+          The import hook %{model}.%{method} should take only 1 argument.
+          Data may not imported correctly.
+          See Upgrading section readme in Rails Admin Import.
+      association_not_found: "Association not found. %{error}"
+      help:
+        model_fields: "The fields above may be included in the import file."
+        association_fields: >
+          These fields map to other tables in the database, lookup via attribute selected below.
+          For "many" associations, you may include multiple columns with the same header in the CSV file.
+        update_if_exists: "Update records found with the lookup field below instead of creating new records"
+        file_limit: "Please limit upload file to %{limit} line items."
+        encoding: "Choose file encoding. Leave empty to auto-detect. Ignored for JSON."

+ 50 - 0
config/locales/import.zh-CN.yml

@@ -0,0 +1,50 @@
+
+en:
+  admin:
+    actions:
+      import:
+        title: "Import"
+        menu: "Import"
+        breadcrumb: "Import"
+        link: "Import"
+        bulk_link: "Import"
+        done: "Imported"
+    import:
+      model_fields: "Model fields"
+      association_fields: "Association fields"
+
+      file: "Data file"
+      missing_file: "You must select a file"
+      format: "File format"
+      invalid_format: "Invalid import format."
+      missing_update_lookup: "Your file must contain a column for the 'Update lookup field' you selected."
+      invalid_json: "The JSON data should be an array of records or an object with a key '%{root_key}' set to an array of records"
+      update_if_exists: "Update if exists"
+      update_lookup: "Update lookup field(s)"
+      mapping: "mapping"
+      encoding: "Encoding"
+      legend:
+        fields: "Fields to import"
+        upload: "Upload file"
+        mapping: "Related fields mapping"
+      import_success:
+        create: "Created %{name}"
+        update: "Updated %{name}"
+      import_error:
+        create: "Failed to create %{name}: %{error}"
+        update: "Failed to update %{name}: %{error}"
+        general: "Error during import: %{error}"
+        line_item_limit: "Please limit upload file to %{limit} line items."
+        old_import_hook: >
+          The import hook %{model}.%{method} should take only 1 argument.
+          Data may not imported correctly.
+          See Upgrading section readme in Rails Admin Import.
+      association_not_found: "Association not found. %{error}"
+      help:
+        model_fields: "The fields above may be included in the import file."
+        association_fields: >
+          These fields map to other tables in the database, lookup via attribute selected below.
+          For "many" associations, you may include multiple columns with the same header in the CSV file.
+        update_if_exists: "Update records found with the lookup field below instead of creating new records"
+        file_limit: "Please limit upload file to %{limit} line items."
+        encoding: "Choose file encoding. Leave empty to auto-detect. Ignored for JSON."

+ 11 - 0
config/locales/models/update_order.yml

@@ -0,0 +1,11 @@
+zh-CN:
+  activerecord:
+    models:
+      update_order: 物流状态更新
+    attributes:
+      update_order:
+        id: Id
+        order_id: 订单号
+        express_order_no: 物流单号
+        express_company: 物流公司
+        status: 状态

+ 38 - 0
config/locales/rails_admin.cn.yml

@@ -10,6 +10,44 @@ cn:
       previous: "&laquo; 上页"
       next: "下页 &raquo;"
       truncate: "…"
+    import:
+      model_fields: "Model fields"
+      association_fields: "Association fields"
+      file: "Data file"
+      missing_file: "You must select a file"
+      format: "File format"
+      invalid_format: "Invalid import format."
+      missing_update_lookup: "Your file must contain a column for the 'Update lookup field' you selected."
+      invalid_json: "The JSON data should be an array of records or an object with a key '%{root_key}' set to an array of records"
+      update_if_exists: "Update if exists"
+      update_lookup: "Update lookup field(s)"
+      mapping: "mapping"
+      encoding: "Encoding"
+      legend:
+        fields: "Fields to import"
+        upload: "Upload file"
+        mapping: "Related fields mapping"
+      import_success:
+        create: "Created %{name}"
+        update: "Updated %{name}"
+      import_error:
+        create: "Failed to create %{name}: %{error}"
+        update: "Failed to update %{name}: %{error}"
+        general: "Error during import: %{error}"
+        line_item_limit: "Please limit upload file to %{limit} line items."
+        old_import_hook: >
+          The import hook %{model}.%{method} should take only 1 argument.
+          Data may not imported correctly.
+          See Upgrading section readme in Rails Admin Import.
+      association_not_found: "Association not found. %{error}"
+      help:
+        model_fields: "The fields above may be included in the import file."
+        association_fields: >
+          These fields map to other tables in the database, lookup via attribute selected below.
+          For "many" associations, you may include multiple columns with the same header in the CSV file.
+        update_if_exists: "Update records found with the lookup field below instead of creating new records"
+        file_limit: "Please limit upload file to %{limit} line items."
+        encoding: "Choose file encoding. Leave empty to auto-detect. Ignored for JSON."
     misc:
       filter_date_format: "mm/dd/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
       search: "搜索"

+ 38 - 0
config/locales/rails_admin.zh-CN.yml

@@ -23,6 +23,44 @@ zh-CN:
       previous: "&laquo; 上一页"
       next: "下一页 &raquo;"
       truncate: "…"
+    import:
+      model_fields: "Model fields"
+      association_fields: "Association fields"
+      file: "Data file"
+      missing_file: "You must select a file"
+      format: "File format"
+      invalid_format: "Invalid import format."
+      missing_update_lookup: "Your file must contain a column for the 'Update lookup field' you selected."
+      invalid_json: "The JSON data should be an array of records or an object with a key '%{root_key}' set to an array of records"
+      update_if_exists: "Update if exists"
+      update_lookup: "Update lookup field(s)"
+      mapping: "mapping"
+      encoding: "Encoding"
+      legend:
+        fields: "Fields to import"
+        upload: "Upload file"
+        mapping: "Related fields mapping"
+      import_success:
+        create: "Created %{name}"
+        update: "Updated %{name}"
+      import_error:
+        create: "Failed to create %{name}: %{error}"
+        update: "Failed to update %{name}: %{error}"
+        general: "Error during import: %{error}"
+        line_item_limit: "Please limit upload file to %{limit} line items."
+        old_import_hook: >
+          The import hook %{model}.%{method} should take only 1 argument.
+          Data may not imported correctly.
+          See Upgrading section readme in Rails Admin Import.
+      association_not_found: "Association not found. %{error}"
+      help:
+        model_fields: "The fields above may be included in the import file."
+        association_fields: >
+          These fields map to other tables in the database, lookup via attribute selected below.
+          For "many" associations, you may include multiple columns with the same header in the CSV file.
+        update_if_exists: "Update records found with the lookup field below instead of creating new records"
+        file_limit: "Please limit upload file to %{limit} line items."
+        encoding: "Choose file encoding. Leave empty to auto-detect. Ignored for JSON."
     misc:
       filter_date_format: "mm/dd/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
       search: "搜索"

+ 21 - 0
db/migrate/20200828114641_create_update_orders.rb

@@ -0,0 +1,21 @@
+# encoding:utf-8
+class CreateUpdateOrders < ActiveRecord::Migration
+  def up
+    #更改订单物流信息表
+    create_table :update_orders do |t|
+      # 订单ID
+      t.column :order_id, :string,:limit => 256
+      # 物流编号
+      t.column :express_order_no, :string,:limit => 256
+      # 物流公司
+      t.column :express_company, :string,:limit => 256
+      # 是否处理
+      t.column :status, :boolean, :default=>1
+      t.timestamps
+    end
+  end
+
+  def down
+  	drop_table :update_orders
+  end
+end