CartGoodsBaseCartExtraChargesPriceNode.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2021/5/26
  8. * Time: 9:25
  9. */
  10. namespace app\frontend\modules\cart\node;
  11. use app\frontend\modules\cart\extra\BaseCartExtraCharges;
  12. use app\frontend\modules\cart\models\CartGoods;
  13. use app\frontend\modules\order\PriceNode;
  14. class CartGoodsBaseCartExtraChargesPriceNode extends PriceNode
  15. {
  16. protected $cartGoods;
  17. private $extraCharges;
  18. public function __construct(CartGoods $cartGoods,BaseCartExtraCharges $extraCharges, $weight)
  19. {
  20. $this->cartGoods = $cartGoods;
  21. $this->extraCharges = $extraCharges;
  22. parent::__construct($weight);
  23. }
  24. public function getKey()
  25. {
  26. return $this->extraCharges->getCode();
  27. }
  28. /**
  29. * @return float|int|mixed
  30. * @throws \app\common\exceptions\AppException
  31. */
  32. public function getPrice()
  33. {
  34. if ($this->cartGoods->isChecked()) {
  35. return $this->cartGoods->getPriceBefore($this->getKey()) + $this->extraCharges->getAmount();
  36. } else {
  37. return $this->cartGoods->getPriceBefore($this->getKey());
  38. }
  39. //return $this->cartGoods->getPriceBefore($this->getKey()) + $this->extraCharges->getAmount();
  40. }
  41. }