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

接口大体完成

... ... @@ -158,8 +158,6 @@ class IndexController extends RestBaseController
/**
* @title 志愿者详情
* @description 志愿者详情
... ...
... ... @@ -983,7 +983,7 @@ class SecondController extends RestBaseController
$Clock=new ClockModel();
$map['user_id']=$userId;
$info=$Clock->where($map)->with(['activity'])->select();
$this->success('',$info);
$this->success('',$info);
}
/**
... ... @@ -994,14 +994,39 @@ class SecondController extends RestBaseController
* @method POST
*
*
*@param name:id type:int require:1 other: desc:订单id
*@param name:id type:int require:1 other: desc:活动id
*@param name:long type:int require:1 other: desc:经度
*@param name:lat type:int require:1 other: desc:纬度
*@header name:XX-Token require:1 default: desc:token
*
*
*@throws
*/
public function startClock(){
$data=input();
$activityModel=new ClockModel();
$activity=$activityModel->where('id',$data['id'])->find();
/*检查时间*/
$date=date('Y-m-d');
if ($date!=$activity['date']){
$this->error('当前日期无法打卡');
}
$config=cmf_get_option('site_info');
$adminStartTime=strtotime("$date.' '.$activity[start_clock_time]");
$now=time();
if (($adminStartTime-$config['before_start_time']*60)>$now || ($adminStartTime+$config['after_start_time']*60)<$now){
$this->error('当前时间无法打卡');
}
/*检查地点*/
$distance=getDistance($activity['lat'],$activity['long'],$data['lat'],$data['long']);
if ($distance*1000>$config['distinct']){
$this->error('不在打卡范围内');
}
$update['status']=1;
$update['user_start']=time();
$result=db('clock')->where('id',$data['id'])->update(['user_start'=>$now]);
$this->success('打卡成功!');
}
... ... @@ -1020,7 +1045,33 @@ class SecondController extends RestBaseController
*@throws
*/
public function endClock(){
$data=input();
$activityModel=new ClockModel();
$activity=$activityModel->where('id',$data['id'])->find();
/*检查时间*/
$date=date('Y-m-d');
if ($date!=$activity['date']){
$this->error('当前日期无法打卡');
}
$config=cmf_get_option('site_info');
$adminEndTime=strtotime("$date.' '.$activity[end_clock_time]");
$now=time();
if (($adminEndTime-$config['before_end_time']*60)>$now || ($adminEndTime+$config['after_end_time']*60)<$now){
$this->error('当前时间无法打卡');
}
/*检查地点*/
$distance=getDistance($activity['lat'],$activity['long'],$data['lat'],$data['long']);
if ($distance*1000>$config['distinct']){
$this->error('不在打卡范围内');
}
$update['status']=2;
$update['user_end']=time();
$result=db('clock')->where('id',$data['id'])->update(['user_end'=>$now]);
if ($result==1){
}
$this->success('打卡成功!');
}
/**
... ... @@ -1035,10 +1086,11 @@ class SecondController extends RestBaseController
*@header name:XX-Token require:1 default: desc:token
*
*@return activity_name:活动名称
*@return content_info:虚拟订单信息
*@return is_real:是否为虚拟订单
*@return expend:消耗工时
*@return good:商品信息
*@return address:地址
*@return status:状态状态0,未打卡1,已开始2,完成打开3,未完成
*@return address:地址
*@return start_clock_time:后台设定开始时间
*@return end_clock_time:后台设定结束时间
*
*@throws
*/
... ... @@ -1046,6 +1098,8 @@ class SecondController extends RestBaseController
$id=input('id');
$Clock=new ClockModel();
$info=$Clock->where('id',$id)->with(['Activity'])->find();
$config=cmf_get_option('site_info');
$info['distance']=$config['distinct'];
$this->success('',$info);
}
... ... @@ -1053,4 +1107,5 @@ class SecondController extends RestBaseController
}
\ No newline at end of file
... ...
... ... @@ -79,6 +79,39 @@
</div>
</div>
<div class="form-group">
<label for="input-site_icp" class="col-sm-2 control-label">上岗打卡提前时间(分钟)</label>
<div class="col-md-6 col-sm-10">
<input type="text" class="form-control" id="before_start_time" name="options[before_start_time]" value="{$before_start_time|default=''}">
</div>
</div>
<div class="form-group">
<label for="input-site_icp" class="col-sm-2 control-label">上岗打卡错后时间(分钟)</label>
<div class="col-md-6 col-sm-10">
<input type="text" class="form-control" id="after_start_time" name="options[after_start_time]" value="{$after_start_time|default=''}">
</div>
</div>
<div class="form-group">
<label for="input-site_icp" class="col-sm-2 control-label">下岗打卡错后时间(分钟)</label>
<div class="col-md-6 col-sm-10">
<input type="text" class="form-control" id="before_end_time" name="options[before_end_time]" value="{$before_end_time|default=''}">
</div>
</div>
<div class="form-group">
<label for="input-site_icp" class="col-sm-2 control-label">下岗打卡错后时间(分钟)</label>
<div class="col-md-6 col-sm-10">
<input type="text" class="form-control" id="after_end_time" name="options[after_end_time]" value="{$after_end_time|default=''}">
</div>
</div>
<div class="form-group">
<label for="input-site_icp" class="col-sm-2 control-label">最大打卡距离(米)</label>
<div class="col-md-6 col-sm-10">
<input type="text" class="form-control" id="distance" name="options[distance]" value="{$distance|default=''}">
</div>
</div>
<div class="form-group">
<label for="input-site_icp" class="col-sm-2 control-label">短信账号</label>
<div class="col-md-6 col-sm-10">
<input type="text" class="form-control" id="input-site_icp" name="options[duanxinbao]" value="{$duanxinbao|default=''}">
... ...
... ... @@ -1934,4 +1934,29 @@ function wxappNotice($message){
return 0;
}
return $level;
}
\ No newline at end of file
}
/**
* 获取距离
* @param $lat1
* @param $lng1
* @param $lat2
* @param $lng2
* @return float
*/
function getDistance($lat1, $lng1, $lat2, $lng2){
// 将角度转为狐度
$radLat1 = deg2rad($lat1);// deg2rad()函数将角度转换为弧度
$radLat2 = deg2rad($lat2);
$radLng1 = deg2rad($lng1);
$radLng2 = deg2rad($lng2);
$a = $radLat1 - $radLat2;
$b = $radLng1 - $radLng2;
$s = 2 * asin(sqrt(pow(sin($a / 2), 2)+cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2))) * 6378.137;
return $s;
}
\ No newline at end of file
... ...