Sfoglia il codice sorgente

会员端首页,增加显示合格截止日期

theo 3 anni fa
parent
commit
f2c3211ac4

+ 14 - 0
common/models/Order.php

@@ -134,4 +134,18 @@ class Order extends \common\components\ActiveRecord
             'EMAIL' => 'Email'
         ];
     }
+    /*
+     * 通过 期数和用户ID
+     * 查询当月订单
+     */
+    public static function fetchOrderCurrentMonth($periodNum, $userId){
+        if($periodNum % 2 == 0){
+            $periods = [$periodNum-1, $periodNum];
+        }else{
+            $periods = [$periodNum];
+        }
+        $periodsStr = implode(",", $periods);
+        $orders = Order::find()->where("USER_ID = '$userId' AND PERIOD_NUM IN (' . $periodsStr . ')");
+        return $orders;
+    }
 }

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

@@ -20,6 +20,7 @@ use common\models\FlowBonus;
 use common\models\Period;
 use common\models\ReconsumePool;
 use common\models\RemainPv;
+use common\models\Order;
 
 class DashboardController extends BaseController
 {
@@ -96,6 +97,22 @@ class DashboardController extends BaseController
 
         //剩余分期PV显示
         $myRemainPv = RemainPv::findOne(['USER_ID'=>$baseInfo['ID']])->REMAIN_PV ?? 0;
+        // 找到当月的所有订单,计算总PV及总REMAIN_PV
+        $myOrders = Order::fetchOrderCurrentMonth($periodNum, $baseInfo['ID']);
+        $currentPv = $myOrders->SUM('PV');
+        $currentRemainPv = $myOrders->SUM('REMAIN_PV');
+
+        $totalRemainPv = $myRemainPv + $currentRemainPv;
+        $remainMonth = $totalRemainPv / 30;
+
+        if($currentPv >= 30){ // 如果当月合格,则活跃资格延后一个月
+            $activeEndStr = date("Y-m", strtotime('next month'));
+        }else{
+            $activeEndStr = date("Y-m");
+        }
+
+        $activeEndStr = $activeEndStr. " + $remainMonth months";
+        $activeEnd = date("Y-m-d H:i:s", strtotime($activeEndStr));
 
         return static::notice([
             'nowTime' => $nowTime,
@@ -107,7 +124,8 @@ class DashboardController extends BaseController
             'news'=>$news,
 //            'periodNum'=>'Period '.$periodNum.' ,'.$curYM['CALC_MONTH'].'月第'.$wkrd.'周,共'.$weeks.'周',
             'periodNum'=>$periodNum.' ,'.$wkrd.' period  of '. $monthArray[$curYM['CALC_MONTH']],
-            'myRemainPv'=>$myRemainPv
+            'myRemainPv'=>$totalRemainPv,
+            'activeEnd'=>$activeEnd
         ]);
     }
 

+ 92 - 88
frontendEle/src/views/dashboard/index.vue

@@ -10,7 +10,8 @@
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
             <el-row :gutter="10">
               <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="12">Current System Time:{{nowDateTime}}</el-col> <!--当前系统时间-->
-              <el-col :xs="24" :sm="24" :md="24" :lg="4" :xl="12">Rank:{{myEmpLv['LEVEL_NAME']!='No Rank'?myEmpLv['LEVEL_NAME']:''}}<!--<span v-if="myEmpLv['ICON_TYPE']==0">No Rank</span><img
+              <el-col :xs="24" :sm="24" :md="24" :lg="4" :xl="12">Rank:{{myEmpLv['LEVEL_NAME']!='No Rank'?myEmpLv['LEVEL_NAME']:''}}
+                <!--<span v-if="myEmpLv['ICON_TYPE']==0">No Rank</span><img
                   :src="getEmpIco(myEmpLv['ICON_TYPE'])" alt=""
                   v-for="(o,key) in parseInt(myEmpLv['ICON_NUM'])"
                   :key="key" v-if="myEmpLv['ICON_TYPE']>0">-->
@@ -18,6 +19,7 @@
               <el-col :xs="24" :sm="24" :md="24" :lg="4" :xl="12">Member Level:{{decLvName}}</el-col><!--会员级别-->
               <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="12">Current Period:{{periodNum}}</el-col><!--当前业绩期-->
               <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="12">Remain BV:{{myRemainPv}}</el-col><!--剩余的PV-->
+              <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="12">Active Deadline Date:{{activeEnd}}</el-col><!--活跃日期截止-->
             </el-row>
           </el-col>
         </el-row>
@@ -67,101 +69,103 @@
 </template>
 
 <script>
-  import network from '@/utils/network'
-  import tool from '@/utils/tool'
-  import baseInfo from '@/utils/baseInfo'
-  import userInfo from '@/utils/userInfo'
-  import countUp from 'vue-countup-v2'
+import network from '@/utils/network'
+import tool from '@/utils/tool'
+import baseInfo from '@/utils/baseInfo'
+import userInfo from '@/utils/userInfo'
+import countUp from 'vue-countup-v2'
 
-  export default {
-    name: 'dashboard_index',
-    components: {
-      countUp
-    },
-    mounted() {
-      network.getData(`dashboard/index`).then(response => {
-        this.myEmpLv.ID = this.baseEmpLevels[response.empLv]['ID']
-        this.myEmpLv.LEVEL_NAME = this.baseEmpLevels[response.empLv]['LEVEL_NAME']
-        this.myEmpLv.ICON_TYPE = this.baseEmpLevels[response.empLv]['ICON_TYPE']
-        this.myEmpLv.ICON_NUM = this.baseEmpLevels[response.empLv]['ICON_NUM']
-        this.slides = response.slides
-        this.news = response.news
-        this.periodNum = response.periodNum
-        this.decLvName = response.decLvName
-        this.myRemainPv = response.myRemainPv
-        this.loading = false
-        this.imgLoad()
-        return network.getData(`dashboard/bonus-num`)
-      })
-      if(this.verified==='0'){
-		  // '您未实名认证,请登录商城系统完善会员资料并上传身份证', '请注意'
-        this.$confirm('You do not have real name authentication, please log in the member system to complete the member information and upload ID card.', 'Please pay attention', {
-          confirmButtonText: 'Confirm',//确定
-          type: 'warning'
-        }).then(() => {
-        }).catch(() => {
+export default {
+  name: 'dashboard_index',
+  components: {
+    countUp
+  },
+  mounted () {
+    network.getData(`dashboard/index`).then(response => {
+      this.myEmpLv.ID = this.baseEmpLevels[response.empLv]['ID']
+      this.myEmpLv.LEVEL_NAME = this.baseEmpLevels[response.empLv]['LEVEL_NAME']
+      this.myEmpLv.ICON_TYPE = this.baseEmpLevels[response.empLv]['ICON_TYPE']
+      this.myEmpLv.ICON_NUM = this.baseEmpLevels[response.empLv]['ICON_NUM']
+      this.slides = response.slides
+      this.news = response.news
+      this.periodNum = response.periodNum
+      this.decLvName = response.decLvName
+      this.myRemainPv = response.myRemainPv
+      this.activeEnd = response.activeEnd
+      this.loading = false
+      this.imgLoad()
+      return network.getData(`dashboard/bonus-num`)
+    })
+    if (this.verified === '0') {
+    // '您未实名认证,请登录商城系统完善会员资料并上传身份证', '请注意'
+      this.$confirm('You do not have real name authentication, please log in the member system to complete the member information and upload ID card.', 'Please pay attention', {
+        confirmButtonText: 'Confirm', // 确定
+        type: 'warning'
+      }).then(() => {
+      }).catch(() => {
 
-        })
-      }
-      this.calcTime()
-      window.addEventListener('resize', () => {
-        this.imgLoad()
-      }, false)
+      })
+    }
+    this.calcTime()
+    window.addEventListener('resize', () => {
+      this.imgLoad()
+    }, false)
+  },
+  data () {
+    return {
+      loading: true,
+      tool: tool,
+      nowTime: tool.getTimestamp(),
+      userName: userInfo.userName(),
+      verified: userInfo.baseData().VERIFIED,
+      baseEmpLevels: baseInfo.empLevels(),
+      myEmpLv: {'ID': 0, 'LEVEL_NAME': null, 'ICON_TYPE': 0, 'ICON_NUM': 0},
+      slides: [],
+      news: [],
+      periodNum: '',
+      decLvName: '',
+      myRemainPv: '',
+      activeEnd: '',
+      bannerHeight: ''
+    }
+  },
+  computed: {
+    nowDateTime: function () {
+      return tool.formatDate(this.nowTime)
+    }
+  },
+  methods: {
+    getEmpIco (type) {
+      if (type) return require('@/assets/emp-ico-' + type + '.png')
     },
-    data() {
-      return {
-        loading: true,
-        tool: tool,
-        nowTime: tool.getTimestamp(),
-        userName: userInfo.userName(),
-        verified: userInfo.baseData().VERIFIED,
-        baseEmpLevels: baseInfo.empLevels(),
-        myEmpLv: {'ID': 0, 'LEVEL_NAME': null, 'ICON_TYPE': 0, 'ICON_NUM': 0},
-        slides: [],
-        news: [],
-        periodNum: '',
-        decLvName: '',
-        myRemainPv: '',
-        bannerHeight: '',
-      }
+    getEmpBg (type) {
+      if (type !== 0) return 'backgroundImage:url(' + require('@/assets/emp-bg-' + type + '.png') + ')'
+    },
+    sub_str (str, len = 15) {
+      if (str) return str.slice(0, len)
     },
-    computed: {
-      nowDateTime: function () {
-        return tool.formatDate(this.nowTime)
+    calcTime () {
+      let obj = this
+      setInterval(function () {
+        obj.nowTime += 1
+      }, 1000)
+    },
+    go: function (url) {
+      this.$router.push(url)
+    },
+    imgLoad () {
+      let _this = this
+      if (_this.$refs.bannerHeight) {
+        _this.$nextTick(function () {
+          _this.bannerHeight = _this.$refs.bannerHeight[0].height
+        })
       }
     },
-    methods: {
-      getEmpIco(type) {
-        if (type) return require('@/assets/emp-ico-' + type + '.png')
-      },
-      getEmpBg(type) {
-        if (type != 0) return 'backgroundImage:url(' + require('@/assets/emp-bg-' + type + '.png') + ')'
-      },
-      sub_str(str, len = 15) {
-        if (str) return str.slice(0, len)
-      },
-      calcTime() {
-        let obj = this
-        setInterval(function () {
-          obj.nowTime += 1
-        }, 1000)
-      },
-      go: function (url) {
-        this.$router.push(url)
-      },
-      imgLoad() {
-        let _this = this
-        if (_this.$refs.bannerHeight) {
-          _this.$nextTick(function () {
-            _this.bannerHeight = _this.$refs.bannerHeight[0].height
-          })
-        }
-      },
-      imageArticle(imageUrl) {
-        return tool.getArImage(imageUrl, '/files/');
-      },
+    imageArticle (imageUrl) {
+      return tool.getArImage(imageUrl, '/files/')
     }
   }
+}
 </script>
 
 <style scoped>