123456789101112131415161718192021222324252627282930 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\model;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class CompanyCatProfit extends Model
- {
- public function GetRate($companyNo,$cat_id,$field){
- $rate=$this->where(["companyNo"=>$companyNo,"cat_id"=>$cat_id])->value($field,0);
- if($rate==0){
- $parent = $this->name("cat")->where(["id"=>$cat_id])->value("pid",0);
- if($parent>0)$rate=$this->GetRate($companyNo,$parent,$field);
- }
- return $rate;
- }
-
- public function GetAllRate($companyNo,$cat_id){
- $rate=$this->where(['companyNo'=>$companyNo,'cat_id'=>$cat_id])->findOrEmpty();
- if($rate->isEmpty()){
- $parent = $this->name('cat')->where(['id'=>$cat_id])->value('pid',0);
- if($parent>0)$rate=$this->GetAllRate($companyNo,$parent);
- }
- return $rate;
- }
- }
|