浏览代码

Merge branch 'new-version' into feature/2047-saveUserLevel

kevin_zhangl 3 年之前
父节点
当前提交
0e7e910ef4

+ 3 - 0
backendApi/config/menu.php

@@ -47,9 +47,12 @@ return [
             ['name'=>'订单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],
             ['name'=>'订单列表导出', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list-export', 'routePath'=>'shop/order-list-export', 'show'=>0,],
             ['name'=>'订单发货', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-delivery', 'routePath'=>'shop/order-delivery', 'show'=>0,],
+            ['name'=>'剩余PV', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'remain-pv', 'routePath'=>'shop/remain-pv', 'show'=>1,], // 剩余BV
+            ['name'=>'剩余PV流水', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'flow-remain-pv', 'routePath'=>'shop/flow-remain-pv', 'show'=>1,], // 剩余BV流水
             ['name'=>'外部商城订单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-shop-list', 'routePath'=>'shop/order-shop-list', 'show'=>1,],
             ['name'=>'外部商城报单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-dec-list', 'routePath'=>'shop/order-dec-list', 'show'=>1,],
             ['name'=>'外部商城达标订单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-standard-list', 'routePath'=>'shop/order-standard-list', 'show'=>1,],
+
         ]
     ],
     'user'=>[

+ 2 - 0
backendApi/config/urlManagerRules.php

@@ -63,6 +63,8 @@ return [
             'GET order-standard-list' => 'order-standard-list',
             'POST import-order-standard-to-excel-table' => 'import-order-standard-to-excel-table',
             'POST import-order-standard' => 'import-order-standard',
+            'GET remain-pv' => 'remain-pv',
+            'GET flow-remain-pv' => 'flow-remain-pv',
         ],
     ],
     [

+ 2 - 2
backendApi/modules/v1/controllers/ConfigController.php

@@ -115,11 +115,11 @@ class ConfigController extends BaseController {
         // 获取会员报单级别的相关参数
         $decLevel = DeclarationLevel::find()->orderBy('SORT ASC')->asArray()->all();
         // 获取会员聘级相关参数
-        $empLevel = EmployLevel::getAllDataWithNumIndex();
+        // $empLevel = EmployLevel::getAllDataWithNumIndex();
         $result = [
             'config' => $configs,
             'decLevel' => $decLevel,
-            'empLevel' => $empLevel,
+            // 'empLevel' => $empLevel,
         ];
         return static::notice($result);
     }

+ 34 - 0
backendApi/modules/v1/controllers/ShopController.php

@@ -18,6 +18,8 @@ use backendApi\modules\v1\models\lists\shop\OrderShopList;
 use backendApi\modules\v1\models\lists\shop\OrderStandardList;
 use backendApi\modules\v1\models\lists\shop\PackageList;
 use common\helpers\bonus\CalcCache;
+use backendApi\modules\v1\models\lists\shop\RemainPvList;
+use backendApi\modules\v1\models\lists\shop\FlowRemainPvList;
 use common\helpers\Cache;
 use common\helpers\Date;
 use common\helpers\Form;
@@ -650,4 +652,36 @@ class ShopController extends BaseController {
         return static::notice('非法请求', 400);
     }
 
+
+    /*
+     * 剩余BV页
+     *
+     */
+    public function actionRemainPv()
+    {
+        $filter = $this->filterCondition([
+            'USER_NAME' => 'U.USER_NAME',
+        ]);
+        $condition = $filter['condition'];
+        $params = $filter['params'];
+        $listObj = new RemainPvList();
+        $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
+        return static::notice($data);
+    }
+
+    /*
+     * 剩余BV流水
+     *
+     */
+    public function actionFlowRemainPv()
+    {
+        $filter = $this->filterCondition([
+            'USER_NAME' => 'U.USER_NAME',
+        ]);
+        $condition = $filter['condition'];
+        $params = $filter['params'];
+        $listObj = new FlowRemainPvList();
+        $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
+        return static::notice($data);
+    }
 }

+ 122 - 0
backendApi/modules/v1/models/lists/shop/FlowRemainPvList.php

@@ -0,0 +1,122 @@
+<?php
+
+namespace backendApi\modules\v1\models\lists\shop;
+
+use common\helpers\Cache;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\DataListInterface;
+use common\libs\dataList\column\DateTime;
+use common\models\FlowRemainPv;
+use Yii;
+
+class FlowRemainPvList extends \common\libs\dataList\DataList implements DataListInterface {
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName() {
+        return '剩余BV流水';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle() {
+        $this->listData = FlowRemainPv::lists($this->condition, $this->params, [
+            'select' => 'FR.*,U.USER_NAME,U.REAL_NAME,U.IS_DEC',
+            'orderBy' => 'FR.UPDATED_AT DESC,FR.ID DESC',
+            'from' => FlowRemainPv::tableName() . ' AS FR',
+            'join' => [
+                ['LEFT JOIN', \common\models\User::tableName() . ' AS U', 'FR.USER_ID=U.ID'],
+            ],
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        foreach ($this->listData['list'] as $key => $value) {
+//            $this->listData['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
+        }
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn() {
+        if (!$this->columns) {
+            $this->columns = [
+                'ID' => null,
+                'PERIOD_NUM' => [
+                    'header' => '期数', // 期数
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'USER_NAME' => [
+                    'header' => '会员编号',//会员编号
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'valueOther' => [
+                        'tag' => ['type' => 'info', 'size' => 'small', 'class' => 'no-border']
+                    ],
+                ],
+                'REAL_NAME' => [
+                    'header' => '会员姓名',//会员姓名
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                    'valueOther' => [
+                        'tag' => ['type' => 'success', 'size' => 'small', 'class' => 'no-border']
+                    ],
+                ],
+                'REMAIN_PV_FLOW' => [
+                    'header' => '剩余PV流水',
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop' => 'REMAIN_PV_FLOW',
+                    ],
+                ],
+                'REMAIN_PV_TOTAL' => [
+                    'header' => '总剩余PV',
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop' => 'REMAIN_PV_TOTAL',
+                    ],
+                ],
+                'UPDATED_AT' => [
+                    'header' => '更新时间',//创建时间
+                    'value' => function ($row) {
+                        return (new DateTime([
+                            'value' => $row['UPDATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+                'ORDER_SN' => [
+                    'header' => '订单编号',
+                    'headerOther' => ['width' => '190'],
+                ]
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes() {
+        if (!$this->filterTypes) {
+            $this->filterTypes = [
+                'UPDATED_AT' => ['isUserTable' => false, 'name' => '更新时间', 'other' => 'date'], // 创建时间
+                'PERIOD_NUM' => ['isUserTable' => false, 'name' => '期数'], // 期数
+                'USER_NAME' => ['isUserTable' => false, 'name' => '会员编号'], // 会员编号
+                'REAL_NAME' => ['isUserTable' => false, 'name' => '会员姓名'], // 会员姓名
+            ];
+        }
+        return $this->filterTypes;
+    }
+}

+ 19 - 0
backendApi/modules/v1/models/lists/shop/OrderList.php

@@ -174,6 +174,17 @@ class OrderList extends \common\libs\dataList\DataList implements DataListInterf
                         return $orderType;
                     },
                 ],
+                'IS_AUTO' => [
+                    'header' => 'Is Auto', // 是否自动
+                    'value' => function ($row) {
+                        switch ($row['IS_AUTO']) {
+                            case 1:
+                                return 'Yes';
+                            case 0:
+                                return 'No';
+                        }
+                    },
+                ],
                 'WAREHOUSE' => [
                     'header' => '发货仓',
                 ],
@@ -301,6 +312,14 @@ class OrderList extends \common\libs\dataList\DataList implements DataListInterf
                 'MOBILE'=> ['name'=> '联系方式1'],
                 'PERIOD_NUM'=> ['name'=> '期数'],
                 'CREATED_AT'=> ['name'=> '创建时间', 'other'=>'date'],
+                'IS_AUTO' => [
+                    'name'=>'自动',
+                    'other'=> 'select',
+                    'selectData'=> [
+                        ['id'=>1, 'name'=>'是'],
+                        ['id'=>0, 'name'=>'否'],
+                    ]
+                ]
             ];
         }
         return $this->filterTypes;

+ 104 - 0
backendApi/modules/v1/models/lists/shop/RemainPvList.php

@@ -0,0 +1,104 @@
+<?php
+
+namespace backendApi\modules\v1\models\lists\shop;
+
+use common\helpers\Cache;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\DataListInterface;
+use common\libs\dataList\column\DateTime;
+use common\models\RemainPv;
+use Yii;
+
+class RemainPvList extends \common\libs\dataList\DataList implements DataListInterface {
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName() {
+        return '剩余BV';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle() {
+        $this->listData = RemainPv::lists($this->condition, $this->params, [
+            'select' => 'FR.*,U.USER_NAME,U.REAL_NAME,U.IS_DEC',
+            'orderBy' => 'FR.UPDATED_AT DESC,FR.ID DESC',
+            'from' => RemainPv::tableName() . ' AS FR',
+            'join' => [
+                ['LEFT JOIN', \common\models\User::tableName() . ' AS U', 'FR.USER_ID=U.ID'],
+            ],
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        foreach ($this->listData['list'] as $key => $value) {
+//            $this->listData['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
+        }
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn() {
+        if (!$this->columns) {
+            $this->columns = [
+                'ID' => null,
+                'USER_NAME' => [
+                    'header' => '会员编号',//会员编号
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'valueOther' => [
+                        'tag' => ['type' => 'info', 'size' => 'small', 'class' => 'no-border']
+                    ],
+                ],
+                'REAL_NAME' => [
+                    'header' => '会员姓名',//会员姓名
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                    'valueOther' => [
+                        'tag' => ['type' => 'success', 'size' => 'small', 'class' => 'no-border']
+                    ],
+                ],
+                'REMAIN_PV' => [
+                    'header' => '剩余PV',
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop' => 'REMAIN_PV',
+                    ],
+                ],
+                'UPDATED_AT' => [
+                    'header' => '更新时间',//创建时间
+                    'value' => function ($row) {
+                        return (new DateTime([
+                            'value' => $row['UPDATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes() {
+        if (!$this->filterTypes) {
+            $this->filterTypes = [
+                'UPDATED_AT' => ['isUserTable' => false, 'name' => '更新时间', 'other' => 'date'], // 创建时间
+                'USER_NAME' => ['isUserTable' => false, 'name' => '会员编号'], // 会员编号
+                'REAL_NAME' => ['isUserTable' => false, 'name' => '会员姓名'], // 会员姓名
+            ];
+        }
+        return $this->filterTypes;
+    }
+}

+ 24 - 0
backendEle/src/router/index.js

@@ -157,6 +157,30 @@ export const constantRouterMap = [
             },
 
         },
+      {
+        path: '/shop/remain-pv',
+        component: _import('shop/remain-pv'),
+        name: 'shop_remain-pv',
+        meta: {
+          title: '剩余PV', // 剩余BV
+          breadcrumb: [
+            {title: '首页', path: '/dashboard/index'}, // Dashboard
+            {title: '商城管理', path: '/shop/index'} // 商城管理
+          ],
+        },
+      },
+      {
+        path: '/shop/flow-remain-pv',
+        component: _import('shop/flow-remain-pv'),
+        name: 'shop_flow-remain-pv',
+        meta: {
+          title: '剩余PV流水', // 剩余BV流水
+          breadcrumb: [
+            {title: '首页', path: '/dashboard/index'}, // Dashboard
+            {title: '商城管理', path: '/shop/index'} // 商城管理
+          ],
+        },
+      },
     ],
   },
   {

+ 2 - 39
backendEle/src/views/config/bonus-opt.vue

@@ -112,44 +112,7 @@
         </div>
       </div>
     </div>
-    <div class="panel" v-if="permission.hasPermission(`config/bonus-dec-level`)">
-      <div class="panel-heading">
-        管理奖
-      </div>
-      <div class="panel-wrapper">
-        <div class="panel-body">
-          <el-table :data="decLevelTableData" stripe style="width: 100%;">
-            <el-table-column prop="LEVEL_NAME" label="级别名称"></el-table-column>
-            <el-table-column label="奇数代数(推广1人)">
-              <template slot-scope="scope">
-                <el-input v-model="scope.row.GL_ODD_DEEP_ONE" min="0" max="100">
-                  <template slot="append">代</template>
-                </el-input>
-              </template>
-            </el-table-column>
-            <el-table-column label="奇数代数(推广2人)">
-              <template slot-scope="scope">
-                <el-input v-model="scope.row.GL_ODD_DEEP_TWO" min="0" max="100">
-                  <template slot="append">代</template>
-                </el-input>
-              </template>
-            </el-table-column>
-            <el-table-column label="奇数代数(推广3人)">
-              <template slot-scope="scope">
-                <el-input v-model="scope.row.GL_ODD_DEEP_THREE" min="0" max="100">
-                  <template slot="append">代</template>
-                </el-input>
-              </template>
-            </el-table-column>
-          </el-table>
-        </div>
-        <div class="panel-footer">
-          <el-button type="primary" @click="onGLSubmit" :loading="glSubmitButtonStat" style="float: right;">保存
-          </el-button>
-        </div>
-      </div>
-    </div>
-    <div class="panel" v-if="permission.hasPermission(`config/bonus-emp-level`)">
+    <!-- <div class="panel" v-if="permission.hasPermission(`config/bonus-emp-level`)">
       <div class="panel-heading">
         荣衔奖和积分配置
       </div>
@@ -185,7 +148,7 @@
           </el-button>
         </div>
       </div>
-    </div>
+    </div> -->
   </div>
 </template>
 

+ 90 - 0
backendEle/src/views/shop/flow-remain-pv.vue

@@ -0,0 +1,90 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <div class="filter-box">
+        <filter-user :filter-types="filterTypes" @select-value="handleFilterUser"></filter-user>
+      </div>
+      <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;" :height="tool.getTableHeight()">
+        <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''" :prop="tableHeader.other.prop ? tableHeader.other.prop : null">
+          <template slot-scope="scope">
+            <template v-if="scope.row[tableHeader.index].other.tag" >
+              <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
+            </template>
+            <template v-else>
+              <div v-html="scope.row[tableHeader.index].value"></div>
+            </template>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="white-box-footer">
+        <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import network from '@/utils/network'
+import tool from '@/utils/tool'
+import baseInfo from '@/utils/baseInfo'
+import FilterUser from '../../components/FilterUser'
+import permission from '@/utils/permission'
+import Pagination from '@/components/Pagination'
+import filterHelper from '@/utils/filterHelper'
+
+export default {
+  name: 'shop_flow-remain-pv',
+  components: {FilterUser, Pagination},
+  mounted () {
+    this.getData()
+  },
+  data () {
+    return {
+      tableHeaders: null,
+      tableData: null,
+      loading: true,
+      multipleSelection: [],
+      currentPage: 1,
+      totalPages: 1,
+      totalCount: 1,
+      pageSize: 20,
+      tool: tool,
+      permission: permission,
+      baseDecLevels: baseInfo.decLevels(),
+      baseEmpLevels: baseInfo.empLevels(),
+      filterTypes: null,
+      filterModel: {}
+    }
+  },
+  methods: {
+    handleCurrentChange (page) {
+      this.getData(page, this.pageSize)
+    },
+    handleSizeChange (pageSize) {
+      this.getData(this.currentPage, pageSize)
+    },
+    handleFilterUser (filterData) {
+      filterHelper.handleFilterUser(this, filterData)
+    },
+    getData (page, pageSize) {
+      network.getPageData(this, 'shop/flow-remain-pv', page, pageSize, this.filterModel, response => {
+        this.filterTypes = response.filterTypes
+      })
+    }
+  }
+}
+
+</script>
+
+<style scoped>
+  .table-box .el-form-item__label {
+    width: 100px;
+    color: #99a9bf;
+  }
+
+  .table-box .el-form-item {
+    width: 30%;
+    margin-right: 0;
+    margin-bottom: 0;
+  }
+</style>

+ 22 - 1
backendEle/src/views/shop/goods-add.vue

@@ -21,7 +21,17 @@
                 <!-- <el-form-item label="复消购买方式">
                     <el-checkbox  v-for="(value,key) in sellType" v-model="form.sellType[key-1]" :key="key" >{{value.name}}</el-checkbox>
                 </el-form-item> -->
-
+                <el-form-item label="PV分期">
+<!--                    <el-checkbox v-model="form.pvSplit"></el-checkbox>-->
+                  <el-select v-model="form.pvSplit" placeholder="">
+                    <el-option
+                      v-for="item in pvSplitOptions"
+                      :key="item.value"
+                      :label="item.label"
+                      :value="item.value">
+                    </el-option>
+                  </el-select>
+                </el-form-item>
                 <el-form-item label="商品编号">
                     <el-input v-model="form.goodsNo"></el-input>
                 </el-form-item>
@@ -91,6 +101,15 @@
                 loading: false,
                 file:null,
                 uploadToken:'',
+      pvSplitOptions: [
+        {
+          value: '0',
+          label: 'No'
+        },
+        {
+          value: '1',
+          label: 'Yes'
+        }],
                 form:{
                     goodsName:'',
                     type:'',
@@ -100,6 +119,7 @@
                     unit:'',
                     marketPrice:'',
                     sellPrice:'',
+        pvSplit: '0',
                     pricePv:'',
                     point:'',
                     storeNums:'',
@@ -197,6 +217,7 @@
                     type: this.form.type,
                     giftType: sen_gift,
                     sellType: sellType,
+                    pvSplit: this.form.pvSplit,
                     goodsNo: this.form.goodsNo,
                     unit: this.form.unit,
                     marketPrice: this.form.marketPrice,

+ 22 - 1
backendEle/src/views/shop/index.vue

@@ -86,7 +86,17 @@
                     <!-- <el-form-item label="复消购买方式">
                          <el-checkbox  v-for="(value,index) in sell_type" v-model="value.checked" :key="index" >{{value.name}}</el-checkbox>
                     </el-form-item> -->
-
+                    <el-form-item label="PV分期">
+<!--                      <el-checkbox v-model="form.pvSplit" :checked="form.pvSplit">Yes</el-checkbox>-->
+            <el-select v-model="form.pvSplit" placeholder="">
+              <el-option
+                v-for="item in pvSplitOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value">
+              </el-option>
+            </el-select>
+                    </el-form-item>
                     <el-form-item label="商品编号">
                         <el-input v-model="form.goodsNo"></el-input>
                     </el-form-item>
@@ -227,6 +237,15 @@
                 dialogEditLoading: false,
                 dialogEditFormVisibleGoodsTimes: false,
                 dialogEditLoadingGoodsTimes: false,
+      pvSplitOptions: [
+        {
+          value: '0',
+          label: 'No'
+        },
+        {
+          value: '1',
+          label: 'Yes'
+        }],
                 form:{
                     sellType:[],
                     goodsName:'',
@@ -245,6 +264,7 @@
                     cover:'',
                     textarea:'',
                     sellDiscount:'',
+                    pvSplit:'',
                     statusdate:'',
                     goodsstatusdate:'',
                     goodsdate:'',
@@ -338,6 +358,7 @@
                     vueObj.form.sort=response.goodsInfo.SORT
                     vueObj.form.id=response.goodsInfo.ID
                     vueObj.form.statusdate=response.goodsInfo.STATUS_DATE
+    vueObj.form.pvSplit = response.goodsInfo.PV_SPLIT
                     vueObj.form.goodsstatusdate=response.goodsInfo.GOODS_STATUS_DATE
                     vueObj.form.goodsdate=response.goodsInfo.GOODS_DATE * 1000
                     // vueObj.form.sellType=vueObj.form.sellType.map((item,index)=>{

+ 90 - 0
backendEle/src/views/shop/remain-pv.vue

@@ -0,0 +1,90 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <div class="filter-box">
+        <filter-user :filter-types="filterTypes" @select-value="handleFilterUser"></filter-user>
+      </div>
+      <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;" :height="tool.getTableHeight()">
+        <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''" :prop="tableHeader.other.prop ? tableHeader.other.prop : null">
+          <template slot-scope="scope">
+            <template v-if="scope.row[tableHeader.index].other.tag" >
+              <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
+            </template>
+            <template v-else>
+              <div v-html="scope.row[tableHeader.index].value"></div>
+            </template>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="white-box-footer">
+        <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import network from '@/utils/network'
+import tool from '@/utils/tool'
+import baseInfo from '@/utils/baseInfo'
+import FilterUser from '../../components/FilterUser'
+import permission from '@/utils/permission'
+import Pagination from '@/components/Pagination'
+import filterHelper from '@/utils/filterHelper'
+
+export default {
+  name: 'shop_remain-pv',
+  components: {FilterUser, Pagination},
+  mounted () {
+    this.getData()
+  },
+  data () {
+    return {
+      tableHeaders: null,
+      tableData: null,
+      loading: true,
+      multipleSelection: [],
+      currentPage: 1,
+      totalPages: 1,
+      totalCount: 1,
+      pageSize: 20,
+      tool: tool,
+      permission: permission,
+      baseDecLevels: baseInfo.decLevels(),
+      baseEmpLevels: baseInfo.empLevels(),
+      filterTypes: null,
+      filterModel: {}
+    }
+  },
+  methods: {
+    handleCurrentChange (page) {
+      this.getData(page, this.pageSize)
+    },
+    handleSizeChange (pageSize) {
+      this.getData(this.currentPage, pageSize)
+    },
+    handleFilterUser (filterData) {
+      filterHelper.handleFilterUser(this, filterData)
+    },
+    getData (page, pageSize) {
+      network.getPageData(this, 'shop/remain-pv', page, pageSize, this.filterModel, response => {
+        this.filterTypes = response.filterTypes
+      })
+    }
+  }
+}
+
+</script>
+
+<style scoped>
+  .table-box .el-form-item__label {
+    width: 100px;
+    color: #99a9bf;
+  }
+
+  .table-box .el-form-item {
+    width: 30%;
+    margin-right: 0;
+    margin-bottom: 0;
+  }
+</style>

+ 4 - 115
common/helpers/bonus/BonusCalc.php

@@ -60,7 +60,7 @@ use yii\helpers\Json;
 class BonusCalc extends BaseObject {
     use StaticInstanceTrait;
 
-    private $_limit = 1000;
+    private $_limit = 10000;
     private $_gxLimit = 500;
     private $_handleUserId;
     private $_companyMonthPerf = 0;
@@ -198,33 +198,7 @@ class BonusCalc extends BaseObject {
             echo('计算推广奖'.($this->_sysConfig['openTG']['VALUE']?'完成':'关闭').',耗时:' . round($t5 - $t4, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(20);
 
-            if($this->_sysConfig['openXF']['VALUE']) {
-                if( $this->_sysConfig['consumeRecPercent']['VALUE'] > 0 ) {
-                    $this->calcBonusXFToRec();
-                }
-                if( $this->_sysConfig['consumeSelfPercent']['VALUE'] > 0 ) {
-                    $this->calcBonusXFToSelf();
-                }
-            }
-            $t6 = microtime(true);
-            echo('计算消费奖'.($this->_sysConfig['openXF']['VALUE']?'完成':'关闭').',耗时:' . round($t6 - $t5, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(25);
-
-            if($this->_sysConfig['openYJ']['VALUE']) {
-                $this->calcBonusBdYJ();
-            }
-            $t7 = microtime(true);
-            echo('计算报单业绩奖'.($this->_sysConfig['openYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(30);
-
-            if($this->_sysConfig['fxOpenYJ']['VALUE']) {
-                $this->calcBonusFxYJ();
-            }
             $t8 = microtime(true);
-            echo('计算复消业绩奖'.($this->_sysConfig['fxOpenYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t8 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(35);
-
-
             if($this->_sysConfig['openQY']['VALUE']) {
                 $this->calcBonusQY();
                 $this->calcBonusBdQY();
@@ -249,19 +223,6 @@ class BonusCalc extends BaseObject {
             echo('计算报单管理奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t13 - $t11, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(50);
 
-//            if($this->_sysConfig['fxOpenGL']['VALUE']) {
-//                $this->calcBonusFxGL();
-//            }
-//            $t14 = microtime(true);
-//            echo('计算复消管理奖'.($this->_sysConfig['fxOpenGL']['VALUE']?'完成':'关闭').',耗时:' . round($t14 - $t13, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-//            $this->_updatePercent(70);
-          
-
-            // if($this->_sysConfig['openYC']['VALUE']) {
-            //     $this->calcBonusYCStepOne();
-            //     $this->calcBonusYCStepTwo();
-            // }
-
             // 计算店服务奖 月奖
             if($this->_sysConfig['openStore']['VALUE']) {
                 if ($this->_sysConfig['openStoreReduce']['VALUE']) {
@@ -276,20 +237,7 @@ class BonusCalc extends BaseObject {
             echo('计算店服务奖金'.($this->_sysConfig['openStore']['VALUE']?'完成':'关闭').',耗时:' . round($t16 - $t13, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(55);
 
-            if($this->_sysConfig['openVIP']['VALUE']) {
-                $this->calcBonusVIP();
-            }
             $t17 = microtime(true);
-            echo('计算VIP奖'.($this->_sysConfig['openVIP']['VALUE']?'完成':'关闭').',耗时:' . round($t17 - $t16, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(60);
-
-            if($this->_sysConfig['openJXS']['VALUE']) {
-                $this->calcBonusStandard();
-            }
-            $t18 = microtime(true);
-            echo('计算达标奖'.($this->_sysConfig['openJXS']['VALUE']?'完成':'关闭').',耗时:' . round($t18 - $t17, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(65);
-
             // 蓝星奖入库,实际上是插入有奖金会员数据缓存中.
             // 调用存储过程,计算蓝星管理奖金
             $this->calcBsProcedure();
@@ -297,8 +245,8 @@ class BonusCalc extends BaseObject {
             $this->calcBonusBsGL();
             $this->calcBonusBsGLCF();
             $this->calcBonusBsYJCF();
-            $t18temp = microtime(true);
-            echo('计算蓝星管理奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t18temp - $t18, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $t18 = microtime(true);
+            echo('计算蓝星管理奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t18 - $t17, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(65);
 
             //把奖金会员写入缓存
@@ -311,7 +259,7 @@ class BonusCalc extends BaseObject {
             $this->loopBonusUsers();
             // 入库完成,将各个奖金计算流水会员聘级,更新成蓝星奖当时计算的聘级
             $this->loopCalcBlueEmpLv();
-            $this->_updatePercent(75);
+            $this->_updatePercent(85);
             unset($calcWrite);
             $t20 = microtime(true);
             echo('奖金写库操作完成,耗时:' . round($t20 - $t19, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
@@ -320,21 +268,7 @@ class BonusCalc extends BaseObject {
             $this->loopMonthBonusUserToDb();
             $t21 = microtime(true);
             echo('奖金会员入库完成,耗时:' . round($t21 - $t20, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(80);
-
-            // 计算基础积分,不可以奖金入库之前计算这样可能会丢掉只有本期的奖金的会员
-            $this->calcBaseScore();
-            $this->_updatePercent(90);
-            $t22 = microtime(true);
-            echo('计算基础积分,耗时:' . round($t22 - $t21, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-
-            //积分入库
-            $this->loopWriteScore();
             $this->_updatePercent(100);
-            $t23 = microtime(true);
-            echo('积分写库操作完成,耗时:' . round($t23 - $t22, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-
-            //@todo 计算房产奖
 
             $t30 = microtime(true);
             echo('结算全部完成,共耗时:' . round($t30 - $t1, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
@@ -509,11 +443,6 @@ class BonusCalc extends BaseObject {
                         'decPercentConfig' => $this->_sysConfig['decPercent']['VALUE'],
                         'recNum' => $bonusUserInfo['REC_NUM'],
                         'decAmount' => $bonusUserInfo['ZC_AMOUNT'],
-                        'bonusTotalLimit' => [
-                            $this->_sysConfig['bonusTotalZeroLimit']['VALUE'],
-                            $this->_sysConfig['bonusTotalOneLimit']['VALUE'],
-                            $this->_sysConfig['bonusTotalTwoLimit']['VALUE'],
-                        ],
                     ]),
                 ];
 
@@ -597,11 +526,6 @@ class BonusCalc extends BaseObject {
                         'recNum' => $userBaseInfo['REC_NUM'],
                         'decAmount' => $userBaseInfo['ZC_AMOUNT'],
                         'decLevel' => $userBaseInfo['DEC_LV'],
-                        'bonusTotalLimit' => [
-                            $this->_sysConfig['bonusTotalZeroLimit']['VALUE'],
-                            $this->_sysConfig['bonusTotalOneLimit']['VALUE'],
-                            $this->_sysConfig['bonusTotalTwoLimit']['VALUE'],
-                        ],
                     ]),
                 ];
 
@@ -685,11 +609,6 @@ class BonusCalc extends BaseObject {
                         'recNum' => $userBaseInfo['REC_NUM'],
                         'decAmount' => $userBaseInfo['ZC_AMOUNT'],
                         'decLevel' => $userBaseInfo['DEC_LV'],
-                        'bonusTotalLimit' => [
-                            $this->_sysConfig['bonusTotalZeroLimit']['VALUE'],
-                            $this->_sysConfig['bonusTotalOneLimit']['VALUE'],
-                            $this->_sysConfig['bonusTotalTwoLimit']['VALUE'],
-                        ],
                     ]),
                 ];
 
@@ -773,11 +692,6 @@ class BonusCalc extends BaseObject {
                         'recNum' => $userBaseInfo['REC_NUM'],
                         'decAmount' => $userBaseInfo['ZC_AMOUNT'],
                         'decLevel' => $userBaseInfo['DEC_LV'],
-                        'bonusTotalLimit' => [
-                            $this->_sysConfig['bonusTotalZeroLimit']['VALUE'],
-                            $this->_sysConfig['bonusTotalOneLimit']['VALUE'],
-                            $this->_sysConfig['bonusTotalTwoLimit']['VALUE'],
-                        ],
                     ]),
                 ];
 
@@ -1189,11 +1103,6 @@ class BonusCalc extends BaseObject {
                             'recNum' => $bonusUserBaseInfo['REC_NUM'],
                             'decAmount' => $bonusUserBaseInfo['ZC_AMOUNT'],
                             'decLevel' => $bonusUserBaseInfo['DEC_LV'],
-                            'bonusTotalLimit' => [
-                                $this->_sysConfig['bonusTotalZeroLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalOneLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalTwoLimit']['VALUE'],
-                            ],
                         ]),
                     ];
 
@@ -1307,11 +1216,6 @@ class BonusCalc extends BaseObject {
                             'recNum' => $bonusUserBaseInfo['REC_NUM'],
                             'decAmount' => $bonusUserBaseInfo['ZC_AMOUNT'],
                             'decLevel' => $bonusUserBaseInfo['DEC_LV'],
-                            'bonusTotalLimit' => [
-                                $this->_sysConfig['bonusTotalZeroLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalOneLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalTwoLimit']['VALUE'],
-                            ],
                         ]),
                     ];
 
@@ -1768,11 +1672,6 @@ class BonusCalc extends BaseObject {
                             'incomeBonus' => $incomeBonus,
                             'recNum' => $userBaseInfo['REC_NUM'],
                             'decAmount' => $userBaseInfo['ZC_AMOUNT'],
-                            'bonusTotalLimit' => [
-                                $this->_sysConfig['bonusTotalZeroLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalOneLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalTwoLimit']['VALUE'],
-                            ],
                         ]),
                     ];
 
@@ -2073,11 +1972,6 @@ class BonusCalc extends BaseObject {
                             'decAmount' => $bonusUserBaseInfo['ZC_AMOUNT'],
                             'fromUserId' => $userId,
                             'decLevel' => $bonusUserBaseInfo['DEC_LV'],
-                            'bonusTotalLimit' => [
-                                $this->_sysConfig['bonusTotalZeroLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalOneLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalTwoLimit']['VALUE'],
-                            ],
                         ]),
                     ];
 
@@ -2208,11 +2102,6 @@ class BonusCalc extends BaseObject {
                             'decAmount' => $bonusUserBaseInfo['ZC_AMOUNT'],
                             'fromUserId' => $userId,
                             'decLevel' => $bonusUserBaseInfo['DEC_LV'],
-                            'bonusTotalLimit' => [
-                                $this->_sysConfig['bonusTotalZeroLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalOneLimit']['VALUE'],
-                                $this->_sysConfig['bonusTotalTwoLimit']['VALUE'],
-                            ],
                         ]),
                     ];
 

+ 121 - 0
common/helpers/bonus/BonusSend.php

@@ -19,6 +19,7 @@ use common\helpers\user\Status;
 use common\libs\api\sms\SmsApi;
 use common\libs\swoole\Process;
 use common\models\DealType;
+use common\models\FlowRemainPv;
 use common\models\PerfPeriod;
 use common\models\DecOrder;
 use common\models\EmployLevel;
@@ -31,6 +32,8 @@ use common\models\UserPerf;
 use common\models\UserPerfUpdate;
 use common\models\UserTeamwork;
 use common\models\YearHighestEmpLv;
+use common\models\Order;
+use common\models\RemainPv;
 use yii\base\BaseObject;
 use yii\base\StaticInstanceTrait;
 use common\helpers\Cache;
@@ -121,6 +124,69 @@ class BonusSend extends BaseObject {
         return $this->_errors;
     }
 
+    /**
+     * 挂网时处理虚假订单
+     *
+     */
+    public function putFakeOrder() {
+        echo('开始处理-假订单' . PHP_EOL);
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NC默认300
+        $fakeOrder= Order::find()->where(['PERIOD_NUM'=>$this->_periodNum, 'IS_AUTO'=>'1'])->asArray()->all();
+//        print_r($fakeOrder);exit;
+        foreach($fakeOrder as $fOrder){
+            $oRemainPv=RemainPv::findOne(["USER_ID"=>$fOrder['USER_ID']]);
+            $transactionRemain = \Yii::$app->db->beginTransaction();
+            try{
+                $flowRemainPvModel = new FlowRemainPv();
+                $flowRemainPvModel->ID = $this->_generateSn();
+                $flowRemainPvModel->USER_ID = $fOrder['USER_ID'];
+                $flowRemainPvModel->REMAIN_PV_FLOW = 0 - $mesureUpCondition;
+                $flowRemainPvModel->REMAIN_PV_TOTAL = $oRemainPv->REMAIN_PV - $mesureUpCondition;
+                $flowRemainPvModel->PERIOD_NUM = $this->_periodNum;
+                $flowRemainPvModel->UPDATED_AT = Date::nowTime();
+                $flowRemainPvModel->ORDER_SN = $fOrder['SN'];
+                if(!$flowRemainPvModel->save()){
+                    $this->addErrors($flowRemainPvModel->getErrors());
+                    return false;
+                }
+                $oRemainPv->updateCounters(['REMAIN_PV'=> 0 - $mesureUpCondition]);
+                $transactionRemain->commit();
+            } catch (Exception $e) {
+                $transactionRemain->rollBack();
+                $this->addError('add', $e->getMessage());
+                return null;
+            }
+        }
+        echo('假订单处理完' . PHP_EOL);
+        return true; // $flowRemainPvModel;
+    }
+    /**
+     * 生成流水号
+     * @return string
+     */
+    private function _generateSn() {
+        return Date::today('Ymd') . $this->_random(10, 1);
+    }
+
+    /**
+     * 生成随机数
+     * @param $length
+     * @param int $numeric
+     * @return string
+     */
+    private function _random($length, $numeric = 0) {
+        $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
+        $seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed));
+        $hash = '';
+        $max = strlen($seed) - 1;
+        for ($i = 0; $i < $length; $i++) {
+            $hash .= $seed[mt_rand(0, $max)];
+        }
+        return $hash;
+    }
+
+
     /**
      * 进行奖金发放步骤
      * @return bool
@@ -130,6 +196,11 @@ class BonusSend extends BaseObject {
             $t1 = microtime(true);
             // 初始化
             $this->initTask();
+            echo('挂网开始');
+            $this->putFakeOrder();
+            // 先把有remainPv的订单处理一下,将remainPv加入到remain_pv及流水表
+            echo('处理当期REMAIN PV ' . date('Y-m-d  H:i:s', time()) . PHP_EOL);
+            $this->_calcRemainPv();
             $t2 = microtime(true);
             echo('初始化完成,当前期数【' . $this->_periodNum . '】,耗时:' . round($t2 - $t1, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             // 改变状态
@@ -195,6 +266,56 @@ class BonusSend extends BaseObject {
         return true;
     }
 
+    /**
+     * 处理order表中有remain_pv的订单
+     * 将结果写入到remainPv相关表中
+     *
+     */
+    private function _calcRemainPv(){
+        $orders = Order::find()->where('PERIOD_NUM=:PERIOD_NUM AND REMAIN_PV>0 AND IS_DELETE=0',[':PERIOD_NUM'=>$this->_periodNum])->asArray()->all();
+        foreach($orders as $order){
+            $oRemainPv = RemainPv::find()->where(['USER_ID' => $order['USER_ID']])->one();
+
+            $transactionRemain = \Yii::$app->db->beginTransaction();
+            try{
+                $flowRemainPvModel = new FlowRemainPv();
+                $flowRemainPvModel->ID = $this->_generateSn();
+                $flowRemainPvModel->USER_ID = $order['USER_ID'];
+                $flowRemainPvModel->REMAIN_PV_FLOW = $order['REMAIN_PV'];
+                $flowRemainPvModel->REMAIN_PV_TOTAL = $oRemainPv['REMAIN_PV'] + $order['REMAIN_PV'];
+                $flowRemainPvModel->PERIOD_NUM = $this->_periodNum;
+                $flowRemainPvModel->UPDATED_AT = Date::nowTime();
+                $flowRemainPvModel->ORDER_SN = $order['SN'];
+                if(!$flowRemainPvModel->save()){
+                    $this->addErrors($flowRemainPvModel->getErrors());
+                    return false;
+                }
+
+                $oRemainPv = RemainPv::find()->where(['USER_ID' => $order['USER_ID']])->one();
+                if($oRemainPv){
+                    $oRemainPv->updateCounters(['REMAIN_PV'=>$order['REMAIN_PV']]);
+                }else{
+                    $remainPvModel = new RemainPv();
+                    $remainPvModel->ID = $this->_generateSn();
+                    $remainPvModel->USER_ID = $order['USER_ID'];
+                    $remainPvModel->UPDATED_AT = Date::nowTime();
+                    $remainPvModel->REMAIN_PV = $order['REMAIN_PV'];
+                    $remainPvModel->STATUS = 1;
+                    if(!$remainPvModel->save()){
+                        $this->addErrors($remainPvModel->getErrors());
+                        return false;
+                    }
+                }
+                $transactionRemain->commit();
+            } catch (Exception $e) {
+                $transactionRemain->rollBack();
+                $this->addError('add', $e->getMessage());
+                return null;
+            }
+        }
+        return null;
+    }
+
     /**
      * 需要多进程执行的任务
      * @param $workId

+ 2 - 1
common/helpers/bonus/CalcCache.php

@@ -24,12 +24,13 @@ use common\models\UserBonus;
 use common\models\UserNetwork;
 use common\models\UserPerf;
 use common\models\UserRelation;
+use common\models\RemainPv;
 use Yii;
 use common\models\UserInfo;
 use yii\helpers\Json;
 
 class CalcCache {
-    const LIMIT = 1000;
+    const LIMIT = 10000;
 
     const REDIS_KEY_PREFIX_USER = 'calc:user_';
     const REDIS_KEY_PREFIX_USER_ACTIVE = 'calc:userActive_';

+ 115 - 19
common/helpers/bonus/PerfCalc.php

@@ -19,6 +19,7 @@ use common\helpers\user\Reconsume;
 use common\models\CalcBonus;
 use common\models\DeclarationLevel;
 use common\models\forms\DeclarationForm;
+use common\models\forms\OrderForm;
 use common\models\Order;
 use common\models\OrderDec;
 use common\models\OrderShop;
@@ -34,13 +35,15 @@ use common\models\EmployLevel;
 use common\models\PerfActiveUser;
 use common\models\StorePerfLog;
 use common\models\UserRelation;
+use common\models\RemainPv;
+use common\models\FlowRemainPv;
 use yii\base\Exception;
 use yii\base\StaticInstanceTrait;
 
 class PerfCalc {
     use StaticInstanceTrait;
 
-    private $_limit = 1000;
+    private $_limit = 10000;
     private $_handleUserId;
     private $_companyMonthPerf = 0;
     private $_cfTotalPercent = 0;
@@ -106,6 +109,110 @@ class PerfCalc {
         return $this->_errors;
     }
 
+    /**
+     * 生成流水号
+     * @return string
+     */
+    private function _generateSn() {
+        return Date::today('Ymd') . $this->_random(10, 1);
+    }
+
+    /**
+     * 生成随机数
+     * @param $length
+     * @param int $numeric
+     * @return string
+     */
+    private function _random($length, $numeric = 0) {
+        $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
+        $seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed));
+        $hash = '';
+        $max = strlen($seed) - 1;
+        for ($i = 0; $i < $length; $i++) {
+            $hash .= $seed[mt_rand(0, $max)];
+        }
+        return $hash;
+    }
+
+    /**
+     * 处理order表中有remain_pv的订单
+     * 将结果写入到remainPv相关表中
+     *
+     */
+    private function _calcRemainPv(){
+        $orders = Order::find()->where('PERIOD_NUM=:PERIOD_NUM AND REMAIN_PV>0',[':PERIOD_NUM'=>$this->_periodNum])->asArray()->all();
+        foreach($orders as $order){
+            $oRemainPv = RemainPv::find()->where(['USER_ID' => $order['USER_ID']])->one();
+
+            $transactionRemain = \Yii::$app->db->beginTransaction();
+            try{
+                $flowRemainPvModel = new FlowRemainPv();
+                $flowRemainPvModel->ID = $this->_generateSn();
+                $flowRemainPvModel->USER_ID = $order['USER_ID'];
+                $flowRemainPvModel->REMAIN_PV_FLOW = $order['REMAIN_PV'];
+                $flowRemainPvModel->REMAIN_PV_TOTAL = $oRemainPv['REMAIN_PV'] + $order['REMAIN_PV'];
+                $flowRemainPvModel->PERIOD_NUM = $this->_periodNum;
+                $flowRemainPvModel->UPDATED_AT = Date::nowTime();
+                $flowRemainPvModel->ORDER_SN = $order['SN'];
+                if(!$flowRemainPvModel->save()){
+                    $this->addErrors($flowRemainPvModel->getErrors());
+                    return false;
+                }
+
+                $oRemainPv = RemainPv::find()->where(['USER_ID' => $order['USER_ID']])->one();
+                if($oRemainPv){
+                    $oRemainPv->updateCounters(['REMAIN_PV'=>$order['REMAIN_PV']]);
+                }else{
+                    $remainPvModel = new RemainPv();
+                    $remainPvModel->ID = $this->_generateSn();
+                    $remainPvModel->USER_ID = $order['USER_ID'];
+                    $remainPvModel->UPDATED_AT = Date::nowTime();
+                    $remainPvModel->REMAIN_PV = $order['REMAIN_PV'];
+                    $remainPvModel->STATUS = 1;
+                    if(!$remainPvModel->save()){
+                        $this->addErrors($remainPvModel->getErrors());
+                        return false;
+                    }
+                }
+                $transactionRemain->commit();
+            } catch (Exception $e) {
+                $transactionRemain->rollBack();
+                $this->addError('add', $e->getMessage());
+                return null;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 生成假订单
+     *
+     */
+    public static function _createFakeOrder($periodNum){
+        echo('假假假'.$periodNum. PHP_EOL);
+        $userHaveRemain = RemainPv::findAllAsArray('REMAIN_PV >0');
+        $currentPeriod = Period::getInfoByPeriodNum($periodNum);
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NC默认300
+        if($currentPeriod['IS_MONTH']){
+            print_r('是月结点'.PHP_EOL);
+            $periods = Period::getCurrentMonthPeriodByPeriodNum($periodNum);
+            //先清除本期的假订单
+            echo('首先,清除上次尝试生成业绩单时所创建的虚假订单'. date('Y-m-d  H:i:s', time()) . PHP_EOL);
+            $delFOrder = Order::deleteAll(['IS_AUTO'=>'1','PERIOD_NUM'=>$periodNum]);
+            echo('检查有结余PV的用户,如果他当月PV不足'.$mesureUpCondition.',则为其创建假订单'. PHP_EOL);
+            foreach($userHaveRemain as $uR){
+                $myPv = Order::find()->where(['PERIOD_NUM'=>$periods, 'USER_ID'=>$uR['USER_ID']])->SUM('PV');
+                if($myPv < $mesureUpCondition){
+                    //制造虚拟订单
+                    echo('不足'.$mesureUpCondition.'了,生成假订单' . PHP_EOL);
+                    $newOrderForm = new OrderForm();
+                    $newOrderForm->addFakeOrder($uR['USER_ID'],$periodNum);
+                }
+            }
+        }
+    }
+
     /**
      * 计算步骤
      * @param $periodNum
@@ -129,9 +236,14 @@ class PerfCalc {
             // 清空相关表数据
             $this->clearTableData();
             $t2 = microtime(true);
+            echo(PHP_EOL . $periodNum. '期,生成业绩单,开始' . PHP_EOL);
             echo('初始化、清空缓存及相关数据表完成,耗时:' . round($t2 - $t1, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(10);
             // 计算月奖,才需要向缓存中加入按推荐深度的所有用户
+            echo('向缓存中加入用户开始 ' . date('Y-m-d  H:i:s', time()) . PHP_EOL);
+            echo('若需要,生成假订单' . date('Y-m-d  H:i:s', time()) . PHP_EOL);
+            $this->_createFakeOrder($periodNum);
+            echo('生成假订单完成,开始缓存用户'. date('Y-m-d  H:i:s', time()) . PHP_EOL);
             //修改每一期都缓存所有用户
             CalcCache::addUsers($this->_periodNum);
             $t3 = microtime(true);
@@ -963,16 +1075,7 @@ class PerfCalc {
                 $periodPerf = CalcCache::nowPeriodPerf($userId, $this->_periodNum);
 
                 $userBaseInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
-                //级别必须为VIP
-                $isVip = false;
-                if( $userBaseInfo['DEC_LV'] === DeclarationLevel::VIP_LEVEL_ID ) {
-                    $isVip= true;
-                }
-                if( $this->_sysConfig['vipBonusGoldDecLevel']['VALUE'] && $userBaseInfo['DEC_LV'] === DeclarationLevel::JIN_ZUAN_LEVEL_ID ) {
-                    $isVip = true;
-                }
-
-
+                
                 $nowMonthPerf = [
                     'USER_ID' => $userId,
                     'FX_AMOUNT_CASH' => $everyData['FX_AMOUNT_CASH_SUM'],
@@ -985,13 +1088,6 @@ class PerfCalc {
                     'PV_4L' => $everyData['PV_4L_SUM'],
                     'PV_5L' => $everyData['PV_5L_SUM'],
 
-                    //VIP统计相关业绩
-                    'VIP_PV_1L_ZC' => $isVip ? $everyData['PV_1L_ZC_SUM'] : 0,
-                    'VIP_PV_2L_ZC' => $isVip ? $everyData['PV_2L_ZC_SUM'] : 0,
-                    'VIP_PV_3L_ZC' => $isVip ? $everyData['PV_3L_ZC_SUM'] : 0,
-                    'VIP_PV_4L_ZC' => $isVip ? $everyData['PV_4L_ZC_SUM'] : 0,
-                    'VIP_PV_5L_ZC' => $isVip ? $everyData['PV_5L_ZC_SUM'] : 0,
-
                     //总数据,历史+本期。不能用上月加本月,因为上月可能没业绩,上上个月有业绩。
                     'PV_1L_TOTAL' => $periodPerf['PV_1L'] + $userLastPerf['PV_1L'],
                     'PV_2L_TOTAL' => $periodPerf['PV_2L'] + $userLastPerf['PV_2L'],
@@ -1005,7 +1101,7 @@ class PerfCalc {
                 CalcCache::addHasMonthPerfUsers($userId, $this->_periodNum);
                 CalcCache::nowMonthPerf($userId, $this->_periodNum, $nowMonthPerf);
 
-                unset($userId, $everyData, $nowMonthPerf, $lastMonthData, $userBaseInfo, $isVip);
+                unset($userId, $everyData, $nowMonthPerf, $lastMonthData, $userBaseInfo);
             }
             unset($allData);
             $this->loopCalcMonthPerfTableData($offset + $this->_limit);

+ 3 - 32
common/helpers/bonus/PreparePerfCalc.php

@@ -844,14 +844,7 @@ class PreparePerfCalc {
                 $periodPerf = PrepareCalcCache::nowPeriodPerf($userId, $this->_periodNum);
 
                 $userBaseInfo = PrepareCalcCache::getUserInfo($userId, $this->_periodNum);
-                //级别必须为VIP
-                $isVip = false;
-                if( $userBaseInfo['DEC_LV'] === DeclarationLevel::VIP_LEVEL_ID ) {
-                    $isVip= true;
-                }
-                if( $this->_sysConfig['vipBonusGoldDecLevel']['VALUE'] && $userBaseInfo['DEC_LV'] === DeclarationLevel::JIN_ZUAN_LEVEL_ID ) {
-                    $isVip = true;
-                }
+
                 // 查询月节点此期业绩,是否包含此用户
                 // 查询perfperiodprepare表中数据,是否有此用户信息.因为是月提前结算,所以此结算期是只有一个数据
                 $monthPrepare = PerfPeriodPrepare::findUseDbCalc()
@@ -903,13 +896,6 @@ class PreparePerfCalc {
                     'PV_4L' => $everyData['PV_4L_SUM'],
                     'PV_5L' => $everyData['PV_5L_SUM'],
 
-                    //VIP统计相关业绩
-                    'VIP_PV_1L_ZC' => $isVip ? $everyData['PV_1L_ZC_SUM'] : 0,
-                    'VIP_PV_2L_ZC' => $isVip ? $everyData['PV_2L_ZC_SUM'] : 0,
-                    'VIP_PV_3L_ZC' => $isVip ? $everyData['PV_3L_ZC_SUM'] : 0,
-                    'VIP_PV_4L_ZC' => $isVip ? $everyData['PV_4L_ZC_SUM'] : 0,
-                    'VIP_PV_5L_ZC' => $isVip ? $everyData['PV_5L_ZC_SUM'] : 0,
-
                     //总数据,历史+本期。不能用上月加本月,因为上月可能没业绩,上上个月有业绩。
                     'PV_1L_TOTAL' => $periodPerf['PV_1L'] + $userLastPerf['PV_1L'],
                     'PV_2L_TOTAL' => $periodPerf['PV_2L'] + $userLastPerf['PV_2L'],
@@ -923,7 +909,7 @@ class PreparePerfCalc {
                 PrepareCalcCache::addHasMonthPerfUsers($userId, $this->_periodNum);
                 PrepareCalcCache::nowMonthPerf($userId, $this->_periodNum, $nowMonthPerf);
 
-                unset($userId, $everyData, $nowMonthPerf, $lastMonthData, $userBaseInfo, $isVip);
+                unset($userId, $everyData, $nowMonthPerf, $lastMonthData, $userBaseInfo);
             }
             unset($allData);
             return $this->loopCalcMonthPerfTableData($offset + $this->_limit);
@@ -977,14 +963,6 @@ class PreparePerfCalc {
                 $periodPerf = PrepareCalcCache::nowPeriodPerf($userId, $this->_periodNum);
 
                 $userBaseInfo = PrepareCalcCache::getUserInfo($userId, $this->_periodNum);
-                //级别必须为VIP
-                $isVip = false;
-                if( $userBaseInfo['DEC_LV'] === DeclarationLevel::VIP_LEVEL_ID ) {
-                    $isVip= true;
-                }
-                if( $this->_sysConfig['vipBonusGoldDecLevel']['VALUE'] && $userBaseInfo['DEC_LV'] === DeclarationLevel::JIN_ZUAN_LEVEL_ID ) {
-                    $isVip = true;
-                }
 
                 $nowMonthPerf = [
                     'USER_ID' => $userId,
@@ -998,13 +976,6 @@ class PreparePerfCalc {
                     'PV_4L' => $everyData['PV_4L_SUM'],
                     'PV_5L' => $everyData['PV_5L_SUM'],
 
-                    //VIP统计相关业绩
-                    'VIP_PV_1L_ZC' => $isVip ? $everyData['PV_1L_ZC_SUM'] : 0,
-                    'VIP_PV_2L_ZC' => $isVip ? $everyData['PV_2L_ZC_SUM'] : 0,
-                    'VIP_PV_3L_ZC' => $isVip ? $everyData['PV_3L_ZC_SUM'] : 0,
-                    'VIP_PV_4L_ZC' => $isVip ? $everyData['PV_4L_ZC_SUM'] : 0,
-                    'VIP_PV_5L_ZC' => $isVip ? $everyData['PV_5L_ZC_SUM'] : 0,
-
                     //总数据,历史+本期。不能用上月加本月,因为上月可能没业绩,上上个月有业绩。
                     'PV_1L_TOTAL' => $periodPerf['PV_1L'] + $userLastPerf['PV_1L'],
                     'PV_2L_TOTAL' => $periodPerf['PV_2L'] + $userLastPerf['PV_2L'],
@@ -1027,7 +998,7 @@ class PreparePerfCalc {
                 );
 
 
-                unset($userId, $everyData, $nowMonthPerf, $lastMonthData, $userBaseInfo, $isVip);
+                unset($userId, $everyData, $nowMonthPerf, $lastMonthData, $userBaseInfo);
             }
             unset($allData);
             return $this->loopCalcMonthPerfTableDataPrepare($offset + $this->_limit);

+ 25 - 0
common/models/FlowRemainPv.php

@@ -0,0 +1,25 @@
+<?php
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%FLOW_REMAIN_PV}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 会员ID
+ * @property int $REMAIN_PV_FLOW 剩余BV FLOW
+ * @property int $UPDATED_AT 更新时间
+ * @property varchar $ORDER_SN 订单SN号
+ */
+class FlowRemainPv extends \common\components\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%FLOW_REMAIN_PV}}';
+    }
+
+}

+ 26 - 0
common/models/Order.php

@@ -126,4 +126,30 @@ class Order extends \common\components\ActiveRecord
             'WAREHOUSE' => '发货仓',
         ];
     }
+    /*
+     * 通过 期数和用户ID
+     * 查询当月订单
+     */
+    public static function fetchOrderCurrentMonth($periodNum, $userId){
+        $currentPeriod = Period::findOneAsArray("PERIOD_NUM = :PERIOD_NUM", [':PERIOD_NUM' => $periodNum]);
+
+        switch ($currentPeriod['WEEK_NUMBER']){
+            case 1:
+                $periods = [$periodNum];
+                break;
+            case 2:
+                $periods = [$periodNum-1, $periodNum];
+                break;
+            case 3:
+                $periods = [$periodNum-2, $periodNum-1, $periodNum];
+                break;
+            case 4:
+                $periods = [$periodNum-3, $periodNum-2, $periodNum-1, $periodNum];
+                break;
+        }
+
+        $periodsStr = implode(",", $periods);
+        $orders = Order::find()->where("USER_ID = :USER_ID AND PERIOD_NUM IN ($periodsStr)", [':USER_ID' => $userId]);
+        return $orders;
+    }
 }

+ 17 - 0
common/models/Period.php

@@ -831,4 +831,21 @@ class Period extends \common\components\ActiveRecord
     public static function getMonthNum($startPeriodNum,$endPeriodNum){
         return self::find()->select('CALC_MONTH')->groupBy('CALC_MONTH')->where('PERIOD_NUM>=:START_PERIOD AND PERIOD_NUM<=:END_PERIOD',[':START_PERIOD'=>$startPeriodNum,':END_PERIOD'=>$endPeriodNum])->count();
     }
+
+    /**
+     * 从期数获取当前月的所有期
+     *
+     */
+    public static function getCurrentMonthPeriodByPeriodNum($periodNum){
+        $currentPeriod = self::getInfoByPeriodNum($periodNum);
+        $currentYear = $currentPeriod['CALC_YEAR'];
+        $currentMonth = $currentPeriod['CALC_MONTH'];
+        $periodsArray = self::findAllAsArray(['CALC_YEAR'=>$currentYear,'CALC_MONTH'=>$currentMonth]);
+        $periods = [];
+        foreach ($periodsArray as $p){
+            $periods[] = $p['PERIOD_NUM'];
+        }
+
+        return $periods;
+    }
 }

+ 22 - 0
common/models/RemainPv.php

@@ -0,0 +1,22 @@
+<?php
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%REMAIN_PV}}".
+ *
+ * @property string $USER_ID 会员ID
+ * @property int $REMAIN_PV 剩余BV
+ * @property int $UPDATED_AT 更新时间
+ */
+class RemainPv extends \common\components\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%REMAIN_PV}}';
+    }
+}

+ 6 - 3
common/models/Withdraw.php

@@ -157,13 +157,16 @@ class Withdraw extends \common\components\ActiveRecord {
      */
     public static function getPeriod($nowTime) {
         $period = Period::instance();
+        $nowPeriodNum = $period->getNowPeriodNum();
         $year = $period->getNowYear();
         $month = $period->getNowMonth();
         $yearMonth = $period->getNowYearMonth();
-        $thisMonth = Period::getPeriodNumRangeFromMonth($year, $month);
-        $period->setPeriodNum($thisMonth['min']);
+//        $thisMonth = Period::getPeriodNumRangeFromMonth($year, $month);
+//        $period->setPeriodNum($thisMonth['min']);
+        $period->setPeriodNum($nowPeriodNum);
         $endTime = $period->getNowPeriodEnd();
-        return ['nowPeriodNum' => $thisMonth['min'], 'nowYear' => $year, 'nowMonth' => $month, 'yearMonth'=>$yearMonth, 'endTime' => $endTime];
+//        return ['nowPeriodNum' => $thisMonth['min'], 'nowYear' => $year, 'nowMonth' => $month, 'yearMonth'=>$yearMonth, 'endTime' => $endTime];
+        return ['nowPeriodNum' => $nowPeriodNum, 'nowYear' => $year, 'nowMonth' => $month, 'yearMonth'=>$yearMonth, 'endTime' => $endTime];
     }
 
     /**

+ 71 - 3
common/models/forms/OrderForm.php

@@ -18,6 +18,8 @@ use common\models\Region;
 use common\models\ShopGoods;
 use common\models\User;
 use common\models\UserNetwork;
+use common\models\RemainPv;
+use common\models\FlowRemainPv;
 use yii\base\Exception;
 
 /**
@@ -52,6 +54,8 @@ class OrderForm extends Model
     private $_freight;
     private $_payAmount;
     private $_orderGoods;
+    private $_remainPv;
+    private $_realPv;
 
     /**
      * @var Order
@@ -270,6 +274,27 @@ class OrderForm extends Model
         return $this->_model;
     }
 
+    /**
+     * BV分期
+     *
+     *
+     */
+    private function _pvSplit($oPv){
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE'];
+        if($oPv>$mesureUpCondition){
+            $currentPv = $oPv % $mesureUpCondition + $mesureUpCondition;
+            $remainPv = $oPv - $currentPv;
+        }else{
+            $currentPv = $oPv;
+            $remainPv = 0;
+        }
+        return [
+            'current' => $currentPv,
+            'remain' => $remainPv
+        ];
+    }
+
     /**
      * 复销
      * @return bool|null
@@ -283,6 +308,7 @@ class OrderForm extends Model
         $ids = $this->goodsId;
         $totalAmount = 0;
         $totalPv = 0;
+        $this->_remainPv = 0;
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
@@ -290,15 +316,28 @@ class OrderForm extends Model
                     $discount = $goods['SELL_DISCOUNT'];
                     $realPrice = $goods['SELL_PRICE'] * $discount;
                     $realPv = $goods['PRICE_PV'] * $discount;
+                    if($goods['PV_SPLIT']==1){ // 当商品为PV分期时
+                        $pvSplit = $this->_pvSplit($realPv);
+                        $currentPv = $pvSplit['current'];
+                        $remainPv = $pvSplit['remain'];
+                        $totalPv += $currentPv * intval($v);
+                        $totalRealPv += $realPv * intval($v);
+                        $this->_remainPv += $remainPv * intval($v);
+                    }else{
+                        $currentPv = $goods['PRICE_PV'];
+                        $totalPv += $realPv * intval($v);
+                        $totalRealPv += $realPv * intval($v);
+                        $remainPv = 0;
+                        $this->_remainPv += 0;
+                    }
                     $totalAmount += $realPrice * intval($v);
-                    $totalPv += $realPv * intval($v);
-
                     $this->_orderGoods[] = [
                         'GOODS_ID' => $goods['ID'],
                         'PRICE' => $goods['SELL_PRICE'],
-                        'PV' => $goods['PRICE_PV'],
+                        'PV' => $currentPv, // $goods['PRICE_PV'],
                         'REAL_PRICE' => $realPrice,
                         'REAL_PV' => $realPv,
+                        'REMAIN_PV' => $remainPv,
                         'POINT' => $goods['POINT'],
                         'BUY_NUMS' => intval($v),
                         'SKU_CODE' => $goods['GOODS_NO'],
@@ -309,6 +348,7 @@ class OrderForm extends Model
         }
         $this->_decAmount = $totalAmount;
         $this->_decPv = $totalPv;
+        $this->_realPv = $totalRealPv;
         $this->_freight = ($totalAmount>=300) ? 0 : 15;
         $this->_payAmount = $this->_decAmount + $this->_freight;
 
@@ -401,6 +441,7 @@ class OrderForm extends Model
         $orderModel->PV = $this->payType =='exchange' ? 0 : $this->_decPv;
         $orderModel->PAY_AMOUNT = $this->_payAmount;
         $orderModel->PAY_PV = $this->payType =='exchange' ? 0 : $this->_decPv; // 兑换积分不能算业绩
+        $orderModel->REMAIN_PV = $this->_remainPv;
         $orderModel->PAY_AT = Date::nowTime();
         $orderModel->PAY_TYPE = $this->payType;
         $orderModel->PERIOD_NUM = $nowPeriodNum;
@@ -644,4 +685,31 @@ class OrderForm extends Model
         }
         return $hash;
     }
+
+    public function addFakeOrder($userId, $periodNum){
+        $userName = Info::getUserNameByUserId($userId);
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NC默认300
+        $ordNo = $this->_generateSn();
+        $orderModel = new Order();
+        $orderModel->SN = 'OS'.$ordNo;
+        $orderModel->DEC_SN = 'DS'.$ordNo;
+        $orderModel->USER_ID = $userId;
+        $orderModel->USER_NAME = $userName;
+        $orderModel->PERIOD_NUM = $periodNum;
+        $orderModel->CREATE_USER = 'AUTO';
+        $orderModel->ORDER_TYPE = 'FX';
+        $orderModel->STATUS = 1;
+        $orderModel->PV = $mesureUpCondition;
+        $orderModel->PAY_PV = $mesureUpCondition;
+        $orderModel->P_CALC_MONTH = '1970-01-01';
+        $orderModel->CREATED_AT = Date::nowTime();
+        $orderModel->EXPRESS_TYPE = 1;
+        $orderModel->IS_AUTO = 1;
+        if(!$orderModel->save()){
+            $this->addErrors($orderModel->getErrors());
+            return false;
+        }
+        return $orderModel;
+    }
 }

+ 27 - 0
frontendApi/modules/v1/controllers/DashboardController.php

@@ -19,6 +19,8 @@ use common\models\CalcBonus;
 use common\models\FlowBonus;
 use common\models\Period;
 use common\models\ReconsumePool;
+use common\models\RemainPv;
+use common\models\Order;
 
 class DashboardController extends BaseController
 {
@@ -72,6 +74,29 @@ class DashboardController extends BaseController
                 $wkrd =$k+1;break;
             }
         }
+        //剩余分期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;
+
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NC默认300
+
+        $remainMonth = round($totalRemainPv / $mesureUpCondition);
+
+        if($currentPv >= $mesureUpCondition){ // 如果当月合格,则活跃资格延后一个月
+            $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,
@@ -82,6 +107,8 @@ class DashboardController extends BaseController
             'slides'=>Ad::findUseSlaves()->select('ID,IMAGE,LID,TITLE,CONTENT,TYPE')->where('LID=:LID AND STATUS=1', [':LID'=>'7EFF6260A16C3CC7E053693418AC03E4'])->orderBy('SORT ASC')->asArray()->all(),
             'news'=>$news,
             'periodNum'=>$periodNum.'期,'.$curYM['CALC_MONTH'].'月第'.$wkrd.'周,共'.$weeks.'周',
+            'myRemainPv'=>$totalRemainPv,
+            'activeEnd'=>$activeEnd
         ]);
     }
 

+ 2 - 2
frontendEle/src/views/bonus/teams.vue

@@ -31,7 +31,7 @@
         </el-table-column>
         <el-table-column
           prop="user_perf"
-          label="业绩"
+          label="个人业绩"
           >
         </el-table-column>
          <el-table-column
@@ -80,7 +80,7 @@
         </el-table-column>
         <el-table-column
           prop="user_perf"
-          label="业绩"
+          label="个人业绩"
           >
         </el-table-column>
          <el-table-column

+ 6 - 0
frontendEle/src/views/dashboard/index.vue

@@ -17,6 +17,8 @@
               </el-col>
               <el-col :xs="24" :sm="24" :md="24" :lg="4" :xl="12">会员级别:{{decLvName}}</el-col>
               <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="12">当前业绩期:{{periodNum}}</el-col>
+              <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="12">剩余PV:{{myRemainPv}}</el-col><!--剩余的PV-->
+              <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="12">活跃日期截止:{{activeEnd}}</el-col><!--活跃日期截止-->
             </el-row>
           </el-col>
         </el-row>
@@ -86,6 +88,8 @@
         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`)
@@ -117,6 +121,8 @@
         news: [],
         periodNum: '',
         decLvName: '',
+        myRemainPv: '',
+        activeEnd: '',
         bannerHeight: '',
       }
     },

+ 144 - 146
frontendEle/src/views/finance/withdraw-add.vue

@@ -57,160 +57,158 @@
 </template>
 
 <script>
-  import Vue from 'vue'
-  import store from '@/utils/vuexStore'
-  import network from '@/utils/network'
-  import tool from '@/utils/tool'
-  import userInfo from '@/utils/userInfo'
-  import {CDN_IMG_URL} from '@/utils/config'
+import Vue from 'vue'
+import store from '@/utils/vuexStore'
+import network from '@/utils/network'
+import tool from '@/utils/tool'
+import userInfo from '@/utils/userInfo'
+import {CDN_IMG_URL} from '@/utils/config'
 
-  export default {
-    name: 'finance_withdraw-add',
-    mounted() {
-      this.init()
-      this.chkWithdrawUserinfo()
-    },
-    data() {
-      return {
-        form: {
-          applyAmount: 0,
-          payPassword: '',
-          withdrawCode: '',
-        },
-        balance: 0,
-        loading: true,
-        userInfo: {
-          WITHDRAW_PROP:100
-        },
-        submitButtonStat: false,
-        openBanks: null,
-        isPact: null,
-        checked: this.chkAgree(),
-        content: null,
-        dialogVisible: false,
-        idCardDialogVisible: false,
-        withdrawProp: 100,
-        maxAmount: 0,
-        minAmount: 0,
-        withdrawFee: 0,
-        idCardInfoQrCodeUrl:'',
-      }
-    },
-    methods: {
-      init() {
-        this.idCardInfoQrCodeUrl = CDN_IMG_URL + "img_data/idCardInfo.png"
+export default {
+  name: 'finance_withdraw-add',
+  mounted () {
+    this.init()
+    this.chkWithdrawUserinfo()
+  },
+  data () {
+    return {
+      form: {
+        applyAmount: 0,
+        payPassword: '',
+        withdrawCode: ''
       },
-      chkAgree() {
-        if (this.isPact === '0') return true
-        return tool.getStorage('withdrawAgree'+userInfo.userId()) === '1' ? true : false
+      balance: 0,
+      loading: true,
+      userInfo: {
+        WITHDRAW_PROP: 100
       },
-      chkWithdrawUserinfo() {
-        network.getData(`finance/chk-withdraw-user`).then(response => {
-          this.loading = false
-          this.userInfo = response.userInfo
-          this.isPact = response.isPact
-          this.checked=this.chkAgree()
-          this.content = response.content
-          this.minAmount = response.minAmount
-          this.withdrawFee = response.withdrawFee
-            this.getBalance()
-        }).catch(() => {
-          this.$router.go(-1)
-        })
-      },
-      getBalance() {
-        this.$message({
-          message: '正获取您的奖金...',
-          type: 'info'
-        })
-        network.getData('finance/available-balance').then(response => {
-          this.$message.closeAll()
-          this.balance = response.bonus
-          this.getMaxAmount()
-          this.loading = false
-        })
-      },
-      getMaxAmount(){
-          this.maxAmount = this.balance
-        // this.maxAmount = Math.floor(tool.formatPrice(this.balance * this.userInfo.WITHDRAW_PROP * 0.01))
-        // this.withdrawProp = this.userInfo.WITHDRAW_PROP
-      },
-      onSubmit() {
-        this.submitButtonStat = true
-        tool.setStorage('withdrawAgree'+userInfo.userId(), 1)
-        console.log(tool.getStorage('withdrawAgree'))
-        let path = 'finance/withdraw-add'
-
-          network.getData('finance/wd-mult-point').then(response => {
-              this.form.withdrawCode = response.withdrawCode
+      submitButtonStat: false,
+      openBanks: null,
+      isPact: null,
+      checked: this.chkAgree(),
+      content: null,
+      dialogVisible: false,
+      idCardDialogVisible: false,
+      withdrawProp: 100,
+      maxAmount: 0,
+      minAmount: 0,
+      withdrawFee: 0,
+      idCardInfoQrCodeUrl: ''
+    }
+  },
+  methods: {
+    init () {
+      this.idCardInfoQrCodeUrl = CDN_IMG_URL + 'img_data/idCardInfo.png'
+    },
+    chkAgree () {
+      if (this.isPact === '0') return true
+      return tool.getStorage('withdrawAgree' + userInfo.userId()) === '1' ? true : false
+    },
+    chkWithdrawUserinfo () {
+      network.getData(`finance/chk-withdraw-user`).then(response => {
+        this.loading = false
+        this.userInfo = response.userInfo
+        this.isPact = response.isPact
+        this.checked = this.chkAgree()
+        this.content = response.content
+        this.minAmount = response.minAmount
+        this.withdrawFee = response.withdrawFee
+        this.getBalance()
+      }).catch(() => {
+        this.$router.go(-1)
+      })
+    },
+    getBalance () {
+      this.$message({
+        message: '正获取您的奖金...',
+        type: 'info'
+      })
+      network.getData('finance/available-balance').then(response => {
+        this.$message.closeAll()
+        this.balance = response.bonus
+        this.getMaxAmount()
+        this.loading = false
+      })
+    },
+    getMaxAmount () {
+      this.maxAmount = this.balance
+      // this.maxAmount = Math.floor(tool.formatPrice(this.balance * this.userInfo.WITHDRAW_PROP * 0.01))
+      // this.withdrawProp = this.userInfo.WITHDRAW_PROP
+    },
+    onSubmit () {
+      this.submitButtonStat = true
+      tool.setStorage('withdrawAgree' + userInfo.userId(), 1)
+      console.log(tool.getStorage('withdrawAgree'))
+      let path = 'finance/withdraw-add'
 
-              this.$prompt('请输入支付密码', '提示', {
-                  confirmButtonText: '确定',
-                  cancelButtonText: '取消',
-                  inputType: 'password',
-                  inputPattern: /\S+/,
-                  inputErrorMessage: '请输入支付密码',
-                  beforeClose:async (action, instance, done)=>{
-                      if (action === 'confirm') {
-                          instance.confirmButtonLoading = true;
-                          instance.confirmButtonText = '执行中...';
-                          console.log(instance.inputValue);
-                          this.form.payPassword = instance.inputValue;
-                          await network.postData(path, this.form).then(response => {
+      network.getData('finance/wd-mult-point').then(response => {
+        this.form.withdrawCode = response.withdrawCode
 
-                              instance.confirmButtonLoading = false;
-                              done();
-                              this.$message({
-                                  message: response,
-                                  type: 'success'
-                              })
-                              tool.setStorage('withdrawAgree', 1)
-                              this.submitButtonStat = false
-                              this.$router.go(-1)
-                          }).catch(error=>{
-                              instance.confirmButtonLoading = false;
-                              this.submitButtonStat = false
-                              if( error.status === 424 ) {
-                                  this.idCardDialogVisible = true
-                              }
-                              done();
-                          })
-                      }else {
-                          this.submitButtonStat = false
-                          done();
-                      }
-                  }
+        this.$prompt('请输入支付密码', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          inputType: 'password',
+          inputPattern: /\S+/,
+          inputErrorMessage: '请输入支付密码',
+          beforeClose: async (action, instance, done) => {
+            if (action === 'confirm') {
+              instance.confirmButtonLoading = true
+              instance.confirmButtonText = '执行中...'
+              console.log(instance.inputValue)
+              this.form.payPassword = instance.inputValue
+              await network.postData(path, this.form).then(response => {
+                instance.confirmButtonLoading = false
+                done()
+                this.$message({
+                  message: response,
+                  type: 'success'
+                })
+                tool.setStorage('withdrawAgree', 1)
+                this.submitButtonStat = false
+                this.$router.go(-1)
+              }).catch(error => {
+                instance.confirmButtonLoading = false
+                this.submitButtonStat = false
+                if (error.status === 424) {
+                  this.idCardDialogVisible = true
+                }
+                done()
               })
-
-          })
-        // this.$prompt('请输入支付密码', '提示', {
-        //   confirmButtonText: '确定',
-        //   cancelButtonText: '取消',
-        //   inputType: 'password',
-        //   inputPattern: /\S+/,
-        //   inputErrorMessage: '请输入支付密码'
-        // }).then(({value}) => {
-        //   this.form.payPassword = value
-        //   return network.postData(path, this.form).then(response => {
-        //     this.$message({
-        //       message: response,
-        //       type: 'success'
-        //     })
-        //     tool.setStorage('withdrawAgree', 1)
-        //     this.submitButtonStat = false
-        //     this.$router.go(-1)
-        //   }).catch((error) => {
-        //     this.submitButtonStat = false
-        //     if( error.status === 424 ) {
-        //         this.idCardDialogVisible = true
-        //     }
-        //   })
-        // }).catch((response) => {
-        //   this.submitButtonStat = false
-        // })
-      },
+            } else {
+              this.submitButtonStat = false
+              done()
+            }
+          }
+        })
+      })
+      // this.$prompt('请输入支付密码', '提示', {
+      //   confirmButtonText: '确定',
+      //   cancelButtonText: '取消',
+      //   inputType: 'password',
+      //   inputPattern: /\S+/,
+      //   inputErrorMessage: '请输入支付密码'
+      // }).then(({value}) => {
+      //   this.form.payPassword = value
+      //   return network.postData(path, this.form).then(response => {
+      //     this.$message({
+      //       message: response,
+      //       type: 'success'
+      //     })
+      //     tool.setStorage('withdrawAgree', 1)
+      //     this.submitButtonStat = false
+      //     this.$router.go(-1)
+      //   }).catch((error) => {
+      //     this.submitButtonStat = false
+      //     if( error.status === 424 ) {
+      //         this.idCardDialogVisible = true
+      //     }
+      //   })
+      // }).catch((response) => {
+      //   this.submitButtonStat = false
+      // })
     }
   }
+}
 </script>
 
 <style scoped>