Explorar el Código

包装费计算问题

shish hace 3 semanas
padre
commit
37b53bc60a

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

@@ -192,11 +192,11 @@ class NoticeController extends PublicController
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
                     }
                 } else {
-                    //标记当天发快递方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
+                    //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
                     $customId = $cg->customId ?? 0;
                     $current = date("Y_m_d");
-                    if (isset($cg->sendType) && $cg->sendType == 4) {
-                        $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
+                    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) {
@@ -411,11 +411,11 @@ class NoticeController extends PublicController
                         Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
                     }
                 } else {
-                    //标记当天发快递方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
+                    //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
                     $customId = $cg->customId ?? 0;
                     $current = date("Y_m_d");
-                    if (isset($cg->sendType) && $cg->sendType == 4) {
-                        $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
+                    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) {
@@ -579,11 +579,11 @@ class NoticeController extends PublicController
                     }
                 } else {
 
-                    //标记当天发快递方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
+                    //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
                     $customId = $cg->customId ?? 0;
                     $current = date("Y_m_d");
-                    if (isset($cg->sendType) && $cg->sendType == 4) {
-                        $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
+                    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) {
@@ -836,18 +836,18 @@ 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) && $cg->sendType == 4) {
-                                $key = 'ghs_custom_today_has_get_pack_cost_' . $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;
-                                Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
+                                //标记当配送方式已收一次包装费/运费,岭南批发市场用的功能,关键词 sh_method_area,只要有成功单就标记,不再要求金额必须>0
+                                $customId = $cg->customId ?? 0;
+                                $current = date("Y_m_d");
+                                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;
+                                    Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
+                                }
                             }
-                        }
 
                         //微信通知
                         $saleId = $cg->saleId ?? 0;

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

@@ -572,7 +572,7 @@ class PurchaseController extends BaseController
                     }
                 }
                 //如果已经算过一次打包费和运费了,则不再费了
-                $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId);
+                $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $sendType);
                 if (!$needAdd) {
                     $packCost = 0;
                     if (isset($ghsInfo['mainId']) && $ghsInfo['mainId'] == 14499) {
@@ -622,7 +622,7 @@ class PurchaseController extends BaseController
                 }
 
                 //如果已经算过一次打包费和运费了,则不再费了
-                $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId);
+                $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $sendType);
                 if ($needAdd == false) {
                     $sendCost = 0;
                 }
@@ -709,15 +709,17 @@ class PurchaseController extends BaseController
                     $post['sendCost'] = $sendCost;
                     $post['sendDistance'] = $sendDistance;
 
-                    //出车、发快递、发物流可以算包装费
+                    // 出车(0)、发快递(4)、发物流可以算包装费
                     $packCost = 0;
                     if (isset($ghsInfo['mainId']) && $ghsInfo['mainId'] == 14499) {
                         noticeUtil::push("走的pfLevel=0", '15280215347');
                     }
                     $itemTotalAmount = $post['itemTotalAmount'] ?? 0;
                     unset($post['itemTotalAmount']);
-                    if ($sendType == dict::getDict('sendType', 'express')) {
-                        $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $itemTotalAmount);
+
+                    // sendType == 0 或 4 都要收包装费
+                    if (in_array($sendType, [0, 4])) {
+                        $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $sendType, $itemTotalAmount);
                         if ($needAdd) {
                             $packCost = $ghsShopInfo->packCost ?? 0;
                         }

+ 3 - 5
biz-hd/shop/classes/ShopClass.php

@@ -46,11 +46,11 @@ class ShopClass extends BaseClass
     }
 
     //需要算上包装费
-    public static function needAddPackCost($ghsShop, $customId, $orderAmount = 0)
+    public static function needAddPackCost($ghsShop, $customId, $sendType = 0, $orderAmount = 0)
     {
+        $current = date("Y_m_d");
+        $key = 'ghs_custom_today_has_get_pack_cost_' . $sendType . '_' . $current . '_' . $customId;
         if (isset($ghsShop->pfLevel) && $ghsShop->pfLevel == 1) {
-            $current = date("Y_m_d");
-            $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
             $has = Yii::$app->redis->executeCommand('GET', [$key]);
             if (!empty($has) && $has == 1) {
                 return false;
@@ -63,8 +63,6 @@ class ShopClass extends BaseClass
             if ($lackExpend <= 0 || $packCost <= 0) {
                 return false;
             }
-            $current = date("Y_m_d");
-            $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
             $has = Yii::$app->redis->executeCommand('GET', [$key]);
             if (!empty($has) && $has == 1) {
                 return false;