...
|
...
|
@@ -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 |
...
|
...
|
|