| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- /**
- * Created by PhpStorm.
- * Name: 芸众商城系统
- * Author: 广州市芸众信息科技有限公司
- * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
- * Date: 2022/5/16
- * Time: 17:47
- */
- namespace app\frontend\modules\dispatch\models;
- use app\common\facades\Setting;
- use app\frontend\modules\order\discount\BaseDiscount;
- class fullAmountFreeFreight extends BaseDiscount
- {
- protected $name = '全场运费满额减';
- protected $code = 'freightEnoughReduce';
- public $amount;
- /**
- * 获取总金额
- * @return float
- */
- public function getAmount()
- {
- if (isset($this->amount)) {
- return $this->amount;
- }
- $this->amount = $this->_getAmount();
- return $this->amount;
- }
- /**
- * @return int|number
- * @throws \app\common\exceptions\AppException
- */
- protected function _getAmount()
- {
- if (!Setting::get('enoughReduce.freeFreight.open')) {
- trace_log()->freight('全场运费满额减','设置未开启');
- return 0;
- }
- //只有商城、应用市场、应用市场-子平台
- if(!in_array($this->order->plugin_id,[0,57,59])){
- trace_log()->freight('全场运费满额减','只有商城,应用市场,应用市场-子平台订单参加');
- return 0;
- }
- // 不参与包邮地区
- if (in_array($this->order->orderAddress->city_id, Setting::get('enoughReduce.freeFreight.city_ids'))) {
- trace_log()->freight('全场运费满额减',"{$this->order->orderAddress->city_id}地区不参加");
- return 0;
- }
- // 订单金额满足满减金额(订单抵扣后价格)
- if (Setting::get('enoughReduce.freeFreight.amount_type') == 1) {
- if (($this->order->getPriceBefore('orderFee') - $this->order->getDispatchAmount()) >= Setting::get('enoughReduce.freeFreight.enough')) {
- trace_log()->freight('全场运费满额减',"订单金额{$this->order->getPriceBefore('orderFee')}满足".Setting::get('enoughReduce.freeFreight.enough'));
- return $this->order->getDispatchAmount();
- }
- trace_log()->freight('全场运费满额减','订单抵扣后价格计算');
- return 0;
- }
- return 0;
- }
- }
|