Browse Source

修改公司信息及获取公司信息修改验证信息

15313670163 3 weeks ago
parent
commit
3009514b07
1 changed files with 26 additions and 23 deletions
  1. 26 23
      app/JsonRpc/NewsService.php

+ 26 - 23
app/JsonRpc/NewsService.php

@@ -1361,7 +1361,7 @@ class NewsService implements NewsServiceInterface
     {
         $user = User::where('user.id', $data['user_id'])
         ->leftJoin('user_info', 'user_info.user_id', 'user.id')
-        ->select('user.user_name','user.mobile','user.email','user.type_id', 'user_info.*')
+        ->select('user.user_name','user.mobile','user.email','user.type_id','user_info.*')
         ->first();
         // return Result::success($user);
         if(empty($user)){
@@ -1377,12 +1377,12 @@ class NewsService implements NewsServiceInterface
                 'company_nature' => $user['company_nature'],     // 公司性质
                 'company_size' => $user['company_size'],         // 公司规模
                 'introduction' => $user['introduction'],         // 公司简介
-                'real_name' => $user['real_name'],               // 企业联系人
-                'mobile' => $user['mobile'],                     // 企业联系电话
+                // 'real_name' => $user['real_name'],               // 企业联系人
+                // 'mobile' => $user['mobile'],                     // 企业联系电话
                 'company_url' => $user['company_url'],           // 企业网址
                 'address_arr_id' => $user['address_arr_id'],     // 企业网址
                 'address' => $user['address'],                   // 企业地址
-                'email' => $user['email'],                       // 企业邮箱
+                // 'email' => $user['email'],                       // 企业邮箱
             ];
         }else{
             return Result::error("用户类型错误", 0);
@@ -1400,8 +1400,7 @@ class NewsService implements NewsServiceInterface
         // return Result::success($data);
         $user = User::where('user.id', $data['user_id'])
         ->where('user.status',1)
-        ->leftJoin('user_info', 'user_info.user_id', 'user.id')
-        ->select('user.user_name','user.type_id', 'user_info.*')
+        ->select('user.user_name','user.type_id')
         ->first();
         if(empty($user)){
             return Result::error("用户不存在", 0);
@@ -1413,28 +1412,32 @@ class NewsService implements NewsServiceInterface
             'company_nature' => $data['company_nature'],     // 公司性质
             'company_size' => $data['company_size'],         // 公司规模
             'introduction' => $data['introduction'],         // 公司简介
-            'real_name' => $data['real_name'],               // 企业联系人
+            // 'real_name' => $data['real_name'],               // 企业联系人
             'company_url' => $data['company_url'],           // 企业网址
             'address_arr_id' => $data['address_arr_id'],     // 企业地址
             'address' => $data['address'],                   // 企业详细地址
         ];
         if($user['type_id'] == 3){
-            $result['user'] = User::where('user.id', $data['user_id'])->update([
-                'mobile' => $data['mobile'],                     // 企业联系电话
-                'email' => $data['email'],                       // 企业邮箱
-            ]);
-            $result['userinfo'] = UserInfo::where('user_id', $data['user_id'])->update([
-                'business_name' => $data['business_name'],       // 企业名称
-                'company_hy_id' => $data['company_hy_id'],       // 企业所属行业
-                'company_nature' => $data['company_nature'],     // 公司性质
-                'company_size' => $data['company_size'],         // 公司规模
-                'introduction' => $data['introduction'],         // 公司简介
-                'real_name' => $data['real_name'],               // 企业联系人
-                'company_url' => $data['company_url'],           // 企业网址
-                'address_arr_id' => $data['address_arr_id'],     // 企业地址
-                'address' => $data['address'],                   // 企业详细地址
-            ]);
-            $result = JobCompany::where('user_id', $data['user_id'])->update($company);
+            Db::beginTransaction();
+            try {
+                $result['userinfo'] = UserInfo::where('user_id', $data['user_id'])->update([
+                    'business_name' => $data['business_name'],       // 企业名称
+                    'company_hy_id' => $data['company_hy_id'],       // 企业所属行业
+                    'company_nature' => $data['company_nature'],     // 公司性质
+                    'company_size' => $data['company_size'],         // 公司规模
+                    'introduction' => $data['introduction'],         // 公司简介
+                    // 'real_name' => $data['real_name'],               // 企业联系人
+                    'company_url' => $data['company_url'],           // 企业网址
+                    'address_arr_id' => $data['address_arr_id'],     // 企业地址
+                    'address' => $data['address'],                   // 企业详细地址
+                ]);
+                $result['job_company'] = JobCompany::where('user_id', $data['user_id'])->update($company);
+                Db::commit();
+            } catch (\Exception $e) {
+                Db::rollBack();
+                return Result::error($e->getMessage(), 0); 
+            }
+           
         }else{
             return Result::error("用户类型错误", 0);
         }