|
|
<?php
|
|
|
/**
|
|
|
* Created by PhpStorm.
|
|
|
* User: Administrator
|
|
|
* Date: 2018/12/31
|
|
|
* Time: 15:35
|
|
|
*/
|
|
|
|
|
|
namespace api\index\controller;
|
|
|
|
|
|
|
|
|
use api\index\model\AboutModel;
|
|
|
use api\index\model\ContactModel;
|
|
|
use api\index\model\JoinModel;
|
|
|
use api\index\model\VolunteerModel;
|
|
|
use api\index\model\UserModel;
|
|
|
use cmf\controller\RestBaseController;
|
|
|
use EasyWeChat\Foundation\Application;
|
|
|
use think\Validate;
|
|
|
|
|
|
/**
|
|
|
* @title 个人中心
|
|
|
* @description 个人中心
|
|
|
*/
|
|
|
class MemberCenterController extends RestBaseController
|
|
|
{
|
|
|
public function _initialize()
|
|
|
{
|
|
|
$user_id = $this->getUserId();
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->where(array('id'=>$user_id))->find();
|
|
|
if($user['user_status'] == 0){
|
|
|
$this->error(['code'=>40005,'msg'=>'您已被列入黑名单,请联系管理员!']);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* @title 个人中心
|
|
|
* @description 个人中心
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/index
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @return id:id
|
|
|
* @return user_nickname:用户昵称
|
|
|
* @return level:用户星级
|
|
|
* @return work_time:工作时长
|
|
|
* @return avatar:头像
|
|
|
* @return type:类型(1为普通,2为管理员)
|
|
|
* @return is_submit:0为未提交过,1为已提交过
|
|
|
*/
|
|
|
public function index(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断当前用户是否提交过
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0));
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if(empty($result)){
|
|
|
$is_submit = 0;
|
|
|
}else {
|
|
|
|
|
|
$is_submit = 1;
|
|
|
}
|
|
|
|
|
|
if (empty($result['level'])){
|
|
|
$result['level']=0;
|
|
|
}
|
|
|
if (empty($result['work_time'])){
|
|
|
$result['work_time']=0;
|
|
|
}
|
|
|
$user['level']=$result['level'];
|
|
|
$user['work_time']=$result['work_time'];
|
|
|
$user['is_submit'] = $is_submit;
|
|
|
$this->success('获取成功!',$user);
|
|
|
}
|
|
|
/**
|
|
|
* @title 判断是否为管理员是否提交过申请
|
|
|
* @description 判断是否为管理员是否提交过申请
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/is_submit_admin
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @return id:id
|
|
|
* @return user_nickname:用户昵称
|
|
|
* @return avatar:头像
|
|
|
* @return type:类型(1为普通,2为管理员)
|
|
|
* @return is_submit:0为未提交过,1为已提交过
|
|
|
*/
|
|
|
public function is_submit_admin(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断当前用户是否提交过
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0));
|
|
|
if(empty($result)){
|
|
|
$is_submit = 0;
|
|
|
}else{
|
|
|
$is_submit = 1;
|
|
|
}
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$is_admin = 0;
|
|
|
}else{
|
|
|
$is_admin = 1;
|
|
|
}
|
|
|
$data['is_submit'] = $is_submit;
|
|
|
$data['is_admin'] = $is_admin;
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
/**
|
|
|
* @title 提交审核
|
|
|
* @description 提交审核
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/submit_form
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:form_id type:str require:1 other: desc:表单id
|
|
|
* @param name:name type:str require:1 other: desc:姓名
|
|
|
* @param name:sex type:str require:1 other: desc:性别(1男,2女)
|
|
|
* @param name:birthday type:str require:1 other: desc:生日
|
|
|
* @param name:nation type:str require:1 other: desc:民族
|
|
|
* @param name:politics type:str require:1 other: desc:政治面貌
|
|
|
* @param name:education type:str require:1 other: desc:学历
|
|
|
* @param name:unit type:str require:1 other: desc:工作单位
|
|
|
* @param name:duty type:str require:1 other: desc:职务
|
|
|
* @param name:addr type:str require:1 other: desc:通讯地址
|
|
|
* @param name:postcode type:str require:1 other: desc:邮编
|
|
|
* @param name:school type:str require:1 other: desc:毕业院校
|
|
|
* @param name:card_number type:str require:1 other: desc:身份证号码
|
|
|
* @param name:fixed_phone type:str require:1 other: desc:固定电话
|
|
|
* @param name:move_phone type:str require:1 other: desc:移动电话
|
|
|
* @param name:email type:str require:1 other: desc:email
|
|
|
* @param name:urgency_phone type:str require:1 other: desc:紧急联系人电话
|
|
|
* @param name:qq type:str require:1 other: desc:qq
|
|
|
* @param name:province type:str require:1 other: desc:省
|
|
|
* @param name:city type:str require:1 other: desc:市
|
|
|
* @param name:county type:str require:1 other: desc:区/县
|
|
|
* @param name:address type:str require:1 other: desc:详细地址
|
|
|
* @param name:type type:int require:1 other: desc:1医院志愿者,2社会志愿者,3办事处志愿者
|
|
|
* @param name:record_start_time type:str require:1 other: desc:开始时间
|
|
|
* @param name:record_end_time type:str require:1 other: desc:结束时间
|
|
|
* @param name:record_unit type:str require:1 other: desc:单位
|
|
|
* @param name:record_duty type:str require:1 other: desc:职务
|
|
|
* @param name:record_name type:str require:1 other: desc:证明人
|
|
|
* @param name:record_phone type:str require:1 other: desc:证明人电话
|
|
|
* @param name:front_card type:str require:1 other: desc:身份证正面照
|
|
|
* @param name:reverse_card type:str require:1 other: desc:身份证背面照
|
|
|
* @param name:photo type:str require:1 other: desc:照片
|
|
|
*/
|
|
|
public function submit_form(){
|
|
|
$user_id = $this->getUserId();
|
|
|
$param = $this->request->param();
|
|
|
$validate = new Validate([
|
|
|
'name' => 'require',
|
|
|
'sex' => 'require',
|
|
|
'birthday' => 'require',
|
|
|
'nation' => 'require',
|
|
|
'politics' => 'require',
|
|
|
'education' => 'require',
|
|
|
'unit' => 'require',
|
|
|
'duty' => 'require',
|
|
|
'addr' => 'require',
|
|
|
'postcode' => 'require',
|
|
|
'school' => 'require',
|
|
|
'card_number' => 'require',
|
|
|
// 'fixed_phone' => 'require',
|
|
|
'move_phone' => 'require',
|
|
|
'email' => 'require',
|
|
|
'urgency_phone' => 'require',
|
|
|
'qq' => 'require',
|
|
|
'province' => 'require',
|
|
|
'city' => 'require',
|
|
|
// 'county' => 'require',
|
|
|
'address' => 'require',
|
|
|
'record_start_time' => 'require',
|
|
|
'record_end_time' => 'require',
|
|
|
'record_unit' => 'require',
|
|
|
'record_duty' => 'require',
|
|
|
'record_name' => 'require',
|
|
|
'record_phone' => 'require',
|
|
|
'front_card' => 'require',
|
|
|
'reverse_card' => 'require',
|
|
|
'photo' => 'require',
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'name' => '缺少参数name',
|
|
|
'sex' => '缺少参数sex',
|
|
|
'birthday' => '缺少参数birthday',
|
|
|
'nation' => '缺少参数nation',
|
|
|
'politics' => '缺少参数politics',
|
|
|
'education' => '缺少参数education',
|
|
|
'unit' => '缺少参数unit',
|
|
|
'duty' => '缺少参数duty',
|
|
|
'addr' => '缺少参数addr',
|
|
|
'postcode' => '缺少参数postcode',
|
|
|
'school' => '缺少参数school',
|
|
|
'card_number' => '缺少参数card_number',
|
|
|
// 'fixed_phone' => '缺少参数fixed_phone',
|
|
|
'move_phone' => '缺少参数move_phone',
|
|
|
'email' => '缺少参数email',
|
|
|
'urgency_phone' => '缺少参数urgency_phone',
|
|
|
'qq' => '缺少参数qq',
|
|
|
'province' => '缺少参数province',
|
|
|
'city' => '缺少参数city',
|
|
|
// 'county' => '缺少参数county',
|
|
|
'address' => '缺少参数address',
|
|
|
'record_start_time' => '缺少参数record_start_time',
|
|
|
'record_end_time' => '缺少参数record_end_time',
|
|
|
'record_unit' => '缺少参数record_unit',
|
|
|
'record_duty' => '缺少参数record_duty',
|
|
|
'record_name' => '缺少参数record_name',
|
|
|
'record_phone' => '缺少参数record_phone',
|
|
|
'front_card' => '缺少参数front_card',
|
|
|
'reverse_card' => '缺少参数reverse_card',
|
|
|
'photo' => '缺少参数photo',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$record_start_time = explode(',',$param['record_start_time']);
|
|
|
$record_end_time = explode(',',$param['record_end_time']);
|
|
|
$record_unit = explode(',',$param['record_unit']);
|
|
|
$record_duty = explode(',',$param['record_duty']);
|
|
|
$record_name = explode(',',$param['record_name']);
|
|
|
$record_phone = explode(',',$param['record_phone']);
|
|
|
$record = [];
|
|
|
foreach($record_start_time as $key => $r_s_t){
|
|
|
$record[$key]['record_start_time'] = !empty($r_s_t) ? $r_s_t : '';
|
|
|
$record[$key]['record_end_time'] = !empty($record_end_time[$key]) ? $record_end_time[$key] : '';
|
|
|
$record[$key]['record_unit'] = !empty($record_unit[$key]) ? $record_unit[$key] :'';
|
|
|
$record[$key]['record_duty'] = !empty($record_duty[$key]) ? $record_duty[$key] :'';
|
|
|
$record[$key]['record_name'] = !empty($record_name[$key]) ? $record_name[$key] :'';
|
|
|
$record[$key]['record_phone'] = !empty($record_phone[$key]) ? $record_phone[$key] :'';
|
|
|
}
|
|
|
if(!empty($record)){
|
|
|
$record = json_encode($record);
|
|
|
}else{
|
|
|
$record = null;
|
|
|
}
|
|
|
$data = [
|
|
|
'name' => $param['name'],
|
|
|
'sex' => $param['sex'],
|
|
|
'birthday' => $param['birthday'],
|
|
|
'nation' => $param['nation'],
|
|
|
'politics' => $param['politics'],
|
|
|
'education' => $param['education'],
|
|
|
'unit' => $param['unit'],
|
|
|
'duty' => $param['duty'],
|
|
|
'addr' => $param['addr'],
|
|
|
'postcode' => $param['postcode'],
|
|
|
'school' => $param['school'],
|
|
|
'card_number' => $param['card_number'],
|
|
|
'fixed_phone' => $param['fixed_phone'],
|
|
|
'move_phone' => $param['move_phone'],
|
|
|
'email' => $param['email'],
|
|
|
'urgency_phone' => $param['urgency_phone'],
|
|
|
'qq' => $param['qq'],
|
|
|
'province' => $param['province'],
|
|
|
'city' => $param['city'],
|
|
|
'county' => !empty($param['county'])?$param['county']:null,
|
|
|
'address' => $param['address'],
|
|
|
/* 'type' => $param['type'],*/
|
|
|
'record' => $record,
|
|
|
'front_card' => $param['front_card'],
|
|
|
'reverse_card' => $param['reverse_card'],
|
|
|
'photo' => $param['photo'],
|
|
|
'status' => 1,
|
|
|
'user_id' => $user_id,
|
|
|
];
|
|
|
$form_id=input('form_id');
|
|
|
if (empty($form_id)){
|
|
|
$this->saveFormId($user_id,$form_id);
|
|
|
}
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$result1 = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0));
|
|
|
//判断该用户是否提交过
|
|
|
if(!empty($result1)){
|
|
|
$data['update_time'] = time();
|
|
|
$volunteerModel->updateData(array('id'=>$result1['id']),$data);
|
|
|
}else{
|
|
|
$data['create_time'] = time();
|
|
|
$volunteerModel->insertData($data);
|
|
|
}
|
|
|
$this->success('提交成功!');
|
|
|
}
|
|
|
/**
|
|
|
* @title 进入修改页面
|
|
|
* @description 进入修改页面
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/edit
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @return name:姓名
|
|
|
* @return sex:性别(1男,2女)
|
|
|
* @return birthday:生日
|
|
|
* @return nation:民族
|
|
|
* @return politics:政治面貌
|
|
|
* @return education:学历
|
|
|
* @return unit:工作单位
|
|
|
* @return duty:职务
|
|
|
* @return addr:通讯地址
|
|
|
* @return postcode:邮编
|
|
|
* @return school: desc:毕业院校
|
|
|
* @return card_number :身份证号码
|
|
|
* @return fixed_phone:固定电话
|
|
|
* @return move_phone:移动电话
|
|
|
* @return email:email
|
|
|
* @return urgency_phone:紧急联系人电话
|
|
|
* @return qq:qq
|
|
|
* @return province:省
|
|
|
* @return city:市
|
|
|
* @return county:区/县
|
|
|
* @return address:详细地址
|
|
|
* @return type:1医院志愿者,2社会志愿者,3办事处志愿者
|
|
|
* @return record_start_time:开始时间
|
|
|
* @return record_end_time:结束时间
|
|
|
* @return record_unit:单位
|
|
|
* @return record_duty:职务
|
|
|
* @return record_name:证明人
|
|
|
* @return record_phone:证明人电话
|
|
|
* @return front_card type:str require:1 other: desc:身份证正面照
|
|
|
* @return reverse_card:身份证背面照
|
|
|
* @return photo:照片
|
|
|
*/
|
|
|
public function edit(){
|
|
|
// $user_id = $this->getUserId();
|
|
|
$user_id = $this->request->param('id');
|
|
|
//判断当前用户是否提交过
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0));
|
|
|
$this->success('获取成功!',$result);
|
|
|
}
|
|
|
/**
|
|
|
* @title 查看审核状态
|
|
|
* @description 查看审核状态
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/status
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @return id:id
|
|
|
* @return status:状态(1审核中,2审核成功,3审核失败)
|
|
|
*/
|
|
|
public function status(){
|
|
|
$user_id = $this->getUserId();
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$data = $volunteerModel->findData(array('user_id'=>$user_id));
|
|
|
if(empty($data)){
|
|
|
$this->success(['code'=>40001,'msg'=>'您还没有提交过申请!']);
|
|
|
}
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
/**
|
|
|
* @title 管理员审核
|
|
|
* @description 管理员审核
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/admin
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0)
|
|
|
* @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10)
|
|
|
*
|
|
|
* @return volunteer:志愿者@
|
|
|
* @volunteer id:id name:姓名 sex:性别 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id
|
|
|
* @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话
|
|
|
* @return page:志愿者下一页
|
|
|
* @return page:活动下一页
|
|
|
*/
|
|
|
public function admin(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
$param = $this->request->param();
|
|
|
$page = !empty($param['page']) ? $param['page'] : 0;//当前页数下标
|
|
|
$pageNum = !empty($param['pageNum']) ? $param['pageNum'] : 10;//每页显示几条数据
|
|
|
//获取志愿者
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
// $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>['in','1,2']));
|
|
|
$volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>'1'));
|
|
|
$data['volunteer'] = $volunteer;
|
|
|
$data['page'] = $page+1;
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 工时管理列表(new)
|
|
|
* @description
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/addTimeList
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0)
|
|
|
* @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10)
|
|
|
*
|
|
|
* @return volunteer:志愿者@
|
|
|
* @volunteer id:id name:姓名 sex:性别 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id
|
|
|
* @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话
|
|
|
* @return page:志愿者下一页
|
|
|
* @return page:活动下一页
|
|
|
*
|
|
|
*/
|
|
|
public function addTimeList(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
$param = $this->request->param();
|
|
|
$page = !empty($param['page']) ? $param['page'] : 0;//当前页数下标
|
|
|
$pageNum = !empty($param['pageNum']) ? $param['pageNum'] : 10;//每页显示几条数据
|
|
|
//获取志愿者
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
// $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>['in','1,2']));
|
|
|
$volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>'2'));
|
|
|
$data['volunteer'] = $volunteer;
|
|
|
$data['page'] = $page+1;
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 管理员添加时间(new)
|
|
|
* @description 管理员审核
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/addTime
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:add_time type:int require:0 other: desc:添加时间
|
|
|
* @param name:user_id type:int require:0 other: desc:用户id
|
|
|
*
|
|
|
*/
|
|
|
public function addTime(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
$map['user_id']=input('user_id');
|
|
|
$time=input('add_time');
|
|
|
// $data['add_time']=['exp','work_time'+$time];
|
|
|
$result=db('volunteer')->where($map)->setInc('work_time',$time);
|
|
|
// echo db('volunteer')->getLastSql();
|
|
|
if ($result>0){
|
|
|
$this->success('修改成功!');
|
|
|
}else{
|
|
|
$this->error('此人不是审核通过的志愿者!');
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* @title 管理员查看活动申请详情
|
|
|
* @description 管理员审核
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/adminGetApplyInfo
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:join_id type:int require:0 other: desc:报名id
|
|
|
*
|
|
|
*/
|
|
|
public function adminGetApplyInfo(){
|
|
|
$map['id']=input('join_id');
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
|
|
|
/*获取*/
|
|
|
|
|
|
if (!empty($return['time'])){
|
|
|
$return['time']= array_reverse($return['time']);
|
|
|
}
|
|
|
|
|
|
$info=db('join')->field('sgin_time,id,type,user_id,activity_id,select_time,apply_stay,apply_food,work_content')->where($map)->find();
|
|
|
$user=db('volunteer')->field('sex,name,birthday,move_phone')->where('user_id',$info['user_id'])->find();
|
|
|
if (!empty($user)){
|
|
|
$return['name']=$user['name'];
|
|
|
$return['birthday']=$user['birthday'];
|
|
|
$return['sex']=$user['sex']==1?'男':'女';
|
|
|
$return['tel']=$user['move_phone'];
|
|
|
}
|
|
|
if (!empty($info)){
|
|
|
$return['work_content']=db('work')->where('id',$info['work_content'])->value('name');
|
|
|
$return['work_content']=$info['work_content'];
|
|
|
$return['select_time']=json_decode($info['select_time'],true);
|
|
|
$return['apply_stay']=json_decode($info['apply_stay'],true);
|
|
|
$return['apply_food']=json_decode($info['apply_food'],true);
|
|
|
$return['id']=$info['id'];
|
|
|
$return['work_type']=$info['type'];
|
|
|
$return['is_complete']=$info['sgin_time']==0?'0':'1';
|
|
|
/* switch ($info['type']){
|
|
|
case 1:
|
|
|
$return['work_type']='线上';
|
|
|
break;
|
|
|
case 2:
|
|
|
$return['work_type']='线下';
|
|
|
break;
|
|
|
case 3:
|
|
|
$return['work_type']='线上及线下';
|
|
|
break;
|
|
|
|
|
|
}*/
|
|
|
}
|
|
|
|
|
|
$this->success('',$return);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 管理员更新状态
|
|
|
* @description 管理员更新状态
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/update_status
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:id type:int require:1 other: desc:志愿者id
|
|
|
* @param name:status type:int require:1 other: desc:状态(点击审核通过传2,点击审核失败传3)
|
|
|
* @param name:refund_reason type:int require:1 other: desc:审核不通过原因
|
|
|
*/
|
|
|
public function update_status(){
|
|
|
$user_id = $this->getUserId();
|
|
|
|
|
|
$id = $this->request->param('id');
|
|
|
if(empty($id)){
|
|
|
$this->error('缺少参数id');
|
|
|
}
|
|
|
$status = $this->request->param('status');
|
|
|
if(empty($status)){
|
|
|
$this->error('缺少参数status');
|
|
|
}
|
|
|
if($status != 2 && $status != 3){
|
|
|
$this->error('status参数错误!');
|
|
|
}
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
//获取志愿者
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$data['status']=input('status');
|
|
|
|
|
|
if ($data['status']==2){
|
|
|
$keyword='审核通过';
|
|
|
}else{
|
|
|
$keyword='审核未通过';
|
|
|
}
|
|
|
$data['refund_reason']=input('refund_reason')??'';
|
|
|
$result = $volunteerModel->updateData(array('id'=>$id),$data);
|
|
|
if(empty($result)){
|
|
|
$this->success(['code'=>40002,'msg'=>'当前申请可能已被其他管理员审核,请刷新页面!']);
|
|
|
}
|
|
|
$userMap['user_id']=$id;
|
|
|
$openid=db('third_party_user')->where($userMap)->value('openid');
|
|
|
$volunteer=db('volunteer')->where('id',$id)->find();
|
|
|
$formMap['user_id']=$id;
|
|
|
$formMap['use_time']=0;
|
|
|
$formMap['expire_time']=['>',time()];
|
|
|
$form_id=\db('form_id')->where($formMap)->find();
|
|
|
|
|
|
$data['keyword1']= $volunteer['name'];
|
|
|
$data['keyword2']='志愿者审核';
|
|
|
$data['keyword3']=$keyword;
|
|
|
$data['keyword4']='志愿者审核';
|
|
|
$message = [
|
|
|
'touser' => $openid,
|
|
|
'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw',
|
|
|
'page' => 'pages/index/index',
|
|
|
'form_id' => $form_id['value'],
|
|
|
'data' => $data,
|
|
|
'emphasis_keyword' =>$data['keyword3']='状态',
|
|
|
];
|
|
|
$this->wxappNotice($message);
|
|
|
$this->success(['code'=>20000,'msg'=>'更新成功!']);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 获取人员参与状态
|
|
|
* @description 管理员更新状态
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/getJoinPerson
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:id type:int require:1 other: desc:活动id
|
|
|
*
|
|
|
* @return photo:摄影(设备自带)
|
|
|
* @return camera:摄像(设备自带)
|
|
|
* @return motorcade:爱心车队
|
|
|
* @return service:现场服务(签到、指引、礼仪等)
|
|
|
* @return question:线上答疑
|
|
|
* @return ill:门诊服务
|
|
|
* @return name:status0,未审核1,已通过2,未通过3,已填写工作汇报(已通过)
|
|
|
*/
|
|
|
public function getJoinPerson(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
//活动id
|
|
|
$id=input('id');
|
|
|
$map['activity_id']=$id;
|
|
|
$map['j.delete_time']=0;
|
|
|
|
|
|
$info=db('join')->alias('j')
|
|
|
->group('j.user_id')
|
|
|
->field('v.*,j.*,j.id as join_id,j.status as status')
|
|
|
->join('volunteer v','v.user_id=j.user_id')
|
|
|
->where($map)
|
|
|
->order('j.id','desc')
|
|
|
->select()
|
|
|
->toArray();
|
|
|
|
|
|
$return=[];
|
|
|
$i0=0;
|
|
|
$i1=0;
|
|
|
$i2=0;
|
|
|
$i3=0;
|
|
|
$i4=0;
|
|
|
$i5=0;
|
|
|
|
|
|
foreach($info as $k=>$v){
|
|
|
switch ($v['work_content']){
|
|
|
case 1:
|
|
|
$return[0]['title']='摄影(设备自带)';
|
|
|
$return[0]['arr'][$i0]['id']=$v['join_id'];
|
|
|
$return[0]['arr'][$i0]['photo']=$v['photo'];
|
|
|
$return[0]['arr'][$i0]['name']=$v['name'];
|
|
|
$return[0]['arr'][$i0]['user_id']=$v['user_id'];
|
|
|
$return[0]['arr'][$i0]['status']=$this->switchStatus($v['status']);
|
|
|
$i0++;
|
|
|
break;
|
|
|
case 2:
|
|
|
$return[1]['title']='摄像(设备自带)';
|
|
|
$return[1]['arr'][$i1]['id']=$v['join_id'];
|
|
|
$return[1]['arr'][$i1]['photo']=$v['photo'];
|
|
|
$return[1]['arr'][$i1]['name']=$v['name'];
|
|
|
$return[1]['arr'][$i1]['user_id']=$v['user_id'];
|
|
|
$return[1]['arr'][$i1]['status']=$this->switchStatus($v['status']);
|
|
|
$i1++;
|
|
|
break;
|
|
|
case 3:
|
|
|
$return[2]['title']='爱心车队';
|
|
|
$return[2]['arr'][$i2]['id']=$v['join_id'];
|
|
|
$return[2]['arr'][$i2]['photo']=$v['photo'];
|
|
|
$return[2]['arr'][$i2]['name']=$v['name'];
|
|
|
$return[2]['arr'][$i2]['user_id']=$v['user_id'];
|
|
|
$return[2]['arr'][$i2]['status']=$this->switchStatus($v['status']);
|
|
|
$i2++;
|
|
|
break;
|
|
|
case 4:
|
|
|
$return[3]['title']='现场服务(签到、指引、礼仪等)';
|
|
|
$return[3]['arr'][$i3]['id']=$v['join_id'];
|
|
|
$return[3]['arr'][$i3]['photo']=$v['photo'];
|
|
|
$return[3]['arr'][$i3]['name']=$v['name'];
|
|
|
$return[3]['arr'][$i3]['user_id']=$v['user_id'];
|
|
|
$return[3]['arr'][$i3]['status']=$this->switchStatus($v['status']);
|
|
|
$i3++;
|
|
|
break;
|
|
|
case 5:
|
|
|
$return[4]['title']='线上答疑';
|
|
|
$return[4]['arr'][$i4]['id']=$v['join_id'];
|
|
|
$return[4]['arr'][$i4]['photo']=$v['photo'];
|
|
|
$return[4]['arr'][$i4]['name']=$v['name'];
|
|
|
$return[4]['arr'][$i4]['user_id']=$v['user_id'];
|
|
|
$return[4]['arr'][$i4]['status']=$this->switchStatus($v['status']);
|
|
|
$i4++;
|
|
|
break;
|
|
|
case 6:
|
|
|
$return[5]['title']='门诊服务';
|
|
|
|
|
|
/*判断是否有user_id*/
|
|
|
$return[5]['arr'][$i5]['id']=$v['join_id'];
|
|
|
$return[5]['arr'][$i5]['photo']=$v['photo'];
|
|
|
$return[5]['arr'][$i5]['name']=$v['name'];
|
|
|
$return[5]['arr'][$i5]['user_id']=$v['user_id'];
|
|
|
$return[5]['arr'][$i5]['status']=$this->switchStatus($v['status']);
|
|
|
$i5++;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
foreach ($return as $k=>$v){
|
|
|
foreach($return[$k] as $k1=>$v1){
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->success('',$return);
|
|
|
}
|
|
|
/**
|
|
|
* @title 管理员审核活动申请是否通过(new)
|
|
|
* @description 管理员更新状态
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/adminApprove
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:id type:int require:1 other: desc:参加id
|
|
|
* @param name:status type:int require:1 other: desc:1通过2.拒绝
|
|
|
* @param name:refund_reason type:int require:1 other: desc:拒绝理由
|
|
|
*
|
|
|
*
|
|
|
*/
|
|
|
public function adminApprove(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
$map['id']=input('id');
|
|
|
$data['status']=input('status');
|
|
|
$refund_reason=input('refund_reason');
|
|
|
if (!empty($refund_reason)){
|
|
|
$data['refund_reason']=input('refund_reason');
|
|
|
}
|
|
|
$result=db('join')->where($map)->update($data);
|
|
|
if ($result>0){
|
|
|
$join=\db('join')->where($map)->find();
|
|
|
$activity=\db('activity')->where('id',$join['activity_id'])->find();
|
|
|
$userMap['user_id']=$join['user_id'];
|
|
|
$openid=db('third_party_user')->where($userMap)->value('openid');
|
|
|
$volunteer=\db('volunteer')->where('user_id',$join['user_id'])->find();
|
|
|
$formMap['user_id']=$join['user_id'];
|
|
|
$formMap['use_time']=0;
|
|
|
$formMap['expire_time']=['>',time()];
|
|
|
$form_id=\db('form_id')->where($formMap)->find();
|
|
|
|
|
|
if ($data['status']==1){
|
|
|
if (!empty($form_id)){
|
|
|
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]);
|
|
|
$data['keyword1']= $volunteer['name'];
|
|
|
$data['keyword2']='活动审核';
|
|
|
$data['keyword3']='通过';
|
|
|
$data['keyword4']=$activity['activity_name'];
|
|
|
$message = [
|
|
|
'touser' => $openid,
|
|
|
'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw',
|
|
|
'page' => 'pages/index/index',
|
|
|
'form_id' => $form_id['value'],
|
|
|
'data' => $data,
|
|
|
'emphasis_keyword' =>$data['keyword3'],
|
|
|
];
|
|
|
$this->wxappNotice($message);
|
|
|
}
|
|
|
}else{
|
|
|
if (!empty($form_id)){
|
|
|
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]);
|
|
|
$data['keyword1']= $volunteer['name'];
|
|
|
$data['keyword2']='活动审核';
|
|
|
$data['keyword3']='未通过';
|
|
|
$data['keyword4']=$activity['activity_name'];
|
|
|
$message = [
|
|
|
'touser' => $openid,
|
|
|
'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw',
|
|
|
'page' => 'pages/index/index',
|
|
|
'form_id' => $form_id['value'],
|
|
|
'data' => $data,
|
|
|
'emphasis_keyword' =>$data['keyword3'],
|
|
|
];
|
|
|
$this->wxappNotice($message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->success('更新成功!');
|
|
|
}else{
|
|
|
$this->error('操作失败!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
protected function wxappNotice($message){
|
|
|
$appId = 'wx7a3bf4e0796c070a';
|
|
|
$secret = '755478f064e09a8301345e0c427c6cf3';
|
|
|
$config = [
|
|
|
'app_id' => $appId,
|
|
|
'secret' => $secret,
|
|
|
];
|
|
|
|
|
|
$wechat=new Application($config);
|
|
|
$notice=$wechat->mini_program->notice;
|
|
|
try{
|
|
|
$result= $notice->send($message);
|
|
|
}catch(Exception $e){
|
|
|
$e->getMessage();
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
|
|
|
protected function switchStatus($status){
|
|
|
switch ($status){
|
|
|
case 0:
|
|
|
return '0';
|
|
|
case 1:
|
|
|
return '1';
|
|
|
case 2:
|
|
|
return '2';
|
|
|
case 3:
|
|
|
return '3';
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* @title 关于我们
|
|
|
* @description 关于我们
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/about
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*/
|
|
|
public function about(){
|
|
|
$aboutModel = new AboutModel();
|
|
|
$data = $aboutModel->findData(array('id'=>1));
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
/**
|
|
|
* @title 联系我们
|
|
|
* @description 联系我们
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/contact
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*/
|
|
|
public function contact(){
|
|
|
$contactModel = new ContactModel();
|
|
|
$data = $contactModel->findData(array('id'=>1));
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
/**
|
|
|
* @title 我参加的活动
|
|
|
* @description 参加过的活动
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/joined
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*/
|
|
|
public function joined(){
|
|
|
$userId=$this->getUserId();
|
|
|
$Join=new JoinModel();
|
|
|
$join=$Join->getUserJoin($userId);
|
|
|
foreach ($join as $k=>$v){
|
|
|
$join[$k]['thumbnail']=cmf_get_image_url($v['thumbnail']);
|
|
|
$join[$k]['create_time']=date('Y-m-d',$v['create_time']);
|
|
|
}
|
|
|
$this->success('',$join);
|
|
|
}
|
|
|
|
|
|
protected function saveFormId($userId,$formId){
|
|
|
if ($formId=='undefined'){
|
|
|
return;
|
|
|
}
|
|
|
$data['user_id']=$userId;
|
|
|
$data['add_time']=time();
|
|
|
$data['value']=$formId;
|
|
|
$data['expire_time']=time()+604800;
|
|
|
db('form_id')->insert($data);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
/**
|
|
|
* Created by PhpStorm.
|
|
|
* User: Administrator
|
|
|
* Date: 2018/12/31
|
|
|
* Time: 15:35
|
|
|
*/
|
|
|
|
|
|
namespace api\index\controller;
|
|
|
|
|
|
|
|
|
use api\index\model\AboutModel;
|
|
|
use api\index\model\ContactModel;
|
|
|
use api\index\model\JoinModel;
|
|
|
use api\index\model\VolunteerModel;
|
|
|
use api\index\model\UserModel;
|
|
|
use cmf\controller\RestBaseController;
|
|
|
use EasyWeChat\Foundation\Application;
|
|
|
use think\Db;
|
|
|
use think\Validate;
|
|
|
|
|
|
/**
|
|
|
* @title 个人中心
|
|
|
* @description 个人中心
|
|
|
*/
|
|
|
class MemberCenterController extends RestBaseController
|
|
|
{
|
|
|
public function _initialize()
|
|
|
{
|
|
|
$user_id = $this->getUserId();
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->where(array('id'=>$user_id))->find();
|
|
|
if($user['user_status'] == 0){
|
|
|
$this->error(['code'=>40005,'msg'=>'您已被列入黑名单,请联系管理员!']);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* @title 个人中心
|
|
|
* @description 个人中心
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/index
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @return id:id
|
|
|
* @return user_nickname:用户昵称
|
|
|
* @return level:用户星级
|
|
|
* @return work_time:工作时长
|
|
|
* @return avatar:头像
|
|
|
* @return type:类型(1为普通,2为管理员)
|
|
|
* @return is_submit:0为未提交过,1为已提交过
|
|
|
*/
|
|
|
public function index(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断当前用户是否提交过
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0));
|
|
|
// dump($result->toArray());
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if(empty($result)){
|
|
|
$is_submit = 0;
|
|
|
}else {
|
|
|
$user['avatar']=$result['photo'];
|
|
|
$user['user_nickname']=$result['name'];
|
|
|
$is_submit = 1;
|
|
|
}
|
|
|
|
|
|
if (empty($result['level'])){
|
|
|
$result['level']=0;
|
|
|
}
|
|
|
|
|
|
if (empty($result['work_time'])){
|
|
|
$result['work_time']=0;
|
|
|
}
|
|
|
|
|
|
$user['level']=$result['level'];
|
|
|
$user['work_time']=$result['work_time'];
|
|
|
$user['is_submit'] = $is_submit;
|
|
|
$this->success('获取成功!',$user);
|
|
|
}
|
|
|
/**
|
|
|
* @title 判断是否为管理员是否提交过申请
|
|
|
* @description 判断是否为管理员是否提交过申请
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/is_submit_admin
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @return id:id
|
|
|
* @return user_nickname:用户昵称
|
|
|
* @return avatar:头像
|
|
|
* @return type:类型(1为普通,2为管理员)
|
|
|
* @return is_submit:0为未提交过,1为已提交过
|
|
|
*/
|
|
|
public function is_submit_admin(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断当前用户是否提交过
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0));
|
|
|
if(empty($result)){
|
|
|
$is_submit = 0;
|
|
|
}else{
|
|
|
$is_submit = 1;
|
|
|
}
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$is_admin = 0;
|
|
|
}else{
|
|
|
$is_admin = 1;
|
|
|
}
|
|
|
$data['is_submit'] = $is_submit;
|
|
|
$data['is_admin'] = $is_admin;
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
/**
|
|
|
* @title 提交审核
|
|
|
* @description 提交审核
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/submit_form
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:form_id type:str require:1 other: desc:表单id
|
|
|
* @param name:name type:str require:1 other: desc:姓名
|
|
|
* @param name:sex type:str require:1 other: desc:性别(1男,2女)
|
|
|
* @param name:birthday type:str require:1 other: desc:生日
|
|
|
* @param name:nation type:str require:1 other: desc:民族
|
|
|
* @param name:politics type:str require:1 other: desc:政治面貌
|
|
|
* @param name:education type:str require:1 other: desc:学历
|
|
|
* @param name:unit type:str require:1 other: desc:工作单位
|
|
|
* @param name:duty type:str require:1 other: desc:职务
|
|
|
* @param name:addr type:str require:1 other: desc:通讯地址
|
|
|
* @param name:postcode type:str require:1 other: desc:邮编
|
|
|
* @param name:school type:str require:1 other: desc:毕业院校
|
|
|
* @param name:card_number type:str require:1 other: desc:身份证号码
|
|
|
* @param name:fixed_phone type:str require:1 other: desc:固定电话
|
|
|
* @param name:move_phone type:str require:1 other: desc:移动电话
|
|
|
* @param name:email type:str require:1 other: desc:email
|
|
|
* @param name:urgency_phone type:str require:1 other: desc:紧急联系人电话
|
|
|
* @param name:qq type:str require:1 other: desc:qq
|
|
|
* @param name:province type:str require:1 other: desc:省
|
|
|
* @param name:city type:str require:1 other: desc:市
|
|
|
* @param name:county type:str require:1 other: desc:区/县
|
|
|
* @param name:address type:str require:1 other: desc:详细地址
|
|
|
* @param name:type type:int require:1 other: desc:1医院志愿者,2社会志愿者,3办事处志愿者
|
|
|
* @param name:record_start_time type:str require:1 other: desc:开始时间
|
|
|
* @param name:record_end_time type:str require:1 other: desc:结束时间
|
|
|
* @param name:record_unit type:str require:1 other: desc:单位
|
|
|
* @param name:record_duty type:str require:1 other: desc:职务
|
|
|
* @param name:record_name type:str require:1 other: desc:证明人
|
|
|
* @param name:record_phone type:str require:1 other: desc:证明人电话
|
|
|
* @param name:front_card type:str require:1 other: desc:身份证正面照
|
|
|
* @param name:reverse_card type:str require:1 other: desc:身份证背面照
|
|
|
* @param name:photo type:str require:1 other: desc:照片
|
|
|
*/
|
|
|
public function submit_form(){
|
|
|
$user_id = $this->getUserId();
|
|
|
$param = $this->request->param();
|
|
|
$validate = new Validate([
|
|
|
'name' => 'require',
|
|
|
'sex' => 'require',
|
|
|
'birthday' => 'require',
|
|
|
'nation' => 'require',
|
|
|
'politics' => 'require',
|
|
|
'education' => 'require',
|
|
|
'unit' => 'require',
|
|
|
'duty' => 'require',
|
|
|
'addr' => 'require',
|
|
|
'postcode' => 'require',
|
|
|
'school' => 'require',
|
|
|
'card_number' => 'require',
|
|
|
// 'fixed_phone' => 'require',
|
|
|
'move_phone' => 'require',
|
|
|
'email' => 'require',
|
|
|
'urgency_phone' => 'require',
|
|
|
'qq' => 'require',
|
|
|
'province' => 'require',
|
|
|
'city' => 'require',
|
|
|
// 'county' => 'require',
|
|
|
'address' => 'require',
|
|
|
'record_start_time' => 'require',
|
|
|
'record_end_time' => 'require',
|
|
|
'record_unit' => 'require',
|
|
|
'record_duty' => 'require',
|
|
|
'record_name' => 'require',
|
|
|
'record_phone' => 'require',
|
|
|
'front_card' => 'require',
|
|
|
'reverse_card' => 'require',
|
|
|
'photo' => 'require',
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'name' => '缺少参数name',
|
|
|
'sex' => '缺少参数sex',
|
|
|
'birthday' => '缺少参数birthday',
|
|
|
'nation' => '缺少参数nation',
|
|
|
'politics' => '缺少参数politics',
|
|
|
'education' => '缺少参数education',
|
|
|
'unit' => '缺少参数unit',
|
|
|
'duty' => '缺少参数duty',
|
|
|
'addr' => '缺少参数addr',
|
|
|
'postcode' => '缺少参数postcode',
|
|
|
'school' => '缺少参数school',
|
|
|
'card_number' => '缺少参数card_number',
|
|
|
// 'fixed_phone' => '缺少参数fixed_phone',
|
|
|
'move_phone' => '缺少参数move_phone',
|
|
|
'email' => '缺少参数email',
|
|
|
'urgency_phone' => '缺少参数urgency_phone',
|
|
|
'qq' => '缺少参数qq',
|
|
|
'province' => '缺少参数province',
|
|
|
'city' => '缺少参数city',
|
|
|
// 'county' => '缺少参数county',
|
|
|
'address' => '缺少参数address',
|
|
|
'record_start_time' => '缺少参数record_start_time',
|
|
|
'record_end_time' => '缺少参数record_end_time',
|
|
|
'record_unit' => '缺少参数record_unit',
|
|
|
'record_duty' => '缺少参数record_duty',
|
|
|
'record_name' => '缺少参数record_name',
|
|
|
'record_phone' => '缺少参数record_phone',
|
|
|
'front_card' => '缺少参数front_card',
|
|
|
'reverse_card' => '缺少参数reverse_card',
|
|
|
'photo' => '缺少参数photo',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$record_start_time = explode(',',$param['record_start_time']);
|
|
|
$record_end_time = explode(',',$param['record_end_time']);
|
|
|
$record_unit = explode(',',$param['record_unit']);
|
|
|
$record_duty = explode(',',$param['record_duty']);
|
|
|
$record_name = explode(',',$param['record_name']);
|
|
|
$record_phone = explode(',',$param['record_phone']);
|
|
|
$record = [];
|
|
|
foreach($record_start_time as $key => $r_s_t){
|
|
|
$record[$key]['record_start_time'] = !empty($r_s_t) ? $r_s_t : '';
|
|
|
$record[$key]['record_end_time'] = !empty($record_end_time[$key]) ? $record_end_time[$key] : '';
|
|
|
$record[$key]['record_unit'] = !empty($record_unit[$key]) ? $record_unit[$key] :'';
|
|
|
$record[$key]['record_duty'] = !empty($record_duty[$key]) ? $record_duty[$key] :'';
|
|
|
$record[$key]['record_name'] = !empty($record_name[$key]) ? $record_name[$key] :'';
|
|
|
$record[$key]['record_phone'] = !empty($record_phone[$key]) ? $record_phone[$key] :'';
|
|
|
}
|
|
|
if(!empty($record)){
|
|
|
$record = json_encode($record);
|
|
|
}else{
|
|
|
$record = null;
|
|
|
}
|
|
|
$data = [
|
|
|
'name' => $param['name'],
|
|
|
'sex' => $param['sex'],
|
|
|
'birthday' => $param['birthday'],
|
|
|
'nation' => $param['nation'],
|
|
|
'politics' => $param['politics'],
|
|
|
'education' => $param['education'],
|
|
|
'unit' => $param['unit'],
|
|
|
'duty' => $param['duty'],
|
|
|
'addr' => $param['addr'],
|
|
|
'postcode' => $param['postcode'],
|
|
|
'school' => $param['school'],
|
|
|
'card_number' => $param['card_number'],
|
|
|
'fixed_phone' => $param['fixed_phone'],
|
|
|
'move_phone' => $param['move_phone'],
|
|
|
'email' => $param['email'],
|
|
|
'urgency_phone' => $param['urgency_phone'],
|
|
|
'qq' => $param['qq'],
|
|
|
'province' => $param['province'],
|
|
|
'city' => $param['city'],
|
|
|
'county' => !empty($param['county'])?$param['county']:null,
|
|
|
'address' => $param['address'],
|
|
|
/* 'type' => $param['type'],*/
|
|
|
'record' => $record,
|
|
|
'front_card' => $param['front_card'],
|
|
|
'reverse_card' => $param['reverse_card'],
|
|
|
'photo' => $param['photo'],
|
|
|
'status' => 1,
|
|
|
'user_id' => $user_id,
|
|
|
];
|
|
|
$form_id=input('form_id');
|
|
|
if (!empty($form_id)){
|
|
|
$this->saveFormId($user_id,$form_id);
|
|
|
}
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$result1 = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0));
|
|
|
//判断该用户是否提交过
|
|
|
if(!empty($result1)){
|
|
|
$data['update_time'] = time();
|
|
|
$volunteerModel->updateData(array('id'=>$result1['id']),$data);
|
|
|
}else{
|
|
|
$data['create_time'] = time();
|
|
|
$volunteerModel->insertData($data);
|
|
|
}
|
|
|
$this->success('提交成功!');
|
|
|
}
|
|
|
/**
|
|
|
* @title 进入修改页面
|
|
|
* @description 进入修改页面
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/edit
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @return name:姓名
|
|
|
* @return sex:性别(1男,2女)
|
|
|
* @return birthday:生日
|
|
|
* @return nation:民族
|
|
|
* @return politics:政治面貌
|
|
|
* @return education:学历
|
|
|
* @return unit:工作单位
|
|
|
* @return duty:职务
|
|
|
* @return addr:通讯地址
|
|
|
* @return postcode:邮编
|
|
|
* @return school: desc:毕业院校
|
|
|
* @return card_number :身份证号码
|
|
|
* @return fixed_phone:固定电话
|
|
|
* @return move_phone:移动电话
|
|
|
* @return email:email
|
|
|
* @return urgency_phone:紧急联系人电话
|
|
|
* @return qq:qq
|
|
|
* @return province:省
|
|
|
* @return city:市
|
|
|
* @return county:区/县
|
|
|
* @return address:详细地址
|
|
|
* @return type:1医院志愿者,2社会志愿者,3办事处志愿者
|
|
|
* @return record_start_time:开始时间
|
|
|
* @return record_end_time:结束时间
|
|
|
* @return record_unit:单位
|
|
|
* @return record_duty:职务
|
|
|
* @return record_name:证明人
|
|
|
* @return record_phone:证明人电话
|
|
|
* @return front_card type:str require:1 other: desc:身份证正面照
|
|
|
* @return reverse_card:身份证背面照
|
|
|
* @return photo:照片
|
|
|
*/
|
|
|
public function edit(){
|
|
|
// $user_id = $this->getUserId();
|
|
|
$user_id = $this->request->param('id');
|
|
|
//判断当前用户是否提交过
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0));
|
|
|
$this->success('获取成功!',$result);
|
|
|
}
|
|
|
/**
|
|
|
* @title 查看审核状态
|
|
|
* @description 查看审核状态
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/status
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @return id:id
|
|
|
* @return status:状态(1审核中,2审核成功,3审核失败)
|
|
|
*/
|
|
|
public function status(){
|
|
|
$user_id = $this->getUserId();
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$data = $volunteerModel->findData(array('user_id'=>$user_id));
|
|
|
if(empty($data)){
|
|
|
$this->success(['code'=>40001,'msg'=>'您还没有提交过申请!']);
|
|
|
}
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
/**
|
|
|
* @title 管理员审核
|
|
|
* @description 管理员审核
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/admin
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0)
|
|
|
* @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10)
|
|
|
*
|
|
|
* @return volunteer:志愿者@
|
|
|
* @volunteer id:id name:姓名 sex:性别 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id
|
|
|
* @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话
|
|
|
* @return page:志愿者下一页
|
|
|
* @return page:活动下一页
|
|
|
*/
|
|
|
public function admin(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
$param = $this->request->param();
|
|
|
$page = !empty($param['page']) ? $param['page'] : 0;//当前页数下标
|
|
|
$pageNum = !empty($param['pageNum']) ? $param['pageNum'] : 10;//每页显示几条数据
|
|
|
//获取志愿者
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
// $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>['in','1,2']));
|
|
|
$volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>'1'));
|
|
|
$data['volunteer'] = $volunteer;
|
|
|
$data['page'] = $page+1;
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 工时管理列表(new)
|
|
|
* @description
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/addTimeList
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0)
|
|
|
* @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10)
|
|
|
*
|
|
|
* @return volunteer:志愿者@
|
|
|
* @volunteer id:id name:姓名 sex:性别 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id
|
|
|
* @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话
|
|
|
* @return page:志愿者下一页
|
|
|
* @return page:活动下一页
|
|
|
*
|
|
|
*/
|
|
|
public function addTimeList(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
$param = $this->request->param();
|
|
|
$page = !empty($param['page']) ? $param['page'] : 0;//当前页数下标
|
|
|
$pageNum = !empty($param['pageNum']) ? $param['pageNum'] : 10;//每页显示几条数据
|
|
|
//获取志愿者
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
// $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>['in','1,2']));
|
|
|
$volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>'2'));
|
|
|
$data['volunteer'] = $volunteer;
|
|
|
$data['page'] = $page+1;
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 管理员添加时间(new)
|
|
|
* @description 管理员审核
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/addTime
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:join_id type:int require:0 other: desc:参加id
|
|
|
*
|
|
|
*/
|
|
|
public function addTime(){
|
|
|
|
|
|
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
$map['id']=input('join_id');
|
|
|
$time=input('add_time');
|
|
|
$user_id1=input('user_id');
|
|
|
if (empty($user_id1)){
|
|
|
$join=\db('join')->where($map)->find();
|
|
|
if (empty($join)){
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
$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);
|
|
|
}
|
|
|
}else{
|
|
|
\db('volunteer')->where('user_id',$user_id1)->setInc('work_time',$time);
|
|
|
}
|
|
|
$result=1;
|
|
|
/* // $data['add_time']=['exp','work_time'+$time];
|
|
|
$result=db('volunteer')->where($map)->setInc('work_time',$time);
|
|
|
// echo db('volunteer')->getLastSql();*/
|
|
|
if ($result>0){
|
|
|
$this->success('修改成功!');
|
|
|
}else{
|
|
|
$this->error('此人不是审核通过的志愿者!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 管理员查看活动申请详情
|
|
|
* @description 管理员审核
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/adminGetApplyInfo
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:join_id type:int require:0 other: desc:报名id
|
|
|
*
|
|
|
*/
|
|
|
public function adminGetApplyInfo(){
|
|
|
$map['id']=input('join_id');
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
/*获取*/
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($return['time'])){
|
|
|
$return['time']= array_reverse($return['time']);
|
|
|
}
|
|
|
|
|
|
$info=db('join')->field('card_number,sgin_time,id,type,user_id,activity_id,select_time,apply_stay,apply_food,work_content')->where($map)->find();
|
|
|
$user=db('volunteer')->field('card_number,sex,name,birthday,move_phone')->where('user_id',$info['user_id'])->find();
|
|
|
if (!empty($user)){
|
|
|
$return['name']=$user['name'];
|
|
|
$return['birthday']=$user['birthday'];
|
|
|
$return['sex']=$user['sex']==1?'男':'女';
|
|
|
$return['tel']=$user['move_phone'];
|
|
|
}
|
|
|
if (!empty($info)){
|
|
|
$return['work_content']=db('work')->where('id',$info['work_content'])->value('name');
|
|
|
$return['work_content']=$info['work_content'];
|
|
|
$return['select_time']=json_decode($info['select_time'],true);
|
|
|
$return['apply_stay']=json_decode($info['apply_stay'],true);
|
|
|
$return['apply_food']=json_decode($info['apply_food'],true);
|
|
|
$return['id']=$info['id'];
|
|
|
$return['work_type']=$info['type'];
|
|
|
$return['card_number']=$user['card_number'];
|
|
|
$return['is_complete']=$info['sgin_time']==0?'0':'1';
|
|
|
/* switch ($info['type']){
|
|
|
case 1:
|
|
|
$return['work_type']='线上';
|
|
|
break;
|
|
|
case 2:
|
|
|
$return['work_type']='线下';
|
|
|
break;
|
|
|
case 3:
|
|
|
$return['work_type']='线上及线下';
|
|
|
break;
|
|
|
|
|
|
}*/
|
|
|
}
|
|
|
|
|
|
$this->success('',$return);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 管理员更新状态
|
|
|
* @description 管理员更新状态
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/update_status
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:id type:int require:1 other: desc:志愿者id
|
|
|
* @param name:status type:int require:1 other: desc:状态(点击审核通过传2,点击审核失败传3)
|
|
|
* @param name:refund_reason type:int require:1 other: desc:审核不通过原因
|
|
|
*/
|
|
|
public function update_status(){
|
|
|
$user_id = $this->getUserId();
|
|
|
|
|
|
$id = $this->request->param('id');
|
|
|
if(empty($id)){
|
|
|
$this->error('缺少参数id');
|
|
|
}
|
|
|
$data['refund_reason']=input('refund_reason')??'';
|
|
|
$status = $this->request->param('status');
|
|
|
if(empty($status)){
|
|
|
$this->error('缺少参数status');
|
|
|
}
|
|
|
if($status != 2 && $status != 3){
|
|
|
$this->error('status参数错误!');
|
|
|
}
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
//获取志愿者
|
|
|
$volunteerModel = new VolunteerModel();
|
|
|
$data['status']=input('status');
|
|
|
|
|
|
if ($data['status']==2){
|
|
|
$keyword='审核通过';
|
|
|
}else{
|
|
|
$keyword="审核未通过 原因:$data[refund_reason]";
|
|
|
}
|
|
|
|
|
|
$result = $volunteerModel->updateData(array('id'=>$id),$data);
|
|
|
if(empty($result)){
|
|
|
$this->success(['code'=>40002,'msg'=>'当前申请可能已被其他管理员审核,请刷新页面!']);
|
|
|
}
|
|
|
|
|
|
$volunteer=db('volunteer')->where('id',$id)->find();
|
|
|
$userMap['user_id']=$volunteer['user_id'];
|
|
|
$openid=db('third_party_user')->where($userMap)->value('openid');
|
|
|
$formMap['user_id']=$volunteer['user_id'];
|
|
|
$formMap['use_time']=0;
|
|
|
$formMap['expire_time']=['>',time()];
|
|
|
$form_id=\db('form_id')->where($formMap)->find();
|
|
|
$now=time();
|
|
|
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>$now]);
|
|
|
if (!empty($form_id)){
|
|
|
$data['keyword1']= $volunteer['name'];
|
|
|
$data['keyword2']='志愿者审核';
|
|
|
$data['keyword3']=$keyword;
|
|
|
$data['keyword4']='志愿者审核';
|
|
|
$message = [
|
|
|
'touser' => $openid,
|
|
|
'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw',
|
|
|
'page' => 'pages/index/index',
|
|
|
'form_id' => $form_id['value'],
|
|
|
'data' => $data,
|
|
|
'emphasis_keyword' =>$data['keyword3']='状态',
|
|
|
];
|
|
|
$this->wxappNotice($message);
|
|
|
}
|
|
|
$this->success(['code'=>20000,'msg'=>'更新成功!']);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @title 获取人员参与状态
|
|
|
* @description 管理员更新状态
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/getJoinPerson
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:id type:int require:1 other: desc:活动id
|
|
|
*
|
|
|
* @return photo:摄影(设备自带)
|
|
|
* @return camera:摄像(设备自带)
|
|
|
* @return motorcade:爱心车队
|
|
|
* @return service:现场服务(签到、指引、礼仪等)
|
|
|
* @return question:线上答疑
|
|
|
* @return ill:门诊服务
|
|
|
* @return name:status0,未审核1,已通过2,未通过3,已填写工作汇报(已通过)
|
|
|
*/
|
|
|
public function getJoinPerson(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
//活动id
|
|
|
$id=input('id');
|
|
|
$map['activity_id']=$id;
|
|
|
$map['j.delete_time']=0;
|
|
|
|
|
|
/* $info=db('join')->alias('j')
|
|
|
->group('j.user_id')
|
|
|
->field('v.*,j.*,j.id as join_id,j.status as status')
|
|
|
->join('volunteer v','v.user_id=j.user_id')
|
|
|
->where($map)
|
|
|
->order('j.id','asc')
|
|
|
->select()
|
|
|
->toArray();*/
|
|
|
/* $subQuery = db('join')->alias('j')
|
|
|
->field('j.user_id,v.name,v.photo,j.id as join_id,j.status as status,j.delete_time,j.activity_id,j.work_content')
|
|
|
->join('volunteer v','v.user_id=j.user_id')
|
|
|
->where($map)
|
|
|
->order('j.id','desc')
|
|
|
->buildSql();
|
|
|
dump($subQuery);
|
|
|
$info= Db::table($subQuery.'a')
|
|
|
->group('a.user_id')
|
|
|
->select()
|
|
|
->toArray();*/
|
|
|
$new_map=[];
|
|
|
$subQuery = db('join')->alias('j')
|
|
|
->field('max(j.id)')
|
|
|
->join('volunteer v','v.user_id=j.user_id')
|
|
|
->where($map)
|
|
|
->group('j.user_id')
|
|
|
->select()
|
|
|
->toArray();
|
|
|
if (!empty($subQuery)){
|
|
|
foreach ($subQuery as $k=>$v){
|
|
|
$new_map[]=$v["max(j.id)"];
|
|
|
}
|
|
|
}
|
|
|
$map1['j.id']=['in',implode(',',$new_map)];
|
|
|
|
|
|
|
|
|
$info=db('join')->alias('j')
|
|
|
->group('j.user_id')
|
|
|
->field('v.*,j.*,j.id as join_id,j.status as status')
|
|
|
->join('volunteer v','v.user_id=j.user_id')
|
|
|
->where($map1)
|
|
|
->order('j.id','asc')
|
|
|
->select()
|
|
|
->toArray();
|
|
|
|
|
|
/*$info=db('join_view')
|
|
|
->group('user_id')
|
|
|
->where($map)
|
|
|
->select()
|
|
|
->toArray();*/
|
|
|
|
|
|
// echo db('join')->getLastSql();
|
|
|
|
|
|
$return=[];
|
|
|
$i0=0;
|
|
|
$i1=0;
|
|
|
$i2=0;
|
|
|
$i3=0;
|
|
|
$i4=0;
|
|
|
$i5=0;
|
|
|
|
|
|
foreach($info as $k=>$v){
|
|
|
switch ($v['work_content']){
|
|
|
case 1:
|
|
|
$return[0]['title']='摄影(设备自带)';
|
|
|
$return[0]['arr'][$i0]['id']=$v['join_id'];
|
|
|
$return[0]['arr'][$i0]['photo']=$v['photo'];
|
|
|
$return[0]['arr'][$i0]['name']=$v['name'];
|
|
|
$return[0]['arr'][$i0]['user_id']=$v['user_id'];
|
|
|
$return[0]['arr'][$i0]['status']=$this->switchStatus($v['status']);
|
|
|
$i0++;
|
|
|
break;
|
|
|
case 2:
|
|
|
$return[1]['title']='摄像(设备自带)';
|
|
|
$return[1]['arr'][$i1]['id']=$v['join_id'];
|
|
|
$return[1]['arr'][$i1]['photo']=$v['photo'];
|
|
|
$return[1]['arr'][$i1]['name']=$v['name'];
|
|
|
$return[1]['arr'][$i1]['user_id']=$v['user_id'];
|
|
|
$return[1]['arr'][$i1]['status']=$this->switchStatus($v['status']);
|
|
|
$i1++;
|
|
|
break;
|
|
|
case 3:
|
|
|
$return[2]['title']='爱心车队';
|
|
|
$return[2]['arr'][$i2]['id']=$v['join_id'];
|
|
|
$return[2]['arr'][$i2]['photo']=$v['photo'];
|
|
|
$return[2]['arr'][$i2]['name']=$v['name'];
|
|
|
$return[2]['arr'][$i2]['user_id']=$v['user_id'];
|
|
|
$return[2]['arr'][$i2]['status']=$this->switchStatus($v['status']);
|
|
|
$i2++;
|
|
|
break;
|
|
|
case 4:
|
|
|
$return[3]['title']='现场服务(签到、指引、礼仪等)';
|
|
|
$return[3]['arr'][$i3]['id']=$v['join_id'];
|
|
|
$return[3]['arr'][$i3]['photo']=$v['photo'];
|
|
|
$return[3]['arr'][$i3]['name']=$v['name'];
|
|
|
$return[3]['arr'][$i3]['user_id']=$v['user_id'];
|
|
|
$return[3]['arr'][$i3]['status']=$this->switchStatus($v['status']);
|
|
|
$i3++;
|
|
|
break;
|
|
|
case 5:
|
|
|
$return[4]['title']='线上答疑';
|
|
|
$return[4]['arr'][$i4]['id']=$v['join_id'];
|
|
|
$return[4]['arr'][$i4]['photo']=$v['photo'];
|
|
|
$return[4]['arr'][$i4]['name']=$v['name'];
|
|
|
$return[4]['arr'][$i4]['user_id']=$v['user_id'];
|
|
|
$return[4]['arr'][$i4]['status']=$this->switchStatus($v['status']);
|
|
|
$i4++;
|
|
|
break;
|
|
|
case 6:
|
|
|
$return[5]['title']='门诊服务';
|
|
|
|
|
|
/*判断是否有user_id*/
|
|
|
$return[5]['arr'][$i5]['id']=$v['join_id'];
|
|
|
$return[5]['arr'][$i5]['photo']=$v['photo'];
|
|
|
$return[5]['arr'][$i5]['name']=$v['name'];
|
|
|
$return[5]['arr'][$i5]['user_id']=$v['user_id'];
|
|
|
$return[5]['arr'][$i5]['status']=$this->switchStatus($v['status']);
|
|
|
$i5++;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
foreach ($return as $k=>$v){
|
|
|
foreach($return[$k] as $k1=>$v1){
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->success('',$return);
|
|
|
}
|
|
|
/**
|
|
|
* @title 管理员审核活动申请是否通过(new)
|
|
|
* @description 管理员更新状态
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/adminApprove
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*
|
|
|
* @param name:id type:int require:1 other: desc:参加id
|
|
|
* @param name:status type:int require:1 other: desc:1通过2.拒绝
|
|
|
* @param name:refund_reason type:int require:1 other: desc:拒绝理由
|
|
|
*
|
|
|
*
|
|
|
*/
|
|
|
public function adminApprove(){
|
|
|
$user_id = $this->getUserId();
|
|
|
//判断这个用户是不是管理员
|
|
|
|
|
|
$userModel = new UserModel();
|
|
|
$user = $userModel->findData(array('id'=>$user_id));
|
|
|
if($user['type'] != 2){
|
|
|
$this->success(['code'=>40001,'msg'=>'查无此人!']);
|
|
|
}
|
|
|
$map['id']=input('id');
|
|
|
$data['status']=input('status');
|
|
|
$refund_reason=input('refund_reason');
|
|
|
if (!empty($refund_reason)){
|
|
|
$data['refund_reason']=input('refund_reason');
|
|
|
}
|
|
|
$result=db('join')->where($map)->update($data);
|
|
|
if ($result>0){
|
|
|
$join=\db('join')->where($map)->find();
|
|
|
$activity=\db('activity')->where('id',$join['activity_id'])->find();
|
|
|
$userMap['user_id']=$join['user_id'];
|
|
|
$openid=db('third_party_user')->where($userMap)->value('openid');
|
|
|
$volunteer=\db('volunteer')->where('user_id',$join['user_id'])->find();
|
|
|
$formMap['user_id']=$join['user_id'];
|
|
|
$formMap['use_time']=0;
|
|
|
$formMap['expire_time']=['>',time()];
|
|
|
$form_id=\db('form_id')->where($formMap)->find();
|
|
|
$now=time();
|
|
|
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>$now]);
|
|
|
|
|
|
if ($data['status']==1){
|
|
|
if (!empty($form_id)){
|
|
|
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]);
|
|
|
$data['keyword1']= $volunteer['name'];
|
|
|
$data['keyword2']='活动审核';
|
|
|
$data['keyword3']='通过';
|
|
|
$data['keyword4']=$activity['activity_name'];
|
|
|
$message = [
|
|
|
'touser' => $openid,
|
|
|
'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw',
|
|
|
'page' => 'pages/index/index',
|
|
|
'form_id' => $form_id['value'],
|
|
|
'data' => $data,
|
|
|
'emphasis_keyword' =>$data['keyword3'],
|
|
|
];
|
|
|
$this->wxappNotice($message);
|
|
|
}
|
|
|
}else{
|
|
|
if (!empty($form_id)){
|
|
|
\db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]);
|
|
|
$data['keyword1']= $volunteer['name'];
|
|
|
$data['keyword2']='活动审核';
|
|
|
$data['keyword3']='未通过 原因:'.$refund_reason;
|
|
|
$data['keyword4']=$activity['activity_name'];
|
|
|
$message = [
|
|
|
'touser' => $openid,
|
|
|
'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw',
|
|
|
'page' => 'pages/index/index',
|
|
|
'form_id' => $form_id['value'],
|
|
|
'data' => $data,
|
|
|
'emphasis_keyword' =>$data['keyword3'],
|
|
|
];
|
|
|
$this->wxappNotice($message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->success('更新成功!');
|
|
|
}else{
|
|
|
$this->error('操作失败!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected function wxappNotice($message){
|
|
|
$appId = 'wx7a3bf4e0796c070a';
|
|
|
$secret = '755478f064e09a8301345e0c427c6cf3';
|
|
|
$config = [
|
|
|
'app_id' => $appId,
|
|
|
'secret' => $secret,
|
|
|
];
|
|
|
|
|
|
$wechat=new Application($config);
|
|
|
$notice=$wechat->mini_program->notice;
|
|
|
try{
|
|
|
$result= $notice->send($message);
|
|
|
}catch(Exception $e){
|
|
|
// $e->getMessage();
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
|
|
|
protected function switchStatus($status){
|
|
|
switch ($status){
|
|
|
case 0:
|
|
|
return '0';
|
|
|
case 1:
|
|
|
return '1';
|
|
|
case 2:
|
|
|
return '2';
|
|
|
case 3:
|
|
|
return '3';
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* @title 关于我们
|
|
|
* @description 关于我们
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/about
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*/
|
|
|
public function about(){
|
|
|
$aboutModel = new AboutModel();
|
|
|
$data = $aboutModel->findData(array('id'=>1));
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
/**
|
|
|
* @title 联系我们
|
|
|
* @description 联系我们
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/contact
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*/
|
|
|
public function contact(){
|
|
|
$contactModel = new ContactModel();
|
|
|
$data = $contactModel->findData(array('id'=>1));
|
|
|
$this->success('获取成功!',$data);
|
|
|
}
|
|
|
/**
|
|
|
* @title 我参加的活动
|
|
|
* @description 参加过的活动
|
|
|
* @author XiaoGang Wang
|
|
|
* @url /index/member_center/joined
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
*/
|
|
|
public function joined(){
|
|
|
$userId=$this->getUserId();
|
|
|
$Join=new JoinModel();
|
|
|
$join=$Join->getUserJoin($userId);
|
|
|
foreach ($join as $k=>$v){
|
|
|
$join[$k]['thumbnail']=cmf_get_image_url($v['thumbnail']);
|
|
|
$join[$k]['create_time']=date('Y-m-d',$v['create_time']);
|
|
|
}
|
|
|
$this->success('',$join);
|
|
|
}
|
|
|
|
|
|
protected function saveFormId($userId,$formId){
|
|
|
if ($formId=='undefined'){
|
|
|
return;
|
|
|
}
|
|
|
$data['user_id']=$userId;
|
|
|
$data['add_time']=time();
|
|
|
$data['value']=$formId;
|
|
|
$data['expire_time']=time()+604800;
|
|
|
db('form_id')->insert($data);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|