GoodsDeduction.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2017/10/13
  6. * Time: 上午11:01
  7. */
  8. namespace app\frontend\modules\deduction;
  9. /**
  10. * 商品抵扣基类
  11. * Class GoodsDeduction
  12. * @package app\frontend\modules\deduction
  13. */
  14. abstract class GoodsDeduction
  15. {
  16. protected $deductionSettingCollection;
  17. function __construct(DeductionSettingCollection $deductionSettingCollection)
  18. {
  19. $this->deductionSettingCollection = $deductionSettingCollection;
  20. }
  21. abstract public function getCode();
  22. /**
  23. * @return DeductionSettingCollection
  24. */
  25. public function getDeductionSettingCollection()
  26. {
  27. return $this->deductionSettingCollection;
  28. }
  29. public function getMaxPriceProportion()
  30. {
  31. return $this->getDeductionSettingCollection()->getImportantAndValidMaxPriceProportion();
  32. }
  33. public function getMaxFixedAmount()
  34. {
  35. return $this->getDeductionSettingCollection()->getImportantAndValidMaxFixedAmount();
  36. }
  37. public function getMaxDeductionAmountCalculationType()
  38. {
  39. return $this->getDeductionSettingCollection()->getImportantAndValidMaxCalculationType();
  40. }
  41. public function getDeductionAmountType()
  42. {
  43. return $this->getDeductionSettingCollection()->getDeductionAmountType();
  44. }
  45. /**
  46. * 获取商品最少可以抵扣的价格比例
  47. * @return float
  48. */
  49. public function getMinPriceProportion()
  50. {
  51. return $this->getDeductionSettingCollection()->getImportantAndValidMinPriceProportion();
  52. }
  53. /**
  54. * 获取商品最少可以抵扣的固定金额
  55. * @return float
  56. */
  57. public function getMinFixedAmount()
  58. {
  59. return $this->getDeductionSettingCollection()->getImportantAndValidMinFixedAmount();
  60. }
  61. /**
  62. * 获取抵扣金额最小值计算方式
  63. * @return string
  64. */
  65. public function getMinDeductionAmountCalculationType()
  66. {
  67. return $this->getDeductionSettingCollection()->getImportantAndValidMinCalculationType();
  68. }
  69. /**
  70. * 影响最终抵扣金额返回方式
  71. * @return mixed|string
  72. */
  73. public function getAffectDeductionAmountType()
  74. {
  75. return $this->getDeductionSettingCollection()->getAffectDeductionAmount();
  76. }
  77. /**
  78. * 商品可使用抵扣
  79. * @param $goods
  80. * @return bool
  81. */
  82. abstract public function deductible($goods);
  83. }