cqpCow 2 rokov pred
rodič
commit
03b826a451

+ 0 - 2
app/Http/Controllers/Api/LoginController.php

@@ -58,8 +58,6 @@ class LoginController extends BaseController
     private function setSqlServer($data,$user_id){
         $array = [
             'sqlserver_zt' => $data['sqlserver_zt'] ?? '',
-            'sqlserver_account' => $data['sqlserver_account'] ?? '',
-            'sqlserver_password' => $data['sqlserver_password'] ?? '',
         ];
         $key = 'fyy_sql_server' . $user_id;
         Redis::set($key,json_encode($array));

+ 5 - 0
app/Service/EmployeeService.php

@@ -37,6 +37,8 @@ class EmployeeService extends Service
             if($data['password'] !== '********'){
                 $model->password   = Hash::make($data['password']);
             }
+            $model->sqlserver_account = $data['sqlserver_account'] ?? '';
+            $model->sqlserver_password = $data['sqlserver_password'] ?? '';
         }
         $model->save();
 
@@ -70,6 +72,8 @@ class EmployeeService extends Service
         if($model->is_admin == 1){
             $model->account = $data['account'];
             $model->password   = Hash::make($data['password']);
+            $model->sqlserver_account = $data['sqlserver_account'] ?? '';
+            $model->sqlserver_password = $data['sqlserver_password'] ?? '';
         }
         $model->save();
 
@@ -518,6 +522,7 @@ class EmployeeService extends Service
 
         $res = Employee::where('del_time',0)
             ->where('account', $data['account'])
+            ->where('emp_name', $data['account'])
             ->get()->toArray();
 
         if(empty($res)) return [false,'账号不存在或已被删除!'];

+ 19 - 2
app/Service/FyySqlServerService.php

@@ -3,6 +3,7 @@
 namespace App\Service;
 
 use App\Model\BoxDetail;
+use App\Model\Employee;
 use App\Model\Orders;
 use App\Model\SaleOrdersProduct;
 use Illuminate\Support\Facades\Config;
@@ -30,15 +31,30 @@ class FyySqlServerService extends Service
 
     public function __construct($user_id = '')
     {
+        //用户信息校验
+        if(empty($user_id)) {
+            $this->error = '福羊羊数据库连接用户参数不能为空!';
+            return;
+        }
+        $emp = Employee::where('id',$user_id)->select('sqlserver_account','sqlserver_password')->first();
+        if(empty($emp)) {
+            $this->error = '福羊羊连接构造失败!';
+            return;
+        }
+        //用友接口统一登录账号密码
+        $this->sUserID = $emp->sqlserver_account ?? '';
+        $this->sPassword = $emp->sqlserver_password ?? '';
+
+        //缓存数据提取  主要是账套
         $key = 'fyy_sql_server' . $user_id;
         $fyy_array = Redis::get($key);
         if(! empty($fyy_array)) {
             $fyy_array = json_decode($fyy_array,true);
+            if(! empty($fyy_array['sqlserver_database'])) $this->database = $this->database_select[$fyy_array['sqlserver_zt']];
+            if(! empty($fyy_array['sqlserver_zt'])) $this->sAccID = '(default)@' . $fyy_array['sqlserver_zt'];
             if(! empty($fyy_array['sqlserver_host'])) $this->host = $fyy_array['sqlserver_host'];
             if(! empty($fyy_array['sqlserver_host_api'])) $this->host_api = $fyy_array['sqlserver_host_api'];
             if(! empty($fyy_array['sqlserver_port'])) $this->port = $fyy_array['sqlserver_port'];
-            if(! empty($fyy_array['sqlserver_database'])) $this->database = $this->database_select[$fyy_array['sqlserver_zt']];
-            if(! empty($fyy_array['sqlserver_zt'])) $this->sAccID = '(default)@' . $fyy_array['sqlserver_zt'];
             if(! empty($fyy_array['sqlserver_account'])) $this->sUserID = $fyy_array['sqlserver_account'];
             if(! empty($fyy_array['sqlserver_password'])) $this->sPassword = $fyy_array['sqlserver_password'];
         }
@@ -73,6 +89,7 @@ class FyySqlServerService extends Service
         }
     }
 
+    //假数据
     private function fakeData(){
         $return = [
             [