CompanyPlatformCatProfit.php 992 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class CompanyPlatformCatProfit extends Model
  9. {
  10. public function GetRate($companyNo,$cat_id,$platform,$field){
  11. $rate=$this->where(['companyNo'=>$companyNo,'cat_id'=>$cat_id,'platform_id'=>$platform])->value($field,'');
  12. if($rate===''){
  13. $parent = $this->name('cat')->where(['id'=>$cat_id])->value('pid',0);
  14. if($parent>0)$rate=$this->GetRate($companyNo,$parent,$platform,$field);
  15. else$rate=0;
  16. }
  17. return $rate;
  18. }
  19. public function GetAllRate($companyNo,$cat_id,$platform){
  20. $rate=$this->where(['companyNo'=>$companyNo,'cat_id'=>$cat_id,'platform_id'=>$platform])->findOrEmpty();
  21. if($rate->isEmpty()){
  22. $parent = $this->name('cat')->where(['id'=>$cat_id])->value('pid',0);
  23. if($parent>0)$rate=$this->GetAllRate($companyNo,$parent,$platform);
  24. }
  25. return $rate;
  26. }
  27. }