PointGoodsDeductionSetting.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2017/10/13
  6. * Time: 下午1:49
  7. */
  8. namespace app\frontend\modules\finance\deduction\deductionSettings;
  9. use app\framework\Support\Facades\Log;
  10. use app\frontend\models\Goods;
  11. use app\frontend\modules\deduction\DeductionSettingInterface;
  12. class PointGoodsDeductionSetting implements DeductionSettingInterface
  13. {
  14. public function getWeight()
  15. {
  16. return 10;
  17. }
  18. /**
  19. * @var \app\frontend\models\goods\Sale
  20. */
  21. private $setting;
  22. // todo 抵扣设置应该分为商品抵扣和订单抵扣两类, 现在缺少订单抵扣设置 ,
  23. function __construct($goods)
  24. {
  25. $this->setting = $goods->hasOneSale;
  26. }
  27. // todo 这个方法应该放在订单抵扣设置中
  28. public function isEnableDeductDispatchPrice()
  29. {
  30. Log::debug("监听订单抵扣设置",\Setting::get('point.set.point_freight'));
  31. return \Setting::get('point.set.point_freight');
  32. }
  33. public function isDispatchDisable()
  34. {
  35. // 商品抵扣设置为0,则商品不参与抵扣
  36. return !\Setting::get('point.set.point_freight') || $this->setting->max_point_deduct === '0';
  37. }
  38. public function isMaxDisable()
  39. {
  40. return !\Setting::get('point.set.point_deduct') || $this->setting->max_point_deduct === '0';
  41. }
  42. public function isMinDisable()
  43. {
  44. return !\Setting::get('point.set.point_deduct') || $this->setting->min_point_deduct === '0';
  45. }
  46. public function getMaxFixedAmount()
  47. {
  48. return str_replace('%', '', $this->setting->max_point_deduct) ?: false;
  49. }
  50. public function getMaxPriceProportion()
  51. {
  52. if (!$this->setting->max_point_deduct) {
  53. return false;
  54. }
  55. return str_replace('%', '', $this->setting->max_point_deduct);
  56. }
  57. public function getMaxDeductionType()
  58. {
  59. // 商品抵扣设置为空,则商品未设置独立抵扣
  60. if($this->setting->max_point_deduct === ''){
  61. return false;
  62. }
  63. if(strexists($this->setting->max_point_deduct, '%')){
  64. return 'GoodsPriceProportion';
  65. }
  66. return 'FixedAmount';
  67. }
  68. public function getMinFixedAmount()
  69. {
  70. return str_replace('%', '', $this->setting->min_point_deduct) ?: false;
  71. }
  72. public function getMinPriceProportion()
  73. {
  74. if (!$this->setting->min_point_deduct) {
  75. return false;
  76. }
  77. return str_replace('%', '', $this->setting->min_point_deduct);
  78. }
  79. public function getMinDeductionType()
  80. {
  81. // 商品抵扣设置为空,则商品未设置独立抵扣
  82. if($this->setting->min_point_deduct === ''){
  83. return false;
  84. }
  85. if(strexists($this->setting->min_point_deduct, '%')){
  86. return 'GoodsPriceProportion';
  87. }
  88. return 'FixedAmount';
  89. }
  90. public function getDeductionAmountType()
  91. {
  92. return false;
  93. }
  94. public function getAffectDeductionAmount()
  95. {
  96. if (\Setting::get('point.set.point_deduction_integer')) {
  97. return 'integer';
  98. }
  99. return false;
  100. }
  101. }