|
@@ -6,6 +6,7 @@ use App\Models\Score\Clockin as Model;
|
|
|
use App\Models\Score\ClockinActive as ClockinActive;
|
|
|
use App\Models\WeiBan\Tags as WeiBanTags;
|
|
|
use App\Models\CustomClockinRecord;
|
|
|
+use http\Env\Request;
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
|
/**
|
|
@@ -47,7 +48,7 @@ class Clockin extends Api
|
|
|
// 接口验签
|
|
|
// $this->verify_sign();
|
|
|
// 验证登录
|
|
|
- $uid = $this->getUid();
|
|
|
+ $uid = $this->checkLogin();
|
|
|
// 获取客户信息
|
|
|
$custom = $uid ? $Custom->getOne($uid) : [];
|
|
|
//客户的城市ID 如果不存在的话
|
|
@@ -81,7 +82,7 @@ class Clockin extends Api
|
|
|
if (!$activeInfo) return json_send(['code'=>'error','msg'=>'暂无签到活动','data'=>['error'=>'暂无签到活动']]);
|
|
|
// 获取列表
|
|
|
$list = $Model->getActiveList($activeInfo['id']);
|
|
|
- $isMark = $CustomClockinRecord->isMarkClock($uid);
|
|
|
+ $isMark = $CustomClockinRecord->isMarkClock($uid,$activeInfo['id']);
|
|
|
$isMark['finish_day'] = empty($isMark['finish_day'])?0:$isMark['finish_day'];
|
|
|
// 循环处理
|
|
|
foreach ( $list as $key => $value ) {
|
|
@@ -94,51 +95,28 @@ class Clockin extends Api
|
|
|
$list = array_values($list);
|
|
|
$list = array_chunk($list,28);
|
|
|
// 返回结果
|
|
|
- return json_send(['code'=>'success','msg'=>'获取成功','data'=>['list'=>$list,'is_mark'=>$isMark]]);
|
|
|
+ return json_send(['code'=>'success','msg'=>'获取成功','data'=>['list'=>$list,'is_mark'=>$isMark,'active_id'=>$activeInfo['id']]]);
|
|
|
}
|
|
|
/**
|
|
|
* 打卡 /api/score_clockin/finish
|
|
|
*
|
|
|
*/
|
|
|
- public function finish(Model $Model,Custom $Custom,WeiBanTags $WeiBanTags,ClockinActive $ClockinActive,CustomClockinRecord $CustomClockinRecord)
|
|
|
+ public function finish(Model $Model,Custom $Custom,ClockinActive $ClockinActive,CustomClockinRecord $CustomClockinRecord)
|
|
|
{
|
|
|
// 接口验签
|
|
|
// $this->verify_sign();
|
|
|
// 验证登录
|
|
|
- $uid = $this->getUid();
|
|
|
+ $uid = $this->checkLogin();
|
|
|
+ $activeId = request('active_id',0);
|
|
|
// 获取客户信息
|
|
|
$custom = $uid ? $Custom->getOne($uid) : [];
|
|
|
//客户的城市ID 如果不存在的话
|
|
|
if( !$custom['city_id'] ) return json_send(['code'=>'error','msg'=>'请选择所在城市','data'=>['error'=>'请选择所在城市']]);
|
|
|
- $cityId = $custom['city_id'];
|
|
|
- // 查询用户标签
|
|
|
- $tags = $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
|
|
|
- //获取打卡活动列表
|
|
|
- $activeList = $ClockinActive->getList();
|
|
|
- if (!$activeList) return json_send(['code'=>'error','msg'=>'暂无签到活动','data'=>['error'=>'暂无签到活动']]);
|
|
|
- $activeInfo = [];
|
|
|
- foreach ($activeList as $value){
|
|
|
- $city_ids = $value['city_ids'] ? explode(',',$value['city_ids']) : [];
|
|
|
- $tag_scope = $value['tag_scope'] ? explode(',',$value['tag_scope']) : [];
|
|
|
- if( !$city_ids || in_array($cityId,$city_ids) ) {
|
|
|
- if ($tag_scope){
|
|
|
- foreach ($tags as $tag) {
|
|
|
- // 标签范围内
|
|
|
- if( in_array($tag['name'],$tag_scope) ) {
|
|
|
- $activeInfo = $value;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- $activeInfo = $value;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if (!$activeInfo) return json_send(['code'=>'error','msg'=>'暂无签到活动','data'=>['error'=>'暂无签到活动']]);
|
|
|
+ if( !$activeId ) return json_send(['code'=>'error','msg'=>'缺少活动id','data'=>['error'=>'缺少活动id']]);
|
|
|
+ $activeInfo = $ClockinActive::query()->where(['id'=>$activeId])->first();
|
|
|
+ if (!$activeInfo) return json_send(['code'=>'error','msg'=>'暂无签到活动','data'=>['error'=>'暂无签到活动']]);
|
|
|
// 获取打卡次数
|
|
|
- $result = $CustomClockinRecord->finish($uid,$activeInfo['id']);
|
|
|
+ $result = $CustomClockinRecord->finish($uid,$activeInfo['id']);
|
|
|
// 失败结束
|
|
|
if( isset($result['error']) ) return json_send(['code'=>'error','msg'=>$result['error'],'data'=>'']);
|
|
|
// 返回结果
|