shish 11 mesi fa
parent
commit
8da3c29b51
1 ha cambiato i file con 15 aggiunte e 8 eliminazioni
  1. 15 8
      app-hd/controllers/CustomController.php

+ 15 - 8
app-hd/controllers/CustomController.php

@@ -232,10 +232,7 @@ class CustomController extends BaseController
     {
         $get = Yii::$app->request->get();
         $type = $get['type'] ?? 0;
-        $name = $get['name'] ?? '';
-        if (empty($name)) {
-            $name = $get['keyword'] ?? '';
-        }
+        $searchStyle = $get['searchStyle'] ?? 0;
         $where = ['shopId' => $this->shopId];
         if ($type == 1) {
             //消费排行
@@ -250,13 +247,23 @@ class CustomController extends BaseController
         } else {
             $sort = 'visitTime DESC';
         }
+
+        $name = $get['name'] ?? '';
+        if (empty($name)) {
+            $name = $get['keyword'] ?? '';
+        }
+        if (empty($name)) {
+            $name = $get['searchText'] ?? '';
+        }
         if (!empty($name)) {
-            if (is_numeric($name) && strlen($name) == 4) {
+            if ($searchStyle == 0) {
                 $where['mobile'] = ['like', $name];
-            } else if (stringUtil::isLetter($name)) {
-                $where['py'] = ['like', $name];
             } else {
-                $where['name'] = ['like', $name];
+                if (stringUtil::isLetter($name)) {
+                    $where['py'] = ['like', $name];
+                } else {
+                    $where['name'] = ['like', $name];
+                }
             }
         }
         $list = CustomService::getCustomList($where, $sort);