feat(zy): 完善签到设置功能
This commit is contained in:
7
add.sql
7
add.sql
@@ -41,3 +41,10 @@ DROP TABLE IF EXISTS `zy_sign`;
|
|||||||
|
|
||||||
ALTER TABLE `zy_sign_record`
|
ALTER TABLE `zy_sign_record`
|
||||||
ADD COLUMN `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '获得礼物备注' AFTER `last`;
|
ADD COLUMN `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '获得礼物备注' AFTER `last`;
|
||||||
|
|
||||||
|
ALTER TABLE `zy_sign_set`
|
||||||
|
ADD COLUMN `name` varchar(255) NOT NULL DEFAULT '' COMMENT '名称' AFTER `status`,
|
||||||
|
ADD COLUMN `begin_date` date NULL DEFAULT NULL COMMENT '有效期开始' AFTER `name`,
|
||||||
|
ADD COLUMN `end_date` date NULL DEFAULT NULL COMMENT '有效期结束' AFTER `begin_date`,
|
||||||
|
ADD COLUMN `intro` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '说明' AFTER `end_date`;
|
||||||
|
-- 已执行 2025-06-17
|
||||||
@@ -142,4 +142,16 @@ class Sys extends Base
|
|||||||
$res = $query->paginate($params['pageSize'] ?? 10);
|
$res = $query->paginate($params['pageSize'] ?? 10);
|
||||||
$this->success('Success', ['list' => $res->items(), 'count' => $res->total()]);
|
$this->success('Success', ['list' => $res->items(), 'count' => $res->total()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function task()
|
||||||
|
{
|
||||||
|
$record = Record::where('user_id', $this->auth->id)->where('date', date('Y-m-d'))->find();
|
||||||
|
$query = SignSet::field('name,begin_date,end_date,intro')->where('status', 1);
|
||||||
|
$res = $query->paginate($params['pageSize'] ?? 10);
|
||||||
|
$list = $res->items();
|
||||||
|
foreach ($list as &$val) {
|
||||||
|
$val['progress'] = empty($record) ? '今日未完成' : '今日已完成';
|
||||||
|
}
|
||||||
|
$this->success('Success', ['list' => $list, 'count' => $res->total()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
namespace app\admin\controller\zy\sign;
|
namespace app\admin\controller\zy\sign;
|
||||||
|
|
||||||
|
use think\Db;
|
||||||
|
use think\Exception;
|
||||||
|
use think\exception\PDOException;
|
||||||
use app\common\controller\Backend;
|
use app\common\controller\Backend;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 签到设置
|
* 签到设置
|
||||||
@@ -69,4 +73,82 @@ class SignSet extends Backend
|
|||||||
return $this->view->fetch();
|
return $this->view->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
if (false === $this->request->isPost()) {
|
||||||
|
return $this->view->fetch();
|
||||||
|
}
|
||||||
|
$params = $this->request->post('row/a');
|
||||||
|
if (empty($params)) {
|
||||||
|
$this->error(__('Parameter %s can not be empty', ''));
|
||||||
|
}
|
||||||
|
$params = $this->preExcludeFields($params);
|
||||||
|
if (empty($params['begin_date'])) $params['begin_date'] = NULL;
|
||||||
|
if (empty($params['end_date'])) $params['end_date'] = NULL;
|
||||||
|
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||||
|
$params[$this->dataLimitField] = $this->auth->id;
|
||||||
|
}
|
||||||
|
$result = false;
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
//是否采用模型验证
|
||||||
|
if ($this->modelValidate) {
|
||||||
|
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||||
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
||||||
|
$this->model->validateFailException()->validate($validate);
|
||||||
|
}
|
||||||
|
$result = $this->model->allowField(true)->save($params);
|
||||||
|
Db::commit();
|
||||||
|
} catch (ValidateException|PDOException|Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
if ($result === false) {
|
||||||
|
$this->error(__('No rows were inserted'));
|
||||||
|
}
|
||||||
|
$this->success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($ids = null)
|
||||||
|
{
|
||||||
|
$row = $this->model->get($ids);
|
||||||
|
if (!$row) {
|
||||||
|
$this->error(__('No Results were found'));
|
||||||
|
}
|
||||||
|
$adminIds = $this->getDataLimitAdminIds();
|
||||||
|
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
||||||
|
$this->error(__('You have no permission'));
|
||||||
|
}
|
||||||
|
if (false === $this->request->isPost()) {
|
||||||
|
$this->view->assign('row', $row);
|
||||||
|
return $this->view->fetch();
|
||||||
|
}
|
||||||
|
$params = $this->request->post('row/a');
|
||||||
|
if (empty($params)) {
|
||||||
|
$this->error(__('Parameter %s can not be empty', ''));
|
||||||
|
}
|
||||||
|
$params = $this->preExcludeFields($params);
|
||||||
|
if (empty($params['begin_date'])) $params['begin_date'] = NULL;
|
||||||
|
if (empty($params['end_date'])) $params['end_date'] = NULL;
|
||||||
|
$result = false;
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
//是否采用模型验证
|
||||||
|
if ($this->modelValidate) {
|
||||||
|
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||||
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
||||||
|
$row->validateFailException()->validate($validate);
|
||||||
|
}
|
||||||
|
$result = $row->allowField(true)->save($params);
|
||||||
|
Db::commit();
|
||||||
|
} catch (ValidateException|PDOException|Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
if (false === $result) {
|
||||||
|
$this->error(__('No rows were updated'));
|
||||||
|
}
|
||||||
|
$this->success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'Last' => '连续签到(a)',
|
'Last' => '连续签到(a)',
|
||||||
|
'Name' => '名称',
|
||||||
'Chance1' => '概率(b)',
|
'Chance1' => '概率(b)',
|
||||||
'Coupon1_id' => '券(c)',
|
'Coupon1_id' => '券(c)',
|
||||||
'Chance2' => '概率(d)',
|
'Chance2' => '概率(d)',
|
||||||
'Coupon2_id' => '券(e)',
|
'Coupon2_id' => '券(e)',
|
||||||
|
'BeginDate' => '有效开始日期',
|
||||||
|
'EndDate' => '有效结束日期',
|
||||||
|
'Intro' => '内容介绍',
|
||||||
'Status' => '状态',
|
'Status' => '状态',
|
||||||
'Create_time' => '创建时间',
|
'Create_time' => '创建时间',
|
||||||
'Update_time' => '修改时间',
|
'Update_time' => '修改时间',
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-2 col-sm-2">{:__('Name')}:</label>
|
||||||
|
<div class="col-xs-10 col-sm-8">
|
||||||
|
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-2 col-sm-2">{:__('Last')}:</label>
|
<label class="control-label col-xs-2 col-sm-2">{:__('Last')}:</label>
|
||||||
<div class="col-xs-10 col-sm-8">
|
<div class="col-xs-10 col-sm-8">
|
||||||
@@ -24,16 +30,29 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-2 col-sm-2">{:__('Chance2')}:</label>
|
<label class="control-label col-xs-2 col-sm-2">{:__('Chance2')}:</label>
|
||||||
<div class="col-xs-2 col-sm-2">
|
<div class="col-xs-2 col-sm-2">
|
||||||
<input id="c-chance2" data-rule="required" class="form-control" name="row[chance2]" type="number" value="0"
|
<input id="c-chance2" class="form-control" name="row[chance2]" type="number" value="0"
|
||||||
min="0" max="100">
|
min="0" max="100">
|
||||||
</div>
|
</div>
|
||||||
<label class="control-label col-xs-2 col-sm-1">{:__('Coupon2_id')}:</label>
|
<label class="control-label col-xs-2 col-sm-1">{:__('Coupon2_id')}:</label>
|
||||||
<div class="col-xs-6 col-sm-5">
|
<div class="col-xs-6 col-sm-5">
|
||||||
<input id="c-coupon2_id" data-rule="required" data-source="shopro/coupon/index"
|
<input id="c-coupon2_id" data-source="shopro/coupon/index"
|
||||||
class="form-control selectpage" name="row[coupon2_id]" type="text" value="">
|
class="form-control selectpage" name="row[coupon2_id]" type="text" value="">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-2 col-sm-2">{:__('BeginDate')}:</label>
|
||||||
|
<div class="col-xs-4 col-sm-3">
|
||||||
|
<input id="c-begin_date" class="form-control datetimepicker" data-date-format="YYYY-MM-DD"
|
||||||
|
data-use-current="true" name="row[begin_date]" type="text" value="">
|
||||||
|
</div>
|
||||||
|
<label class="control-label col-xs-2 col-sm-2">{:__('EndDate')}:</label>
|
||||||
|
<div class="col-xs-4 col-sm-3">
|
||||||
|
<input id="c-end_date" class="form-control datetimepicker" data-date-format="YYYY-MM-DD"
|
||||||
|
data-use-current="true" name="row[end_date]" type="text" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-2 col-sm-2">{:__('Status')}:</label>
|
<label class="control-label col-xs-2 col-sm-2">{:__('Status')}:</label>
|
||||||
<div class="col-xs-10 col-sm-8">
|
<div class="col-xs-10 col-sm-8">
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-2 col-sm-2">{:__('Name')}:</label>
|
||||||
|
<div class="col-xs-10 col-sm-8">
|
||||||
|
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-2 col-sm-2">{:__('Last')}:</label>
|
<label class="control-label col-xs-2 col-sm-2">{:__('Last')}:</label>
|
||||||
<div class="col-xs-10 col-sm-8">
|
<div class="col-xs-10 col-sm-8">
|
||||||
@@ -25,16 +31,29 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-2 col-sm-2">{:__('Chance2')}:</label>
|
<label class="control-label col-xs-2 col-sm-2">{:__('Chance2')}:</label>
|
||||||
<div class="col-xs-2 col-sm-2">
|
<div class="col-xs-2 col-sm-2">
|
||||||
<input id="c-chance2" data-rule="required" class="form-control" name="row[chance2]" type="number" value="{$row.chance2|htmlentities}"
|
<input id="c-chance2" class="form-control" name="row[chance2]" type="number" value="{$row.chance2|htmlentities}"
|
||||||
min="0" max="100">
|
min="0" max="100">
|
||||||
</div>
|
</div>
|
||||||
<label class="control-label col-xs-2 col-sm-1">{:__('Coupon2_id')}:</label>
|
<label class="control-label col-xs-2 col-sm-1">{:__('Coupon2_id')}:</label>
|
||||||
<div class="col-xs-6 col-sm-5">
|
<div class="col-xs-6 col-sm-5">
|
||||||
<input id="c-coupon2_id" data-rule="required" data-source="shopro/coupon/index"
|
<input id="c-coupon2_id" data-source="shopro/coupon/index"
|
||||||
class="form-control selectpage" name="row[coupon2_id]" type="text" value="{$row.coupon2_id|htmlentities}">
|
class="form-control selectpage" name="row[coupon2_id]" type="text" value="{$row.coupon2_id|htmlentities}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-2 col-sm-2">{:__('BeginDate')}:</label>
|
||||||
|
<div class="col-xs-4 col-sm-3">
|
||||||
|
<input id="c-begin_date" class="form-control datetimepicker" data-date-format="YYYY-MM-DD"
|
||||||
|
data-use-current="true" name="row[begin_date]" type="text" value="{$row.begin_date|htmlentities}">
|
||||||
|
</div>
|
||||||
|
<label class="control-label col-xs-2 col-sm-2">{:__('EndDate')}:</label>
|
||||||
|
<div class="col-xs-4 col-sm-3">
|
||||||
|
<input id="c-end_date" class="form-control datetimepicker" data-date-format="YYYY-MM-DD"
|
||||||
|
data-use-current="true" name="row[end_date]" type="text" value="{$row.end_date|htmlentities}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||||
<div class="col-xs-12 col-sm-8">
|
<div class="col-xs-12 col-sm-8">
|
||||||
|
|||||||
@@ -26,17 +26,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
[
|
[
|
||||||
{ checkbox: true },
|
{ checkbox: true },
|
||||||
{ field: 'id', title: __('Id') },
|
{ field: 'id', title: __('Id') },
|
||||||
|
{ field: 'name', title: __('Name') },
|
||||||
{ field: 'last', title: __('Last') },
|
{ field: 'last', title: __('Last') },
|
||||||
{ field: 'chance1', title: __('Chance1') },
|
{ field: 'chance1', title: __('Chance1') },
|
||||||
{ field: 'coupon1.name', title: __('Coupon1.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content },
|
{ field: 'coupon1.name', title: __('Coupon1.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content },
|
||||||
// {field: 'coupon1_id', title: __('Coupon1_id')},
|
|
||||||
{ field: 'chance2', title: __('Chance2') },
|
{ field: 'chance2', title: __('Chance2') },
|
||||||
{ field: 'coupon2.name', title: __('Coupon2.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content },
|
{ field: 'coupon2.name', title: __('Coupon2.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content },
|
||||||
// {field: 'coupon2_id', title: __('Coupon2_id')},
|
{field: 'begin_date', title: __('BeginDate')},
|
||||||
|
{field: 'end_date', title: __('EndDate')},
|
||||||
|
{field: 'intro', title: __('Intro')},
|
||||||
{ field: 'status', title: __('Status'), formatter: Table.api.formatter.label, searchList: { 0: __('Status0'), 1: __('Status1') } },
|
{ field: 'status', title: __('Status'), formatter: Table.api.formatter.label, searchList: { 0: __('Status0'), 1: __('Status1') } },
|
||||||
{ field: 'create_time', title: __('Create_time'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false },
|
{ 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: '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 }
|
{ field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate }
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user