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

+ 7 - 1
app-hd/controllers/GhsController.php

@@ -160,7 +160,13 @@ class GhsController extends BaseController
         $info['tjFl'] = $ghsShop->tjFl ?? 0;
         $info['tjFlAmount'] = $ghsShop->tjFlAmount ?? 0;
         $info['packCost'] = $ghsShop->packCost ? floatval($ghsShop->packCost) : 0;
-        $info['lackExpend'] = $ghsShop->lackExpend ? floatval($ghsShop->lackExpend) : 0;
+        $lackExpend = $ghsShop->lackExpend ? floatval($ghsShop->lackExpend) : 0;
+        $customId = $info['customId'] ?? 0;
+        $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShop, $customId);
+        if ($needAdd == false) {
+            $lackExpend = 0;
+        }
+        $info['lackExpend'] = $lackExpend;
         $info['buyNotice'] = $ghsShop->buyNotice ?? 0;
         $info['lsShopId'] = $ghsShop->lsShopId ?? 0;
         //预订单的最低公斤数和每公斤服务费

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

@@ -254,10 +254,15 @@ class PurchaseController extends BaseController
                 $sendCost = $result['fee'] ?? 0;
             }
             $post['sendCost'] = $sendCost;
-            //出车和发快递可以算打包
+            //出车、发快递、发物流可以算包装
             $packCost = 0;
-            if ($sendType == dict::getDict('sendType', 'thirdSend') || $sendType == dict::getDict('sendType', 'carGet')) {
-                $packCost = $ghsShopInfo->packCost ?? 0;
+            $itemTotalAmount = $post['itemTotalAmount'] ?? 0;
+            unset($post['itemTotalAmount']);
+            if ($sendType == dict::getDict('sendType', 'thirdSend') || $sendType == dict::getDict('sendType', 'carGet') || $sendType == dict::getDict('sendType', 'wl')) {
+                $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $itemTotalAmount);
+                if ($needAdd) {
+                    $packCost = $ghsShopInfo->packCost ?? 0;
+                }
             }
             $post['packCost'] = $packCost;
 
@@ -288,6 +293,11 @@ class PurchaseController extends BaseController
 
             $transaction->commit();
 
+            //标记当天已收包装费,岭南批发市场
+            $current = date("Y_m_d");
+            $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
+            Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
+
             util::success($respond);
 
         } catch (Exception $e) {

+ 24 - 0
biz-hd/shop/classes/ShopClass.php

@@ -21,6 +21,30 @@ class ShopClass extends BaseClass
 
     public static $baseFile = '\bizHd\shop\models\Shop';
 
+    //需要算上包装费
+    public static function needAddPackCost($ghsShop, $customId, $orderAmount = 0)
+    {
+        $lackExpend = $ghsShop->lackExpend ? floatval($ghsShop->lackExpend) : 0;
+        $packCost = $ghsShop->packCost ? floatval($ghsShop->packCost) : 0;
+        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;
+        }
+        if ($orderAmount > 0) {
+            if ($orderAmount < $lackExpend) {
+                return true;
+            }
+        } else {
+            return true;
+        }
+        return false;
+    }
+
     public static function getNewShopList()
     {
         $where = ['ptStyle' => dict::getDict('ptStyle', 'hd')];