Prechádzať zdrojové kódy

Merge branch 'master' into zhongqi-hb

shish 7 mesiacov pred
rodič
commit
9784777985

+ 14 - 7
app-ghs/controllers/CustomController.php

@@ -926,7 +926,11 @@ class CustomController extends BaseController
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
         $homeAmount = $get['homeAmount'] ?? 0;
-        $homeType = $get['homeType'] ?? 0;
+        $homeNum = $get['homeNum'] ?? 0;
+        if (isset($get['homeType'])) {
+            //早期系统有带这个参数,来判断
+            util::fail('请升级系统');
+        }
         $custom = CustomClass::getById($id, true);
         if (empty($custom)) {
             util::fail('没有找到客户');
@@ -940,10 +944,10 @@ class CustomController extends BaseController
             util::fail('没有找到供货商');
         }
         $custom->homeAmount = $homeAmount;
-        $custom->homeType = $homeType;
+        $custom->homeNum = $homeNum;
         $custom->save();
         $ghs->homeAmount = $homeAmount;
-        $ghs->homeType = $homeType;
+        $ghs->homeNum = $homeNum;
         $ghs->save();
         util::complete('修改成功');
     }
@@ -955,14 +959,17 @@ class CustomController extends BaseController
     {
         $get = Yii::$app->request->get();
         $homeAmount = $get['homeAmount'] ?? 0;
-        $homeType = $get['homeType'] ?? 0;
+        $homeNum = $get['homeNum'] ?? 0;
+        if (isset($get['homeType'])) {
+            util::fail('请升级APP');
+        }
         $shopId = $this->shopId;
-        ShopClass::updateById($shopId, ['homeAmount' => $homeAmount, 'homeType' => $homeType]);
+        ShopClass::updateById($shopId, ['homeAmount' => $homeAmount, 'homeNum' => $homeNum]);
 
         // 批量更新客户信息
-        CustomClass::updateByCondition(['ownMainId' => $this->mainId], ['homeAmount' => $homeAmount, 'homeType' => $homeType]);
+        CustomClass::updateByCondition(['ownMainId' => $this->mainId], ['homeAmount' => $homeAmount, 'homeNum' => $homeNum]);
         //批量更新供货商信息
-        GhsClass::updateByCondition(['shopId' => $shopId], ['homeAmount' => $homeAmount, 'homeType' => $homeType]);
+        GhsClass::updateByCondition(['shopId' => $shopId], ['homeAmount' => $homeAmount, 'homeNum' => $homeNum]);
         util::complete('修改成功');
     }
 

+ 9 - 73
app-hd/controllers/PurchaseController.php

@@ -330,7 +330,7 @@ class PurchaseController extends BaseController
                 $presellData = [];
                 $nowTime = strtotime(date("Y-m-d"));
                 foreach ($productInfoList as $currentInfo) {
-                    if (isset($currentInfo['mainId']) == false || $currentInfo['mainId'] != $ghsMainId) {
+                    if (!isset($currentInfo['mainId']) || $currentInfo['mainId'] != $ghsMainId) {
                         util::fail('只能选择同一家的商品哦');
                     }
                     $currentName = $currentInfo['name'] ?? '';
@@ -427,46 +427,6 @@ class PurchaseController extends BaseController
             $ghsInfo['kiloFee'] = $ghsShopInfo->kiloFee ?? 0;
             $ghsInfo['miniKilo'] = $ghsShopInfo->miniKilo ?? 0;
 
-            //旭海银柳的临时解决办法
-            if (getenv('YII_ENV') == 'production') {
-                if ($ghsShopInfo->mainId == 41121) {
-                    $mer = [1903693, 1903712, 1903789, 1903796, 1903816, 1903841, 1903855, 1903859, 1903860, 1903864];
-                    $getIds = array_column($productList, 'productId');
-                    $hasYl = false;
-                    foreach ($productList as $ylVal) {
-                        $ylProductId = $ylVal['productId'];
-                        if (in_array($ylProductId, $mer)) {
-                            $hasYl = true;
-                        }
-                    }
-                    if ($hasYl) {
-                        $myInfoList = ProductClass::getAllByCondition(['id' => ['in', $getIds]], null, '*', 'id');
-                        $currentMap = [1903693 => 220, 1903712 => 150, 1903789 => 100, 1903796 => 60, 1903816 => 45, 1903841 => 80, 1903855 => 55, 1903859 => 40, 1903860 => 25, 1903864 => 20];
-                        foreach ($productList as $ylKey => $ylValue) {
-                            $ylProductId = $ylValue['productId'];
-                            $num = $ylValue['bigNum'] ?? 0;
-                            if (!isset($currentMap[$ylProductId])) {
-                                util::fail('花材有问题');
-                            }
-                            $mustBeNum = $currentMap[$ylProductId];
-                            $myInfo = $myInfoList[$ylProductId] ?? [];
-                            if (empty($myInfo)) {
-                                util::fail('花材有问题哦');
-                            }
-                            $myName = $myInfo['name'] ?? '';
-                            if ($num >= $mustBeNum) {
-                                $curVal = $num / $mustBeNum;
-                                if ($curVal != intval($curVal)) {
-                                    util::fail($myName . ' 要' . $mustBeNum . '捆或' . $mustBeNum . '的倍数');
-                                }
-                            } else {
-                                util::fail($myName . ' 数量要' . $mustBeNum . '捆');
-                            }
-                        }
-                    }
-                }
-            }
-
             $post['product'] = $productList;
 
             $sendType = $post['sendType'] ?? 0;
@@ -518,7 +478,7 @@ class PurchaseController extends BaseController
                 }
                 //如果已经算过一次打包费和运费了,则不再费了
                 $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId);
-                if ($needAdd == false) {
+                if (!$needAdd) {
                     $packCost = 0;
                     if (isset($ghsInfo['mainId']) && $ghsInfo['mainId'] == 14499) {
                         noticeUtil::push("没有计算打包费原因:已经算过一次了", '15280215347');
@@ -692,41 +652,17 @@ class PurchaseController extends BaseController
                     if ($ghsInfo['home'] == 0) {
                         util::fail('暂不支持送货上门,请选其它配送方式');
                     }
-                    if (!empty($ghsInfo['homeAmount'])) {
-                        $homeType = $ghsInfo['homeType'] ?? 0;
-                        $homeAmount = floatval($ghsInfo['homeAmount']);
-                        if ($homeType == 0) {
-                            if ($homeAmount > $respond->actPrice) {
-                                util::fail("满{$homeAmount}元 可送货上门");
-                            }
-                        }
-                        if ($homeType == 1) {
-                            if ($homeAmount > $respond->bigNum) {
-                                util::fail("满{$homeAmount}扎 可送货上门");
-                            }
-                        }
-                    }
-                }
-
-            }
-
-            if (getenv('YII_ENV') == 'production') {
-                //昆明花落谁家
-                if ($ghsShopId == 13398) {
-                    if ($respond->bigNum < 15) {
-                        $transaction->rollBack();
-                        util::fail('不足15扎,请联系店长');
+                    $homeAmount = $ghsInfo['homeAmount'] ? floatval($ghsInfo['homeAmount']) : 0;
+                    $homeNum = $ghsInfo['homeNum'] ? floatval($ghsInfo['homeNum']) : 0;
+                    if ($homeAmount > 0 && $homeAmount > $respond->actPrice) {
+                        util::fail("满{$homeAmount}元 可送货上门");
                     }
-                }
-                //盛丰最少要20扎
-                if ($ghsShopId == 44556) {
-                    if ($respond->bigNum < 20) {
-                        $transaction->rollBack();
-                        util::fail('最少要20扎');
+                    if ($homeNum > 0 && $homeNum > $respond->bigNum) {
+                        util::fail("满{$homeNum}扎 可送货上门");
                     }
                 }
-            }
 
+            }
             $transaction->commit();
 
             util::success($respond);

+ 3 - 3
biz/ghs/classes/GhsClass.php

@@ -52,7 +52,7 @@ class GhsClass extends BaseClass
         $needCheck = $ghsShop['needCheck'] ?? 0;
         $home = $ghsShop['home'] ?? 0;
         $homeAmount = $ghsShop['homeAmount'] ?? 0;
-        $homeType = $ghsShop['homeType'] ?? 0;
+        $homeNum = $ghsShop['homeNum'] ?? 0;
         $passStatus = $needCheck == 1 ? 0 : 1;
         $live = $ghsShop['live'] ?? 1;
         $isHd = $ghsShop['isHd'] ?? 1;
@@ -104,7 +104,7 @@ class GhsClass extends BaseClass
                 'passStatus' => $passStatus,
                 'home' => $home,
                 'homeAmount' => $homeAmount,
-                'homeType' => $homeType,
+                'homeNum' => $homeNum,
             ];
             $ghs = self::addGhs($data);
         }
@@ -162,7 +162,7 @@ class GhsClass extends BaseClass
                 'passStatus' => $passStatus,
                 'home' => $home,
                 'homeAmount' => $homeAmount,
-                'homeType' => $homeType,
+                'homeNum' => $homeNum,
             ];
             $custom = CustomClass::addCustom($customData);
         }

+ 25 - 1
console/controllers/TestController.php

@@ -32,6 +32,30 @@ use yii\console\Controller;
 class TestController extends Controller
 {
 
+    public function actionCustom()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+        $list = \bizGhs\custom\classes\CustomClass::getAllByCondition(['homeAmount>' => 0], null, null, null, true);
+        foreach ($list as $custom) {
+            $homeType = $custom->homeType ?? 0;
+            $homeAmount = $custom->homeAmount ?? 0;
+            $ghsId = $custom->ghsId ?? 0;
+            $ghs = GhsClass::getById($ghsId, true);
+            if ($homeType === 1) {
+                $custom->homeNum = $homeAmount;
+                $custom->homeAmount = 0;
+                $custom->save();
+                if (!empty($ghs)) {
+                    $ghs->homeNum = $homeAmount;
+                    $ghs->homeAmount = 0;
+                    $ghs->save();
+                }
+                echo $custom->id . "OK\n";
+            }
+        }
+    }
+
     public function actionSendStatus()
     {
 
@@ -93,7 +117,7 @@ class TestController extends Controller
         $totalCount = 0;
         foreach ($query->batch(1000) as $batch) {
             $ids = array_column($batch, 'id');
-            OrderClass::updateByIds($ids, ['status' => 4,'sendStatus' => -4]);
+            OrderClass::updateByIds($ids, ['status' => 4, 'sendStatus' => -4]);
             $totalCount += count($ids);
             echo "已处理 " . $totalCount . " 条记录\n";
         }