From 519ef1464d138b6d11a20edeebb9848bb55a1397 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Mon, 1 Jul 2024 15:50:47 +0800 Subject: [PATCH] YS --- application/controllers/Api/Remind.php | 7 ++++--- application/models/Squirrel.php | 15 ++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/application/controllers/Api/Remind.php b/application/controllers/Api/Remind.php index 952e7a5..ce43328 100644 --- a/application/controllers/Api/Remind.php +++ b/application/controllers/Api/Remind.php @@ -47,10 +47,11 @@ class Api_RemindController extends Ctrl_Api{ $RemindModel = new RemindModel(); $uid= empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; $id= empty($this->POST['id'])?Tool_Fnc::apiMsg('待办ID缺失', '500'):$this->POST['id']; + $status = $RemindModel->field('status')->where("id={$id} and user_id={$uid}")->fRow(); $data['id'] = $id; - $data['status'] = 1; - if(!$RemindModel->update($data)) Tool_Fnc::apiMsg('删除失败', '500'); - Tool_Fnc::apiMsg('成功', '200'); + $data['status'] = $status==0?"1":0; + if(!$RemindModel->update($data)) Tool_Fnc::apiMsg('设置失败', '500'); + Tool_Fnc::apiMsg('设置成功', '200'); } function time_tran($the_time) { $now_time = time(); diff --git a/application/models/Squirrel.php b/application/models/Squirrel.php index de49fc0..7713f0f 100644 --- a/application/models/Squirrel.php +++ b/application/models/Squirrel.php @@ -86,15 +86,20 @@ class SquirrelModel extends Orm_Base{ public function partent($cage){ $time = date('Y-m-d',time()); - $exec=$this->field('id,number,sex')->where("is_delete=0 and is_kill=0 and grow_time<'{$time}'"); + $data=$this->field('id,number,sex')->where("is_delete=0 and is_kill=0 and grow_time<'{$time}' and sex in (1,2)")->fList(); + $data[] = ['id'=>0,'number'=>"未知",'sex'=>2]; + $data[] = ['id'=>0,'number'=>"未知",'sex'=>1]; if(!empty($cage)){ $CageModel = new CageModel(); $cageinfo = $CageModel->field("type")->where("id={$cage}")->fRow(); - if($cageinfo['type']==2) $exec->where("cage={$cage}"); + if($cageinfo['type']==2) { + $data = []; + $n = $this->field('id,number,sex')->where("is_delete=0 and is_kill=0 and grow_time<'{$time}' and sex=1 and cage={$cage}")->fRow(); + $m = $this->field('id,number,sex')->where("is_delete=0 and is_kill=0 and grow_time<'{$time}' and sex=2 and cage={$cage}")->fList(); + $data[]=empty($n)?['id'=>0,'number'=>"未知",'sex'=>1]:$n; + $data[]=empty($m)?['id'=>0,'number'=>"未知",'sex'=>2]:$m; + } } - $data = $exec->fList(); - $data[] = ['id'=>0,'number'=>"未知",'sex'=>2]; - $data[] = ['id'=>0,'number'=>"未知",'sex'=>1]; return $data; } public function getIcon($squirrel){