作者 sgj
1 个管道 的构建 失败 耗费 9 秒

打卡操作

... ... @@ -24,6 +24,13 @@ class ActivityController extends AdminBaseController
$param = $this->request->param();
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
$team_id=$this->getAdminTeamId();
if (!empty($team_id)){
$where['a.team_id']=$team_id;
}
if (!empty($startTime) && !empty($endTime)) {
$where['a.create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
} else {
... ... @@ -70,6 +77,10 @@ class ActivityController extends AdminBaseController
public function news(){
$where=[];
$param = $this->request->param();
$team_id=$this->getAdminTeamId();
if (!empty($team_id)){
$where['team_id']=$team_id;
}
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
if (!empty($startTime) && !empty($endTime)) {
... ... @@ -141,6 +152,9 @@ class ActivityController extends AdminBaseController
Db::name('activity')
->where('id',$id)
->update($param);
if ($teamId>0){
$this->addTeamLog($teamId,'活动','编辑活动',$param);
}
$this->success('更新成功!');
}else{
$data=Db::name('activity')
... ... @@ -196,6 +210,9 @@ class ActivityController extends AdminBaseController
Db::name('activity_news')
->where('id',$id)
->update($param);
if ($teamId>0){
$this->addTeamLog($teamId,'活动新闻','编辑活动新闻',$param);
}
$this->success('更新成功!');
}else{
$data=Db::name('activity_news')
... ... @@ -227,6 +244,7 @@ class ActivityController extends AdminBaseController
$teamId=$this->getAdminTeamId();
if($this->request->isPost()){
$param=$this->request->param();
$param['team_id']=$teamId;
$param['create_time']=time();
$param['update_time']=time();
$param['time']=strtotime($param['time']);
... ... @@ -252,6 +270,9 @@ class ActivityController extends AdminBaseController
}
Db::name('activity')
->insert($param);
if ($teamId>0){
$this->addTeamLog($teamId,'活动','添加活动',$param);
}
$this->success('添加成功!');
}else{
$activity_type=\db('activity_type')->where('delete_time','0')->select()->toArray();
... ... @@ -275,10 +296,13 @@ class ActivityController extends AdminBaseController
}
public function addNews(){
$teamId=$this->getAdminTeamId();
if($this->request->isPost()){
$param=$this->request->param();
$param['item_id']=$this->getAdminTeamId();
$param['create_time']=time();
$param['update_time']=time();
$param['team_id']=$teamId;
$param['time']=strtotime($param['time']);
$validate = new Validate([
'activity_name' => 'require',
... ... @@ -301,6 +325,10 @@ class ActivityController extends AdminBaseController
}
Db::name('activity_news')
->insert($param);
if ($teamId>0){
$this->addTeamLog($teamId,'活动新闻','编辑新闻',$param);
}
$this->success('添加成功!');
}else{
$activity_type=\db('news_type')->select()->toArray();
... ... @@ -352,13 +380,16 @@ class ActivityController extends AdminBaseController
}
public function deleteNews(){
$param = $this->request->param();
$teamId=$this->getAdminTeamId();
if (isset($param['id'])) {
$id = $this->request->param('id', 0, 'intval');
$resultPortal = Db::name('activity_news')
->where(['id' => $id])
->update(['delete_time' => time()]);
if($resultPortal){
if ($teamId>0){
$this->addTeamLog($teamId,'活动新闻','删除新闻',$id);
}
$this->success("删除成功!", '');
}else{
$this->error("删除失败!", '');
... ... @@ -371,6 +402,9 @@ class ActivityController extends AdminBaseController
->where(['id' => ['in', $ids]])
->update(['delete_time' => time()]);
if ($result) {
if ($teamId>0){
$this->addTeamLog($teamId,'活动新闻','删除新闻',$id);
}
$this->success("删除成功!", '');
}else{
$this->error("删除失败!", '');
... ...
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/1/3
* Time: 19:46
*/
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use think\Db;
use think\Validate;
/**
* Class AdminLogController
* @package app\admin\controller
*/
class AdminLogController extends AdminBaseController
{
public function index(){
$param=$this->request->param();
$map=[];
$teamId=$this->getAdminTeamId();
if ($teamId>0){
$map['a.team_id']=$teamId;
}
$data= db('admin_log')
->alias('l')
->join('user u','u.id=l.admin_id')
->field('l.*,u.user_login')
->where($map)
->paginate();
$data->appends($param);
$list=$data->items();
$this->assign([
'data'=>$list,
'page'=>$data->render(),
]);
return $this->fetch();
}
}
\ No newline at end of file
... ...
... ... @@ -21,6 +21,21 @@ class ClockController extends AdminBaseController
public function index(){
$param=$this->request->param();
$map=[];
$teamId=$this->getAdminTeamId();
if ($teamId>0){
$map['a.team_id']=$teamId;
}
if(!isset($param['status'])){
$this->assign('status','');
}elseif($param['status']==0){
$this->assign('status',$param['status']);
$map['c.status']=$param['status'];
}else{
$map['c.status']=$param['status'];
$this->assign('status',$param['status']);
}
if(!empty($param['keyword'])){
$map['c.activity_name|c.address']=['like',"%$param[keyword]%"];
}
... ... @@ -29,6 +44,7 @@ class ClockController extends AdminBaseController
->field('v.name as user_name,v.photo,c.*')
->join('user u','u.id=c.user_id')
->join('volunteer v','v.user_id=c.user_id')
->join('activity a','a.id=c.activity_id')
->where($map)
->order('c.id desc')
->paginate();
... ... @@ -45,6 +61,7 @@ class ClockController extends AdminBaseController
public function addclock(){
$param=input();
$teamId=$this->getAdminTeamId();
$map['j.id']=$param['id'];
$data= db('join')->alias('j')
->field('v.name as user_name,v.photo,v.sex,v.birthday,v.move_phone,v.card_number as id_card,j.*,a.activity_name,a.start_time,a.long,a.lat,a.address_name')
... ... @@ -79,8 +96,12 @@ class ClockController extends AdminBaseController
*/
public function addpost(){
$update= $this->request->param();
$teamId=$this->getAdminTeamId();
$result=db('clock')->insert($update);
if ($result){
if ($teamId>0){
$this->addTeamLog($teamId,'打卡','添加打卡',$update);
}
$this->success('操作成功!');
}else{
$this->error('操作失败!');
... ... @@ -93,7 +114,7 @@ class ClockController extends AdminBaseController
*/
public function addPostMul(){
$update= $this->request->param();
$teamId=$this->getAdminTeamId();
$start_time=strtotime(input('start_date'));
$end_time=strtotime(input('end_date'));
$time=$start_time;
... ... @@ -112,6 +133,9 @@ class ClockController extends AdminBaseController
$update['user_id']=$v;
$update['date'] =$v1;
$result=db('clock')->insert($update);
if ($teamId>0){
$this->addTeamLog($teamId,'打卡','添加打卡',$update);
}
}
}
if ($result){
... ... @@ -135,6 +159,7 @@ class ClockController extends AdminBaseController
* @return mixed
*/
public function edit(){
$teamId=$this->getAdminTeamId();
$id = input('id');
$param = $this->request->param();
$map['c.id'] = $id;
... ... @@ -171,10 +196,14 @@ class ClockController extends AdminBaseController
public function editPost(){
$id = input('id');
$teamId =$this->getAdminTeamId();
$update= $this->request->param();
$update['user_start']=strtotime($update['user_start']);
$update['user_end']=strtotime($update['user_end']);
$result=db('clock')->where('id',$id)->update($update);
if ($teamId>0){
$this->addTeamLog($teamId,'打卡','编辑打卡',$update);
}
$this->success('操作成功!');
}
... ...
... ... @@ -17,6 +17,11 @@ class JoinController extends AdminBaseController
public function index(){
$param=$this->request->param();
$map=[];
$teamId=$this->getAdminTeamId();
if ($teamId>0){
$map['a.team_id']=$teamId;
}
$data= db('join')->alias('j')
->field('v.name as user_name,v.photo,j.*,a.activity_name')
->join('user u','u.id=j.user_id')
... ... @@ -25,6 +30,7 @@ class JoinController extends AdminBaseController
->where($map)
->order('j.id desc')
->paginate();
$data->appends($param);
$list=$data->items();
$this->assign([
... ... @@ -36,6 +42,7 @@ class JoinController extends AdminBaseController
public function edit(){
$id=input('id');
$map['j.id']=$id;
$data= db('join')->alias('j')
... ... @@ -46,6 +53,7 @@ class JoinController extends AdminBaseController
->where($map)
->find();
//dump($data);
$this->assign('data',$data);
return $this->fetch();
... ... @@ -53,10 +61,14 @@ class JoinController extends AdminBaseController
public function editPost(){
$teamId=$this->getAdminTeamId();
$id=input('id');
$update['status']=input('status');
$result=db('join')->where('id',$id)->update($update);
if ($result==1){
if ($teamId>0){
$this->addTeamLog($teamId,'参加活动','修改',$data);
}
$this->success('操作成功');
}else{
$this->error('操作失败');
... ... @@ -68,10 +80,14 @@ class JoinController extends AdminBaseController
*批量通过
*/
public function pass(){
$teamId=$this->getAdminTeamId();
$idArray=input('ids/a');
foreach ($idArray as $k=>$v){
$status=db('join')->where('id',$v)->value('status');
if($status ==0){
if ($teamId>0){
$this->addTeamLog($teamId,'参加活动','活动审批通过',$idArray);
}
db('join')->where('id',$v)->update(['status'=>1]);
}
}
... ...
... ... @@ -103,6 +103,7 @@ class TeamController extends AdminBaseController
public function apply_pass(){
$teamId=$this->getAdminTeamId();
$data=input();
$update['status']=$data['status'];
$info=db('team_apply')->where('id',$data['id'])->find();
... ... @@ -110,6 +111,15 @@ class TeamController extends AdminBaseController
$info=db('team_apply')->where('id',$data['id'])->update($update);
if (!empty($info)){
if ($teamId>0){
if ($data['status']==1){
$action='审核通过';
}else{
$action='审核不同过';
}
$this->addTeamLog($teamId,'团队',$action,$info);
}
$this->success('操作成功!');
}else{
$this->error('操作失败');
... ...
... ... @@ -4,6 +4,7 @@ return array (
'ADMIN_ACTIVITY_ACTIVITYTYPE' => '活动类型管理',
'ADMIN_ACTIVITY_INDEX' => '活动列表',
'ADMIN_ACTIVITY_NEWS' => '活动新闻',
'ADMIN_ADMINLOG_INDEX' => '团队管理日志',
'ADMIN_CLOCK_INDEX' => '活动打卡管理',
'ADMIN_CONTACT_INDEX' => '联系我们',
'ADMIN_GOOD_INDEX' => '商品列表',
... ...
... ... @@ -15,7 +15,6 @@
<option value='2' <if condition="$type eq 2">selected</if>>媒体报道</option>
<option value='3' <if condition="$type eq 3">selected</if>>通知公告</option>
<option value='4' <if condition="$type eq 4">selected</if>>志愿随笔</option>
</select> &nbsp;&nbsp;
<input type="submit" class="btn btn-primary" value="搜索"/>
<a class="btn btn-danger" href="{:url('news')}">清空</a>
... ...
<include file="public@header" />
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="{:url('index')}">打卡列表</a></li>
<!--<li>-->
<!--<a href="{:url('add')}">打卡添加</a>-->
<!--</li>-->
</ul>
<form class="js-ajax-form" action="" method="post">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th width="20">id</th>
<th width="50">团队名称</th>
<th width="50">管理员名称</th>
<th width="50">操作模块</th>
<th width="50">操作内容</th>
<th width="50">操作时间</th>
<!--<th width="100">操作数据</th>-->
</tr>
</thead>
<tbody>
<foreach name="data" item="vo">
<tr>
<td>{$vo.id}</td>
<td>{$vo.team_name}</td>
<td>{$vo.user_login}</td>
<td>{$vo.model}</td>
<td>{$vo.action_name}</td>
<td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
<!--<td>{$vo.data}</td>-->
</tr>
</foreach>
</tbody>
</table>
<div class="pagination">{$page}</div>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -10,7 +10,15 @@
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('index')}">
关键字:
<select class="form-control" name="status" style="width: 140px;">
<option value=''>全部</option>
<option value='0' <if condition="$status eq '0'">selected</if> >未打卡</option>
<option value='1' <if condition="$status eq '1'">selected</if> >已开始</option>
<option value='2' <if condition="$status eq '2'">selected</if>>完成打卡</option>
<option value='3' <if condition="$status eq '3'">selected</if>>未完成</option>
</select>
关键字:
<input type="text" class="form-control" name="keyword" style="width: 150px;" value="{$keyword|default=''}" placeholder="请输入关键字">
<input type="submit" class="btn btn-primary" value="搜索" />
<a class="btn btn-danger" href="{:url('index')}">清空</a>
... ...
... ... @@ -80,6 +80,24 @@ class AdminBaseController extends BaseController
/**
* 添加日志记录
* @param $team_id
* @param $model
* @param $action
* @param $postData
*/
public function addTeamLog($team_id,$model,$action,$postData){
$data['admin_id']=$this->getAdminTeamId();
$data['team_id']=$team_id;
$data['team_name']=\db('team')->where('id',$team_id)->value('name');
$data['model']=$model;
$data['action_name']=$action;
$data['data']=json_encode($postData,true);
$data['create_time']=time();
\db('admin_log')->insert($data);
}
/**
* 初始化后台菜单
*/
public function initMenu()
... ...