GoodsInstallLink.php 749 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\common\model;
  3. use think\db\Query;
  4. use think\Model;
  5. /**
  6. * @property GoodsInstall install
  7. */
  8. class GoodsInstallLink extends Model
  9. {
  10. public function scopeSku(Query $query,$sku_id,$goods_id=null){
  11. $query->where('goods_sku_id',$sku_id);
  12. if($goods_id){
  13. $query->where('goods_id',$goods_id);
  14. }
  15. }
  16. public function install(){
  17. return $this->belongsTo(GoodsInstall::class);
  18. }
  19. public static function getFee($sku_id,$num){
  20. $installLink=self::where('goods_sku_id',$sku_id)->with(['install'])->find();
  21. $fee=0;
  22. if($installLink){
  23. $install=$installLink->install;
  24. $fee=$install->getFee($num);
  25. }
  26. return $fee;
  27. }
  28. }