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