From 46b52e6ae5ba286bce8776cff1cf285e32cfa5a7 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sat, 16 Mar 2024 16:06:05 +0800 Subject: [PATCH 1/3] 1 --- addons/shopro/controller/Category.php | 14 ++++++++++++++ addons/shopro/controller/order/Order.php | 3 +++ 2 files changed, 17 insertions(+) diff --git a/addons/shopro/controller/Category.php b/addons/shopro/controller/Category.php index e581b18..1509a0f 100755 --- a/addons/shopro/controller/Category.php +++ b/addons/shopro/controller/Category.php @@ -3,6 +3,7 @@ namespace addons\shopro\controller; use app\admin\model\shopro\Category as CategoryModel; +use app\admin\model\shopro\goods\Goods; class Category extends Common { @@ -28,4 +29,17 @@ class Category extends Common $this->success('商城分类', $categories); } + + /** + * 商城列表 + * @return + */ + public function goodsList() { + $category = CategoryModel::where('parent_id', 0)->normal()->order('weigh', 'desc')->order('id', 'desc')->select(); + foreach ($category as &$item) { + $item['goods_list'] = Goods::where('category_ids', 'in', $item['id'])->show()->select(); + } + + $this->success('商城分类', $category); + } } diff --git a/addons/shopro/controller/order/Order.php b/addons/shopro/controller/order/Order.php index 3ca15ca..f48cfbb 100755 --- a/addons/shopro/controller/order/Order.php +++ b/addons/shopro/controller/order/Order.php @@ -37,6 +37,9 @@ class Order extends Common case 'nocomment': $orders = $orders->paid()->nocomment(); break; + case 'completed': + $orders = $orders->paid()->completed(); + break; } $orders = $orders->order('id', 'desc')->paginate(request()->param('list_rows', 10))->toArray(); From cc37b21349844a886013d4b99a6e13750cc1a0aa Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sat, 16 Mar 2024 16:37:09 +0800 Subject: [PATCH 2/3] 1 --- addons/shopro/controller/Category.php | 20 +++++++++++++++++--- application/common.php | 4 ++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/addons/shopro/controller/Category.php b/addons/shopro/controller/Category.php index 1509a0f..677d6e9 100755 --- a/addons/shopro/controller/Category.php +++ b/addons/shopro/controller/Category.php @@ -36,10 +36,24 @@ class Category extends Common */ public function goodsList() { $category = CategoryModel::where('parent_id', 0)->normal()->order('weigh', 'desc')->order('id', 'desc')->select(); - foreach ($category as &$item) { - $item['goods_list'] = Goods::where('category_ids', 'in', $item['id'])->show()->select(); + $category_ids = []; + foreach ($category as $item) { + $categories = CategoryModel::where('parent_id', $item['id'])->column('id'); + $category_ids = array_merge($category_ids, $categories); + } + $category = CategoryModel::where('id', 'in', $category_ids)->normal()->order('weigh', 'desc')->order('id', 'desc')->select(); + + foreach ($category as &$row) { + $row['image'] = formatImage($row['image']); + $row['goods_list'] = Goods::where('category_ids', 'in', $row['id'])->show()->select(); + foreach ($row['goods_list'] as $v) { + $v->image = formatImage($v->image); + $v->images = array_map('formatImage', $v->images); + } } - $this->success('商城分类', $category); } + + + } diff --git a/application/common.php b/application/common.php index 0259248..e1c5a84 100755 --- a/application/common.php +++ b/application/common.php @@ -560,3 +560,7 @@ EOT; return $icon; } } + + function formatImage($url) { + return request()->domain().$url; +} From ab83029544639b982bbebe6f691439c084a6b9c3 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sat, 16 Mar 2024 21:12:41 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BB=93=E5=BA=93=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Warehouse.php | 37 ++++++ application/admin/lang/zh-cn/warehouse.php | 11 ++ application/admin/model/Warehouse.php | 40 ++++++ application/admin/validate/Warehouse.php | 27 ++++ application/admin/view/warehouse/add.html | 33 +++++ application/admin/view/warehouse/edit.html | 33 +++++ application/admin/view/warehouse/index.html | 29 +++++ .../admin/view/warehouse/recyclebin.html | 25 ++++ public/assets/js/backend/warehouse.js | 116 ++++++++++++++++++ 9 files changed, 351 insertions(+) create mode 100644 application/admin/controller/Warehouse.php create mode 100644 application/admin/lang/zh-cn/warehouse.php create mode 100644 application/admin/model/Warehouse.php create mode 100644 application/admin/validate/Warehouse.php create mode 100644 application/admin/view/warehouse/add.html create mode 100644 application/admin/view/warehouse/edit.html create mode 100644 application/admin/view/warehouse/index.html create mode 100644 application/admin/view/warehouse/recyclebin.html create mode 100644 public/assets/js/backend/warehouse.js diff --git a/application/admin/controller/Warehouse.php b/application/admin/controller/Warehouse.php new file mode 100644 index 0000000..3c3d2a8 --- /dev/null +++ b/application/admin/controller/Warehouse.php @@ -0,0 +1,37 @@ +model = new \app\admin\model\Warehouse; + + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + +} diff --git a/application/admin/lang/zh-cn/warehouse.php b/application/admin/lang/zh-cn/warehouse.php new file mode 100644 index 0000000..ea1fc59 --- /dev/null +++ b/application/admin/lang/zh-cn/warehouse.php @@ -0,0 +1,11 @@ + '地址名称', + 'Linkname' => '联系人', + 'Linkphone' => '联系电话', + 'Address' => '地址', + 'Deletetime' => '删除时间', + 'Createtime' => '创建时间', + 'Updatetime' => '更新时间' +]; diff --git a/application/admin/model/Warehouse.php b/application/admin/model/Warehouse.php new file mode 100644 index 0000000..c492b64 --- /dev/null +++ b/application/admin/model/Warehouse.php @@ -0,0 +1,40 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/warehouse/add.html b/application/admin/view/warehouse/add.html new file mode 100644 index 0000000..9f0a742 --- /dev/null +++ b/application/admin/view/warehouse/add.html @@ -0,0 +1,33 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/warehouse/edit.html b/application/admin/view/warehouse/edit.html new file mode 100644 index 0000000..276dc0f --- /dev/null +++ b/application/admin/view/warehouse/edit.html @@ -0,0 +1,33 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/warehouse/index.html b/application/admin/view/warehouse/index.html new file mode 100644 index 0000000..aeab4da --- /dev/null +++ b/application/admin/view/warehouse/index.html @@ -0,0 +1,29 @@ +
+ {:build_heading()} + +
+ +
+
diff --git a/application/admin/view/warehouse/recyclebin.html b/application/admin/view/warehouse/recyclebin.html new file mode 100644 index 0000000..c38cfc4 --- /dev/null +++ b/application/admin/view/warehouse/recyclebin.html @@ -0,0 +1,25 @@ +
+ {:build_heading()} + +
+
+
+ +
+ +
+
+
diff --git a/public/assets/js/backend/warehouse.js b/public/assets/js/backend/warehouse.js new file mode 100644 index 0000000..7b9d147 --- /dev/null +++ b/public/assets/js/backend/warehouse.js @@ -0,0 +1,116 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'warehouse/index' + location.search, + add_url: 'warehouse/add', + edit_url: 'warehouse/edit', + del_url: 'warehouse/del', + multi_url: 'warehouse/multi', + import_url: 'warehouse/import', + table: 'warehouse', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'name', title: __('Name'), operate: 'LIKE'}, + {field: 'linkname', title: __('Linkname'), operate: 'LIKE'}, + {field: 'linkphone', title: __('Linkphone'), operate: 'LIKE'}, + {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + recyclebin: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + 'dragsort_url': '' + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: 'warehouse/recyclebin' + location.search, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'name', title: __('Name'), align: 'left'}, + { + field: 'deletetime', + title: __('Deletetime'), + operate: 'RANGE', + addclass: 'datetimerange', + formatter: Table.api.formatter.datetime + }, + { + field: 'operate', + width: '140px', + title: __('Operate'), + table: table, + events: Table.api.events.operate, + buttons: [ + { + name: 'Restore', + text: __('Restore'), + classname: 'btn btn-xs btn-info btn-ajax btn-restoreit', + icon: 'fa fa-rotate-left', + url: 'warehouse/restore', + refresh: true + }, + { + name: 'Destroy', + text: __('Destroy'), + classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit', + icon: 'fa fa-times', + url: 'warehouse/destroy', + refresh: true + } + ], + formatter: Table.api.formatter.operate + } + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +});