WIN-2308041133\Administrator před 1 dnem
rodič
revize
40e53463d2
2 změnil soubory, kde provedl 19 přidání a 23 odebrání
  1. 4 4
      app/api/controller/Pub.php
  2. 15 19
      app/model/api/User.php

+ 4 - 4
app/api/controller/Pub.php

@@ -326,10 +326,10 @@ class Pub extends BaseController
         $post["page"] = $post["page"] <= 0 ? 1 : (int)$post["page"];
         $post["status"] = 1;
         $data = (new UserModel)->getNewApiWorkerList($post);
-//        foreach ($data['list'] as &$item) {
-//            $item['is_type_audit'] = $item['is_type_audit'] == 1 ? 1 : 0;
-//            $item['ancestral_place'] = $item['ancestral_place'] ?? '';
-//        }
+        foreach ($data['list'] as &$item) {
+            $item['is_type_audit'] = $item['is_type_audit'] == 1 ? 1 : 0;
+            $item['ancestral_place'] = $item['ancestral_place'] ?? '';
+        }
         return app('json')->success($data);
     }
 

+ 15 - 19
app/model/api/User.php

@@ -431,25 +431,21 @@ class User extends BaseModel
     {
         $post["pageSize"] = $post["pageSize"] > 20 ? 20 : (int)$post["pageSize"];
         $post["page"] = $post["page"] <= 0 ? 1 : (int)$post["page"];
+
         // 构建基础条件
-        $where = [["work_type_id", ">", 0], ["status", "=", 1]];
+        $where = [["u.work_type_id", ">", 0], ["u.status", "=", 1]];
         if (!empty($post['work_type_id'])) {
-            $where[] = ["work_type_id", "=", $post['work_type_id']];
+            $where[] = ["u.work_type_id", "=", $post['work_type_id']];
+        }
+        if ($post['servicePrice'] > 0) {
+            $where[] = ["a.service_min_price", "<=", $post['servicePrice']];
+        }
+        if (!empty($post['timetype'])) {
+            $where[] = ["a.service_type", "=", $post['timetype']];
+        }
+        if ($post['is_china'] != '') {
+            $where[] = ["a.is_china", '=', $post['is_china']];
         }
-//        // 构建基础条件
-//        $where = [["u.work_type_id", ">", 0], ["u.status", "=", 1]];
-//        if (!empty($post['work_type_id'])) {
-//            $where[] = ["u.work_type_id", "=", $post['work_type_id']];
-//        }
-//        if ($post['servicePrice'] > 0) {
-//            $where[] = ["a.service_min_price", "<=", $post['servicePrice']];
-//        }
-//        if (!empty($post['timetype'])) {
-//            $where[] = ["a.service_type", "=", $post['timetype']];
-//        }
-//        if ($post['is_china'] != '') {
-//            $where[] = ["a.is_china", '=', $post['is_china']];
-//        }
         
         // 城市查询条件
         $serviceAreaWhere = null;
@@ -475,8 +471,8 @@ class User extends BaseModel
 
         // 构建查询(不设置 field,用默认查所有,减少解析开销)
         $query = $this
-//            ->alias("u")
-//            ->leftJoin("info_audit a", "u.uid=a.uid and a.status = 1 and a.is_show = 1")
+            ->alias("u")
+            ->leftJoin("info_audit a", "u.uid=a.uid and a.status = 1 and a.is_show = 1")
 //            ->leftJoin("user_show_template ut", "ut.uid = u.uid and ut.is_default = 1")
             ->where($where);
         if ($serviceAreaWhere) {
@@ -490,7 +486,7 @@ class User extends BaseModel
         $data = [];
         if ($totalCount > 0) {
             $offset = ($post["page"] - 1) * $post["pageSize"];
-            $result = $query->order("uid", "desc")
+            $result = $query->order("u.uid", "desc")
                 ->limit($offset, $post["pageSize"])
                 ->select();
             if (!empty($result)) {