소스 검색

价格有异常

shish 3 년 전
부모
커밋
a79877e1ab
3개의 변경된 파일68개의 추가작업 그리고 2개의 파일을 삭제
  1. 17 0
      app-ghs/controllers/ItemController.php
  2. 49 0
      biz-ghs/item/classes/ItemClass.php
  3. 2 2
      console/controllers/ItemController.php

+ 17 - 0
app-ghs/controllers/ItemController.php

@@ -12,6 +12,23 @@ use Yii;
 class ItemController extends BaseController
 {
 
+    //列出C级价格大于B级的花材 ssh 20221204
+    public function actionErrorPriceList()
+    {
+        $shop = $this->shop;
+        $list = ItemClass::errorPrice($shop);
+        util::success(['list' => $list]);
+    }
+
+    //是否有C级价格大于B级的 ssh 20221204
+    public function actionHasErrorPrice()
+    {
+        $shop = $this->shop;
+        $list = ItemClass::errorPrice($shop);
+        $has = !empty($list) ? 1 : 0;
+        util::success(['has' => $has]);
+    }
+
     //列出所有花材,包括特价花材列表 ssh 20220315
     public function actionShowList()
     {

+ 49 - 0
biz-ghs/item/classes/ItemClass.php

@@ -16,6 +16,55 @@ class ItemClass extends BaseClass
 
     public static $baseFile = '\bizGhs\item\models\Item';
 
+    public static function errorPrice($shop)
+    {
+        $mainId = $shop->mainId ?? 0;
+        $itemList = ItemClass::getAllByCondition(['mainId' => $mainId, 'delStatus' => 0], null, '*');
+        $arr = [];
+        if (!empty($itemList)) {
+            foreach ($itemList as $item) {
+                $name = $item['name'] ?? '';
+                $price = $item['price'] ?? 0;
+                $name = trim(strtolower($name));
+                $name = str_replace(" ", "", $name);
+
+                $hasLevel = true;
+                $keyName = '';
+                $keyLevel = 'a';
+                if (strstr($name, "a级") != false) {
+                    $keyName = str_replace("a级", "x级", $name);
+                    $keyLevel = 'a';
+                } elseif (strstr($name, "b级") != false) {
+                    $keyName = str_replace("b级", "x级", $name);
+                    $keyLevel = 'b';
+                } elseif (strstr($name, "c级") != false) {
+                    $keyName = str_replace("c级", "x级", $name);
+                    $keyLevel = 'c';
+                } else {
+                    $hasLevel = false;
+                }
+                if ($hasLevel) {
+                    $arr[$keyName][$keyLevel] = $price;
+                }
+            }
+        }
+        $error = [];
+        if (!empty($arr)) {
+            foreach ($arr as $key => $it) {
+                if (isset($it['a']) && isset($it['b']) && $it['b'] > $it['a']) {
+                    $error[$key] = $it;
+                }
+                if (isset($it['b']) && isset($it['c']) && $it['c'] > $it['b']) {
+                    $error[$key] = $it;
+                }
+                if (isset($it['a']) && isset($it['c']) && $it['c'] > $it['a']) {
+                    $error[$key] = $it;
+                }
+            }
+        }
+        return $error;
+    }
+
     //初始化花材 lqh 2021.4.12  modify ssh 20210711
     public static function initItem($mainId)
     {

+ 2 - 2
console/controllers/ItemController.php

@@ -37,7 +37,7 @@ class ItemController extends Controller
                 $py = stringUtil::py($name);
                 $product->py = $py;
                 $product->save();
-                echo $name.' '.$py."\n";
+                echo $name . ' ' . $py . "\n";
             }
         }
         $item = PtItemClass::getAllByCondition([], null, '*', null, true);
@@ -48,7 +48,7 @@ class ItemController extends Controller
                     $py = stringUtil::py($name);
                     $it->py = $py;
                     $it->save();
-                    echo $name.' '.$py."\n";
+                    echo $name . ' ' . $py . "\n";
                 }
             }
         }