Explorar el Código

feat: EK-2086: Member Portal : Dashboard Article and Ad only show self country.

kevin hace 4 meses
padre
commit
6b4f2c0a6e

+ 16 - 5
frontendApi/modules/v1/controllers/ArticleController.php

@@ -9,6 +9,7 @@ namespace frontendApi\modules\v1\controllers;
 
 use common\models\Article;
 use common\models\ArticleCategory;
+use common\models\User;
 use Yii;
 
 class ArticleController extends BaseController
@@ -20,10 +21,17 @@ class ArticleController extends BaseController
      * @return mixed
      * @throws \yii\web\HttpException
      */
-    public function actionIndex(){
+    public function actionIndex()
+    {
         $news=ArticleCategory::find()->select('ID,CATE_NAME')->asArray()->all();
         foreach ($news as &$value){
-            $value['LISTS']=Article::find()->select('ID,TITLE,CID,CREATED_AT')->where('CID=:CID AND STATUS=1',[':CID'=>$value['ID']])->orderBy('CREATED_AT DESC')->limit(5)->asArray()->all();
+            $value['LISTS']=Article::find()
+                ->select('ID,TITLE,CID,CREATED_AT')
+                ->where('CID=:CID AND STATUS=1 AND COUNTRY_ID=:COUNTRY_ID', [':CID'=>$value['ID'], ':COUNTRY_ID'=>$baseInfo['COUNTRY_ID']])
+                ->orderBy('CREATED_AT DESC')
+                ->limit(5)
+                ->asArray()
+                ->all();
         }
         return static::notice($news);
     }
@@ -52,10 +60,13 @@ class ArticleController extends BaseController
      * @return mixed
      * @throws \yii\web\HttpException
      */
-    public function actionList(){
+    public function actionList()
+    {
+        $userInfo = User::getEnCodeInfo(\Yii::$app->user->id);
+
         $cid = \Yii::$app->request->get('cid');
-        $condition = ' AND A.STATUS=1';
-        $params = [];
+        $condition = ' AND A.STATUS=1 AND A.COUNTRY_ID=:COUNTRY_ID';
+        $params = [':COUNTRY_ID' => $userInfo['COUNTRY_ID']];
         if($cid){
             $condition .= ' AND CID=:CID';
             $params[':CID'] = $cid;

+ 19 - 4
frontendApi/modules/v1/controllers/DashboardController.php

@@ -44,13 +44,21 @@ class DashboardController extends BaseController
         $nowTime = Date::nowTime();
         $baseInfo=Info::baseInfoZh(\Yii::$app->user->id);
         $news=ArticleCategory::find()->select('ID,CATE_NAME')->orderBy('SORT ASC')->asArray()->all();
-        $where = ' CID=:CID AND STATUS=1';
+        $where = ' CID=:CID AND STATUS=1 AND COUNTRY_ID=:COUNTRY_ID';
         foreach ($news as &$value){
             $params = [
-                ':CID'=>$value['ID'],
+                ':CID' => $value['ID'],
+                ':COUNTRY_ID' => $baseInfo['COUNTRY_ID'],
             ];
-            $value['LISTS']=Article::find()->select('ID,TITLE,CID,CREATED_AT')->where($where,$params)->orderBy('CREATED_AT DESC')->limit(6)->asArray()->all();
+            $value['LISTS'] = Article::find()
+                ->select('ID,TITLE,CID,CREATED_AT')
+                ->where($where,$params)
+                ->orderBy('CREATED_AT DESC')
+                ->limit(6)
+                ->asArray()
+                ->all();
         }
+
         $empLv = $baseInfo['EMP_LV'];
         $empLvName = $baseInfo['EMP_LV_NAME'];
         if($baseInfo['SHOW_EMP_LV']){
@@ -121,6 +129,13 @@ class DashboardController extends BaseController
         $activeEndStr = $activeEndStr. " + $remainMonth months";
         $activeEnd = date("Y-m-d H:i:s", strtotime($activeEndStr));
 
+        $sliders = Ad::findUseSlaves()
+            ->select('ID,IMAGE,LID,TITLE,CONTENT,TYPE')
+            ->where('LID=:LID AND STATUS=1 AND COUNTRY_ID=:COUNTRY_ID', [':LID'=>'7EFF6260A16C3CC7E053693418AC03E4', ':COUNTRY_ID'=>$baseInfo['COUNTRY_ID']])
+            ->orderBy('SORT ASC')
+            ->asArray()
+            ->all();
+
         return static::notice([
             'nowTime' => $nowTime,
             'empLv'=>$empLv,
@@ -129,7 +144,7 @@ class DashboardController extends BaseController
             'decLvName'=>$decLvName,
             'eliteLv'=>$eliteLv,
             'eliteLvName'=>$eliteLvName,
-            'slides'=>Ad::findUseSlaves()->select('ID,IMAGE,LID,TITLE,CONTENT,TYPE')->where('LID=:LID AND STATUS=1', [':LID'=>'7EFF6260A16C3CC7E053693418AC03E4'])->orderBy('SORT ASC')->asArray()->all(),
+            'slides'=> $sliders,
             'news'=>$news,
             'periodNum'=>$periodNum . ', ' . $wkrd . ' '. Yii::t('app', 'pcOf') . ' '. $monthArray[$curYM['CALC_MONTH']],
             'myRemainPv'=>$totalRemainPv,