BaseGoodsPriceAdapter.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020/9/3
  6. * Time: 15:27
  7. */
  8. namespace app\frontend\modules\orderGoods\price\adapter;
  9. abstract class BaseGoodsPriceAdapter
  10. {
  11. protected $goods;
  12. protected $dealPrice;
  13. protected $appoint_price;
  14. public function __construct($goods)
  15. {
  16. $this->goods = $goods;
  17. }
  18. final public function setAppointPrice($price)
  19. {
  20. $this->appoint_price = $price;
  21. }
  22. //成交价
  23. public function getDealPrice()
  24. {
  25. //指定成交价格
  26. if (isset($this->appoint_price)) {
  27. return $this->appoint_price;
  28. }
  29. $this->dealPrice = $this->_getDealPrice();
  30. if (is_null($this->dealPrice)) {
  31. $this->dealPrice = $this->getDefaultDealPrice();
  32. }
  33. return $this->dealPrice;
  34. }
  35. abstract protected function getDefaultDealPrice();
  36. abstract protected function _getDealPrice();
  37. //商品成本价
  38. abstract function getCostPrice();
  39. //商品现价
  40. abstract function getPrice();
  41. //商品原价/市场价
  42. abstract function getMarketPrice();
  43. abstract protected function goods();
  44. }