feat(接口): 补卡相关接口完成
							parent
							
								
									2dd1b85729
								
							
						
					
					
						commit
						6f1d50bffa
					
				|  | @ -881,7 +881,7 @@ class Manager extends Base | |||
|         } | ||||
| 
 | ||||
|         $update = [ | ||||
|             'status' => $status, | ||||
|             'status'  => $status, | ||||
|             'content' => $content, | ||||
|         ]; | ||||
| 
 | ||||
|  | @ -959,18 +959,69 @@ class Manager extends Base | |||
|                         break; | ||||
|                 } | ||||
|                 $item->create_time = date('Y年m月d日 H:i:s', $item->create_time); | ||||
|                 $typeText   = ClockLog::typeText()[$item->type] ?? ''; | ||||
|                 $dayText    = date('Y年m月d日', strtotime($item->day)); | ||||
|                 $item->desc    = "补打$dayText $typeText 打卡"; | ||||
|                 unset($item->check_by); | ||||
|                 unset($item->check_at); | ||||
|                 unset($item->account_id); | ||||
|                 unset($item->created_at); | ||||
|                 unset($item->type); | ||||
|                 unset($item->day); | ||||
|                 unset($item->day_text); | ||||
|                 unset($item->worksite_id); | ||||
|                 unset($item->is_statistic); | ||||
|                 unset($item->need_statistic); | ||||
|                 unset($item->indexs); | ||||
|                 unset($item->handle_count); | ||||
|                 unset($item->is_replenish); | ||||
|                 unset($item->role); | ||||
|                 unset($item->type); | ||||
|                 unset($item->status); | ||||
|             }); | ||||
|             $res['list'] = arrayNullToString($res['list']->toArray()); | ||||
|         } | ||||
| 
 | ||||
|         return $this->json(0, 'success', $res); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 审核补卡 支持批量 | ||||
|      * | ||||
|      * @return Json | ||||
|      */ | ||||
|     public function checkReplenish(): Json | ||||
|     { | ||||
|         try { | ||||
|             $accountId = $this->request->user['user_id'] ?? 0; | ||||
|             $type      = input('type/d', 1);//类型 1=通过 0=不通过
 | ||||
|             $ids       = input('id/s');//待审核记录ID 多个用逗号分割
 | ||||
|             $ids       = explode(',', $ids); | ||||
|             $ids       = array_filter($ids); | ||||
| 
 | ||||
|             if (!in_array($type, [0, 1])) { | ||||
|                 return $this->json(4001, '审核参数错误'); | ||||
|             } | ||||
| 
 | ||||
|             if (!$account = Account::findById($accountId, ['id, role'])) { | ||||
|                 return $this->json(6001, '请先登录'); | ||||
|             } | ||||
| 
 | ||||
|             if ($account['role'] <= Account::COMMON_ON) { | ||||
|                 // 工地负责人才能操作
 | ||||
|                 return $this->json(4003, '无此权限'); | ||||
|             } | ||||
| 
 | ||||
|             $worksiteIds = AccountWorksite::where('account_id', $accountId)->column('worksite_id'); | ||||
|             if (ClockLog::whereIn('id', $ids)->whereNotIn('worksite_id', $worksiteIds)->count() > 0) { | ||||
|                 return $this->json(4003, '部分记录不在您权限操作的范围'); | ||||
|             } | ||||
| 
 | ||||
|             ClockLog::whereIn('id', $ids)->where('status', ClockLog::COMMON_OFF)->update([ | ||||
|                 'status'   => $type == 1 ? 1 : -1, | ||||
|                 'check_at' => date('Y-m-d H:i:s'), | ||||
|                 'check_by' => $accountId, | ||||
|             ]); | ||||
|             return $this->json(); | ||||
|         } catch (Exception $e) { | ||||
|             return $this->json(5000, '审核失败'.$e->getMessage()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -794,6 +794,20 @@ class Worker extends Base | |||
|             $time = time(); | ||||
|             $now  = date('Y-m-d H:i:s', $time); | ||||
|             $day  = date('Ymd', strtotime($input['day'])); | ||||
| 
 | ||||
|             $where = [ | ||||
|                 'account_id'   => $accountId, | ||||
|                 'type'         => $input['type'], | ||||
|                 'worksite_id'  => $input['worksite_id'], | ||||
|                 'day'          => $day, | ||||
|                 'role'         => $customer['role'], | ||||
|                 'indexs'       => $accountId.'-'.$input['worksite_id'].'-'.$day, | ||||
|             ]; | ||||
| 
 | ||||
|             if (ClockLog::where($where)->whereIn('status', [0, 1])->count() > 0) { | ||||
|                 return $this->json(4001, '记录存在,无需补卡!'); | ||||
|             } | ||||
| 
 | ||||
|             $data = [ | ||||
|                 'account_id'   => $accountId, | ||||
|                 'type'         => $input['type'], | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue