...
|
...
|
@@ -9,6 +9,7 @@ |
|
|
namespace app\admin\controller;
|
|
|
|
|
|
|
|
|
use app\admin\model\Excel;
|
|
|
use cmf\controller\AdminBaseController;
|
|
|
use think\Request;
|
|
|
use think\Validate;
|
...
|
...
|
@@ -24,34 +25,48 @@ class ActivityController extends AdminBaseController |
|
|
$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)) {
|
|
|
$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
$where['a.create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
} else {
|
|
|
if (!empty($startTime)) {
|
|
|
$where['create_time'] = ['>= time', $startTime];
|
|
|
$where['a.create_time'] = ['>= time', $startTime];
|
|
|
}
|
|
|
if (!empty($endTime)) {
|
|
|
$where['create_time'] = ['<= time', $endTime];
|
|
|
$where['a.create_time'] = ['<= time', $endTime];
|
|
|
}
|
|
|
}
|
|
|
$keyword = empty($param['keyword']) ? '' : $param['keyword'];
|
|
|
if (!empty($keyword)) {
|
|
|
$where['activity_name|abstract'] = ['like', "%$keyword%"];
|
|
|
$where['a.activity_name|a.abstract'] = ['like', "%$keyword%"];
|
|
|
}
|
|
|
$data=Db::name('activity')
|
|
|
->where('delete_time',0)
|
|
|
->alias('a')
|
|
|
->field('a.*,at.type_name,pc.province_name as city_name')
|
|
|
->join('activity_type at','a.activity_type=at.id','LEFT')
|
|
|
->join('position_province pc','a.position_id=pc.id','LEFT')
|
|
|
->where('a.delete_time',0)
|
|
|
->where($where)
|
|
|
->order('create_time desc')
|
|
|
->order('a.create_time desc')
|
|
|
->paginate(10);
|
|
|
$data->appends($param);
|
|
|
$list=$data->items();
|
|
|
foreach ($list as $k=>$v){
|
|
|
$join_map['status']=['in','1,3'];
|
|
|
$join_map['activity_id']=$v['id'];
|
|
|
$join_map['delete_time']=0;
|
|
|
$list[$k]['count']=\db('join')->where($join_map)->count('*');
|
|
|
}
|
|
|
$this->assign([
|
|
|
'data'=>$data,
|
|
|
'data'=>$list,
|
|
|
'page'=>$data->render(),
|
|
|
]);
|
|
|
//dump($list);
|
|
|
$this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : '');
|
|
|
$this->assign('end_time', isset($param['end_time']) ? $param['end_time'] : '');
|
|
|
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
|
|
|
public function news(){
|
|
|
$where=[];
|
|
|
$param = $this->request->param();
|
...
|
...
|
@@ -121,7 +136,7 @@ class ActivityController extends AdminBaseController |
|
|
$data=Db::name('activity')
|
|
|
->where('id',$id)
|
|
|
->find();
|
|
|
$activity_type=\db('activity_type')->select()->toArray();
|
|
|
$activity_type=\db('activity_type')->where('delete_time','0')->select()->toArray();
|
|
|
foreach ($activity_type as $k=>$v){
|
|
|
$activity[$v['id']]['type_name']=$v['type_name'];
|
|
|
$activity[$v['id']]['id']=$v['id'];
|
...
|
...
|
@@ -225,7 +240,7 @@ class ActivityController extends AdminBaseController |
|
|
->insert($param);
|
|
|
$this->success('添加成功!');
|
|
|
}else{
|
|
|
$activity_type=\db('activity_type')->select()->toArray();
|
|
|
$activity_type=\db('activity_type')->where('delete_time','0')->select()->toArray();
|
|
|
foreach ($activity_type as $k=>$v){
|
|
|
$activity[$v['id']]['type_name']=$v['type_name'];
|
|
|
$activity[$v['id']]['id']=$v['id'];
|
...
|
...
|
@@ -333,7 +348,6 @@ class ActivityController extends AdminBaseController |
|
|
}else{
|
|
|
$this->error("删除失败!", '');
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isset($param['ids'])) {
|
...
|
...
|
@@ -442,9 +456,9 @@ class ActivityController extends AdminBaseController |
|
|
|
|
|
public function join(){
|
|
|
$map['j.activity_id']=input('id');
|
|
|
$map['j.delete_time']=0;
|
|
|
//$map['j.delete_time']=0;
|
|
|
$join=\db('join')
|
|
|
->field('j.*,v.name,v.photo')
|
|
|
->field('j.*,v.name,v.photo,v.card_number')
|
|
|
->alias('j')
|
|
|
->join('volunteer v','v.user_id=j.user_id')
|
|
|
->where($map)
|
...
|
...
|
@@ -458,8 +472,8 @@ class ActivityController extends AdminBaseController |
|
|
$join[$k]['sgin_time']=date('Y-m-d H:i:s',$v['sgin_time']);
|
|
|
}
|
|
|
$join[$k]['work_content']=\db('work')->where('id',$v['work_content'])->value('name');
|
|
|
$join[$k]['select_time']=json_decode($v['select_time'],true);
|
|
|
$join[$k]['apply_stay']=json_decode($v['apply_stay'],true);
|
|
|
$join[$k]['select_time'] =json_decode($v['select_time'],true);
|
|
|
$join[$k]['apply_stay'] =json_decode($v['apply_stay'],true);
|
|
|
$join[$k]['apply_food']=json_decode($v['apply_food'],true);
|
|
|
}
|
|
|
$this->assign('data',$join);
|
...
|
...
|
@@ -512,19 +526,18 @@ class ActivityController extends AdminBaseController |
|
|
}
|
|
|
|
|
|
protected function wxappNotice($message){
|
|
|
|
|
|
$appId = 'wx7a3bf4e0796c070a';
|
|
|
$secret = '755478f064e09a8301345e0c427c6cf3';
|
|
|
$config = [
|
|
|
'app_id' => $appId,
|
|
|
'secret' => $secret,
|
|
|
];
|
|
|
try{
|
|
|
$wechat=new Application($config);
|
|
|
$notice=$wechat->mini_program->notice;
|
|
|
try{
|
|
|
$result= $notice->send($message);
|
|
|
}catch(Exception $e){
|
|
|
$e->getMessage();
|
|
|
//$e->getMessage();
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
...
|
...
|
@@ -540,6 +553,7 @@ class ActivityController extends AdminBaseController |
|
|
$this->error('参数错误!');
|
|
|
}
|
|
|
$update['status']='2';
|
|
|
$update['refund_reason']=input('refund_reason');
|
|
|
$result=\db('join')->where($map)->update($update);
|
|
|
if ($result>0){
|
|
|
|
...
|
...
|
@@ -556,7 +570,7 @@ class ActivityController extends AdminBaseController |
|
|
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]);
|
|
|
$data['keyword1']= $volunteer['name'];
|
|
|
$data['keyword2']='活动审核';
|
|
|
$data['keyword3']='未通过';
|
|
|
$data['keyword3']='未通过 原因:'.$update['refund_reason'];
|
|
|
$data['keyword4']=$activity['activity_name'];
|
|
|
$message = [
|
|
|
'touser' => $openid,
|
...
|
...
|
@@ -568,8 +582,6 @@ class ActivityController extends AdminBaseController |
|
|
];
|
|
|
$this->wxappNotice($message);
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->success('操作成功!');
|
|
|
}else{
|
|
|
$this->error('操作失败!');
|
...
|
...
|
@@ -594,28 +606,25 @@ class ActivityController extends AdminBaseController |
|
|
public function joinTimePost(){
|
|
|
$map['id']=input('id');
|
|
|
$data['work_time']=input('work_time');
|
|
|
|
|
|
$result=\db('join')->where($map)->update($data);
|
|
|
/*更新用户使用时间*/
|
|
|
$time=input('work_time');
|
|
|
$join=\db('join')->where($map)->find();
|
|
|
$user_id=$join['user_id'];
|
|
|
$all_map['user_id']=$user_id;
|
|
|
$all_result=\db('join')->where($all_map)->sum('work_time');
|
|
|
|
|
|
|
|
|
\db('volunteer')->where('user_id',$user_id)->setInc('work_time',$data['work_time']);
|
|
|
$all_result=\db('volunteer')->where('user_id',$user_id)->value('work_time');
|
|
|
$level_map['min']=['<=',$all_result];
|
|
|
$level_map['max']=['>',$all_result];
|
|
|
$level=db('level')->where($level_map)->value('level');
|
|
|
//dump($all_result);
|
|
|
//var_dump($level);
|
|
|
\db('volunteer')->where('user_id',$user_id)->update(['level'=>$level]);
|
|
|
$joinUpdate['work_time']=$time;
|
|
|
\db('join')->where($map)->update($joinUpdate);
|
|
|
if ($time>$join['work_time']){
|
|
|
$add_time=$time-$join['work_time'];
|
|
|
$volunteerUpdate['work_time']=$add_time;
|
|
|
\db('volunteer')->where('user_id',$join['user_id'])->setInc('work_time',$add_time);
|
|
|
}else{
|
|
|
$add_time=$join['work_time']-$time;
|
|
|
\db('volunteer')->where('user_id',$join['user_id'])->setDec('work_time',$add_time);
|
|
|
}
|
|
|
$result=1;
|
|
|
if ($result>0){
|
|
|
$this->success('编辑成功!');
|
|
|
$this->success('修改成功!');
|
|
|
}else{
|
|
|
$this->error('时长没有变化!');
|
|
|
$this->error('此人不是审核通过的志愿者!');
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public function userWork(){
|
...
|
...
|
@@ -631,13 +640,172 @@ class ActivityController extends AdminBaseController |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->assign('info',$info);
|
|
|
$this->assign('pic',$pic);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
public function refund(){
|
|
|
$id=input('id');
|
|
|
$this->assign('id',$id);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
public function excel(){
|
|
|
$map['j.activity_id']=input('id');
|
|
|
$activity=\db('activity')->where('id',$map['j.activity_id'])->find();
|
|
|
$map['j.status']=['in','1,3'];
|
|
|
$map['j.delete_time']=0;
|
|
|
$join=\db('join')
|
|
|
->field('j.*,v.name,v.photo,v.sex,v.card_number,v.move_phone,v.birthday')
|
|
|
->alias('j')
|
|
|
->join('volunteer v','v.user_id=j.user_id')
|
|
|
->where($map)
|
|
|
->select()
|
|
|
->toArray();
|
|
|
$work=\db('work')->select()->toArray();
|
|
|
/* dump($join);
|
|
|
exit();*/
|
|
|
//dump(get_image_path('https://volunteer.cnpu.org/upload/20190112/9bd2840928f0acee61ce6c906cda32c3.jpg'));
|
|
|
foreach ($join as $k=>$v){
|
|
|
/*dump($k);*/
|
|
|
$join[$k]['card_number']='`'.$v['card_number'];
|
|
|
if (!empty($v['add_time'])){
|
|
|
$join[$k]['add_time']=date('Y-m-d H:i:s',$v['add_time']);
|
|
|
}
|
|
|
if (!empty($v['sgin_time'])){
|
|
|
$join[$k]['sgin_time']=date('Y-m-d H:i:s',$v['sgin_time']);
|
|
|
}
|
|
|
|
|
|
$join[$k]['work_content']=\db('work')->where('id',$v['work_content'])->value('name');
|
|
|
$join[$k]['photo']=get_image_path($v['photo']);
|
|
|
|
|
|
if (!empty($v['select_time'])){
|
|
|
$select[$k]=json_decode($v['select_time'],true);
|
|
|
foreach ($select[$k] as $k1=>$v1){
|
|
|
$date[$k]['time'][$k1]=$v1['date'].' '.$v1['time'];
|
|
|
}
|
|
|
$join[$k]['select']=implode(',',$date[$k]['time']);
|
|
|
}else{
|
|
|
$join[$k]['apply_stay']='';
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!empty($v['apply_stay'])){
|
|
|
$select[$k]=json_decode($v['apply_stay'],true);
|
|
|
foreach ($select[$k] as $k1=>$v1){
|
|
|
$date[$k]['time'][$k1]=$v1['date'];
|
|
|
}
|
|
|
$join[$k]['stay']=implode(',',$date[$k]['time']);
|
|
|
}else{
|
|
|
$join[$k]['apply_stay']='';
|
|
|
}
|
|
|
|
|
|
if (!empty($v['apply_food'])){
|
|
|
$select[$k]=json_decode($v['apply_food'],true);
|
|
|
foreach ($select[$k] as $k1=>$v1){
|
|
|
$date[$k]['time'][$k1]=$v1['date'].' '.$v1['time'];
|
|
|
}
|
|
|
$join[$k]['food']=implode(',',$date[$k]['time']);
|
|
|
}else{
|
|
|
$join[$k]['apply_food']='';
|
|
|
}
|
|
|
switch ($v['status']){
|
|
|
case 0:
|
|
|
$join[$k]['status']='未审核';
|
|
|
break;
|
|
|
case 1:
|
|
|
$join[$k]['status']='已通过';
|
|
|
break;
|
|
|
case 2:
|
|
|
$join[$k]['status']='未通过';
|
|
|
break;
|
|
|
case 3:
|
|
|
$join[$k]['status']='已提交工作汇报';
|
|
|
break;
|
|
|
}
|
|
|
switch ($v['type']){
|
|
|
case 1:
|
|
|
$join[$k]['type']='线上';
|
|
|
break;
|
|
|
case 2:
|
|
|
$join[$k]['type']='线下';
|
|
|
break;
|
|
|
case 3:
|
|
|
$join[$k]['type']='线上及线下';
|
|
|
break;
|
|
|
}
|
|
|
switch ($v['sex']){
|
|
|
case 1:
|
|
|
$join[$k]['sex']='男';
|
|
|
break;
|
|
|
case 2:
|
|
|
$join[$k]['sex']='女';
|
|
|
break;
|
|
|
}
|
|
|
$join[$k]['work_content']=$work[$v['work_content']-1]['name'];
|
|
|
}
|
|
|
$title = [
|
|
|
['ID', 15, 'id', 1],
|
|
|
['姓名', 15, 'name', 1],
|
|
|
['性别', 15, 'sex', 1],
|
|
|
['出生日期', 15, 'birthday', 1],
|
|
|
['电话', 15, 'move_phone', 1],
|
|
|
['身份证号', 25, 'card_number', 1],
|
|
|
['参与方式', 15, 'type', 1],
|
|
|
['审核状态', 15, 'status', 1],
|
|
|
['工作内容', 15, 'work_content', 1],
|
|
|
['选择时间', 30, 'select', 1],
|
|
|
['申请入住', 30, 'stay', 1],
|
|
|
['申请用餐', 30, 'food', 1],
|
|
|
['工作报告', 50, 'work_report', 1],
|
|
|
['拒绝原因', 20, 'refund_reason', 1],
|
|
|
];
|
|
|
$Excel = new Excel();
|
|
|
$letter = $Excel->excelAcross(count($title));
|
|
|
|
|
|
$Excel->excel($letter, $title, $join, "$activity[activity_name]参与人员");
|
|
|
}
|
|
|
|
|
|
public function addtime(){
|
|
|
$id=input('id');
|
|
|
$user_id=input('user_id');
|
|
|
$this->assign('id',$id);
|
|
|
$this->assign('user_id',$user_id);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
|
|
|
public function addtimepost(){
|
|
|
$id=input('id');
|
|
|
$time=input('time');
|
|
|
$user_id=input('user_id');
|
|
|
$map['activity_id']=$id;
|
|
|
// $map['status']=['in','1,3'];
|
|
|
// $map['delete_time']=0;
|
|
|
// $join=\db('join')->where($map)->select();
|
|
|
// foreach ($join as $k=>$v){
|
|
|
// /*是否已经设置过时间*/
|
|
|
// if (empty($v['work_time'])){
|
|
|
// /*添加用户时间和活动时间*/
|
|
|
// \db('join')->where('id',$v['id'])->update(['work_time'=>$time]);
|
|
|
// \db('volunteer')->where('user_id',$v['user_id'])->setInc('work_time',$time);
|
|
|
// $flag=1;
|
|
|
// }
|
|
|
// }
|
|
|
$users=explode(',',$user_id);
|
|
|
foreach($users as $k=>$v){
|
|
|
\db('join')->where('id',$v)->update(['work_time'=>$time]);
|
|
|
$info= db('join')->where('id',$v)->find();
|
|
|
\db('volunteer')->where('user_id',$info['user_id'])->setInc('work_time',$time);
|
|
|
$flag=1;
|
|
|
}
|
|
|
$this->success('设置工作时长成功!');
|
|
|
/* if (isset($flag)){
|
|
|
$this->success('设置工作时长成功!');
|
|
|
}else{
|
|
|
$this->error('全部已经确定了工作时长');
|
|
|
}*/
|
|
|
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|