shish 3 週間 前
コミット
cf7937a051

+ 12 - 12
app-hd/controllers/NoticeController.php

@@ -198,9 +198,9 @@ class NoticeController extends PublicController
                     if (isset($cg->sendType) && in_array($cg->sendType, [0, 4])) {
                         $key = 'ghs_custom_today_has_get_pack_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
-                    }
-                    if (isset($cg->sendType) && $cg->sendType == 0) {
-                        $sendKey = 'ghs_custom_today_has_get_send_cost_' . $current . '_' . $customId;
+
+                        // 兼容快递收运费的情况
+                        $sendKey = 'ghs_custom_today_has_get_send_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                     }
                 }
@@ -417,9 +417,9 @@ class NoticeController extends PublicController
                     if (isset($cg->sendType) && in_array($cg->sendType, [0, 4])) {
                         $key = 'ghs_custom_today_has_get_pack_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
-                    }
-                    if (isset($cg->sendType) && $cg->sendType == 0) {
-                        $sendKey = 'ghs_custom_today_has_get_send_cost_' . $current . '_' . $customId;
+
+                        // 兼容快递收运费的情况
+                        $sendKey = 'ghs_custom_today_has_get_send_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                     }
                 }
@@ -585,9 +585,9 @@ class NoticeController extends PublicController
                     if (isset($cg->sendType) && in_array($cg->sendType, [0, 4])) {
                         $key = 'ghs_custom_today_has_get_pack_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
-                    }
-                    if (isset($cg->sendType) && $cg->sendType == 0) {
-                        $sendKey = 'ghs_custom_today_has_get_send_cost_' . $current . '_' . $customId;
+
+                        // 兼容快递收运费的情况
+                        $sendKey = 'ghs_custom_today_has_get_send_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                     }
 
@@ -842,9 +842,9 @@ class NoticeController extends PublicController
                                 if (isset($cg->sendType) && in_array($cg->sendType, [0, 4])) {
                                     $key = 'ghs_custom_today_has_get_pack_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                                     Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
-                                }
-                                if (isset($cg->sendType) && $cg->sendType == 0) {
-                                    $sendKey = 'ghs_custom_today_has_get_send_cost_' . $current . '_' . $customId;
+
+                                    // 兼容快递收运费的情况
+                                    $sendKey = 'ghs_custom_today_has_get_send_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                                     Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                                 }
                             }

+ 6 - 8
app-hd/controllers/PurchaseController.php

@@ -963,16 +963,14 @@ class PurchaseController extends BaseController
                     Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
                 }
             } else {
-                //标记当已收一次包装费/运费,岭南批发市场用的功能,只要有成功单就标记,不再要求金额必须>0
+                //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
                 $current = date("Y_m_d");
-                if (isset($info->sendType) && $info->sendType == 4) {
-                    $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
+                if (isset($info->sendType) && in_array($info->sendType, [0, 4])) {
+                    $key = 'ghs_custom_today_has_get_pack_cost_' . $info->sendType . '_' . $current . '_' . $customId;
                     Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
-                }
-                noticeUtil::push("运费:" . $info->sendCost . ' sendType:' . $info->sendType, '15280215347');
-                if (isset($info->sendType) && $info->sendType == 0) {
-                    noticeUtil::push("执行到了", '15280215347');
-                    $sendKey = 'ghs_custom_today_has_get_send_cost_' . $current . '_' . $customId;
+
+                    // 兼容快递收运费的情况
+                    $sendKey = 'ghs_custom_today_has_get_send_cost_' . $info->sendType . '_' . $current . '_' . $customId;
                     Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                 }
             }

+ 6 - 3
app-hd/controllers/ShMethodController.php

@@ -48,11 +48,14 @@ class ShMethodController extends BaseController
             }
 
             if ($customId > 0) {
-                $hasPaidSendCost = ShMethodClass::isSendCostPaidToday($customId);
-                $hasPaidPackCost = ShMethodClass::isPaidToday($customId);
-                
                 foreach ($configs as &$config) {
+                    $style = (int)($config['style'] ?? 0);
                     $unMeet = (int)($config['unMeet'] ?? 0);
+
+                    // 针对每个配送方式分别检查是否已支付运费或包装费
+                    $hasPaidSendCost = ShMethodClass::isSendCostPaidToday($customId, $style);
+                    $hasPaidPackCost = ShMethodClass::isPackPaidToday($customId, $style);
+
                     // 如果是加收运费或加收包装费,并且今天已经收过对应的费用
                     // 则将前端展示的条件清空(设为0),从而不再显示要收附加费的提示
                     if ($unMeet === 0 && $hasPaidSendCost) {

+ 11 - 9
biz-ghs/order/classes/ShMethodClass.php

@@ -270,10 +270,10 @@ class ShMethodClass extends BaseClass
             $feeToCheck = $unMeet === 2 ? $packCost : $sendCost;
             
             // 如果今天已经收过对应的附加费用,则直接通过校验
-            if ($unMeet === 2 && self::isPaidToday($customId)) {
+            if ($unMeet === 2 && self::isPackPaidToday($customId, $style)) {
                 return '';
             }
-            if ($unMeet === 0 && self::isSendCostPaidToday($customId)) {
+            if ($unMeet === 0 && self::isSendCostPaidToday($customId, $style)) {
                 return '';
             }
             
@@ -287,18 +287,19 @@ class ShMethodClass extends BaseClass
     }
 
     /**
-     * 判断当天是否已经收过附加费(运费或包装费)
+     * 判断当天是否已经收过附加费(包装费)
      * 与其他逻辑共用同一个 Redis Key,保证一天只收一次
      * @param int $customId 客户ID
+     * @param int $sendType 配送方式 (0: 送货, 4: 快递)
      * @return bool
      */
-    public static function isPaidToday($customId)
+    public static function isPackPaidToday($customId, $sendType = 0)
     {
         if (empty($customId)) {
             return false;
         }
         $current = date("Y_m_d");
-        $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
+        $key = 'ghs_custom_today_has_get_pack_cost_' . $sendType . '_' . $current . '_' . $customId;
         $has = \Yii::$app->redis->executeCommand('GET', [$key]);
         return (!empty($has) && $has == 1);
     }
@@ -306,15 +307,16 @@ class ShMethodClass extends BaseClass
     /**
      * 判断当天是否已经收过运费
      * @param int $customId 客户ID
+     * @param int $sendType 配送方式
      * @return bool
      */
-    public static function isSendCostPaidToday($customId)
+    public static function isSendCostPaidToday($customId, $sendType = 0)
     {
         if (empty($customId)) {
             return false;
         }
         $current = date("Y_m_d");
-        $key = 'ghs_custom_today_has_get_send_cost_' . $current . '_' . $customId;
+        $key = 'ghs_custom_today_has_get_send_cost_' . $sendType . '_' . $current . '_' . $customId;
         $has = \Yii::$app->redis->executeCommand('GET', [$key]);
         return (!empty($has) && $has == 1);
     }
@@ -380,11 +382,11 @@ class ShMethodClass extends BaseClass
         if ($unMeetFee > 0) {
             // unMeet: 0 加收运费(默认),2 加收包装费
             if ($unMeet === 0) {
-                if (!self::isSendCostPaidToday($customId)) {
+                if (!self::isSendCostPaidToday($customId, $style)) {
                     $costs['sendCost'] = $unMeetFee;
                 }
             } elseif ($unMeet === 2) {
-                if (!self::isPaidToday($customId)) {
+                if (!self::isPackPaidToday($customId, $style)) {
                     $costs['packCost'] = $unMeetFee;
                 }
             }