12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\data\controller;
- use think\admin\Controller;
- use think\admin\extend\CodeExtend;
- /**
- * 活动奖品管理
- * Class LuckdrawPrize
- * @package app\data\controller
- */
- class LuckdrawPrize extends Controller
- {
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'ActivityLuckdrawPrize';
- /**
- * 活动奖品管理
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function index()
- {
- $this->title = '活动奖品管理';
- $query = $this->_query($this->table)->like('code,name');
- $query->equal('status')->dateBetween('create_at')->page();
- }
- /**
- * 添加活动奖品
- * @auth true
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function add()
- {
- $this->_form($this->table, 'form', 'code');
- }
- /**
- * 编辑活动奖品
- * @auth true
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function edit()
- {
- $this->_form($this->table, 'form', 'code');
- }
- /**
- * 表单数据处理
- * @param array $data
- */
- protected function _form_filter(array &$data)
- {
- $data['code'] = $data['code'] ?? CodeExtend::uniqidNumber(16, 'P');
- }
- /**
- * 修改奖品状态
- * @auth true
- * @throws \think\db\exception\DbException
- */
- public function state()
- {
- $this->_save($this->table, $this->_vali([
- 'status.in:0,1' => '状态值范围异常!',
- 'status.require' => '状态值不能为空!',
- ]));
- }
- /**
- * 删除活动奖品
- * @auth true
- * @throws \think\db\exception\DbException
- */
- public function remove()
- {
- $this->_delete($this->table);
- }
- }
|