Pārlūkot izejas kodu

Merge branch 'master' into redesign‌-260706

shish 1 dienu atpakaļ
vecāks
revīzija
b99e59f03f

+ 5 - 0
app-ghs/controllers/CustomController.php

@@ -1113,6 +1113,11 @@ class CustomController extends BaseController
         if (empty($ghs)) {
             util::fail('没有找到供货商');
         }
+        if (isset($get['home'])) {
+            $home = (int)$get['home'];
+            $custom->home = $home;
+            $ghs->home = $home;
+        }
         $custom->homeAmount = $homeAmount;
         $custom->homeNum = $homeNum;
         $custom->homeUnMeet = $homeUnMeet;

+ 1 - 1
app-ghs/controllers/ShMethodController.php

@@ -67,7 +67,7 @@ class ShMethodController extends BaseController
      * - sort: 排序
      * - minAmount: 最低消费金额
      * - minNum: 最低消费数量
-     * - unMeet: 不满条件处理方式 (0: 收运费, 1: 不能下单, 2: 收包装费)
+     * - unMeet: 不满条件处理方式 (0: 收运费, 1: 收包装费, 2: 不能下单)
      * - unMeetFee: 运费/包装费金额
      * - startKm: 起步公里数
      * - startPrice: 起步价格

+ 4 - 3
app-ghs/controllers/TestController.php

@@ -494,9 +494,10 @@ class TestController extends BaseController
             //['name' => '亳州花鲜谷', 'merchantNo' => '82238105992004A', 'wx' => [908947821, 908946480], 'zfb' => '2088780700742980'],
             //['name' => '福建清流美朵花业', 'merchantNo' => '82239505992002F', 'wx' => [909185571, 2000017120], 'zfb' => '2088780716665741'],
             //['name' => '东莞丰行', 'merchantNo' => '8226020599200RW', 'wx' => [909917474, 909917851], 'zfb' => '2088780774491467'],
-            ['name' => '中山淘花里小榄店', 'merchantNo' => '8226030599200D5', 'wx' => [911061554, 911061963], 'zfb' => '2088780851935068'],
-            ['name' => '重庆大金地', 'merchantNo' => '8226900599201GA', 'wx' => [910648990, 910644127], 'zfb' => '2088780830897617'],
-            ['name' => '云南珑松珠海店', 'merchantNo' => '82258505992009Q', 'wx' => [910384498, 910385532], 'zfb' => '2088780804010303'],
+            ['name' => '商丘花鲜谷鲜花', 'merchantNo' => '82250605992009Q', 'wx' => [911392567, 911392641], 'zfb' => '2088780883539375'],
+            //['name' => '中山淘花里小榄店', 'merchantNo' => '8226030599200D5', 'wx' => [911061554, 911061963], 'zfb' => '2088780851935068'],
+            //['name' => '重庆大金地', 'merchantNo' => '8226900599201GA', 'wx' => [910648990, 910644127], 'zfb' => '2088780830897617'],
+            //['name' => '云南珑松珠海店', 'merchantNo' => '82258505992009Q', 'wx' => [910384498, 910385532], 'zfb' => '2088780804010303'],
             //['name' => '义乌我要花', 'merchantNo' => '82239505992002H', 'wx' => [910330169, 910330807], 'zfb' => '2088780802113602'],
             //['name' => '仁寿花鲜谷', 'merchantNo' => '82266705992003V', 'wx' => [910335651, 910335572], 'zfb' => '2088780803109765'],
             //['name' => '泉州花多多批发', 'merchantNo' => '8223970599200LK', 'wx' => [910038898, 910040329], 'zfb' => '2088780782679844'],

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

@@ -192,14 +192,13 @@ class NoticeController extends PublicController
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
                     }
                 } else {
-                    //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
+                    //标记当配送方式已成功下过单,后续不再要求门槛或加收费用
                     $customId = $cg->customId ?? 0;
                     $current = date("Y_m_d");
-                    if (isset($cg->sendType) && in_array($cg->sendType, [0, 4])) {
+                    if (isset($cg->sendType)) {
                         $key = 'ghs_custom_today_has_get_pack_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
 
-                        // 兼容快递收运费的情况
                         $sendKey = 'ghs_custom_today_has_get_send_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                     }
@@ -411,14 +410,13 @@ class NoticeController extends PublicController
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
                     }
                 } else {
-                    //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
+                    //标记当配送方式已成功下过单,后续不再要求门槛或加收费用
                     $customId = $cg->customId ?? 0;
                     $current = date("Y_m_d");
-                    if (isset($cg->sendType) && in_array($cg->sendType, [0, 4])) {
+                    if (isset($cg->sendType)) {
                         $key = 'ghs_custom_today_has_get_pack_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
 
-                        // 兼容快递收运费的情况
                         $sendKey = 'ghs_custom_today_has_get_send_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                     }
@@ -579,14 +577,13 @@ class NoticeController extends PublicController
                     }
                 } else {
 
-                    //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
+                    //标记当配送方式已成功下过单,后续不再要求门槛或加收费用
                     $customId = $cg->customId ?? 0;
                     $current = date("Y_m_d");
-                    if (isset($cg->sendType) && in_array($cg->sendType, [0, 4])) {
+                    if (isset($cg->sendType)) {
                         $key = 'ghs_custom_today_has_get_pack_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
 
-                        // 兼容快递收运费的情况
                         $sendKey = 'ghs_custom_today_has_get_send_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                         Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                     }
@@ -836,14 +833,13 @@ class NoticeController extends PublicController
                                 Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
                             }
                         } else {
-                                //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
+                                //标记当配送方式已成功下过单,后续不再要求门槛或加收费用
                                 $customId = $cg->customId ?? 0;
                                 $current = date("Y_m_d");
-                                if (isset($cg->sendType) && in_array($cg->sendType, [0, 4])) {
+                                if (isset($cg->sendType)) {
                                     $key = 'ghs_custom_today_has_get_pack_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                                     Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
 
-                                    // 兼容快递收运费的情况
                                     $sendKey = 'ghs_custom_today_has_get_send_cost_' . $cg->sendType . '_' . $current . '_' . $customId;
                                     Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                                 }

+ 3 - 3
app-hd/controllers/PurchaseController.php

@@ -1036,13 +1036,13 @@ class PurchaseController extends BaseController
                     Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
                 }
             } else {
-                //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
+                //标记当配送方式已收一次包装费/运费,只要有成功单就标记,后续不再重复要求门槛或加收费用
                 $current = date("Y_m_d");
-                if (isset($info->sendType) && in_array($info->sendType, [0, 4])) {
+                if (isset($info->sendType)) {
                     $key = 'ghs_custom_today_has_get_pack_cost_' . $info->sendType . '_' . $current . '_' . $customId;
                     Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
 
-                    // 兼容快递收运费的情况
+                    // 兼容快递/送货/跑腿收运费或限制下单的情况
                     $sendKey = 'ghs_custom_today_has_get_send_cost_' . $info->sendType . '_' . $current . '_' . $customId;
                     Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
                 }

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

@@ -59,13 +59,9 @@ class ShMethodController extends BaseController
                     $hasPaidSendCost = ShMethodClass::isSendCostPaidToday($customId, $style);
                     $hasPaidPackCost = ShMethodClass::isPackPaidToday($customId, $style);
 
-                    // 如果是加收运费或加收包装费,并且今天已经收过对应的费用
-                    // 则将前端展示的条件清空(设为0),从而不再显示要收附加费的提示
-                    if ($unMeet === 0 && $hasPaidSendCost) {
-                        $config['minAmount'] = 0;
-                        $config['minNum'] = 0;
-                        $config['unMeetFee'] = 0;
-                    } elseif ($unMeet === 2 && $hasPaidPackCost) {
+                    // 如果是加收运费、加收包装费或不能下单,并且今天已经成功下单/收取过费用
+                    // 则将前端展示的条件清空(设为0),从而不再显示要收附加费或限制下单的提示
+                    if (($unMeet === 0 && $hasPaidSendCost) || ($unMeet === 1 && $hasPaidPackCost) || ($unMeet === 2 && ($hasPaidSendCost || $hasPaidPackCost))) {
                         $config['minAmount'] = 0;
                         $config['minNum'] = 0;
                         $config['unMeetFee'] = 0;

+ 12 - 8
biz-ghs/order/classes/ShMethodClass.php

@@ -254,7 +254,11 @@ class ShMethodClass extends BaseClass
         $unMeetFee = isset($config['unMeetFee']) ? (float)$config['unMeetFee'] : 0;
 
         // 不满最低消费且不允许下单
-        if ($unMeet === 1) {
+        if ($unMeet === 2) {
+            // 如果当天该配送方式已成功下过单,不再限制,直接放行
+            if (self::isPackPaidToday($customId, $style) || self::isSendCostPaidToday($customId, $style)) {
+                return '';
+            }
             if ($minAmount > 0 && (float)$actPrice < $minAmount) {
                 return "满{$minAmount}元 可{$methodName}";
             }
@@ -265,12 +269,12 @@ class ShMethodClass extends BaseClass
         }
 
         // 不满最低消费但允许加收费用时,校验包装费/运费是否已写入采购单,防止前端绕过
-        if (($unMeet === 0 || $unMeet === 2) && $unMeetFee > 0) {
-            // unMeet === 0 加收运费, unMeet === 2 加收包装费
-            $feeToCheck = $unMeet === 2 ? $packCost : $sendCost;
+        if (($unMeet === 0 || $unMeet === 1) && $unMeetFee > 0) {
+            // unMeet === 0 加收运费, unMeet === 1 加收包装费
+            $feeToCheck = $unMeet === 1 ? $packCost : $sendCost;
             
             // 如果今天已经收过对应的附加费用,则直接通过校验
-            if ($unMeet === 2 && self::isPackPaidToday($customId, $style)) {
+            if ($unMeet === 1 && self::isPackPaidToday($customId, $style)) {
                 return '';
             }
             if ($unMeet === 0 && self::isSendCostPaidToday($customId, $style)) {
@@ -278,7 +282,7 @@ class ShMethodClass extends BaseClass
             }
             
             if (bccomp((string)$feeToCheck, (string)$unMeetFee, 2) < 0) {
-                $feeLabel = $unMeet === 2 ? '包装费' : '运费';
+                $feeLabel = $unMeet === 1 ? '包装费' : '运费';
                 return "未达最低消费,需加收{$feeLabel}{$unMeetFee}元";
             }
         }
@@ -378,12 +382,12 @@ class ShMethodClass extends BaseClass
         $unMeetFee = isset($config['unMeetFee']) ? (float)$config['unMeetFee'] : 0;
         
         if ($unMeetFee > 0) {
-            // unMeet: 0 加收运费(默认),2 加收包装费
+            // unMeet: 0 加收运费(默认),1 加收包装费,2 不能下单
             if ($unMeet === 0) {
                 if (!self::isSendCostPaidToday($customId, $style)) {
                     $costs['sendCost'] = $unMeetFee;
                 }
-            } elseif ($unMeet === 2) {
+            } elseif ($unMeet === 1) {
                 if (!self::isPackPaidToday($customId, $style)) {
                     $costs['packCost'] = $unMeetFee;
                 }

+ 3 - 1
common/components/delivery/util/DeliveryQuoteUtil.php

@@ -167,7 +167,9 @@ class DeliveryQuoteUtil
         $shConfig = $params['shConfig'] ?? [];
         $sendCost = $params['sendCost'] ?? 0;
         $sendDistance = $params['sendDistance'] ?? 0;
+        $sendDistanceKm = bcdiv($sendDistance, 1000, 2);
         $freightType = $params['freightType'] ?? 0;
+        //0 花束 1 花材
         $property = $params['property'] ?? 1;
         $totalPrice = $params['totalPrice'] ?? 0;
         $totalNum = $params['totalNum'] ?? 0;
@@ -185,7 +187,7 @@ class DeliveryQuoteUtil
                 $freeKm = (float)($rule['freeKm'] ?? 0);
 
                 // 校验规则:金额满 meetAmount 且 数量满 meetNum 且 距离在 freeKm 以内
-                if ($totalPrice >= $meetAmount && $totalNum >= $meetNum && $sendDistance <= $freeKm) {
+                if ($totalPrice >= $meetAmount && $totalNum >= $meetNum && $sendDistanceKm <= $freeKm) {
                     return ['sendCost' => 0];
                 }
             }