where($where)->find(); if(!$taskInfo) { return false; } // 添加/修改任务日志 $where = []; $where["user_id"] = $user_id; $where["task_id"] = $taskInfo["id"]; $taskInfo["type_id"] == 2 && $where["finish_date"] = date("Ymd"); $tasklogInfo = $tasklogModel->where($where)->find(); if($tasklogInfo) { if($tasklogInfo["finish_number"] >= $taskInfo["number"] || $tasklogInfo["is_finish"] == 1) { if($tasklogInfo["finish_number"] >= $taskInfo["number"]) { $tasklogInfo->is_finish = 1; $tasklogInfo->save(); } else { return false; } } $finish_number = $tasklogInfo["finish_number"]+$number; $where = []; $where["id"] = $tasklogInfo["id"]; $data = []; $data["finish_number"] = $finish_number; $data["pace"] = round($finish_number/$taskInfo["number"],2)*100; $data["finish_date"] = date("Ymd"); if($data["pace"]>=100) { $data["is_finish"] = 1; $data["finish_time"] = time(); } $res = $tasklogModel->update($data,$where); } else { $data = []; $data["user_id"] = $user_id; $data["task_id"] = $taskInfo["id"]; $data["finish_number"] = $number; $data["pace"] = round($number/$taskInfo["number"],2)*100; $data["finish_date"] = date("Ymd"); if($data["pace"]==100) { $data["is_finish"] = 1; $data["finish_time"] = time(); } $data["createtime"] = time(); $res = $tasklogModel->insertGetId($data); } return $res; } }