From 7d7b61ce8643b8a5eb734476141ed6543a1a96e2 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Mon, 20 May 2024 14:44:32 +0800 Subject: [PATCH] YS --- application/models/NewSquirrel.php | 15 +++++++++++---- application/models/Squirrel.php | 8 ++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/application/models/NewSquirrel.php b/application/models/NewSquirrel.php index eb53d2e..f577e45 100644 --- a/application/models/NewSquirrel.php +++ b/application/models/NewSquirrel.php @@ -24,14 +24,21 @@ class NewSquirrelModel extends Orm_Base{ ); public $pk = 'id'; public function getModelList($params){ - $SquirrelModel = new SquirrelModel; + $CageModel = new CageModel(); //获取幼崽信息 - $data=$this->field('id,count,birthday,father,mother,strains,gene,remark')->where("id>0 {$params['where']}")->fList(); - + $data=$this->field('id,count,birthday,father,mother,strains,gene,remark,cage')->where("id>0 {$params['where']}")->fList(); + foreach($data as $key => &$val){ + $val['cage'] = $CageModel->field('number')->where("id={$val['cage']}")->fRow()['number']; + $val['icon'] = "/public/icon/small.png"; + } return $data; } public function getOneInfo($squirrel){ - return $this->field('id,count,birthday,father,mother,strains,gene,remark')->where("id={$squirrel}")->fRow(); + $CageModel = new CageModel(); + $data = $this->field('id,count,birthday,father,mother,strains,gene,remark,cage')->where("id={$squirrel}")->fRow(); + $data['cage'] = $CageModel->field('number')->where("id={$data['cage']}")->fRow()['number']; + $data['icon'] = "/public/icon/small.png"; + return $data; } } diff --git a/application/models/Squirrel.php b/application/models/Squirrel.php index 853b161..72b5c39 100644 --- a/application/models/Squirrel.php +++ b/application/models/Squirrel.php @@ -84,10 +84,14 @@ class SquirrelModel extends Orm_Base{ public function getIcon($squirrel){ $date = strtotime(date('Y-m-d',time())); $info = $this->field('nursing_time')->where("id={$squirrel}")->fRow(); - if(strtotime($info['nursing_time'])>$date){ + if(empty($info)){ $data['icon'] = Yaf_Registry::get("config")->cangshu->url->small; }else{ - $data['icon'] = Yaf_Registry::get("config")->cangshu->url->big; + if(strtotime($info['nursing_time'])<$date){ + $data['icon'] = Yaf_Registry::get("config")->cangshu->url->big; + }else{ + $data['icon'] = Yaf_Registry::get("config")->cangshu->url->small; + } } return $data; }