Просмотр исходного кода

Merge branch 'liuzj-permission-dev' into test

liuzejian 2 лет назад
Родитель
Сommit
395887643c

+ 10 - 10
modules/Callback/Http/Controllers/JuliangAccountController.php

@@ -20,7 +20,7 @@ class JuliangAccountController extends CatchController
         $advAccountName = $request->input('account_name');
 
         return DB::table('juliang_account_callback_config')
-            ->where(['company_uid' => $this->getCompanyUid()])
+            ->where(['company_uid' => $this->getOptimizerUid()])
             ->when($advAccountId, function ($query, $advAccountId) {
                 return $query->where('adv_account_id' , $advAccountId);
             })->when($advAccountName, function ($query, $advAccountName) {
@@ -42,7 +42,7 @@ class JuliangAccountController extends CatchController
         ]);
 
         if(DB::table('juliang_account_callback_config')
-            ->where(['company_uid' => $this->getCompanyUid(), 'adv_account_id' => $request->input('account_id')])
+            ->where(['company_uid' => $this->getOptimizerUid(), 'adv_account_id' => $request->input('account_id')])
             ->exists()) {
             CommonBusinessException::throwError(Errors::JULIANG_ACCOUNT_EXISTS);
         }
@@ -61,20 +61,20 @@ class JuliangAccountController extends CatchController
                 'rate_time_config' => \json_encode($request->input('rate_time_config', [])),
                 'min_money' => $request->input('min_money'),
                 'max_money' => $request->input('max_money'),
-                'company_uid' => $this->getCompanyUid(),
+                'company_uid' => $this->getOptimizerUid(),
                 'created_at' => $now,
                 'updated_at' => $now,
             ]);
         DB::table('juliang_account_rate_config_log')
             ->insert([
-                'company_uid' => $this->getCompanyUid(),
+                'company_uid' => $this->getOptimizerUid(),
                 'account_id' => $request->input('account_id'),
                 'config_per' => $request->input('default_rate'),
                 'created_at' => $now,
                 'updated_at' => $now,
             ]);
         if($request->input('rate_time_config')) {
-            $this->saveTimeConfig($this->getCompanyUid(), $request->input('account_id'), $request);
+            $this->saveTimeConfig($this->getOptimizerUid(), $request->input('account_id'), $request);
         }
         return 'ok';
     }
@@ -96,7 +96,7 @@ class JuliangAccountController extends CatchController
         $now = date('Y-m-d H:i:s');
         foreach ($request->input('ids') as $id) {
             DB::table('juliang_account_callback_config')
-                ->where(['id' => $id, 'company_uid' => $this->getCompanyUid()])
+                ->where(['id' => $id, 'company_uid' => $this->getOptimizerUid()])
                 ->update([
                     'state' => $request->input('state'),
                     'protect_num' => $request->input('protect_num'),
@@ -109,24 +109,24 @@ class JuliangAccountController extends CatchController
         }
         $advAccountIds = DB::table('juliang_account_callback_config')
             ->whereIn('id', $request->input('ids'))
-            ->where('company_uid', $this->getCompanyUid())
+            ->where('company_uid', $this->getOptimizerUid())
             ->select('adv_account_id')->get()->pluck('adv_account_id');
         if($advAccountIds->isNotEmpty()) {
             DB::table('juliang_account_rate_config_log')
-                ->where('company_uid', $this->getCompanyUid())
+                ->where('company_uid', $this->getOptimizerUid())
                 ->whereIn('account_id', $advAccountIds)
                 ->where('is_enabled', 1)
                 ->update(['is_enabled' => 0, 'updated_at' => $now]);
             foreach ($advAccountIds as $accountId) {
                 DB::table('juliang_account_rate_config_log')
                     ->insert([
-                        'company_uid' => $this->getCompanyUid(),
+                        'company_uid' => $this->getOptimizerUid(),
                         'account_id' => $accountId,
                         'config_per' => $request->input('default_rate'),
                         'created_at' => $now,
                         'updated_at' => $now,
                     ]);
-                $this->saveTimeConfig($this->getCompanyUid(), $accountId, $request);
+                $this->saveTimeConfig($this->getOptimizerUid(), $accountId, $request);
             }
         }
 

+ 3 - 2
modules/Common/Exceptions/CommonBusinessException.php

@@ -2,13 +2,14 @@
 
 namespace Modules\Common\Exceptions;
 
+use Catch\Exceptions\CatchException;
 use Throwable;
 
-class CommonBusinessException extends \RuntimeException
+class CommonBusinessException extends CatchException
 {
     public function __construct($message = "", $code = 0, Throwable $previous = null)
     {
-        parent::__construct($message, $code, $previous);
+        parent::__construct($message, $code);
     }
 
     public static function throwError($error, Throwable $previous = null) {

+ 2 - 5
modules/User/Http/Controllers/UserTrait.php

@@ -76,13 +76,10 @@ trait UserTrait
         return compact('loginUser', 'loginUserRoles', 'operateUserRoles', 'operateUser');
     }
 
-    public function getCompanyUid() {
+    public function getOptimizerUid() {
         $currentUserRoles = $this->listUserRoles();
-        if($currentUserRoles->contains('company')) {
-            return $this->getCurrentUser()->id;
-        }
         if($currentUserRoles->contains('optimizer')) {
-            return $this->getCurrentUser()->pid;
+            return $this->getCurrentUser()->id;
         }
         return null;
     }

+ 1 - 1
modules/Video/Http/Controllers/EpisodeController.php

@@ -81,7 +81,7 @@ class EpisodeController extends CatchController
             return collect($data)->keyBy('series_sequence')->get($item)['series_name'];
         });
         if($alreadySeries->isNotEmpty()) {
-            CommonBusinessException::throwError([-1, $alreadySeries->join(', ') . ' 已经存在']);
+            CommonBusinessException::throwError([-2333, $alreadySeries->join(', ') . ' 已经存在']);
         }
 
         DB::table('video_series')->insert($data);

+ 2 - 2
tests/UsedTestCase.php

@@ -13,11 +13,11 @@ abstract class UsedTestCase extends BaseTestCase
     {
         parent::setUp(); // TODO: Change the autogenerated stub
         $tokenInfo = $this->post('http://localhost/api/login', [
-//            'email' => 'catch@admin.com',
+            'email' => 'catch@admin.com',
             'remember' => false,
 //            'email' => 'xiaoli@qq.com',
             'password' => 'catchadmin',
-            'email' => 'aa@test.com',
+//            'email' => 'aa@test.com',
         ])->json();
         $this->token = $tokenInfo['data']['token'];
     }