ソースを参照

feat: EK-879: 【AE】管理员增加“Country”属性,根据所选国家限制登录后所显示的奖金、余额等数据(二期).

kevinElken 9 ヶ月 前
コミット
0e1cb03829

+ 11 - 0
backendApi/modules/v1/controllers/BonusController.php

@@ -899,6 +899,17 @@ class BonusController extends BaseController {
             $params[':PERIOD_NUM'] = $periodNum;
         }
 
+        $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
+        if (!$isSuper) {
+            $adminId = Yii::$app->getUser()->getUserInfo()['id'];
+            $adminCountry = AdminCountry::getCountry($adminId);
+            $quotedAdminCountry = array_map(function($item) {
+                return "'" . addslashes($item) . "'";
+            }, $adminCountry);
+
+            $condition .= " AND CU.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
+        }
+
         $listObj = new PeriodBonusList();
         return $listObj->getList(['condition'=>$condition, 'params'=>$params, 'others'=>['yearMonth'=>$yearMonth]]);
     }

+ 5 - 1
backendApi/modules/v1/models/lists/bonus/PeriodBonusList.php

@@ -6,10 +6,12 @@ use common\helpers\Tool;
 use common\helpers\user\Info;
 use common\libs\dataList\DataListInterface;
 use common\models\CalcBonus;
+use common\models\Countries;
 use common\models\DeclarationLevel;
 use common\models\EliteLevel;
 use common\models\EmployLevel;
 use common\models\Period;
+use common\models\User;
 use common\models\UserInfo;
 use Yii;
 
@@ -31,11 +33,13 @@ class PeriodBonusList extends \common\libs\dataList\DataList implements DataList
     {
         $yearMonth = $this->others['yearMonth'];
         $this->listData = CalcBonus::lists($this->condition, $this->params, [
-            'select'=>'CB.*,UI.CON_UID,UI.REC_UID,PO.CALC_YEAR,PO.CALC_MONTH',
+            'select'=>'CB.*,UI.CON_UID,UI.REC_UID,PO.CALC_YEAR,PO.CALC_MONTH, C.NAME AS COUNTRY',
             'from' => CalcBonus::tableName().' AS CB',
             'join' => [
                 ['INNER JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
                 ['INNER JOIN', Period::tableName() . ' AS PO', 'PO.PERIOD_NUM=CB.PERIOD_NUM'],
+                ['INNER JOIN', User::tableName() . ' AS CU', 'UI.USER_ID=CU.ID'],
+                ['INNER JOIN', Countries::tableName() . ' AS C', 'CU.COUNTRY_ID=C.ID'],
             ],
             'yearMonth' => $yearMonth,
             'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',