OrderGoodsDeductionPriceNode.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2019/1/23
  6. * Time: 3:01 PM
  7. */
  8. namespace app\frontend\modules\orderGoods;
  9. use app\common\modules\orderGoods\models\PreOrderGoods;
  10. use app\frontend\modules\deduction\orderGoods\PreOrderGoodsDeduction;
  11. use app\frontend\modules\order\PriceNode;
  12. use app\frontend\modules\orderGoods\discount\BaseDiscount;
  13. use app\frontend\modules\orderGoods\price\option\BaseOrderGoodsPrice;
  14. class OrderGoodsDeductionPriceNode extends BaseOrderGoodsPriceNode
  15. {
  16. /**
  17. * @var PreOrderGoodsDeduction
  18. */
  19. private $preOrderGoodsDeduction;
  20. public function __construct(BaseOrderGoodsPrice $orderGoodsPrice, PreOrderGoodsDeduction $preOrderGoodsDeduction, $weight)
  21. {
  22. $this->preOrderGoodsDeduction = $preOrderGoodsDeduction;
  23. parent::__construct($orderGoodsPrice, $weight);
  24. }
  25. function getKey()
  26. {
  27. return $this->preOrderGoodsDeduction->code.'Deduction';
  28. }
  29. /**
  30. * @return float|int|mixed
  31. * @throws \app\common\exceptions\AppException
  32. */
  33. function getPrice()
  34. {
  35. return $this->orderGoodsPrice->getPriceBefore($this->getKey()) - $this->preOrderGoodsDeduction->used_amount;
  36. }
  37. }