shish 3 недель назад
Родитель
Сommit
8d64f27de4

+ 5 - 2
app-hd/controllers/PurchaseController.php

@@ -711,7 +711,9 @@ class PurchaseController extends BaseController
                     $ghsMainId,
                     $sendType,
                     $shMethodItemAmount,
-                    $shMethodBigNum
+                    $shMethodBigNum,
+                    $customId,
+                    $ghsInfo
                 );
 
                 // 如果产生了附加运费,与前面可能产生的 sendCost 进行累加或覆盖
@@ -738,7 +740,8 @@ class PurchaseController extends BaseController
                     $post['packCost'] ?? 0,
                     $post['sendCost'] ?? 0,
                     $post['wlName'] ?? '',
-                    $customId
+                    $customId,
+                    $ghsInfo
                 );
                 if ($shMethodError !== '') {
                     $transaction->rollBack();

+ 12 - 0
app-hd/controllers/ShMethodController.php

@@ -35,6 +35,18 @@ class ShMethodController extends BaseController
             $customId = $ghs['customId'] ?? 0;
             $configs = ShMethodClass::getAllConfigs($shopId, $mainId);
 
+            if (isset($ghs['homeRule']) && $ghs['homeRule'] == 1) {
+                foreach ($configs as &$config) {
+                    if ($config['style'] == 0) {
+                        $config['status'] = $ghs['home'] ?? 0;
+                        $config['minAmount'] = $ghs['homeAmount'] ?? 0;
+                        $config['minNum'] = $ghs['homeNum'] ?? 0;
+                        $config['unMeet'] = $ghs['homeUnMeet'] ?? 0;
+                        $config['unMeetFee'] = $ghs['homeUnFee'] ?? 0;
+                    }
+                }
+            }
+
             if ($customId > 0) {
                 $hasPaidSendCost = ShMethodClass::isSendCostPaidToday($customId);
                 $hasPaidPackCost = ShMethodClass::isPaidToday($customId);

+ 24 - 2
biz-ghs/order/classes/ShMethodClass.php

@@ -197,9 +197,10 @@ class ShMethodClass extends BaseClass
      * @param float $sendCost 已写入采购单的运费
      * @param string $wlName 物流公司名称(style=3 时必填)
      * @param int $customId 客户ID,用于判断当天是否已收过
+     * @param array|object $ghsInfo 客户与该供货商的关系信息(xhGhs)
      * @return string 空字符串表示通过,否则为需提示用户的错误文案
      */
-    public static function checkLimit($shopId, $mainId, $sendType, $actPrice, $bigNum, $packCost = 0, $sendCost = 0, $wlName = '', $customId = 0)
+    public static function checkLimit($shopId, $mainId, $sendType, $actPrice, $bigNum, $packCost = 0, $sendCost = 0, $wlName = '', $customId = 0, $ghsInfo = [])
     {
         $style = (int)$sendType;
         if ($style < 0 || $style > 4) {
@@ -207,10 +208,20 @@ class ShMethodClass extends BaseClass
         }
 
         $config = self::getConfig($shopId, $mainId, $style);
+
         if (empty($config)) {
             return '配送方式配置异常';
         }
 
+        if ($style === 0 && !empty($ghsInfo) && isset($ghsInfo['homeRule']) && $ghsInfo['homeRule'] == 1) {
+            // 如果 homeRule == 1,特定字段取xhGhs的设置(优先级最高),其余(如name)保留原配置
+            $config['status'] = $ghsInfo['home'] ?? 0;
+            $config['minAmount'] = $ghsInfo['homeAmount'] ?? 0;
+            $config['minNum'] = $ghsInfo['homeNum'] ?? 0;
+            $config['unMeet'] = $ghsInfo['homeUnMeet'] ?? 0;
+            $config['unMeetFee'] = $ghsInfo['homeUnFee'] ?? 0;
+        }
+
         $methodName = !empty($config['name']) ? $config['name'] : '该配送方式';
 
         // 配送方式已禁用,对齐旧逻辑「暂不支持送货上门,请选其它配送方式」
@@ -321,9 +332,10 @@ class ShMethodClass extends BaseClass
      * @param float $itemTotalAmount 花材合计金额(下单前,与前端 commodityPrice 一致)
      * @param int|float $bigNum 下单扎数
      * @param int $customId 客户ID,用于判断当天是否已收过
+     * @param array|object $ghsInfo 客户与该供货商的关系信息(xhGhs)
      * @return array ['sendCost' => 运费, 'packCost' => 包装费]
      */
-    public static function calcFee($shopId, $mainId, $sendType, $itemTotalAmount, $bigNum, $customId = 0)
+    public static function calcFee($shopId, $mainId, $sendType, $itemTotalAmount, $bigNum, $customId = 0, $ghsInfo = [])
     {
         $costs = ['sendCost' => 0, 'packCost' => 0];
         
@@ -333,10 +345,20 @@ class ShMethodClass extends BaseClass
         }
 
         $config = self::getConfig($shopId, $mainId, $style);
+
         if (empty($config)) {
             return $costs;
         }
 
+        if ($style === 0 && !empty($ghsInfo) && isset($ghsInfo['homeRule']) && $ghsInfo['homeRule'] == 1) {
+            // 如果 homeRule == 1,特定字段取xhGhs的设置(优先级最高),其余(如name)保留原配置
+            $config['status'] = $ghsInfo['home'] ?? 0;
+            $config['minAmount'] = $ghsInfo['homeAmount'] ?? 0;
+            $config['minNum'] = $ghsInfo['homeNum'] ?? 0;
+            $config['unMeet'] = $ghsInfo['homeUnMeet'] ?? 0;
+            $config['unMeetFee'] = $ghsInfo['homeUnFee'] ?? 0;
+        }
+
         // 直接合并 isBelowMinimum 的逻辑,方便理解,不再套用额外的方法
         $minAmount = isset($config['minAmount']) ? (float)$config['minAmount'] : 0.00;
         $minNum = isset($config['minNum']) ? (int)$config['minNum'] : 0;