作者 sgj
1 个管道 的构建 通过 耗费 1 秒

接口完成

... ... @@ -314,5 +314,94 @@ class IndexController extends RestBaseController
$this->success('获取成功!',$activity);
}
/**
* @title 签到
* @description 活动签到
* @author Xiaogang Wang
* @url /index/index/sginIn
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:id type:int require:1 other: desc:活动id
*
*/
public function sginIn(){
$userId=$this->getUserId();
$activity_id=input('activity_id');
$Join=new JoinModel();
$where['user_id']=$userId;
$where['activity_id']=$activity_id;
$join=$Join->findData($where);
if (empty($join)){
$this->error('您还未报名此活动');
}
if ($join['status']==3){
$this->error('您已经签到过了');
}
if ($join['status']==2||$join['status']==0){
$this->error('还没有通过审核');
}
if ($join['status']==1){
$data['sgin_time']=time();
$data['status']=3;
$result=$Join->update($data,$where);
if ($result==0){
$this->error('签到失败');
}
}
$this->success('签到成功!');
}
/**
* @title 申请活动
* @description 活动申请
* @author Xiaogang Wang
* @url /index/index/applyJoin
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:id type:int require:1 other: desc:活动id
* @param name:type type:int require:1 other: desc:活动类型1:线上2:线下3:线上+线下
* @param name:start_time type:int require:1 other: desc:开始时间
* @param name:end_time type:int require:1 other: desc:结束时间
*
*/
public function applyJoin(){
$userId=$this->getUserId();
$activity_id=input('id');
$type=input('type');
$start_time=input('start_time');
$end_time=input('end_time');
$activity_id=input('id');
/*判断是否未志愿者*/
$Volunteer=new VolunteerModel();
$where['user_id']=$userId;
$volunter=$Volunteer->findData($where);
if (empty($volunter)){
$this->error('请先成为志愿者!');
}
/*判断是否参加了活动*/
$Join=new JoinModel();
$map['user_id']=$userId;
$map['activity_id']=$activity_id;
$join=$Join->findData($map);
if ($join){
$this->error('已经报名参加过该活动!');
}
$data['user_id']=$userId;
$data['activity_id']=$activity_id;
$data['type']=$type;
$data['start_time']=$start_time;
$data['end_time']=$end_time;
$result=$Join->insert($data);
if ($result>0){
$this->success('报名成功,请等待审核!');
}
$this->error('报名失败');
}
}
\ No newline at end of file
... ...
... ... @@ -42,6 +42,8 @@ class MemberCenterController extends RestBaseController
*
* @return id:id
* @return user_nickname:用户昵称
* @return level:用户星级
* @return work_time:工作时长
* @return avatar:头像
* @return type:类型(1为普通,2为管理员)
* @return is_submit:0为未提交过,1为已提交过
... ... @@ -51,13 +53,16 @@ class MemberCenterController extends RestBaseController
//判断当前用户是否提交过
$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{
$user['lever']=$result['level'];
$user['work_time']=$result['work_time'];
$is_submit = 1;
}
$userModel = new UserModel();
$user = $userModel->findData(array('id'=>$user_id));
$user['is_submit'] = $is_submit;
$this->success('获取成功!',$user);
}
... ... @@ -447,4 +452,6 @@ class MemberCenterController extends RestBaseController
$this->success('获取成功!',$data);
}
}
\ No newline at end of file
... ...