52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: blank
|
|
* Date: 2022/4/14
|
|
* Time: 15:24
|
|
*/
|
|
|
|
namespace app\frontend\modules\dispatch\models;
|
|
|
|
use app\frontend\modules\order\models\PreOrder;
|
|
|
|
/**
|
|
* 给需要自定义运费的订单使用
|
|
* Class DefaultOrderFreight
|
|
* @property PreOrder $order 订单类
|
|
* @property float $initialAmount 设置运费金额
|
|
* @property bool $discountDisable 是否禁用运费优惠计算
|
|
* @package app\frontend\modules\dispatch\models
|
|
*/
|
|
class DefaultOrderFreight extends OrderFreight
|
|
{
|
|
|
|
/**
|
|
* @var float
|
|
*/
|
|
protected $initialAmount;
|
|
|
|
public $discountDisable;
|
|
|
|
/**
|
|
* DefaultOrderFreight constructor.
|
|
* @param PreOrder $order 订单模型
|
|
* @param $initialFreight 运费初始金额
|
|
* @param bool $discountDisable 是否禁用运费优惠计算
|
|
*/
|
|
public function __construct(PreOrder $order, $initialFreight, $discountDisable = false)
|
|
{
|
|
$this->initialAmount = $initialFreight;
|
|
$this->discountDisable = $discountDisable;
|
|
parent::__construct($order);
|
|
}
|
|
|
|
public function getDiscounts()
|
|
{
|
|
if ($this->discountDisable) {
|
|
return collect([]);
|
|
}
|
|
return parent::getDiscounts(); // TODO: Change the autogenerated stub
|
|
}
|
|
|
|
} |