135 lines
4.1 KiB
PHP
135 lines
4.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\adminapi\controller;
|
||
|
|
|
||
|
|
use app\admin\model\AdminLog;
|
||
|
|
use app\common\controller\adminApi;
|
||
|
|
use think\Config;
|
||
|
|
use think\Db;
|
||
|
|
use think\Hook;
|
||
|
|
use think\Session;
|
||
|
|
use think\Validate;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 版本管理
|
||
|
|
* @internal
|
||
|
|
*/
|
||
|
|
class Tasks extends adminApi
|
||
|
|
{
|
||
|
|
protected $noNeedLogin = [];
|
||
|
|
protected $noNeedRight = [];
|
||
|
|
protected $table = 'vs_daily_tasks';
|
||
|
|
public $task_type = [
|
||
|
|
'1' => '每日任务',
|
||
|
|
'2' => '每日特殊任务',
|
||
|
|
'3' => '平台常规任务'
|
||
|
|
];
|
||
|
|
|
||
|
|
public function _initialize()
|
||
|
|
{
|
||
|
|
parent::_initialize();
|
||
|
|
|
||
|
|
}
|
||
|
|
/*
|
||
|
|
* 任务列表
|
||
|
|
*/
|
||
|
|
public function task_list(){
|
||
|
|
$page = input('page', 1);
|
||
|
|
$page_limit = input('page_limit', 10);
|
||
|
|
$seach_task_type = input('seach_task_type', '');
|
||
|
|
$where=[];
|
||
|
|
if($seach_task_type != ''){
|
||
|
|
$where['task_type'] = $seach_task_type;
|
||
|
|
}
|
||
|
|
$list = db::name('vs_daily_tasks')->where(['delete_time'=>0])->where($where)->page($page, $page_limit)->order(['sort'=>'desc','task_id'=>'desc'])->select();
|
||
|
|
$count = db::name('vs_daily_tasks')->where(['delete_time'=>0])->where($where)->count();
|
||
|
|
$list_data = [];
|
||
|
|
foreach ($list as $k=>$v){
|
||
|
|
$list_data[$k]['task_id'] = $v['task_id'];
|
||
|
|
$list_data[$k]['icon'] = $v['icon'];
|
||
|
|
$list_data[$k]['task_name'] = $v['task_name'];
|
||
|
|
$list_data[$k]['task_description'] = $v['task_description']??"";
|
||
|
|
$list_data[$k]['gold_reward'] = $v['gold_reward'];
|
||
|
|
$list_data[$k]['target_quantity'] = $v['target_quantity'];
|
||
|
|
$list_data[$k]['task_type'] = $v['task_type'];
|
||
|
|
$list_data[$k]['task_type_str'] = $this->task_type[$v['task_type']];
|
||
|
|
$list_data[$k]['sort'] = $v['sort'];
|
||
|
|
$list_data[$k]['bag_id'] = $v['bag_id'];
|
||
|
|
$list_data[$k]['bag_name'] = $v['bag_id']?db::name('vs_gift_bag')->where(['id'=>$v['bag_id']])->value('name'):'';
|
||
|
|
$list_data[$k]['is_active'] = $v['is_active'];
|
||
|
|
}
|
||
|
|
$return_data = [
|
||
|
|
'page' =>$page,
|
||
|
|
'page_limit' => $page_limit,
|
||
|
|
'count' => $count,
|
||
|
|
'lists' => $list_data,
|
||
|
|
'task_type' => $this->task_type,
|
||
|
|
];
|
||
|
|
return V(1,"成功", $return_data);
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* 编辑
|
||
|
|
*/
|
||
|
|
public function task_edit(){
|
||
|
|
$task_id = input('task_id', '');
|
||
|
|
$task_name = input('task_name', '');
|
||
|
|
$task_type = input('task_type', '');
|
||
|
|
$task_description = input('task_description', '');
|
||
|
|
$icon = input('icon', '');
|
||
|
|
$gold_reward = input('gold_reward', '');
|
||
|
|
$target_quantity = input('target_quantity', '');
|
||
|
|
$sort = input('sort', '');
|
||
|
|
$bag_id = input('bag_id', '');
|
||
|
|
$is_active = input('is_active', '');
|
||
|
|
if($task_name != ''){
|
||
|
|
$data['task_name'] = $task_name;
|
||
|
|
}
|
||
|
|
if($task_description != ''){
|
||
|
|
$data['task_description'] = $task_description;
|
||
|
|
}
|
||
|
|
if($icon != ''){
|
||
|
|
$data['icon'] = $icon;
|
||
|
|
}
|
||
|
|
if($sort != ''){
|
||
|
|
$data['sort'] = $sort;
|
||
|
|
}
|
||
|
|
if($bag_id != ''){
|
||
|
|
$data['bag_id'] = $bag_id;
|
||
|
|
}
|
||
|
|
if($is_active != ''){
|
||
|
|
$data['is_active'] = $is_active;
|
||
|
|
}
|
||
|
|
if($task_type != ''){
|
||
|
|
$data['task_type'] = $task_type;
|
||
|
|
}
|
||
|
|
if($gold_reward != ''){
|
||
|
|
$data['gold_reward'] = $gold_reward;
|
||
|
|
}
|
||
|
|
if($target_quantity){
|
||
|
|
$data['target_quantity'] = $target_quantity;
|
||
|
|
}
|
||
|
|
$res = db::name($this->table)->where(['task_id'=>$task_id])->update($data);
|
||
|
|
if($res){
|
||
|
|
return V(1,"修改成功");
|
||
|
|
}else{
|
||
|
|
return V(0,"修改失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* 开启任务
|
||
|
|
*/
|
||
|
|
public function task_open(){
|
||
|
|
$task_id = input('task_id', '');
|
||
|
|
$is_active = input('is_active', '');
|
||
|
|
$res = db::name($this->table)->where(['task_id'=>$task_id])->update(['is_active'=>$is_active]);
|
||
|
|
if($res){
|
||
|
|
return V(1,"开启成功");
|
||
|
|
}else{
|
||
|
|
return V(0,"开启失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|