Selaa lähdekoodia

调整0号线获取和设置接口

sunxbiao 1 vuosi sitten
vanhempi
commit
957fbc8636
2 muutettua tiedostoa jossa 59 lisäystä ja 6 poistoa
  1. 58 6
      app/controller/admin/user/User.php
  2. 1 0
      route/admin.php

+ 58 - 6
app/controller/admin/user/User.php

@@ -1829,14 +1829,66 @@ class User extends BaseController
1829 1829
 
1830 1830
     /**
1831 1831
      * 获取零号线用户列表
1832
-     * @return array[]
1832
+     * @return mixed
1833
+     * @throws DataNotFoundException
1834
+     * @throws DbException
1835
+     * @throws ModelNotFoundException
1833 1836
      */
1834 1837
     public function getZeroLineUserList()
1835 1838
     {
1836
-        return app('json')->success('获取成功',
1837
-            [
1838
-                ['uid' => 37, 'teamName' => '陈震']
1839
-            ]
1840
-        );
1839
+        $result = Db::name('user_zero_line')
1840
+            ->where('status', '=',1)
1841
+            ->select()
1842
+            ->toArray();
1843
+        return app('json')->success('获取成功', $result);
1844
+    }
1845
+
1846
+    /**
1847
+     * 获取零号线用户列表
1848
+     * @return mixed
1849
+     * @throws DataNotFoundException
1850
+     * @throws DbException
1851
+     * @throws ModelNotFoundException
1852
+     */
1853
+    public function setZeroLineUser()
1854
+    {
1855
+        $team_uid = request()->param('team_uid', 0);
1856
+        $team_name = request()->param('team_name', null);
1857
+        $status = request()->param('status', null);
1858
+
1859
+        $userData = Db::name('user')
1860
+            ->where('uid', '=', $team_uid)
1861
+            ->where('is_del', '=', 0)
1862
+            ->find()
1863
+            ->toArray();
1864
+        if (!$userData) {
1865
+            return app('json')->fail('用户不存在');
1866
+        }
1867
+
1868
+        if ($team_name === '') {
1869
+            $team_name = $userData['nickname'] . '0号线';
1870
+        }
1871
+
1872
+        $isExist = Db::name('user_zero_line')
1873
+            ->where('team_uid', '=', $team_uid)
1874
+            ->find()
1875
+            ->toArray();
1876
+        if ($isExist) {
1877
+            $result = Db::name('user_zero_line')
1878
+                ->where('team_uid', '=', $team_uid)
1879
+                ->update([
1880
+                    'team_name' => $team_name,
1881
+                    'status' => $status
1882
+                ]);
1883
+        } else {
1884
+            $result = Db::name('user_zero_line')
1885
+                ->insert([
1886
+                    'team_uid' => $team_uid,
1887
+                    'team_name' => $team_name,
1888
+                    'status' => $status
1889
+                ]);
1890
+        }
1891
+
1892
+        return app('json')->success('设置成功', $result);
1841 1893
     }
1842 1894
 }

+ 1 - 0
route/admin.php

@@ -456,6 +456,7 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
456 456
             Route::post('stock/create', '/stockCreate')->name('systemUserStockCreate');
457 457
             Route::delete('stock/delete/:id', '/stockDelete')->name('systemUserStockDelete');
458 458
             Route::get('getZeroLineUserList', '/getZeroLineUserList')->name('systemGetZeroLineUserList');
459
+            Route::post('setZeroLineUser', '/setZeroLineUser')->name('systemSetZeroLineUser');
459 460
 
460 461
         })->prefix('admin.user.User');
461 462