From 3ef8b708234bb4e6f52060967f5aacf85ef9240f Mon Sep 17 00:00:00 2001 From: xiadc <251308692@qq.com> Date: Mon, 16 Jun 2025 21:28:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(database):=20=E7=AD=BE=E5=88=B0=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- add.sql | 7 +- .../admin/controller/zy/sign/Record.php | 71 ++++++++++++++++++ .../admin/controller/zy/sign/SignSet.php | 72 +++++++++++++++++++ .../admin/lang/zh-cn/zy/sign/record.php | 10 +++ .../admin/lang/zh-cn/zy/sign/sign_set.php | 13 ++++ application/admin/model/zy/sign/Record.php | 44 ++++++++++++ application/admin/model/zy/sign/SignSet.php | 50 +++++++++++++ application/admin/validate/zy/sign/Record.php | 27 +++++++ .../admin/validate/zy/sign/SignSet.php | 27 +++++++ .../admin/view/zy/sign/record/add.html | 39 ++++++++++ .../admin/view/zy/sign/record/edit.html | 39 ++++++++++ .../admin/view/zy/sign/record/index.html | 29 ++++++++ .../admin/view/zy/sign/sign_set/add.html | 57 +++++++++++++++ .../admin/view/zy/sign/sign_set/edit.html | 57 +++++++++++++++ .../admin/view/zy/sign/sign_set/index.html | 29 ++++++++ public/assets/js/backend/zy/sign/record.js | 56 +++++++++++++++ public/assets/js/backend/zy/sign/sign_set.js | 61 ++++++++++++++++ 17 files changed, 687 insertions(+), 1 deletion(-) create mode 100644 application/admin/controller/zy/sign/Record.php create mode 100644 application/admin/controller/zy/sign/SignSet.php create mode 100644 application/admin/lang/zh-cn/zy/sign/record.php create mode 100644 application/admin/lang/zh-cn/zy/sign/sign_set.php create mode 100644 application/admin/model/zy/sign/Record.php create mode 100644 application/admin/model/zy/sign/SignSet.php create mode 100644 application/admin/validate/zy/sign/Record.php create mode 100644 application/admin/validate/zy/sign/SignSet.php create mode 100644 application/admin/view/zy/sign/record/add.html create mode 100644 application/admin/view/zy/sign/record/edit.html create mode 100644 application/admin/view/zy/sign/record/index.html create mode 100644 application/admin/view/zy/sign/sign_set/add.html create mode 100644 application/admin/view/zy/sign/sign_set/edit.html create mode 100644 application/admin/view/zy/sign/sign_set/index.html create mode 100644 public/assets/js/backend/zy/sign/record.js create mode 100644 public/assets/js/backend/zy/sign/sign_set.js diff --git a/add.sql b/add.sql index c2b2256..b33b26b 100644 --- a/add.sql +++ b/add.sql @@ -31,4 +31,9 @@ CREATE TABLE `zy_sign_set` ( PRIMARY KEY (`id`) USING BTREE, KEY `type` (`last`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='签到设置'; --- 已执行 2025-06-16 \ No newline at end of file + +ALTER TABLE `zy_sign_set` +ADD COLUMN `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态(0禁用,1启用)' AFTER `coupon2_id`; + +DROP TABLE IF EXISTS `zy_sign`; +-- 已执行 2025-06-16 diff --git a/application/admin/controller/zy/sign/Record.php b/application/admin/controller/zy/sign/Record.php new file mode 100644 index 0000000..e6b9acd --- /dev/null +++ b/application/admin/controller/zy/sign/Record.php @@ -0,0 +1,71 @@ +model = new \app\admin\model\zy\sign\Record; + + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['user']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + + $row->getRelation('user')->visible(['username']); + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/application/admin/controller/zy/sign/SignSet.php b/application/admin/controller/zy/sign/SignSet.php new file mode 100644 index 0000000..ae85d6d --- /dev/null +++ b/application/admin/controller/zy/sign/SignSet.php @@ -0,0 +1,72 @@ +model = new \app\admin\model\zy\sign\SignSet; + + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['coupon1','coupon2']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + + $row->getRelation('coupon1')->visible(['name']); + $row->getRelation('coupon2')->visible(['name']); + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/application/admin/lang/zh-cn/zy/sign/record.php b/application/admin/lang/zh-cn/zy/sign/record.php new file mode 100644 index 0000000..600347d --- /dev/null +++ b/application/admin/lang/zh-cn/zy/sign/record.php @@ -0,0 +1,10 @@ + '用户id', + 'Date' => '签到日期', + 'Last' => '已持续天数', + 'Create_time' => '创建时间', + 'Update_time' => '修改时间', + 'User.username' => '用户名' +]; diff --git a/application/admin/lang/zh-cn/zy/sign/sign_set.php b/application/admin/lang/zh-cn/zy/sign/sign_set.php new file mode 100644 index 0000000..1f8cd4f --- /dev/null +++ b/application/admin/lang/zh-cn/zy/sign/sign_set.php @@ -0,0 +1,13 @@ + '连续天数', + 'Chance1' => '概率1', + 'Coupon1_id' => '券1', + 'Chance2' => '概率2', + 'Coupon2_id' => '券2', + 'Status' => '状态(0禁用,1启用)', + 'Create_time' => '创建时间', + 'Update_time' => '修改时间', + 'Coupon.name' => '名称' +]; diff --git a/application/admin/model/zy/sign/Record.php b/application/admin/model/zy/sign/Record.php new file mode 100644 index 0000000..c24ba79 --- /dev/null +++ b/application/admin/model/zy/sign/Record.php @@ -0,0 +1,44 @@ +belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/application/admin/model/zy/sign/SignSet.php b/application/admin/model/zy/sign/SignSet.php new file mode 100644 index 0000000..95f0e1b --- /dev/null +++ b/application/admin/model/zy/sign/SignSet.php @@ -0,0 +1,50 @@ +belongsTo('app\admin\model\shopro\Coupon', 'coupon1_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + + public function coupon2() + { + return $this->belongsTo('app\admin\model\shopro\Coupon', 'coupon2_id', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/application/admin/validate/zy/sign/Record.php b/application/admin/validate/zy/sign/Record.php new file mode 100644 index 0000000..9311540 --- /dev/null +++ b/application/admin/validate/zy/sign/Record.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/validate/zy/sign/SignSet.php b/application/admin/validate/zy/sign/SignSet.php new file mode 100644 index 0000000..1e6233e --- /dev/null +++ b/application/admin/validate/zy/sign/SignSet.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/zy/sign/record/add.html b/application/admin/view/zy/sign/record/add.html new file mode 100644 index 0000000..4bf97f0 --- /dev/null +++ b/application/admin/view/zy/sign/record/add.html @@ -0,0 +1,39 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/zy/sign/record/edit.html b/application/admin/view/zy/sign/record/edit.html new file mode 100644 index 0000000..cd8ab3e --- /dev/null +++ b/application/admin/view/zy/sign/record/edit.html @@ -0,0 +1,39 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/zy/sign/record/index.html b/application/admin/view/zy/sign/record/index.html new file mode 100644 index 0000000..e16f879 --- /dev/null +++ b/application/admin/view/zy/sign/record/index.html @@ -0,0 +1,29 @@ +
+ {:build_heading()} + +
+
+
+
+
+ + + + + + + +
+ +
+
+
+ +
+
+
diff --git a/application/admin/view/zy/sign/sign_set/add.html b/application/admin/view/zy/sign/sign_set/add.html new file mode 100644 index 0000000..f83a6d4 --- /dev/null +++ b/application/admin/view/zy/sign/sign_set/add.html @@ -0,0 +1,57 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
diff --git a/application/admin/view/zy/sign/sign_set/edit.html b/application/admin/view/zy/sign/sign_set/edit.html new file mode 100644 index 0000000..43b9306 --- /dev/null +++ b/application/admin/view/zy/sign/sign_set/edit.html @@ -0,0 +1,57 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/zy/sign/sign_set/index.html b/application/admin/view/zy/sign/sign_set/index.html new file mode 100644 index 0000000..59828f2 --- /dev/null +++ b/application/admin/view/zy/sign/sign_set/index.html @@ -0,0 +1,29 @@ +
+ {:build_heading()} + +
+
+
+ +
+ +
+
+
diff --git a/public/assets/js/backend/zy/sign/record.js b/public/assets/js/backend/zy/sign/record.js new file mode 100644 index 0000000..057371a --- /dev/null +++ b/public/assets/js/backend/zy/sign/record.js @@ -0,0 +1,56 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'zy/sign/record/index' + location.search, + add_url: 'zy/sign/record/add', + edit_url: 'zy/sign/record/edit', + del_url: 'zy/sign/record/del', + multi_url: 'zy/sign/record/multi', + import_url: 'zy/sign/record/import', + table: 'zy_sign_record', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'user_id', title: __('User_id')}, + {field: 'user.username', title: __('User.username'), operate: 'LIKE'}, + {field: 'date', title: __('Date')}, + {field: 'last', title: __('Last')}, + {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, 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; +}); diff --git a/public/assets/js/backend/zy/sign/sign_set.js b/public/assets/js/backend/zy/sign/sign_set.js new file mode 100644 index 0000000..0a3bb44 --- /dev/null +++ b/public/assets/js/backend/zy/sign/sign_set.js @@ -0,0 +1,61 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'zy/sign/sign_set/index' + location.search, + add_url: 'zy/sign/sign_set/add', + edit_url: 'zy/sign/sign_set/edit', + del_url: 'zy/sign/sign_set/del', + multi_url: 'zy/sign/sign_set/multi', + import_url: 'zy/sign/sign_set/import', + table: 'zy_sign_set', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'last', title: __('Last')}, + {field: 'chance1', title: __('Chance1')}, + {field: 'coupon1.name', title: __('Coupon.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + // {field: 'coupon1_id', title: __('Coupon1_id')}, + {field: 'chance2', title: __('Chance2')}, + {field: 'coupon2.name', title: __('Coupon.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + // {field: 'coupon2_id', title: __('Coupon2_id')}, + {field: 'status', title: __('Status')}, + {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + // {field: 'coupon.id', title: __('Coupon.id')}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, 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; +});