소스 검색

细节优化

萤火科技 1 년 전
부모
커밋
7718f52b58
3개의 변경된 파일과 4개의 추가작업 그리고 78개의 파일을 삭제
  1. 1 53
      app/api/service/order/Checkout.php
  2. 0 20
      app/common/model/Coupon.php
  3. 3 5
      app/common/service/delivery/Express.php

+ 1 - 53
app/api/service/order/Checkout.php

@@ -71,14 +71,6 @@ class Checkout extends BaseService
         'isUsePoints' => true,          // 积分抵扣
         'isUsePoints' => true,          // 积分抵扣
     ];
     ];
 
 
-    // 记录叠加的优惠 (动态计算)
-    private array $stackingData = [
-        // 已启用的叠加优惠
-        'enabled' => [],
-        // 禁用的叠加优惠
-        'disabled' => []
-    ];
-
     /**
     /**
      * 订单来源
      * 订单来源
      * @var array
      * @var array
@@ -597,10 +589,6 @@ class Checkout extends BaseService
         helper::setDataAttribute($this->goodsList, [
         helper::setDataAttribute($this->goodsList, [
             'coupon_money' => 0,    // 优惠券抵扣金额
             'coupon_money' => 0,    // 优惠券抵扣金额
         ], true);
         ], true);
-        // 验证订单叠加优惠中是否支持满额立减
-        if ($this->checkDisabledStacking(DiscountTypeEnum::COUPON)) {
-            return;
-        }
         // 验证选择的优惠券ID是否合法
         // 验证选择的优惠券ID是否合法
         if (!$this->verifyOrderCouponId($userCouponId, $couponList)) {
         if (!$this->verifyOrderCouponId($userCouponId, $couponList)) {
             return;
             return;
@@ -625,8 +613,6 @@ class Checkout extends BaseService
         // 记录订单优惠券信息
         // 记录订单优惠券信息
         $this->orderData['couponId'] = $userCouponId;
         $this->orderData['couponId'] = $userCouponId;
         $this->orderData['couponMoney'] = helper::number2(helper::bcdiv($CouponMoney->getActualReducedMoney(), 100));
         $this->orderData['couponMoney'] = helper::number2(helper::bcdiv($CouponMoney->getActualReducedMoney(), 100));
-        // 记录启用的叠加优惠
-        $this->updateEnabledStacking(DiscountTypeEnum::COUPON);
     }
     }
 
 
     /**
     /**
@@ -692,11 +678,9 @@ class Checkout extends BaseService
             $notInRuleGoodsName = $ExpressService->getNotInRuleGoodsName();
             $notInRuleGoodsName = $ExpressService->getNotInRuleGoodsName();
             $this->setError("很抱歉,您的收货地址不在商品 [{$notInRuleGoodsName}] 的配送范围内");
             $this->setError("很抱歉,您的收货地址不在商品 [{$notInRuleGoodsName}] 的配送范围内");
         }
         }
-        // 是否参与满额包邮
-        $allowFullFree = !$this->checkDisabledStacking(DiscountTypeEnum::FULL_FREE);
         // 订单总运费金额
         // 订单总运费金额
         $this->orderData['isIntraRegion'] = $isIntraRegion;
         $this->orderData['isIntraRegion'] = $isIntraRegion;
-        $this->orderData['expressPrice'] = $ExpressService->getDeliveryFee($allowFullFree);
+        $this->orderData['expressPrice'] = $ExpressService->getDeliveryFee(true);
     }
     }
 
 
     /**
     /**
@@ -925,40 +909,4 @@ class Checkout extends BaseService
             'detail' => $address['detail'],
             'detail' => $address['detail'],
         ]);
         ]);
     }
     }
-
-    /**
-     * 记录启用的叠加优惠数据
-     * @param string $value
-     * @return void
-     */
-    private function updateEnabledStacking(string $value)
-    {
-        if (!in_array($value, $this->stackingData['enabled'])) {
-            $this->stackingData['enabled'][] = $value;
-        }
-    }
-
-    /**
-     * 记录禁用的叠加优惠数据
-     * @param array $disabled
-     * @return void
-     */
-    private function updateDisabledStacking(array $disabled)
-    {
-        foreach ($disabled as $value) {
-            if (!in_array($value, $this->stackingData['disabled'])) {
-                $this->stackingData['disabled'][] = $value;
-            }
-        }
-    }
-
-    /**
-     * 验证叠加优惠是否禁用
-     * @param string $discountType
-     * @return bool
-     */
-    private function checkDisabledStacking(string $discountType): bool
-    {
-        return \in_array($discountType, $this->stackingData['disabled']);
-    }
 }
 }

+ 0 - 20
app/common/model/Coupon.php

@@ -102,16 +102,6 @@ class Coupon extends BaseModel
         return $config;
         return $config;
     }
     }
 
 
-    /**
-     * 获取器:可叠加的优惠方式
-     * @param $value
-     * @return array
-     */
-    public function getStackingAttr($value): array
-    {
-        return !empty($value) ? helper::jsonDecode($value) : [];
-    }
-
     /**
     /**
      * 修改器:格式化折扣率
      * 修改器:格式化折扣率
      * @param $value
      * @param $value
@@ -132,16 +122,6 @@ class Coupon extends BaseModel
         return helper::jsonEncode($array);
         return helper::jsonEncode($array);
     }
     }
 
 
-    /**
-     * 修改器:可叠加的优惠方式
-     * @param $value
-     * @return string
-     */
-    public function setStackingAttr($value): string
-    {
-        return helper::jsonEncode($value);
-    }
-
     /**
     /**
      * 优惠券详情
      * 优惠券详情
      * @param int $couponId 优惠券ID
      * @param int $couponId 优惠券ID

+ 3 - 5
app/common/service/delivery/Express.php

@@ -95,19 +95,18 @@ class Express extends BaseService
     /**
     /**
      * 获取订单的配送费用
      * 获取订单的配送费用
      * @param bool $allowFullFree 是否参与满额包邮
      * @param bool $allowFullFree 是否参与满额包邮
-     * @param array $enabledStacking 启用的叠加优惠
      * @return string
      * @return string
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\db\exception\ModelNotFoundException
      */
      */
-    public function getDeliveryFee(bool $allowFullFree, array $enabledStacking): string
+    public function getDeliveryFee(bool $allowFullFree): string
     {
     {
         if (empty($this->cityId) || empty($this->goodsList) || $this->notInRuleGoodsId > 0) {
         if (empty($this->cityId) || empty($this->goodsList) || $this->notInRuleGoodsId > 0) {
             return helper::number2(0.00);
             return helper::number2(0.00);
         }
         }
         // 处理满额包邮
         // 处理满额包邮
-        $this->freeShipping($allowFullFree, $enabledStacking);
+        $this->freeShipping($allowFullFree);
         // 计算配送金额
         // 计算配送金额
         foreach ($this->data as &$item) {
         foreach ($this->data as &$item) {
             // 计算当前配送模板的运费
             // 计算当前配送模板的运费
@@ -160,13 +159,12 @@ class Express extends BaseService
     /**
     /**
      * 商品满额包邮
      * 商品满额包邮
      * @param bool $allowFullFree 是否参与满额包邮
      * @param bool $allowFullFree 是否参与满额包邮
-     * @param array $enabledStacking 启用的叠加优惠
      * @return void
      * @return void
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\db\exception\ModelNotFoundException
      */
      */
-    private function freeShipping(bool $allowFullFree, array $enabledStacking): void
+    private function freeShipping(bool $allowFullFree): void
     {
     {
         // 设置默认数据:包邮的商品列表
         // 设置默认数据:包邮的商品列表
         helper::setDataAttribute($this->data, ['free_goods_list' => []], true);
         helper::setDataAttribute($this->data, ['free_goods_list' => []], true);