Browse Source

一个投手有多个广告账号

liuzejian 1 year ago
parent
commit
d434d83489

+ 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);
             }
         }
 

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

@@ -78,13 +78,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;
     }