Pārlūkot izejas kodu

Merge branch 'new-version' into feature/kevin-1241-1324-develop

# Conflicts:
#	frontendApi/modules/v1/controllers/ShopController.php
#	frontendEle/src/views/shop/dec-order-list.vue
kevin_zhangl 3 gadi atpakaļ
vecāks
revīzija
c89b5f1c55
81 mainītis faili ar 14179 papildinājumiem un 9784 dzēšanām
  1. 3 2
      backendApi/config/menu.php
  2. 2 0
      backendApi/config/urlManagerRules.php
  3. 65 3
      backendApi/modules/v1/controllers/BonusController.php
  4. 1 0
      backendApi/modules/v1/controllers/ShopController.php
  5. 421 421
      backendApi/modules/v1/models/lists/bonus/BalanceList.php
  6. 206 206
      backendApi/modules/v1/models/lists/bonus/FlowExchangePointsList.php
  7. 555 555
      backendApi/modules/v1/models/lists/bonus/OtherPeriodBonusList.php
  8. 228 228
      backendApi/modules/v1/models/lists/bonus/PerfMonthList.php
  9. 152 152
      backendApi/modules/v1/models/lists/bonus/PerfStandardList.php
  10. 713 713
      backendApi/modules/v1/models/lists/bonus/PeriodBonusList.php
  11. 135 135
      backendApi/modules/v1/models/lists/bonus/PeriodPerfList.php
  12. 201 201
      backendApi/modules/v1/models/lists/bonus/TraceDownBdList.php
  13. 200 200
      backendApi/modules/v1/models/lists/bonus/TraceDownGlList.php
  14. 201 201
      backendApi/modules/v1/models/lists/bonus/TraceDownGxList.php
  15. 182 182
      backendApi/modules/v1/models/lists/bonus/TraceDownQyList.php
  16. 201 201
      backendApi/modules/v1/models/lists/bonus/TraceDownTgList.php
  17. 202 202
      backendApi/modules/v1/models/lists/bonus/TraceDownXfList.php
  18. 165 165
      backendApi/modules/v1/models/lists/bonus/TraceDownYcList.php
  19. 200 200
      backendApi/modules/v1/models/lists/bonus/TraceDownYjList.php
  20. 206 206
      backendApi/modules/v1/models/lists/bonus/TraceUpBdList.php
  21. 206 206
      backendApi/modules/v1/models/lists/bonus/TraceUpGlList.php
  22. 206 206
      backendApi/modules/v1/models/lists/bonus/TraceUpGxList.php
  23. 306 306
      backendApi/modules/v1/models/lists/bonus/TraceUpQyList.php
  24. 206 206
      backendApi/modules/v1/models/lists/bonus/TraceUpTgList.php
  25. 206 206
      backendApi/modules/v1/models/lists/bonus/TraceUpXfList.php
  26. 206 206
      backendApi/modules/v1/models/lists/bonus/TraceUpYcList.php
  27. 206 206
      backendApi/modules/v1/models/lists/bonus/TraceUpYjList.php
  28. 2 0
      backendApi/modules/v1/models/lists/shop/DecOrderList.php
  29. 623 623
      backendApi/modules/v1/models/lists/user/IndexList.php
  30. 13 1
      backendEle/src/router/index.js
  31. 253 253
      backendEle/src/utils/network.js
  32. 212 0
      backendEle/src/views/bonus/prepare-period.vue
  33. 1 1
      backendEle/src/views/config/transfer.vue
  34. 4 1
      backendEle/src/views/finance/change-balance-opt.vue
  35. 181 181
      backendEle/src/views/reconsume/pool-list.vue
  36. 1 0
      backendEle/src/views/shop/dec-order-list.vue
  37. 846 845
      backendEle/src/views/user/index.vue
  38. 52 52
      common/components/Controller.php
  39. 2 0
      common/components/SwooleAsyncTimer.php
  40. 69 58
      common/config/main.php
  41. 2 1
      common/config/params.php
  42. 9 5
      common/helpers/Cache.php
  43. 156 156
      common/helpers/CaptchaAction.php
  44. 5 0
      common/helpers/Tool.php
  45. 23 3
      common/helpers/bonus/BonusCalc.php
  46. 2 2
      common/helpers/bonus/PerfCalc.php
  47. 1509 0
      common/helpers/bonus/PrepareCalcCache.php
  48. 1290 0
      common/helpers/bonus/PreparePerfCalc.php
  49. 2 0
      common/libs/dataList/DataList.php
  50. 1 1
      common/models/BalanceAudit.php
  51. 290 290
      common/models/CalcBonus.php
  52. 69 69
      common/models/OrderGoods.php
  53. 71 71
      common/models/OrderGoodsDec.php
  54. 69 69
      common/models/OrderGoodsShop.php
  55. 192 0
      common/models/PerfMonthPrepare.php
  56. 130 0
      common/models/PerfOrderPrepare.php
  57. 228 0
      common/models/PerfPeriodPrepare.php
  58. 155 0
      common/models/PeriodPrepare.php
  59. 175 175
      common/models/ShopGoods.php
  60. 1 0
      common/models/Transfer.php
  61. 3 2
      common/models/UserNetwork.php
  62. 59 59
      common/models/UserPeriodExchangePoints.php
  63. 3 2
      common/models/UserRelation.php
  64. 610 610
      common/models/forms/OrderForm.php
  65. 121 0
      common/models/forms/PreparePeriodForm.php
  66. 29 3
      common/models/forms/TransferForm.php
  67. 2 1
      common/models/forms/WithdrawForm.php
  68. 25 2
      console/controllers/BonusController.php
  69. 1 0
      frontendApi/config/menu.php
  70. 1 0
      frontendApi/config/urlManagerRules.php
  71. 107 4
      frontendApi/modules/v1/controllers/BonusController.php
  72. 1 0
      frontendApi/modules/v1/controllers/FinanceController.php
  73. 12 0
      frontendEle/src/router/index.js
  74. 2 1
      frontendEle/src/views/bonus/index.vue
  75. 48 47
      frontendEle/src/views/bonus/new.vue
  76. 101 99
      frontendEle/src/views/bonus/other.vue
  77. 245 0
      frontendEle/src/views/bonus/teams.vue
  78. 253 252
      frontendEle/src/views/dashboard/index.vue
  79. 11 4
      frontendEle/src/views/finance/transfer-add.vue
  80. 1 1
      frontendEle/src/views/shop/order.vue
  81. 125 125
      mysql_db_yyj.sql

+ 3 - 2
backendApi/config/menu.php

@@ -184,6 +184,7 @@ return [
         'routePath'=>'bonus',
         'show'=>1,
         'child'=>[
+            ['name'=>'预算月业绩', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'prepare-period', 'routePath'=>'bonus/prepare-period', 'show'=>1,],
             ['name'=>'封期管理', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'period', 'routePath'=>'bonus/period', 'show'=>1,],
             ['name'=>'封期操作', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'close-period', 'routePath'=>'bonus/close-period', 'show'=>0,],
             ['name'=>'生成业绩单', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'perf-period', 'routePath'=>'bonus/perf-period', 'show'=>0,],
@@ -207,8 +208,8 @@ return [
 //            ['name'=>'领袖分红奖流水导出', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-lx-export', 'routePath'=>'bonus/flow-lx-export', 'show'=>0,],
             ['name'=>'复消积分流水', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-rp', 'routePath'=>'bonus/flow-rp', 'show'=>1,],
             ['name'=>'复消积分流水导出', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-rp-export', 'routePath'=>'bonus/flow-rp-export', 'show'=>0,],
-            ['name'=>'兑换积分流水', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-exchange', 'routePath'=>'bonus/flow-exchange', 'show'=>1,],
-            ['name'=>'兑换积分流水导出', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-exchange-export', 'routePath'=>'bonus/flow-exchange-export', 'show'=>0,],
+            ['name'=>'兑换点数流水', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-exchange', 'routePath'=>'bonus/flow-exchange', 'show'=>1,],
+            ['name'=>'兑换点数流水导出', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-exchange-export', 'routePath'=>'bonus/flow-exchange-export', 'show'=>0,],
             ['name'=>'会员余额流水', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-balance', 'routePath'=>'bonus/flow-balance', 'show'=>1,],
             ['name'=>'会员余额流水导出', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-balance-export', 'routePath'=>'bonus/flow-balance-export', 'show'=>0,],
 //            ['name'=>'区域津贴核算', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'calc-qy', 'routePath'=>'bonus/calc-qy', 'show'=>1,],

+ 2 - 0
backendApi/config/urlManagerRules.php

@@ -298,8 +298,10 @@ return [
         'controller' => 'v1/bonus',
         'extraPatterns' => [
             'GET period' => 'period',
+            'GET prepare-period' => 'prepare-period',
             'GET close-period/<periodNum>' => 'close-period',
             'GET perf-period/<periodNum>' => 'perf-period',
+            'GET prepare-perf-period/<periodNum>' => 'prepare-perf-period',
             'GET calc-period/<periodNum>' => 'calc-period',
             'GET send-period/<periodNum>' => 'send-period',
             'GET perf' => 'perf',

+ 65 - 3
backendApi/modules/v1/controllers/BonusController.php

@@ -61,7 +61,9 @@ use common\models\Config;
 use common\models\FlowBonus;
 use common\models\FlowExchangePoints;
 use common\models\forms\PeriodForm;
+use common\models\forms\PreparePeriodForm;
 use common\models\Period;
+use common\models\PeriodPrepare;
 use Exception;
 
 class BonusController extends BaseController {
@@ -73,6 +75,66 @@ class BonusController extends BaseController {
         return $behaviors;
     }
 
+    /**
+     * 查看预计计算月业绩数据状态
+     * @return mixed
+     * @throws \yii\db\Exception
+     * @throws \yii\web\HttpException
+     */
+    public function actionPreparePeriod() {
+        $filter = $this->filterCondition([
+            'periodNum' => 'PERIOD_NUM',
+            'year' => 'CALC_YEAR',
+            'month' => 'CALC_MONTH',
+            'startTime' => 'START_TIME',
+            'endTime' => 'END_TIME',
+            'closedAt' => 'CLOSED_AT',
+            'perfStartedAt' => 'PERF_STARTED_AT',
+            'perfedAt' => 'PERFED_AT',
+            'calStartedAt' => 'CALCULATE_STARTED_AT',
+            'calculatedAt' => 'CALCULATED_AT',
+            'sendStartedAt' => 'SEND_STARTED_AT',
+            'sentAt' => 'SENT_AT',
+        ]);
+        $oriPeriodObj = Period::instance();
+        $nowPeriodNum = $oriPeriodObj->getNowPeriodNum();
+        $condition = $filter['condition'];
+        $params = $filter['params'];
+        // $condition .= ' AND PERIOD_NUM=:PERIOD_NUM';
+        $params[':PERIOD_NUM'] = $nowPeriodNum;
+        $data = PeriodPrepare::lists($condition, $params, ['orderBy' => 'PERIOD_NUM ASC']);
+        foreach ($data['list'] as $key => $value) {
+           
+            // 是否可生成业绩单
+            $data['list'][$key]['IS_CAN_PERF'] = true;
+                        
+            // 操作数据按钮是否可用
+            $data['list'][$key]['BUTTON_IS_CAN'] = true;
+            
+        }
+        return static::notice($data);
+    }
+
+    /**
+     * 对预计算业绩进行生成
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionPreparePerfPeriod() {
+        $periodNum = \Yii::$app->request->get('periodNum');
+        if (!$periodNum) {
+            return static::notice('期数不存在', 400);
+        }
+        
+        $formModel = new PreparePeriodForm();
+        $formModel->scenario = 'perf';
+        if ($formModel->load(Yii::$app->request->get(), '') && $formModel->perfWebToAsync()) {
+            return static::notice('预计算正在生成月业绩单,请等待');
+        } else {
+            return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
+        }
+    }
+
     /**
      * 期数列表
      * @return mixed
@@ -398,7 +460,7 @@ class BonusController extends BaseController {
 
 
     /**
-     * 兑换积分流水
+     * 兑换点数流水
      * @return mixed
      * @throws \yii\base\Exception
      * @throws \yii\web\HttpException
@@ -425,7 +487,7 @@ class BonusController extends BaseController {
     }
 
     /**
-     * 兑换积分流水导出
+     * 兑换点数流水导出
      * @return mixed
      * @throws \yii\db\Exception
      * @throws \yii\web\HttpException
@@ -445,7 +507,7 @@ class BonusController extends BaseController {
             'REMARK' => 'REMARK',
         ]);
         $form = new BonusExportForm();
-        $result = $form->run($filter, '兑换积分流水');
+        $result = $form->run($filter, '兑换点数流水');
         if (!$result) {
             return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
         }

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

@@ -306,6 +306,7 @@ class ShopController extends BaseController {
             'CREATED_AT'=> 'DO.CREATED_AT',
             'UPDATED_AT'=> 'DO.UPDATED_AT',
         ]);
+
         $condition = $filter['condition'];
         $params = $filter['params'];
         $condition .= ' AND DO.IS_DEL=0';

+ 421 - 421
backendApi/modules/v1/models/lists/bonus/BalanceList.php

@@ -1,422 +1,422 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\User;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserWallet;
-use common\models\Withdraw;
-use Yii;
-
-class BalanceList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '会员奖金余额列表';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $this->condition .= ' AND UI.STATUS=1 AND I.LAST_LOGIN_AT>=1620748800';
-        $this->listData = UserBonus::lists($this->condition, $this->params, [
-            'select' => 'UB.*,UI.*,UW.CASH',
-            'from' => UserBonus::tableName() . ' AS UB',
-            'join' => [
-//                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'UI.USER_ID=UB.USER_ID'],
-                ['LEFT JOIN', User::tableName() . ' AS UI', 'UI.ID=UB.USER_ID'],
-                ['LEFT JOIN', UserWallet::tableName() . ' AS UW', 'UW.USER_ID=UB.USER_ID'],
-                ['LEFT JOIN', UserInfo::tableName() . ' AS I', 'I.USER_ID=UB.USER_ID']
-            ],
-            'orderBy' => 'UB.CREATED_AT ASC, UB.ID ASC',
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-
-//        foreach ($this->listData['list'] as $key => $value) {
-//            $userInfo = Info::baseInfo($value['USER_ID']);
-//            $this->listData['list'][$key] = array_merge($value, $userInfo);
-//            $this->listData['list'][$key]['WITHDRAW_WAIT'] = Withdraw::getWithdrawTotal($value['USER_ID'], Withdraw::STATUS_WAIT_PAID);
-//            $this->listData['list'][$key]['WITHDRAW_FAIL'] = Withdraw::getWithdrawTotal($value['USER_ID'], Withdraw::STATUS_PAID_FALSE);
-//        }
-        //总计
-//        $sumData = UserBonus::find()->select('SUM(BONUS) AS SUM_BONUS,SUM(CF) AS SUM_CF,SUM(LX) AS SUM_LX')
-//            ->from(UserBonus::tableName() . ' AS UB')
-//            ->leftJoin(UserInfo::tableName() . ' AS UI', 'UI.USER_ID=UB.USER_ID')
-//            ->where('1=1 ' . $this->condition, $this->params)->asArray()->one();
-//        $sumData['SUM_WITHDRAW_WAIT'] = Withdraw::getAllWithdrawTotal(Withdraw::STATUS_WAIT_PAID);
-//        $sumData['SUM_WITHDRAW_FAIL'] = Withdraw::getAllWithdrawTotal(Withdraw::STATUS_PAID_FALSE);
-//        $this->listData['sumData'] = $sumData;
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
-                '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']
-                    ],
-                ],
-//                'DEC_LV_NAME' => [
-//                    'header' => '会员级别',
-//                    'headerOther' => [
-//                        'width' => '110',
-//                    ],
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
-//                    ],
-//                ],
-//                'EMP_LV_NAME' => [
-//                    'header' => '聘级',
-//                    'headerOther' => [
-//                        'width' => '130',
-//                    ],
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
-//                    ],
-//                ],
-                'IS_DEC' => [
-                    'header' => '是否报单中心',
-                    'value' => function($row) {
-                        return (new YesNo([
-                            'value' => $row['IS_DEC'],
-                        ]))->result();
-                    },
-                    'headerOther' => function($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function($row) {
-                        return [
-                            'tag'=>['type'=>(isset($row['IS_DEC']) && $row['IS_DEC'] )? 'success' : 'info', 'size' => 'small']
-                        ];
-                    },
-                ],
-//                'DEC_ROLE_NAME' => [
-//                    'header' => '报单中心级别',
-//                    'headerOther' => ['width' => '110'],
-//                ],
-//                'SYSTEM_NAME' => [
-//                    'header' => '体系名称',
-//                    'headerOther' => ['width' => '150'],
-//                ],
-                'BONUS' => [
-                    'header' => '会员奖金余额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                        'prop'=>'BONUS',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                    ],
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '会员复消积分',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                        'prop'=>'BONUS',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                    ],
-                ],
-                'EXCHANGE_POINTS' => [
-                    'header' => '兑换积分',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['EXCHANGE_POINTS'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                        'prop'=>'BONUS',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                    ],
-                ],
-                'CASH' => [
-                    'header' => '会员余额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['CASH'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                        'prop'=>'BONUS',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                    ],
-                ],
-//                'CF' => [
-//                    'header' => '车房养老余额',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['CF'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '150',
-//                        'prop'=>'CF',
-//                    ],
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-//                    ],
-//                ],
-//                'LX' => [
-//                    'header' => '领袖分红余额',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['LX'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '150',
-//                        'prop'=>'LX',
-//                    ],
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-//                    ],
-//                ],
-//                'WITHDRAW_WAIT' => [
-//                    'header' => '提现金额',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['WITHDRAW_WAIT'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '150',
-//                        'prop'=>'WITHDRAW_WAIT',
-//                    ],
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
-//                    ],
-//                ],
-//                'TAX' => [
-//                    'header' => '个税',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['WITHDRAW_WAIT'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '150',
-//                        'prop'=>'TAX',
-//                    ],
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
-//                    ],
-//                ],
-//                'DEDUCT' => [
-//                    'header' => '扣款',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['WITHDRAW_WAIT'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '150',
-//                        'prop'=>'DEDUCT',
-//                    ],
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
-//                    ],
-//                ],
-//                'REAL_PAID' => [
-//                    'header' => '实付金额',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['WITHDRAW_WAIT'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '150',
-//                        'prop'=>'REAL_PAID',
-//                    ],
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
-//                    ],
-//                ],
-//                'WITHDRAW_FAIL' => [
-//                    'header' => '实付失败金额',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['WITHDRAW_FAIL'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '150',
-//                        'prop'=>'WITHDRAW_FAIL',
-//                    ],
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
-//                    ],
-//                ],
-//                'STATUS' => [
-//                    'header' => '会员状态',
-//                    'value' => function($row){
-//                        return Yii::$app->params['userStatus'][$row['STATUS']]['label'];
-//                    },
-//                    'headerOther' => ['width' => '110'],
-//                ],
-//                'STATUS_AT' => [
-//                    'header' => '会员状态变更时间',
-//                    'value' => function($row) {
-//                        return (new DateTime([
-//                            'value' => $row['STATUS_AT'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => ['width' => '170'],
-//                ],
-//                'HIGHEST_EMP_LV_NAME' => [
-//                    'header' => '历史最高聘级',
-//                    'headerOther' => ['width' => '130'],
-//                ],
-                'PERIOD_AT' => '加入期数',
-//                'DEC_DEC_ROLE_NAME' => [
-//                    'header' => '所属报单中心级别',
-//                    'headerOther' => ['width' => '150'],
-//                ],
-//                'DEC_USER_NAME' => [
-//                    'header' => '所属报单中心编号',
-//                    'headerOther' => ['width' => '150'],
-//                ],
-//                'DEC_REAL_NAME' => [
-//                    'header' => '所属报单中心姓名',
-//                    'headerOther' => ['width' => '150'],
-//                ],
-                'MOBILE' => [
-                    'header' => '手机号码',
-                    'value' => function($row) {
-                        return "\t".$row['MOBILE'];
-                    },
-                    'headerOther' => ['width' => '120'],
-                ],
-                'TEL' => [
-                    'header' => '备用手机号码',
-                    'value' => function($row) {
-                        return "\t".$row['TEL'];
-                    },
-                    'headerOther' => ['width' => '120'],
-                ],
-//                'AREA' => [
-//                    'header' => '常用地址',
-//                    'value' => function($row) {
-//                        return $row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'];
-//                    },
-//                    'showValue' => function($row) {
-//                        return '<div class="addr" :title='.$row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'].'>'.$row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'].'</div>';
-//                    },
-//                    'headerOther' => [
-//                        'width' => '200'
-//                    ],
-//                ],
-//                'SUB_COM_NAME' => [
-//                    'header' => '所属分公司',
-//                    'headerOther' => ['width' => '100'],
-//                ],
-//                'IS_DIRECT_SELLER' => [
-//                    'header' => '是否直销员',
-//                    'value' => function($row) {
-//                        return (new YesNo([
-//                            'value' => $row['IS_DIRECT_SELLER'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => function($row) {
-//                        return [
-//                            'width' => '120',
-//                        ];
-//                    },
-//                    'valueOther' => function($row) {
-//                        return [
-//                            'tag'=>['type'=>(isset($row['IS_DIRECT_SELLER']) && $row['IS_DIRECT_SELLER']) ? 'success' : 'info', 'size' => 'small']
-//                        ];
-//                    },
-//                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [
-                'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
-                'REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
-//                'DEC_LV_NAME'=> ['isUserTable'=> true, 'name'=> '会员级别', 'other'=> 'decLevel'],
-//                'EMP_LV_NAME'=> ['isUserTable'=> true, 'name'=> '聘级', 'other'=> 'empLevel'],
-                'IS_DEC'=> ['isUserTable'=> false, 'name'=> '是否报单中心', 'other'=> 'yesOrNo'],
-//                'DEC_ROLE_NAME'=> ['isUserTable'=> true, 'name'=> '报单中心级别', 'other'=> 'decRole'],
-//                'SYSTEM_NAME'=> ['isUserTable'=> false, 'name'=> '体系名称', 'other'=> 'systems'],
-                'BONUS'=> ['isUserTable'=> false, 'name'=> '会员奖金余额'],
-                'RECONSUME_POINTS'=> ['isUserTable'=> false, 'name'=> '会员复消积分'],
-                'CASH'=> ['isUserTable'=> false, 'name'=> '会员余额'],
-//                'CF'=> ['isUserTable'=> false, 'name'=> '车房养老余额'],
-//                'LX'=> ['isUserTable'=> false, 'name'=> '领袖分红余额'],
-//                'STATUS'=> ['isUserTable'=> true, 'name'=> '会员状态', 'other'=> 'status'],
-//                'STATUS_AT'=> ['isUserTable'=> true, 'name'=> '会员状态变更时间', 'other'=> 'date'],
-//                'HIGHEST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> '历史最高聘级', 'other'=> 'empLevel'],
-                'PERIOD_AT'=> ['isUserTable'=> false, 'name'=> '加入期数'],
-//                'DEC_DEC_ROLE_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心级别', 'other'=> 'decRole'],
-//                'DEC_USER_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心编号'],
-//                'DEC_REAL_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心姓名'],
-                'MOBILE'=> ['isUserTable'=> false, 'name'=> '手机号码'],
-                'TEL'=> ['isUserTable'=> false, 'name'=> '备用手机号码'],
-//                'AREA'=> ['isUserTable'=> true, 'name'=> '常用地址', 'other'=> 'area'],
-//                'SUB_COM_NAME'=> ['isUserTable'=> true, 'name'=> '所属分公司', 'other'=> 'subCompany'],
-//                'IS_DIRECT_SELLER'=> ['isUserTable'=> true, 'name'=> '是否直销员', 'other'=> 'yesOrNo'],
-            ];
-        }
-        return $this->filterTypes;
-    }
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\User;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserWallet;
+use common\models\Withdraw;
+use Yii;
+
+class BalanceList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '会员奖金余额列表';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $this->condition .= ' AND UI.STATUS=1 AND I.LAST_LOGIN_AT>=1620748800';
+        $this->listData = UserBonus::lists($this->condition, $this->params, [
+            'select' => 'UB.*,UI.*,UW.CASH',
+            'from' => UserBonus::tableName() . ' AS UB',
+            'join' => [
+//                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'UI.USER_ID=UB.USER_ID'],
+                ['LEFT JOIN', User::tableName() . ' AS UI', 'UI.ID=UB.USER_ID'],
+                ['LEFT JOIN', UserWallet::tableName() . ' AS UW', 'UW.USER_ID=UB.USER_ID'],
+                ['LEFT JOIN', UserInfo::tableName() . ' AS I', 'I.USER_ID=UB.USER_ID']
+            ],
+            'orderBy' => 'UB.CREATED_AT ASC, UB.ID ASC',
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+
+//        foreach ($this->listData['list'] as $key => $value) {
+//            $userInfo = Info::baseInfo($value['USER_ID']);
+//            $this->listData['list'][$key] = array_merge($value, $userInfo);
+//            $this->listData['list'][$key]['WITHDRAW_WAIT'] = Withdraw::getWithdrawTotal($value['USER_ID'], Withdraw::STATUS_WAIT_PAID);
+//            $this->listData['list'][$key]['WITHDRAW_FAIL'] = Withdraw::getWithdrawTotal($value['USER_ID'], Withdraw::STATUS_PAID_FALSE);
+//        }
+        //总计
+//        $sumData = UserBonus::find()->select('SUM(BONUS) AS SUM_BONUS,SUM(CF) AS SUM_CF,SUM(LX) AS SUM_LX')
+//            ->from(UserBonus::tableName() . ' AS UB')
+//            ->leftJoin(UserInfo::tableName() . ' AS UI', 'UI.USER_ID=UB.USER_ID')
+//            ->where('1=1 ' . $this->condition, $this->params)->asArray()->one();
+//        $sumData['SUM_WITHDRAW_WAIT'] = Withdraw::getAllWithdrawTotal(Withdraw::STATUS_WAIT_PAID);
+//        $sumData['SUM_WITHDRAW_FAIL'] = Withdraw::getAllWithdrawTotal(Withdraw::STATUS_PAID_FALSE);
+//        $this->listData['sumData'] = $sumData;
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
+                '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']
+                    ],
+                ],
+//                'DEC_LV_NAME' => [
+//                    'header' => '会员级别',
+//                    'headerOther' => [
+//                        'width' => '110',
+//                    ],
+//                    'valueOther' => [
+//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
+//                    ],
+//                ],
+//                'EMP_LV_NAME' => [
+//                    'header' => '聘级',
+//                    'headerOther' => [
+//                        'width' => '130',
+//                    ],
+//                    'valueOther' => [
+//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
+//                    ],
+//                ],
+                'IS_DEC' => [
+                    'header' => '是否报单中心',
+                    'value' => function($row) {
+                        return (new YesNo([
+                            'value' => $row['IS_DEC'],
+                        ]))->result();
+                    },
+                    'headerOther' => function($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function($row) {
+                        return [
+                            'tag'=>['type'=>(isset($row['IS_DEC']) && $row['IS_DEC'] )? 'success' : 'info', 'size' => 'small']
+                        ];
+                    },
+                ],
+//                'DEC_ROLE_NAME' => [
+//                    'header' => '报单中心级别',
+//                    'headerOther' => ['width' => '110'],
+//                ],
+//                'SYSTEM_NAME' => [
+//                    'header' => '体系名称',
+//                    'headerOther' => ['width' => '150'],
+//                ],
+                'BONUS' => [
+                    'header' => '会员奖金余额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop'=>'BONUS',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                    ],
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '会员复消积分',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop'=>'BONUS',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                    ],
+                ],
+                'EXCHANGE_POINTS' => [
+                    'header' => '兑换点数',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['EXCHANGE_POINTS'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop'=>'BONUS',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                    ],
+                ],
+                'CASH' => [
+                    'header' => '会员余额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['CASH'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop'=>'BONUS',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                    ],
+                ],
+//                'CF' => [
+//                    'header' => '车房养老余额',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['CF'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '150',
+//                        'prop'=>'CF',
+//                    ],
+//                    'valueOther' => [
+//                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+//                    ],
+//                ],
+//                'LX' => [
+//                    'header' => '领袖分红余额',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['LX'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '150',
+//                        'prop'=>'LX',
+//                    ],
+//                    'valueOther' => [
+//                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+//                    ],
+//                ],
+//                'WITHDRAW_WAIT' => [
+//                    'header' => '提现金额',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['WITHDRAW_WAIT'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '150',
+//                        'prop'=>'WITHDRAW_WAIT',
+//                    ],
+//                    'valueOther' => [
+//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
+//                    ],
+//                ],
+//                'TAX' => [
+//                    'header' => '个税',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['WITHDRAW_WAIT'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '150',
+//                        'prop'=>'TAX',
+//                    ],
+//                    'valueOther' => [
+//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
+//                    ],
+//                ],
+//                'DEDUCT' => [
+//                    'header' => '扣款',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['WITHDRAW_WAIT'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '150',
+//                        'prop'=>'DEDUCT',
+//                    ],
+//                    'valueOther' => [
+//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
+//                    ],
+//                ],
+//                'REAL_PAID' => [
+//                    'header' => '实付金额',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['WITHDRAW_WAIT'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '150',
+//                        'prop'=>'REAL_PAID',
+//                    ],
+//                    'valueOther' => [
+//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
+//                    ],
+//                ],
+//                'WITHDRAW_FAIL' => [
+//                    'header' => '实付失败金额',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['WITHDRAW_FAIL'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '150',
+//                        'prop'=>'WITHDRAW_FAIL',
+//                    ],
+//                    'valueOther' => [
+//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
+//                    ],
+//                ],
+//                'STATUS' => [
+//                    'header' => '会员状态',
+//                    'value' => function($row){
+//                        return Yii::$app->params['userStatus'][$row['STATUS']]['label'];
+//                    },
+//                    'headerOther' => ['width' => '110'],
+//                ],
+//                'STATUS_AT' => [
+//                    'header' => '会员状态变更时间',
+//                    'value' => function($row) {
+//                        return (new DateTime([
+//                            'value' => $row['STATUS_AT'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => ['width' => '170'],
+//                ],
+//                'HIGHEST_EMP_LV_NAME' => [
+//                    'header' => '历史最高聘级',
+//                    'headerOther' => ['width' => '130'],
+//                ],
+                'PERIOD_AT' => '加入期数',
+//                'DEC_DEC_ROLE_NAME' => [
+//                    'header' => '所属报单中心级别',
+//                    'headerOther' => ['width' => '150'],
+//                ],
+//                'DEC_USER_NAME' => [
+//                    'header' => '所属报单中心编号',
+//                    'headerOther' => ['width' => '150'],
+//                ],
+//                'DEC_REAL_NAME' => [
+//                    'header' => '所属报单中心姓名',
+//                    'headerOther' => ['width' => '150'],
+//                ],
+                'MOBILE' => [
+                    'header' => '手机号码',
+                    'value' => function($row) {
+                        return "\t".$row['MOBILE'];
+                    },
+                    'headerOther' => ['width' => '120'],
+                ],
+                'TEL' => [
+                    'header' => '备用手机号码',
+                    'value' => function($row) {
+                        return "\t".$row['TEL'];
+                    },
+                    'headerOther' => ['width' => '120'],
+                ],
+//                'AREA' => [
+//                    'header' => '常用地址',
+//                    'value' => function($row) {
+//                        return $row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'];
+//                    },
+//                    'showValue' => function($row) {
+//                        return '<div class="addr" :title='.$row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'].'>'.$row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'].'</div>';
+//                    },
+//                    'headerOther' => [
+//                        'width' => '200'
+//                    ],
+//                ],
+//                'SUB_COM_NAME' => [
+//                    'header' => '所属分公司',
+//                    'headerOther' => ['width' => '100'],
+//                ],
+//                'IS_DIRECT_SELLER' => [
+//                    'header' => '是否直销员',
+//                    'value' => function($row) {
+//                        return (new YesNo([
+//                            'value' => $row['IS_DIRECT_SELLER'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => function($row) {
+//                        return [
+//                            'width' => '120',
+//                        ];
+//                    },
+//                    'valueOther' => function($row) {
+//                        return [
+//                            'tag'=>['type'=>(isset($row['IS_DIRECT_SELLER']) && $row['IS_DIRECT_SELLER']) ? 'success' : 'info', 'size' => 'small']
+//                        ];
+//                    },
+//                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [
+                'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
+                'REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
+//                'DEC_LV_NAME'=> ['isUserTable'=> true, 'name'=> '会员级别', 'other'=> 'decLevel'],
+//                'EMP_LV_NAME'=> ['isUserTable'=> true, 'name'=> '聘级', 'other'=> 'empLevel'],
+                'IS_DEC'=> ['isUserTable'=> false, 'name'=> '是否报单中心', 'other'=> 'yesOrNo'],
+//                'DEC_ROLE_NAME'=> ['isUserTable'=> true, 'name'=> '报单中心级别', 'other'=> 'decRole'],
+//                'SYSTEM_NAME'=> ['isUserTable'=> false, 'name'=> '体系名称', 'other'=> 'systems'],
+                'BONUS'=> ['isUserTable'=> false, 'name'=> '会员奖金余额'],
+                'RECONSUME_POINTS'=> ['isUserTable'=> false, 'name'=> '会员复消积分'],
+                'CASH'=> ['isUserTable'=> false, 'name'=> '会员余额'],
+//                'CF'=> ['isUserTable'=> false, 'name'=> '车房养老余额'],
+//                'LX'=> ['isUserTable'=> false, 'name'=> '领袖分红余额'],
+//                'STATUS'=> ['isUserTable'=> true, 'name'=> '会员状态', 'other'=> 'status'],
+//                'STATUS_AT'=> ['isUserTable'=> true, 'name'=> '会员状态变更时间', 'other'=> 'date'],
+//                'HIGHEST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> '历史最高聘级', 'other'=> 'empLevel'],
+                'PERIOD_AT'=> ['isUserTable'=> false, 'name'=> '加入期数'],
+//                'DEC_DEC_ROLE_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心级别', 'other'=> 'decRole'],
+//                'DEC_USER_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心编号'],
+//                'DEC_REAL_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心姓名'],
+                'MOBILE'=> ['isUserTable'=> false, 'name'=> '手机号码'],
+                'TEL'=> ['isUserTable'=> false, 'name'=> '备用手机号码'],
+//                'AREA'=> ['isUserTable'=> true, 'name'=> '常用地址', 'other'=> 'area'],
+//                'SUB_COM_NAME'=> ['isUserTable'=> true, 'name'=> '所属分公司', 'other'=> 'subCompany'],
+//                'IS_DIRECT_SELLER'=> ['isUserTable'=> true, 'name'=> '是否直销员', 'other'=> 'yesOrNo'],
+            ];
+        }
+        return $this->filterTypes;
+    }
 }

+ 206 - 206
backendApi/modules/v1/models/lists/bonus/FlowExchangePointsList.php

@@ -1,207 +1,207 @@
-<?php
-
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use common\helpers\Cache;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\DealType;
-use common\libs\dataList\column\DateTime;
-use common\models\FlowExchangePoints;
-use Yii;
-
-class FlowExchangePointsList extends \common\libs\dataList\DataList implements DataListInterface {
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName() {
-        return '兑换积分流水';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle() {
-        $this->listData = FlowExchangePoints::lists($this->condition, $this->params, [
-            'orderBy' => 'CREATED_AT DESC, ID DESC',
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        foreach ($this->listData['list'] as $key => $value) {
-            $userInfo = Info::baseInfoZh($value['USER_ID']);
-            $this->listData['list'][$key] = array_merge($userInfo, $value);
-            $this->listData['list'][$key]['DEAL_TYPE_NAME'] = DealType::getAllTypesForShow()[$value['DEAL_TYPE_ID']]['TYPE_NAME'] ?? '';
-            $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-            $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-            $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,
-                'CREATED_AT' => [
-                    'header' => '创建时间',
-                    'value' => function ($row) {
-                        return (new DateTime([
-                            'value' => $row['CREATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-                'PERIOD_NUM' => '期数',
-                'CALC_MONTH' => '结算月',
-                'DEAL_TYPE_NAME' => [
-                    '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']
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '会员级别',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                    'valueOther' => [
-                        'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '聘级',
-                    'headerOther' => [
-                        'width' => '130',
-                    ],
-                    'valueOther' => [
-                        'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
-                    ],
-                ],
-                'IS_DEC' => [
-                    'header' => '是否报单中心',
-                    'value' => function ($row) {
-                        return (new YesNo([
-                            'value' => $row['IS_DEC'],
-                        ]))->result();
-                    },
-                    'headerOther' => function ($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function ($row) {
-                        return [
-                            'tag' => ['type' => (isset($row['IS_DEC']) && $row['IS_DEC']) ? 'success' : 'info', 'size' => 'small']
-                        ];
-                    },
-                ],
-                'BEFORE_BALANCE' => [
-                    'header' => '交易前余额',
-                    'value' => function ($row) {
-                        return (new Price([
-                            'value' => $row['TOTAL'] - $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '交易额',
-                    'value' => function ($row) {
-                        $result = (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                        return $row['IS_INCR'] > 0 ? '+' . $result : $result;
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                        'prop' => 'BONUS',
-                    ],
-                    'valueOther' => function ($row) {
-                        if ($row['IS_INCR'] > 0) {
-                            $type = 'success';
-                        } elseif ($row['IS_INCR'] == 0) {
-                            $type = 'danger';
-                        } else {
-                            $type = 'info';
-                        }
-                        return [
-                            'tag' => ['type' => $type, 'size' => 'small']
-                        ];
-                    },
-                ],
-                'TOTAL' => [
-                    'header' => '交易后余额',
-                    'value' => function ($row) {
-                        return (new Price([
-                            'value' => $row['TOTAL'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'ADMIN_NAME' => [
-                    'header' => '操作人',
-                    'headerOther' => ['width' => '110'],
-                ],
-                'REMARK' => [
-                    'header' => '备注',
-                    'headerOther' => ['width' => '250'],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes() {
-        if (!$this->filterTypes) {
-            $this->filterTypes = [
-                'CREATED_AT' => ['isUserTable' => false, 'name' => '创建时间', 'other' => 'date'],
-                'PERIOD_NUM' => ['isUserTable' => false, 'name' => '期数'],
-                'CALC_MONTH' => ['isUserTable' => false, 'name' => '结算月', 'other' => 'month'],
-                'DEAL_TYPE_NAME' => ['isUserTable' => false, 'name' => '交易类型', 'other' => 'dealTypes'],
-                'USER_NAME' => ['isUserTable' => true, 'name' => '会员编号'],
-                'REAL_NAME' => ['isUserTable' => true, 'name' => '会员姓名'],
-                'LAST_DEC_LV_NAME' => ['isUserTable' => false, 'name' => '会员级别', 'other' => 'decLevel'],
-                'LAST_EMP_LV_NAME' => ['isUserTable' => false, 'name' => '聘级', 'other' => 'empLevel'],
-                'IS_DEC' => ['isUserTable' => true, 'name' => '是否报单中心', 'other' => 'yesOrNo'],
-                'AMOUNT' => ['isUserTable' => false, 'name' => '交易额'],
-                'TOTAL' => ['isUserTable' => false, 'name' => '交易后余额'],
-                'ADMIN_NAME' => ['isUserTable' => false, 'name' => '操作人'],
-                'REMARK' => ['isUserTable' => false, 'name' => '备注'],
-            ];
-        }
-        return $this->filterTypes;
-    }
+<?php
+
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use common\helpers\Cache;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\DealType;
+use common\libs\dataList\column\DateTime;
+use common\models\FlowExchangePoints;
+use Yii;
+
+class FlowExchangePointsList extends \common\libs\dataList\DataList implements DataListInterface {
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName() {
+        return '兑换点数流水';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle() {
+        $this->listData = FlowExchangePoints::lists($this->condition, $this->params, [
+            'orderBy' => 'CREATED_AT DESC, ID DESC',
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        foreach ($this->listData['list'] as $key => $value) {
+            $userInfo = Info::baseInfoZh($value['USER_ID']);
+            $this->listData['list'][$key] = array_merge($userInfo, $value);
+            $this->listData['list'][$key]['DEAL_TYPE_NAME'] = DealType::getAllTypesForShow()[$value['DEAL_TYPE_ID']]['TYPE_NAME'] ?? '';
+            $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+            $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+            $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,
+                'CREATED_AT' => [
+                    'header' => '创建时间',
+                    'value' => function ($row) {
+                        return (new DateTime([
+                            'value' => $row['CREATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+                'PERIOD_NUM' => '期数',
+                'CALC_MONTH' => '结算月',
+                'DEAL_TYPE_NAME' => [
+                    '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']
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '会员级别',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                    'valueOther' => [
+                        'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '聘级',
+                    'headerOther' => [
+                        'width' => '130',
+                    ],
+                    'valueOther' => [
+                        'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
+                    ],
+                ],
+                'IS_DEC' => [
+                    'header' => '是否报单中心',
+                    'value' => function ($row) {
+                        return (new YesNo([
+                            'value' => $row['IS_DEC'],
+                        ]))->result();
+                    },
+                    'headerOther' => function ($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function ($row) {
+                        return [
+                            'tag' => ['type' => (isset($row['IS_DEC']) && $row['IS_DEC']) ? 'success' : 'info', 'size' => 'small']
+                        ];
+                    },
+                ],
+                'BEFORE_BALANCE' => [
+                    'header' => '交易前余额',
+                    'value' => function ($row) {
+                        return (new Price([
+                            'value' => $row['TOTAL'] - $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '交易额',
+                    'value' => function ($row) {
+                        $result = (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                        return $row['IS_INCR'] > 0 ? '+' . $result : $result;
+                    },
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop' => 'BONUS',
+                    ],
+                    'valueOther' => function ($row) {
+                        if ($row['IS_INCR'] > 0) {
+                            $type = 'success';
+                        } elseif ($row['IS_INCR'] == 0) {
+                            $type = 'danger';
+                        } else {
+                            $type = 'info';
+                        }
+                        return [
+                            'tag' => ['type' => $type, 'size' => 'small']
+                        ];
+                    },
+                ],
+                'TOTAL' => [
+                    'header' => '交易后余额',
+                    'value' => function ($row) {
+                        return (new Price([
+                            'value' => $row['TOTAL'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'ADMIN_NAME' => [
+                    'header' => '操作人',
+                    'headerOther' => ['width' => '110'],
+                ],
+                'REMARK' => [
+                    'header' => '备注',
+                    'headerOther' => ['width' => '250'],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes() {
+        if (!$this->filterTypes) {
+            $this->filterTypes = [
+                'CREATED_AT' => ['isUserTable' => false, 'name' => '创建时间', 'other' => 'date'],
+                'PERIOD_NUM' => ['isUserTable' => false, 'name' => '期数'],
+                'CALC_MONTH' => ['isUserTable' => false, 'name' => '结算月', 'other' => 'month'],
+                'DEAL_TYPE_NAME' => ['isUserTable' => false, 'name' => '交易类型', 'other' => 'dealTypes'],
+                'USER_NAME' => ['isUserTable' => true, 'name' => '会员编号'],
+                'REAL_NAME' => ['isUserTable' => true, 'name' => '会员姓名'],
+                'LAST_DEC_LV_NAME' => ['isUserTable' => false, 'name' => '会员级别', 'other' => 'decLevel'],
+                'LAST_EMP_LV_NAME' => ['isUserTable' => false, 'name' => '聘级', 'other' => 'empLevel'],
+                'IS_DEC' => ['isUserTable' => true, 'name' => '是否报单中心', 'other' => 'yesOrNo'],
+                'AMOUNT' => ['isUserTable' => false, 'name' => '交易额'],
+                'TOTAL' => ['isUserTable' => false, 'name' => '交易后余额'],
+                'ADMIN_NAME' => ['isUserTable' => false, 'name' => '操作人'],
+                'REMARK' => ['isUserTable' => false, 'name' => '备注'],
+            ];
+        }
+        return $this->filterTypes;
+    }
 }

+ 555 - 555
backendApi/modules/v1/models/lists/bonus/OtherPeriodBonusList.php

@@ -1,556 +1,556 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\Cache;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\PerfOrder;
-use common\models\Period;
-use common\models\Region;
-use common\models\User as modelUser;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserPerf;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class OtherPeriodBonusList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '往期奖金列表';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $this->listData = CalcBonus::lists($this->condition, $this->params, [
-            //'select'=>'CB.*, UP.SURPLUS_1L AS UP_SURPLUS_1L, UP.SURPLUS_2L AS UP_SURPLUS_2L, UP.SURPLUS_3L AS UP_SURPLUS_3L,UI.CON_UID,UI.REC_UID',
-            'select'=>'CB.*,UI.CON_UID,UI.REC_UID',
-            'from' => CalcBonus::tableName().' AS CB',
-            'join' => [
-                //['LEFT JOIN', UserPerf::tableName() . ' AS UP', 'CB.USER_ID=UP.USER_ID'],
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
-            ],
-            'yearMonth' => $yearMonth,
-            'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        unset($yearMonth);
-        if ($this->listData['list']) {
-            foreach ($this->listData['list'] as $key => $value) {
-                $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'];
-                $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'];
-                $this->listData['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'];
-
-                $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
-                $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
-                $this->listData['list'][$key]['LAST_CON_USER_NAME'] = Info::getUserNameByUserId($value['CON_UID']);
-                $this->listData['list'][$key]['LAST_CON_REAL_NAME'] = Info::getUserRealNameByUserId($value['CON_UID']);
-            }
-        }
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'ID' => null,
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
-                    ],
-                ],
-                'CALCULATED_AT' => [
-                    'header' => '结算时间',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['CALCULATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-                'LAST_USER_NAME' => [
-                    'header' => '会员编号',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
-                    ],
-                ],
-                'LAST_REAL_NAME' => [
-                    'header' => '会员姓名',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'LAST_MOBILE' => [
-                    'header' => '手机号码',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_PERIOD_AT' => [
-                    'header' => '加入期数',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'LAST_CREATED_AT' => [
-                    'header' => '加入时间',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['LAST_CREATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-                'LAST_REC_USER_NAME' => [
-                    'header' => '开拓者编号',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_REC_REAL_NAME' => [
-                    'header' => '开拓者姓名',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'LAST_CON_USER_NAME' => [
-                    'header' => '上级编号',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_CON_REAL_NAME' => [
-                    'header' => '上级姓名',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'PV_1L' => [
-                    'header' => '一市场新增业绩',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_1L'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'PV_1L',
-                    ],
-                ],
-                'SURPLUS_1L' => [
-                    'header' => '一市场结余业绩',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['SURPLUS_1L'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'SURPLUS_1L',
-                    ],
-                ],
-                'PV_2L' => [
-                    'header' => '二市场新增业绩',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_2L'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'PV_2L',
-                    ],
-                ],
-                'SURPLUS_2L' => [
-                    'header' => '二市场结余业绩',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['SURPLUS_2L'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'SURPLUS_2L',
-                    ],
-                ],
-//                'UP_SURPLUS_2L' => [
-//                    'header' => '当前二市场结余业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['UP_SURPLUS_2L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'UP_SURPLUS_2L',
-//                    ],
-//                ],
-                'PV_3L' => [
-                    'header' => '三市场新增业绩',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_3L'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'PV_3L',
-                    ],
-                ],
-                'SURPLUS_3L' => [
-                    'header' => '三市场结余业绩',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['SURPLUS_3L'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'SURPLUS_3L',
-                    ],
-                ],
-//                'UP_SURPLUS_3L' => [
-//                    'header' => '当前三市场结余业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['UP_SURPLUS_3L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'UP_SURPLUS_3L',
-//                    ],
-//                ],
-                'BONUS_BD' => [
-                    'header' => '服务奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_BD'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_BD',
-                    ],
-                ],
-                'ORI_BONUS_BD' => [
-                    'header' => '服务奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_BD'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_BD',
-                    ],
-                ],
-                'BONUS_TG' => [
-                    'header' => '推广奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_TG'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_TG',
-                    ],
-                ],
-                'ORI_BONUS_TG' => [
-                    'header' => '推广奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_TG'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_TG',
-                    ],
-                ],
-                'BONUS_XF' => [
-                    'header' => '消费奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_XF'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_XF',
-                    ],
-                ],
-                'ORI_BONUS_XF' => [
-                    'header' => '消费奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_XF'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_XF',
-                    ],
-                ],
-                'BONUS_YJ' => [
-                    'header' => '业绩奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_YJ'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_YJ',
-                    ],
-                ],
-                'ORI_BONUS_YJ' => [
-                    'header' => '业绩奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_YJ'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_YJ',
-                    ],
-                ],
-                'BONUS_GX' => [
-                    'header' => '共享奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_GX'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_GX',
-                    ],
-                ],
-                'ORI_BONUS_GX' => [
-                    'header' => '共享奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_GX'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_GX',
-                    ],
-                ],
-                'BONUS_GL' => [
-                    'header' => '管理奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_GL'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_GL',
-                    ],
-                ],
-                'ORI_BONUS_GL' => [
-                    'header' => '管理奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_GL'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_GL',
-                    ],
-                ],
-                'BONUS_QY' => [
-                    'header' => '团队奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_QY'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_QY',
-                    ],
-                ],
-                'ORI_BONUS_QY' => [
-                    'header' => '团队奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_QY'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_QY',
-                    ],
-                ],
-                'ORI_BONUS_QY_BD' => [
-                    'header' => '报单团队奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_QY_BD'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_QY_BD',
-                    ],
-                ],
-                'BONUS_YC' => [
-                    'header' => '荣衔奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_YC'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_YC',
-                    ],
-                ],
-                'ORI_BONUS_YC' => [
-                    'header' => '荣衔奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_YC'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_YC',
-                    ],
-                ],
-                'BONUS_TOTAL' => [
-                    'header' => '总奖金',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_TOTAL'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_TOTAL',
-                    ],
-                ],
-                'BONUS_INCOME' => [
-                    'header' => '总收入',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_INCOME'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_INCOME',
-                    ],
-                ],
-                'ORI_BONUS_STANDARD' => [
-                    'header' => '团队成长奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_STANDARD'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_STANDARD',
-                    ],
-                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [
-                'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
-                'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
-                'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> '结算时会员级别', 'other'=> 'decLevel'],
-                'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> '结算时会员聘级', 'other'=> 'empLevel'],
-                'LAST_MOBILE'=> ['isUserTable'=> false, 'name'=> '手机号'],
-                'LAST_PERIOD_AT'=> ['isUserTable'=> false, 'name'=> '加入期数'],
-                'LAST_CREATED_AT'=> ['isUserTable'=> false, 'name'=> '加入时间', 'other'=> 'date'],
-                'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者编号'],
-                'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者姓名'],
-                'LAST_CON_USER_NAME'=> ['isUserTable'=> false, 'name'=> '上级编号'],
-                'LAST_CON_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '上级姓名'],
-                'PV_1L'=> ['isUserTable'=> false, 'name'=> '一市场新增业绩'],
-                'SURPLUS_1L'=> ['isUserTable'=> false, 'name'=> '一市场结余业绩'],
-                'PV_2L'=> ['isUserTable'=> false, 'name'=> '二市场新增业绩'],
-                'SURPLUS_2L'=> ['isUserTable'=> false, 'name'=> '二市场结余业绩'],
-                'PV_3L'=> ['isUserTable'=> false, 'name'=> '三市场新增业绩'],
-                'SURPLUS_3L'=> ['isUserTable'=> false, 'name'=> '三市场结余业绩'],
-                'BONUS_BD'=> ['isUserTable'=> false, 'name'=> '服务奖'],
-                'BONUS_TG'=> ['isUserTable'=> false, 'name'=> '推广奖'],
-                'BONUS_XF'=> ['isUserTable'=> false, 'name'=> '消费奖'],
-                'BONUS_YJ'=> ['isUserTable'=> false, 'name'=> '业绩奖'],
-                'BONUS_GX'=> ['isUserTable'=> false, 'name'=> '共享奖'],
-                'BONUS_GL'=> ['isUserTable'=> false, 'name'=> '管理奖'],
-                'BONUS_QY'=> ['isUserTable'=> false, 'name'=> '团队奖'],
-                'BONUS_YC'=> ['isUserTable'=> false, 'name'=> '荣衔奖'],
-                'ORI_BONUS_STANDARD'=> ['isUserTable'=> false, 'name'=> '团队成长奖'],
-                'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
-            ];
-        }
-        return $this->filterTypes;
-    }
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\Cache;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\PerfOrder;
+use common\models\Period;
+use common\models\Region;
+use common\models\User as modelUser;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserPerf;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class OtherPeriodBonusList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '往期奖金列表';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $this->listData = CalcBonus::lists($this->condition, $this->params, [
+            //'select'=>'CB.*, UP.SURPLUS_1L AS UP_SURPLUS_1L, UP.SURPLUS_2L AS UP_SURPLUS_2L, UP.SURPLUS_3L AS UP_SURPLUS_3L,UI.CON_UID,UI.REC_UID',
+            'select'=>'CB.*,UI.CON_UID,UI.REC_UID',
+            'from' => CalcBonus::tableName().' AS CB',
+            'join' => [
+                //['LEFT JOIN', UserPerf::tableName() . ' AS UP', 'CB.USER_ID=UP.USER_ID'],
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
+            ],
+            'yearMonth' => $yearMonth,
+            'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        unset($yearMonth);
+        if ($this->listData['list']) {
+            foreach ($this->listData['list'] as $key => $value) {
+                $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'];
+                $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'];
+                $this->listData['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'];
+
+                $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
+                $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
+                $this->listData['list'][$key]['LAST_CON_USER_NAME'] = Info::getUserNameByUserId($value['CON_UID']);
+                $this->listData['list'][$key]['LAST_CON_REAL_NAME'] = Info::getUserRealNameByUserId($value['CON_UID']);
+            }
+        }
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'ID' => null,
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
+                    ],
+                ],
+                'CALCULATED_AT' => [
+                    'header' => '结算时间',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['CALCULATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+                'LAST_USER_NAME' => [
+                    'header' => '会员编号',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
+                    ],
+                ],
+                'LAST_REAL_NAME' => [
+                    'header' => '会员姓名',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'LAST_MOBILE' => [
+                    'header' => '手机号码',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_PERIOD_AT' => [
+                    'header' => '加入期数',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'LAST_CREATED_AT' => [
+                    'header' => '加入时间',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['LAST_CREATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+                'LAST_REC_USER_NAME' => [
+                    'header' => '开拓者编号',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_REC_REAL_NAME' => [
+                    'header' => '开拓者姓名',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'LAST_CON_USER_NAME' => [
+                    'header' => '上级编号',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_CON_REAL_NAME' => [
+                    'header' => '上级姓名',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'PV_1L' => [
+                    'header' => '一市场新增业绩',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_1L'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'PV_1L',
+                    ],
+                ],
+                'SURPLUS_1L' => [
+                    'header' => '一市场结余业绩',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['SURPLUS_1L'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'SURPLUS_1L',
+                    ],
+                ],
+                'PV_2L' => [
+                    'header' => '二市场新增业绩',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_2L'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'PV_2L',
+                    ],
+                ],
+                'SURPLUS_2L' => [
+                    'header' => '二市场结余业绩',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['SURPLUS_2L'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'SURPLUS_2L',
+                    ],
+                ],
+//                'UP_SURPLUS_2L' => [
+//                    'header' => '当前二市场结余业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['UP_SURPLUS_2L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'UP_SURPLUS_2L',
+//                    ],
+//                ],
+                'PV_3L' => [
+                    'header' => '三市场新增业绩',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_3L'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'PV_3L',
+                    ],
+                ],
+                'SURPLUS_3L' => [
+                    'header' => '三市场结余业绩',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['SURPLUS_3L'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'SURPLUS_3L',
+                    ],
+                ],
+//                'UP_SURPLUS_3L' => [
+//                    'header' => '当前三市场结余业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['UP_SURPLUS_3L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'UP_SURPLUS_3L',
+//                    ],
+//                ],
+                'BONUS_BD' => [
+                    'header' => '服务奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_BD'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_BD',
+                    ],
+                ],
+                'ORI_BONUS_BD' => [
+                    'header' => '服务奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_BD'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_BD',
+                    ],
+                ],
+                'BONUS_TG' => [
+                    'header' => '推广奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_TG'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_TG',
+                    ],
+                ],
+                'ORI_BONUS_TG' => [
+                    'header' => '推广奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_TG'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_TG',
+                    ],
+                ],
+                'BONUS_XF' => [
+                    'header' => '消费奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_XF'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_XF',
+                    ],
+                ],
+                'ORI_BONUS_XF' => [
+                    'header' => '消费奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_XF'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_XF',
+                    ],
+                ],
+                'BONUS_YJ' => [
+                    'header' => '业绩奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_YJ'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_YJ',
+                    ],
+                ],
+                'ORI_BONUS_YJ' => [
+                    'header' => '业绩奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_YJ'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_YJ',
+                    ],
+                ],
+                'BONUS_GX' => [
+                    'header' => '共享奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_GX'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_GX',
+                    ],
+                ],
+                'ORI_BONUS_GX' => [
+                    'header' => '共享奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_GX'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_GX',
+                    ],
+                ],
+                'BONUS_GL' => [
+                    'header' => '管理奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_GL'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_GL',
+                    ],
+                ],
+                'ORI_BONUS_GL' => [
+                    'header' => '管理奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_GL'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_GL',
+                    ],
+                ],
+                'BONUS_QY' => [
+                    'header' => '团队奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_QY'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_QY',
+                    ],
+                ],
+                'ORI_BONUS_QY' => [
+                    'header' => '团队奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_QY'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_QY',
+                    ],
+                ],
+                'ORI_BONUS_QY_BD' => [
+                    'header' => '报单团队奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_QY_BD'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_QY_BD',
+                    ],
+                ],
+                'BONUS_YC' => [
+                    'header' => '荣衔奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_YC'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_YC',
+                    ],
+                ],
+                'ORI_BONUS_YC' => [
+                    'header' => '荣衔奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_YC'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_YC',
+                    ],
+                ],
+                'BONUS_TOTAL' => [
+                    'header' => '总奖金',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_TOTAL'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_TOTAL',
+                    ],
+                ],
+                'BONUS_INCOME' => [
+                    'header' => '总收入',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_INCOME'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_INCOME',
+                    ],
+                ],
+                'ORI_BONUS_STANDARD' => [
+                    'header' => '团队成长奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_STANDARD'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_STANDARD',
+                    ],
+                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [
+                'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
+                'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
+                'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> '结算时会员级别', 'other'=> 'decLevel'],
+                'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> '最新聘级', 'other'=> 'empLevel'],
+                'LAST_MOBILE'=> ['isUserTable'=> false, 'name'=> '手机号'],
+                'LAST_PERIOD_AT'=> ['isUserTable'=> false, 'name'=> '加入期数'],
+                'LAST_CREATED_AT'=> ['isUserTable'=> false, 'name'=> '加入时间', 'other'=> 'date'],
+                'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者编号'],
+                'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者姓名'],
+                'LAST_CON_USER_NAME'=> ['isUserTable'=> false, 'name'=> '上级编号'],
+                'LAST_CON_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '上级姓名'],
+                'PV_1L'=> ['isUserTable'=> false, 'name'=> '一市场新增业绩'],
+                'SURPLUS_1L'=> ['isUserTable'=> false, 'name'=> '一市场结余业绩'],
+                'PV_2L'=> ['isUserTable'=> false, 'name'=> '二市场新增业绩'],
+                'SURPLUS_2L'=> ['isUserTable'=> false, 'name'=> '二市场结余业绩'],
+                'PV_3L'=> ['isUserTable'=> false, 'name'=> '三市场新增业绩'],
+                'SURPLUS_3L'=> ['isUserTable'=> false, 'name'=> '三市场结余业绩'],
+                'BONUS_BD'=> ['isUserTable'=> false, 'name'=> '服务奖'],
+                'BONUS_TG'=> ['isUserTable'=> false, 'name'=> '推广奖'],
+                'BONUS_XF'=> ['isUserTable'=> false, 'name'=> '消费奖'],
+                'BONUS_YJ'=> ['isUserTable'=> false, 'name'=> '业绩奖'],
+                'BONUS_GX'=> ['isUserTable'=> false, 'name'=> '共享奖'],
+                'BONUS_GL'=> ['isUserTable'=> false, 'name'=> '管理奖'],
+                'BONUS_QY'=> ['isUserTable'=> false, 'name'=> '团队奖'],
+                'BONUS_YC'=> ['isUserTable'=> false, 'name'=> '荣衔奖'],
+                'ORI_BONUS_STANDARD'=> ['isUserTable'=> false, 'name'=> '团队成长奖'],
+                'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
+            ];
+        }
+        return $this->filterTypes;
+    }
 }

+ 228 - 228
backendApi/modules/v1/models/lists/bonus/PerfMonthList.php

@@ -1,229 +1,229 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use common\helpers\Cache;
-use common\helpers\user\Info;
-use common\models\PerfMonth;
-use common\models\User as modelUser;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\DataListInterface;
-use common\libs\dataList\column\DateTime;
-use common\models\UserInfo;
-use Yii;
-
-class PerfMonthList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '月业绩列表';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $data = PerfMonth::lists($this->condition, $this->params, [
-            'select'=>'PM.*, U.USER_NAME, U.REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,',
-            'from' => PerfMonth::tableName().' AS PM',
-            'join' => [
-                ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PM.USER_ID=U.ID'],
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'PM.USER_ID=UI.USER_ID'],
-                ['LEFT JOIN', modelUser::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
-            ],
-            'orderBy' => 'PM.CREATED_AT DESC, PM.ID DESC',
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-            }
-        }
-        $this->listData = $data;
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'USER_NAME' => [
-                    'header' => '会员编号',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'REAL_NAME' => [
-                    'header' => '会员姓名',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'REC_USER_NAME' => [
-                    'header' => '推荐人编号',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'REC_REAL_NAME' => [
-                    'header' => '推荐人姓名',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'PV_PCS' => [
-                    'header' => '个人业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_PCS'],
-                        ]))->result();
-                    },
-                ],
-                'VIP_PV_1L_ZC' => [
-                    'header' => '一市场新增报单业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['VIP_PV_1L_ZC'],
-                        ]))->result();
-                    },
-                ],
-                'VIP_PV_2L_ZC' => [
-                    'header' => '二市场新增报单业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['VIP_PV_2L_ZC'],
-                        ]))->result();
-                    },
-                ],
-                'VIP_PV_3L_ZC' => [
-                    'header' => '三市场新增报单业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['VIP_PV_3L_ZC'],
-                        ]))->result();
-                    },
-                ],
-                'VIP_SURPLUS_1L_ZC' => [
-                    'header' => '一市场月剩余报单业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['VIP_SURPLUS_1L_ZC'],
-                        ]))->result();
-                    },
-                ],
-                'VIP_SURPLUS_2L_ZC' => [
-                    'header' => '二市场月剩余报单业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['VIP_SURPLUS_2L_ZC'],
-                        ]))->result();
-                    },
-                ],
-                'VIP_SURPLUS_3L_ZC' => [
-                    'header' => '三市场月剩余报单业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['VIP_SURPLUS_3L_ZC'],
-                        ]))->result();
-                    },
-                ],
-                'PV_PSS' => [
-                    'header' => '月新增团队业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_PSS'],
-                        ]))->result();
-                    },
-                ],
-                'PV_PSS_TOTAL' => [
-                    'header' => '月累计团队业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_PSS_TOTAL'],
-                        ]))->result();
-                    },
-                ],
-                'CREATED_AT' => [
-                    'header' => '创建时间',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['CREATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [
-                'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
-                'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
-                'REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '推荐人编号'],
-                'CREATED_AT'=> ['isUserTable'=> false, 'name'=> '创建时间', 'other'=> 'date'],
-            ];
-        }
-        return $this->filterTypes;
-    }
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use common\helpers\Cache;
+use common\helpers\user\Info;
+use common\models\PerfMonth;
+use common\models\User as modelUser;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\DataListInterface;
+use common\libs\dataList\column\DateTime;
+use common\models\UserInfo;
+use Yii;
+
+class PerfMonthList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '月业绩列表';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $data = PerfMonth::lists($this->condition, $this->params, [
+            'select'=>'PM.*, U.USER_NAME, U.REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,',
+            'from' => PerfMonth::tableName().' AS PM',
+            'join' => [
+                ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PM.USER_ID=U.ID'],
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'PM.USER_ID=UI.USER_ID'],
+                ['LEFT JOIN', modelUser::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
+            ],
+            'orderBy' => 'PM.CREATED_AT DESC, PM.ID DESC',
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+            }
+        }
+        $this->listData = $data;
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'USER_NAME' => [
+                    'header' => '会员编号',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'REAL_NAME' => [
+                    'header' => '会员姓名',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'REC_USER_NAME' => [
+                    'header' => '推荐人编号',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'REC_REAL_NAME' => [
+                    'header' => '推荐人姓名',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'PV_PCS' => [
+                    'header' => '个人业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_PCS'],
+                        ]))->result();
+                    },
+                ],
+                'VIP_PV_1L_ZC' => [
+                    'header' => '一市场新增报单业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['VIP_PV_1L_ZC'],
+                        ]))->result();
+                    },
+                ],
+                'VIP_PV_2L_ZC' => [
+                    'header' => '二市场新增报单业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['VIP_PV_2L_ZC'],
+                        ]))->result();
+                    },
+                ],
+                'VIP_PV_3L_ZC' => [
+                    'header' => '三市场新增报单业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['VIP_PV_3L_ZC'],
+                        ]))->result();
+                    },
+                ],
+                'VIP_SURPLUS_1L_ZC' => [
+                    'header' => '一市场月剩余报单业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['VIP_SURPLUS_1L_ZC'],
+                        ]))->result();
+                    },
+                ],
+                'VIP_SURPLUS_2L_ZC' => [
+                    'header' => '二市场月剩余报单业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['VIP_SURPLUS_2L_ZC'],
+                        ]))->result();
+                    },
+                ],
+                'VIP_SURPLUS_3L_ZC' => [
+                    'header' => '三市场月剩余报单业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['VIP_SURPLUS_3L_ZC'],
+                        ]))->result();
+                    },
+                ],
+                'PV_PSS' => [
+                    'header' => '月新增团队业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_PSS'],
+                        ]))->result();
+                    },
+                ],
+                'PV_PSS_TOTAL' => [
+                    'header' => '月累计团队业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_PSS_TOTAL'],
+                        ]))->result();
+                    },
+                ],
+                'CREATED_AT' => [
+                    'header' => '创建时间',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['CREATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [
+                'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
+                'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
+                'REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '推荐人编号'],
+                'CREATED_AT'=> ['isUserTable'=> false, 'name'=> '创建时间', 'other'=> 'date'],
+            ];
+        }
+        return $this->filterTypes;
+    }
 }

+ 152 - 152
backendApi/modules/v1/models/lists/bonus/PerfStandardList.php

@@ -1,153 +1,153 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use common\helpers\Cache;
-use common\helpers\user\Info;
-use common\models\PerfMonth;
-use common\models\PerfStandard;
-use common\models\User as modelUser;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\DataListInterface;
-use common\libs\dataList\column\DateTime;
-use common\models\UserInfo;
-use Yii;
-
-class PerfStandardList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '达标业绩列表';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $data = PerfStandard::lists($this->condition, $this->params, [
-            'select'=>'PS.*, U.USER_NAME, U.REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,',
-            'from' => PerfStandard::tableName().' AS PS',
-            'join' => [
-                ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PS.USER_ID=U.ID'],
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'PS.USER_ID=UI.USER_ID'],
-                ['LEFT JOIN', modelUser::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
-            ],
-            'orderBy' => 'PS.ID DESC',
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-            }
-        }
-        $this->listData = $data;
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'USER_NAME' => [
-                    'header' => '会员编号',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'REAL_NAME' => [
-                    'header' => '会员姓名',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'REC_USER_NAME' => [
-                    'header' => '推荐人编号',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'REC_REAL_NAME' => [
-                    'header' => '推荐人姓名',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'AMOUNT_PCS' => [
-                    'header' => '个人销售额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT_PCS'],
-                        ]))->result();
-                    },
-                ],
-                'AMOUNT_PSS' => [
-                    'header' => '团队销售额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT_PSS'],
-                        ]))->result();
-                    },
-                ],
-                'CREATED_AT' => [
-                    'header' => '创建时间',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['CREATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [
-                'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
-                'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
-                'REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '推荐人编号'],
-                'CREATED_AT'=> ['isUserTable'=> false, 'name'=> '创建时间', 'other'=> 'date'],
-            ];
-        }
-        return $this->filterTypes;
-    }
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use common\helpers\Cache;
+use common\helpers\user\Info;
+use common\models\PerfMonth;
+use common\models\PerfStandard;
+use common\models\User as modelUser;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\DataListInterface;
+use common\libs\dataList\column\DateTime;
+use common\models\UserInfo;
+use Yii;
+
+class PerfStandardList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '达标业绩列表';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $data = PerfStandard::lists($this->condition, $this->params, [
+            'select'=>'PS.*, U.USER_NAME, U.REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,',
+            'from' => PerfStandard::tableName().' AS PS',
+            'join' => [
+                ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PS.USER_ID=U.ID'],
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'PS.USER_ID=UI.USER_ID'],
+                ['LEFT JOIN', modelUser::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
+            ],
+            'orderBy' => 'PS.ID DESC',
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+            }
+        }
+        $this->listData = $data;
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'USER_NAME' => [
+                    'header' => '会员编号',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'REAL_NAME' => [
+                    'header' => '会员姓名',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'REC_USER_NAME' => [
+                    'header' => '推荐人编号',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'REC_REAL_NAME' => [
+                    'header' => '推荐人姓名',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'AMOUNT_PCS' => [
+                    'header' => '个人销售额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT_PCS'],
+                        ]))->result();
+                    },
+                ],
+                'AMOUNT_PSS' => [
+                    'header' => '团队销售额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT_PSS'],
+                        ]))->result();
+                    },
+                ],
+                'CREATED_AT' => [
+                    'header' => '创建时间',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['CREATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [
+                'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
+                'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
+                'REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '推荐人编号'],
+                'CREATED_AT'=> ['isUserTable'=> false, 'name'=> '创建时间', 'other'=> 'date'],
+            ];
+        }
+        return $this->filterTypes;
+    }
 }

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

@@ -1,714 +1,714 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\Cache;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\PerfOrder;
-use common\models\Period;
-use common\models\Region;
-use common\models\User as modelUser;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserPerf;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class PeriodBonusList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '奖金列表';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $this->listData = CalcBonus::lists($this->condition, $this->params, [
-//            'select'=>'CB.*, UP.SURPLUS_1L AS UP_SURPLUS_1L, UP.SURPLUS_2L AS UP_SURPLUS_2L, UP.SURPLUS_3L AS UP_SURPLUS_3L,UI.CON_UID,UI.REC_UID',
-            'select'=>'CB.*,UI.CON_UID,UI.REC_UID',
-            'from' => CalcBonus::tableName().' AS CB',
-            'join' => [
-//                ['LEFT JOIN', UserPerf::tableName() . ' AS UP', 'CB.USER_ID=UP.USER_ID'],
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
-            ],
-            'yearMonth' => $yearMonth,
-            'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        unset($yearMonth);
-        if ($this->listData['list']) {
-            foreach ($this->listData['list'] as $key => $value) {
-                $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'];
-                $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'];
-                $this->listData['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'];
-
-                $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
-                $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
-                $this->listData['list'][$key]['LAST_CON_USER_NAME'] = Info::getUserNameByUserId($value['CON_UID']);
-                $this->listData['list'][$key]['LAST_CON_REAL_NAME'] = Info::getUserRealNameByUserId($value['CON_UID']);
-            }
-        }
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'ID' => null,
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
-                    ],
-                ],
-                'CALCULATED_AT' => [
-                    'header' => '结算时间',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['CALCULATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-                'LAST_USER_NAME' => [
-                    'header' => '会员编号',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
-                    ],
-                ],
-                'LAST_REAL_NAME' => [
-                    'header' => '会员姓名',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'LAST_MOBILE' => [
-                    'header' => '手机号码',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_PERIOD_AT' => [
-                    'header' => '加入期数',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'LAST_CREATED_AT' => [
-                    'header' => '加入时间',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['LAST_CREATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-                'LAST_REC_USER_NAME' => [
-                    'header' => '开拓者编号',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_REC_REAL_NAME' => [
-                    'header' => '开拓者姓名',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'LAST_CON_USER_NAME' => [
-                    'header' => '上级编号',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_CON_REAL_NAME' => [
-                    'header' => '上级姓名',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-//                'PV_1L' => [
-//                    'header' => '一市场新增业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['PV_1L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'PV_1L',
-//                    ],
-//                ],
-//                'SURPLUS_1L' => [
-//                    'header' => '一市场结余业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['SURPLUS_1L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'SURPLUS_1L',
-//                    ],
-//                ],
-//                'UP_SURPLUS_1L' => [
-//                    'header' => '当前一市场结余业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['UP_SURPLUS_1L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'UP_SURPLUS_1L',
-//                    ],
-//                ],
-//                'PV_2L' => [
-//                    'header' => '二市场新增业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['PV_2L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'PV_2L',
-//                    ],
-//                ],
-//                'SURPLUS_2L' => [
-//                    'header' => '二市场结余业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['SURPLUS_2L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'SURPLUS_2L',
-//                    ],
-//                ],
-//                'UP_SURPLUS_2L' => [
-//                    'header' => '当前二市场结余业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['UP_SURPLUS_2L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'UP_SURPLUS_2L',
-//                    ],
-//                ],
-//                'PV_3L' => [
-//                    'header' => '三市场新增业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['PV_3L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'PV_3L',
-//                    ],
-//                ],
-//                'SURPLUS_3L' => [
-//                    'header' => '三市场结余业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['SURPLUS_3L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'SURPLUS_3L',
-//                    ],
-//                ],
-//                'UP_SURPLUS_3L' => [
-//                    'header' => '当前三市场结余业绩',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['UP_SURPLUS_3L'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'UP_SURPLUS_3L',
-//                    ],
-//                ],
-                'BONUS_TG' => [
-                    'header' => '推广奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_TG'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_TG',
-                    ],
-                ],
-                'ORI_BONUS_TG' => [
-                    'header' => '推广奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_TG'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_TG',
-                    ],
-                ],
-                'BONUS_QY' => [
-                    'header' => '团队奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_QY'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_QY',
-                    ],
-                ],
-                'ORI_BONUS_QY' => [
-                    'header' => '团队奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_QY'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_QY',
-                    ],
-                ],
-                'ORI_BONUS_QY_BD' => [
-                    'header' => '报单团队奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_QY_BD'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_QY_BD',
-                    ],
-                ],
-                'BONUS_BS' => [
-                    'header' => '蓝星管理奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_BS'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_BS',
-                    ],
-                ],
-                'ORI_BONUS_BS' => [
-                    'header' => '蓝星管理奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_BS'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_BS',
-                    ],
-                ],
-                // 'REAL_BONUS_BS' => [
-                //     'header' => '实发蓝星管理奖',
-                //     'value' => function($row) {
-                //         return (new Price([
-                //             'value' => $row['REAL_BONUS_BS'],
-                //         ]))->result();
-                //     },
-                //     'headerOther' => [
-                //         'width' => '120',
-                //         'prop'=>'REAL_BONUS_BS',
-                //     ],
-                // ],
-                'BONUS_GX' => [
-                    'header' => '共享奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_GX'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_GX',
-                    ],
-                ],
-                'ORI_BONUS_GX' => [
-                    'header' => '共享奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_GX'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_GX',
-                    ],
-                ],
-                'REAL_BONUS_GX' => [
-                    'header' => '实发共享奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['REAL_BONUS_GX'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'REAL_BONUS_GX',
-                    ],
-                ],
-                'BONUS_BD' => [
-                    'header' => '服务奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_BD'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_BD',
-                    ],
-                ],
-                'ORI_BONUS_BD' => [
-                    'header' => '服务奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_BD'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_BD',
-                    ],
-                ],
-                'BONUS_REAL' => [
-                    'header' => '实发奖金',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_REAL'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_REAL',
-                    ],
-                ],
-                'BONUS_TOTAL' => [
-                    'header' => '总奖金',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_TOTAL'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_TOTAL',
-                    ],
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'MANAGE_TAX',
-                    ],
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复销积分',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'RECONSUME_POINTS',
-                    ],
-                ],
-                'BONUS_INCOME' => [
-                    'header' => '总收入',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_INCOME'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_INCOME',
-                    ],
-                ],
-                'ORI_BONUS_STANDARD' => [
-                    'header' => '团队成长奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_STANDARD'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_STANDARD',
-                    ],
-                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'BONUS_XF' => [
-                    'header' => '消费奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_XF'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_XF',
-                    ],
-                ],
-                'ORI_BONUS_XF' => [
-                    'header' => '消费奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_XF'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_XF',
-                    ],
-                ],
-                'BONUS_YJ' => [
-                    'header' => '业绩奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_YJ'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_YJ',
-                    ],
-                ],
-                'ORI_BONUS_YJ' => [
-                    'header' => '业绩奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_YJ'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_YJ',
-                    ],
-                ],
-                'BONUS_YC' => [
-                    'header' => '荣衔奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_YC'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_YC',
-                    ],
-                ],
-                'ORI_BONUS_YC' => [
-                    'header' => '荣衔奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_YC'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_YC',
-                    ],
-                ],
-                'BONUS_VIP' => [
-                    'header' => 'VIP奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_VIP'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_VIP',
-                    ],
-                ],
-                'ORI_BONUS_VIP' => [
-                    'header' => 'VIP奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_VIP'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_VIP',
-                    ],
-                ],
-                'BONUS_GL' => [
-                    'header' => '管理奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['BONUS_GL'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'BONUS_GL',
-                    ],
-                ],
-                'ORI_BONUS_GL' => [
-                    'header' => '管理奖原金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS_GL'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'ORI_BONUS_GL',
-                    ],
-                ],
-                'REAL_BONUS_GL' => [
-                    'header' => '实发管理奖',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['REAL_BONUS_GL'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '120',
-                        'prop'=>'REAL_BONUS_GL',
-                    ],
-                ],
-//                'BONUS_FW' => [
-//                    'header' => '服务奖',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['BONUS_FW'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'BONUS_FW',
-//                    ],
-//                ],
-//                'ORI_BONUS_FW' => [
-//                    'header' => '服务奖原金额',
-//                    'value' => function($row) {
-//                        return (new Price([
-//                            'value' => $row['ORI_BONUS_FW'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => [
-//                        'width' => '120',
-//                        'prop'=>'ORI_BONUS_FW',
-//                    ],
-//                ],
-                
-                
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [
-                'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
-                'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
-                'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> '结算时会员级别', 'other'=> 'decLevel'],
-                'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> '结算时会员聘级', 'other'=> 'empLevel'],
-                'LAST_MOBILE'=> ['isUserTable'=> false, 'name'=> '手机号'],
-                'LAST_PERIOD_AT'=> ['isUserTable'=> false, 'name'=> '加入期数'],
-                'LAST_CREATED_AT'=> ['isUserTable'=> false, 'name'=> '加入时间', 'other'=> 'date'],
-                'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者编号'],
-                'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者姓名'],
-                'LAST_CON_USER_NAME'=> ['isUserTable'=> false, 'name'=> '上级编号'],
-                'LAST_CON_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '上级姓名'],
-                'PV_1L'=> ['isUserTable'=> false, 'name'=> '一市场新增业绩'],
-                'SURPLUS_1L'=> ['isUserTable'=> false, 'name'=> '一市场结余业绩'],
-                'PV_2L'=> ['isUserTable'=> false, 'name'=> '二市场新增业绩'],
-                'SURPLUS_2L'=> ['isUserTable'=> false, 'name'=> '二市场结余业绩'],
-                'PV_3L'=> ['isUserTable'=> false, 'name'=> '三市场新增业绩'],
-                'SURPLUS_3L'=> ['isUserTable'=> false, 'name'=> '三市场结余业绩'],
-                'BONUS_BD'=> ['isUserTable'=> false, 'name'=> '服务奖'],
-                'BONUS_TG'=> ['isUserTable'=> false, 'name'=> '推广奖'],
-                'BONUS_XF'=> ['isUserTable'=> false, 'name'=> '消费奖'],
-                'BONUS_YJ'=> ['isUserTable'=> false, 'name'=> '业绩奖'],
-                'BONUS_GX'=> ['isUserTable'=> false, 'name'=> '共享奖'],
-                'BONUS_GL'=> ['isUserTable'=> false, 'name'=> '管理奖'],
-                'BONUS_QY'=> ['isUserTable'=> false, 'name'=> '团队奖'],
-                'BONUS_YC'=> ['isUserTable'=> false, 'name'=> '荣衔奖'],
-                'ORI_BONUS_STANDARD'=> ['isUserTable'=> false, 'name'=> '团队成长奖'],
-                'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
-            ];
-        }
-        return $this->filterTypes;
-    }
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\Cache;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\PerfOrder;
+use common\models\Period;
+use common\models\Region;
+use common\models\User as modelUser;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserPerf;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class PeriodBonusList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '奖金列表';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $this->listData = CalcBonus::lists($this->condition, $this->params, [
+//            'select'=>'CB.*, UP.SURPLUS_1L AS UP_SURPLUS_1L, UP.SURPLUS_2L AS UP_SURPLUS_2L, UP.SURPLUS_3L AS UP_SURPLUS_3L,UI.CON_UID,UI.REC_UID',
+            'select'=>'CB.*,UI.CON_UID,UI.REC_UID',
+            'from' => CalcBonus::tableName().' AS CB',
+            'join' => [
+//                ['LEFT JOIN', UserPerf::tableName() . ' AS UP', 'CB.USER_ID=UP.USER_ID'],
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
+            ],
+            'yearMonth' => $yearMonth,
+            'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        unset($yearMonth);
+        if ($this->listData['list']) {
+            foreach ($this->listData['list'] as $key => $value) {
+                $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'];
+                $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'];
+                $this->listData['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'];
+
+                $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
+                $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
+                $this->listData['list'][$key]['LAST_CON_USER_NAME'] = Info::getUserNameByUserId($value['CON_UID']);
+                $this->listData['list'][$key]['LAST_CON_REAL_NAME'] = Info::getUserRealNameByUserId($value['CON_UID']);
+            }
+        }
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'ID' => null,
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
+                    ],
+                ],
+                'CALCULATED_AT' => [
+                    'header' => '结算时间',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['CALCULATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+                'LAST_USER_NAME' => [
+                    'header' => '会员编号',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
+                    ],
+                ],
+                'LAST_REAL_NAME' => [
+                    'header' => '会员姓名',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'LAST_MOBILE' => [
+                    'header' => '手机号码',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_PERIOD_AT' => [
+                    'header' => '加入期数',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'LAST_CREATED_AT' => [
+                    'header' => '加入时间',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['LAST_CREATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+                'LAST_REC_USER_NAME' => [
+                    'header' => '开拓者编号',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_REC_REAL_NAME' => [
+                    'header' => '开拓者姓名',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'LAST_CON_USER_NAME' => [
+                    'header' => '上级编号',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_CON_REAL_NAME' => [
+                    'header' => '上级姓名',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+//                'PV_1L' => [
+//                    'header' => '一市场新增业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['PV_1L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'PV_1L',
+//                    ],
+//                ],
+//                'SURPLUS_1L' => [
+//                    'header' => '一市场结余业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['SURPLUS_1L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'SURPLUS_1L',
+//                    ],
+//                ],
+//                'UP_SURPLUS_1L' => [
+//                    'header' => '当前一市场结余业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['UP_SURPLUS_1L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'UP_SURPLUS_1L',
+//                    ],
+//                ],
+//                'PV_2L' => [
+//                    'header' => '二市场新增业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['PV_2L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'PV_2L',
+//                    ],
+//                ],
+//                'SURPLUS_2L' => [
+//                    'header' => '二市场结余业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['SURPLUS_2L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'SURPLUS_2L',
+//                    ],
+//                ],
+//                'UP_SURPLUS_2L' => [
+//                    'header' => '当前二市场结余业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['UP_SURPLUS_2L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'UP_SURPLUS_2L',
+//                    ],
+//                ],
+//                'PV_3L' => [
+//                    'header' => '三市场新增业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['PV_3L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'PV_3L',
+//                    ],
+//                ],
+//                'SURPLUS_3L' => [
+//                    'header' => '三市场结余业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['SURPLUS_3L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'SURPLUS_3L',
+//                    ],
+//                ],
+//                'UP_SURPLUS_3L' => [
+//                    'header' => '当前三市场结余业绩',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['UP_SURPLUS_3L'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'UP_SURPLUS_3L',
+//                    ],
+//                ],
+                'BONUS_TG' => [
+                    'header' => '推广奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_TG'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_TG',
+                    ],
+                ],
+                'ORI_BONUS_TG' => [
+                    'header' => '推广奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_TG'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_TG',
+                    ],
+                ],
+                'BONUS_QY' => [
+                    'header' => '团队奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_QY'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_QY',
+                    ],
+                ],
+                'ORI_BONUS_QY' => [
+                    'header' => '团队奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_QY'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_QY',
+                    ],
+                ],
+                'ORI_BONUS_QY_BD' => [
+                    'header' => '报单团队奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_QY_BD'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_QY_BD',
+                    ],
+                ],
+                'BONUS_BS' => [
+                    'header' => '蓝星管理奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_BS'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_BS',
+                    ],
+                ],
+                'ORI_BONUS_BS' => [
+                    'header' => '蓝星管理奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_BS'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_BS',
+                    ],
+                ],
+                // 'REAL_BONUS_BS' => [
+                //     'header' => '实发蓝星管理奖',
+                //     'value' => function($row) {
+                //         return (new Price([
+                //             'value' => $row['REAL_BONUS_BS'],
+                //         ]))->result();
+                //     },
+                //     'headerOther' => [
+                //         'width' => '120',
+                //         'prop'=>'REAL_BONUS_BS',
+                //     ],
+                // ],
+                'BONUS_GX' => [
+                    'header' => '共享奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_GX'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_GX',
+                    ],
+                ],
+                'ORI_BONUS_GX' => [
+                    'header' => '共享奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_GX'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_GX',
+                    ],
+                ],
+                'REAL_BONUS_GX' => [
+                    'header' => '实发共享奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['REAL_BONUS_GX'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'REAL_BONUS_GX',
+                    ],
+                ],
+                'BONUS_BD' => [
+                    'header' => '服务奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_BD'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_BD',
+                    ],
+                ],
+                'ORI_BONUS_BD' => [
+                    'header' => '服务奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_BD'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_BD',
+                    ],
+                ],
+                'BONUS_REAL' => [
+                    'header' => '实发奖金',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_REAL'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_REAL',
+                    ],
+                ],
+                'BONUS_TOTAL' => [
+                    'header' => '总奖金',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_TOTAL'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_TOTAL',
+                    ],
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'MANAGE_TAX',
+                    ],
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复销积分',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'RECONSUME_POINTS',
+                    ],
+                ],
+                'BONUS_INCOME' => [
+                    'header' => '总收入',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_INCOME'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_INCOME',
+                    ],
+                ],
+                'ORI_BONUS_STANDARD' => [
+                    'header' => '团队成长奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_STANDARD'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_STANDARD',
+                    ],
+                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'BONUS_XF' => [
+                    'header' => '消费奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_XF'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_XF',
+                    ],
+                ],
+                'ORI_BONUS_XF' => [
+                    'header' => '消费奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_XF'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_XF',
+                    ],
+                ],
+                'BONUS_YJ' => [
+                    'header' => '业绩奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_YJ'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_YJ',
+                    ],
+                ],
+                'ORI_BONUS_YJ' => [
+                    'header' => '业绩奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_YJ'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_YJ',
+                    ],
+                ],
+                'BONUS_YC' => [
+                    'header' => '荣衔奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_YC'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_YC',
+                    ],
+                ],
+                'ORI_BONUS_YC' => [
+                    'header' => '荣衔奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_YC'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_YC',
+                    ],
+                ],
+                'BONUS_VIP' => [
+                    'header' => 'VIP奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_VIP'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_VIP',
+                    ],
+                ],
+                'ORI_BONUS_VIP' => [
+                    'header' => 'VIP奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_VIP'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_VIP',
+                    ],
+                ],
+                'BONUS_GL' => [
+                    'header' => '管理奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['BONUS_GL'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'BONUS_GL',
+                    ],
+                ],
+                'ORI_BONUS_GL' => [
+                    'header' => '管理奖原金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS_GL'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'ORI_BONUS_GL',
+                    ],
+                ],
+                'REAL_BONUS_GL' => [
+                    'header' => '实发管理奖',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['REAL_BONUS_GL'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '120',
+                        'prop'=>'REAL_BONUS_GL',
+                    ],
+                ],
+//                'BONUS_FW' => [
+//                    'header' => '服务奖',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['BONUS_FW'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'BONUS_FW',
+//                    ],
+//                ],
+//                'ORI_BONUS_FW' => [
+//                    'header' => '服务奖原金额',
+//                    'value' => function($row) {
+//                        return (new Price([
+//                            'value' => $row['ORI_BONUS_FW'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => [
+//                        'width' => '120',
+//                        'prop'=>'ORI_BONUS_FW',
+//                    ],
+//                ],
+                
+                
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [
+                'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
+                'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
+                'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> '结算时会员级别', 'other'=> 'decLevel'],
+                'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> '最新聘级', 'other'=> 'empLevel'],
+                'LAST_MOBILE'=> ['isUserTable'=> false, 'name'=> '手机号'],
+                'LAST_PERIOD_AT'=> ['isUserTable'=> false, 'name'=> '加入期数'],
+                'LAST_CREATED_AT'=> ['isUserTable'=> false, 'name'=> '加入时间', 'other'=> 'date'],
+                'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者编号'],
+                'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者姓名'],
+                'LAST_CON_USER_NAME'=> ['isUserTable'=> false, 'name'=> '上级编号'],
+                'LAST_CON_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '上级姓名'],
+                'PV_1L'=> ['isUserTable'=> false, 'name'=> '一市场新增业绩'],
+                'SURPLUS_1L'=> ['isUserTable'=> false, 'name'=> '一市场结余业绩'],
+                'PV_2L'=> ['isUserTable'=> false, 'name'=> '二市场新增业绩'],
+                'SURPLUS_2L'=> ['isUserTable'=> false, 'name'=> '二市场结余业绩'],
+                'PV_3L'=> ['isUserTable'=> false, 'name'=> '三市场新增业绩'],
+                'SURPLUS_3L'=> ['isUserTable'=> false, 'name'=> '三市场结余业绩'],
+                'BONUS_BD'=> ['isUserTable'=> false, 'name'=> '服务奖'],
+                'BONUS_TG'=> ['isUserTable'=> false, 'name'=> '推广奖'],
+                'BONUS_XF'=> ['isUserTable'=> false, 'name'=> '消费奖'],
+                'BONUS_YJ'=> ['isUserTable'=> false, 'name'=> '业绩奖'],
+                'BONUS_GX'=> ['isUserTable'=> false, 'name'=> '共享奖'],
+                'BONUS_GL'=> ['isUserTable'=> false, 'name'=> '管理奖'],
+                'BONUS_QY'=> ['isUserTable'=> false, 'name'=> '团队奖'],
+                'BONUS_YC'=> ['isUserTable'=> false, 'name'=> '荣衔奖'],
+                'ORI_BONUS_STANDARD'=> ['isUserTable'=> false, 'name'=> '团队成长奖'],
+                'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
+            ];
+        }
+        return $this->filterTypes;
+    }
 }

+ 135 - 135
backendApi/modules/v1/models/lists/bonus/PeriodPerfList.php

@@ -1,136 +1,136 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use common\helpers\Cache;
-use common\models\PerfMonth;
-use common\models\PerfPeriod;
-use common\models\User as modelUser;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\DataListInterface;
-use common\libs\dataList\column\DateTime;
-use Yii;
-
-class PeriodPerfList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '期业绩列表';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $data = PerfPeriod::lists($this->condition, $this->params, [
-            'select'=>'PM.*, U.USER_NAME, U.REAL_NAME',
-            'from' => PerfPeriod::tableName().' AS PM',
-            'join' => [
-                ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PM.USER_ID=U.ID'],
-            ],
-            'orderBy' => 'PM.CREATED_AT DESC, PM.ID DESC',
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-            }
-        }
-        $this->listData = $data;
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '期数',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'USER_NAME' => [
-                    'header' => '会员编号',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'REAL_NAME' => [
-                    'header' => '会员姓名',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'PV_PCS' => [
-                    'header' => '个人业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_PCS'],
-                        ]))->result();
-                    },
-                ],
-                'PV_PSS' => [
-                    'header' => '新增团队业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_PSS'],
-                        ]))->result();
-                    },
-                ],
-                'CREATED_AT' => [
-                    'header' => '创建时间',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['CREATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [
-                'PERIOD_NUM'=> ['isUserTable'=> false, 'name'=> '期数'],
-                'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
-                'CREATED_AT'=> ['isUserTable'=> false, 'name'=> '创建时间', 'other'=> 'date'],
-            ];
-        }
-        return $this->filterTypes;
-    }
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use common\helpers\Cache;
+use common\models\PerfMonth;
+use common\models\PerfPeriod;
+use common\models\User as modelUser;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\DataListInterface;
+use common\libs\dataList\column\DateTime;
+use Yii;
+
+class PeriodPerfList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '期业绩列表';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $data = PerfPeriod::lists($this->condition, $this->params, [
+            'select'=>'PM.*, U.USER_NAME, U.REAL_NAME',
+            'from' => PerfPeriod::tableName().' AS PM',
+            'join' => [
+                ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PM.USER_ID=U.ID'],
+            ],
+            'orderBy' => 'PM.CREATED_AT DESC, PM.ID DESC',
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+            }
+        }
+        $this->listData = $data;
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '期数',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'USER_NAME' => [
+                    'header' => '会员编号',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'REAL_NAME' => [
+                    'header' => '会员姓名',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'PV_PCS' => [
+                    'header' => '个人业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_PCS'],
+                        ]))->result();
+                    },
+                ],
+                'PV_PSS' => [
+                    'header' => '新增团队业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_PSS'],
+                        ]))->result();
+                    },
+                ],
+                'CREATED_AT' => [
+                    'header' => '创建时间',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['CREATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [
+                'PERIOD_NUM'=> ['isUserTable'=> false, 'name'=> '期数'],
+                'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
+                'CREATED_AT'=> ['isUserTable'=> false, 'name'=> '创建时间', 'other'=> 'date'],
+            ];
+        }
+        return $this->filterTypes;
+    }
 }

+ 201 - 201
backendApi/modules/v1/models/lists/bonus/TraceDownBdList.php

@@ -1,202 +1,202 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusBD;
-use common\models\CalcBonusYC;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceDownBdList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '服务奖向下追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusBD::lists($this->condition, $this->params, [
-            'select' => 'CBB.*',
-            'from' => CalcBonusBD::tableName() . ' AS CBB',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CBB.USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CBB.CREATED_AT ASC, CBB.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '服务奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusBD;
+use common\models\CalcBonusYC;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceDownBdList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '服务奖向下追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusBD::lists($this->condition, $this->params, [
+            'select' => 'CBB.*',
+            'from' => CalcBonusBD::tableName() . ' AS CBB',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CBB.USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CBB.CREATED_AT ASC, CBB.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '服务奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 200 - 200
backendApi/modules/v1/models/lists/bonus/TraceDownGlList.php

@@ -1,201 +1,201 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusGL;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceDownGlList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '管理奖向下追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusGL::lists($this->condition, $this->params, [
-            'select' => 'CGL.*',
-            'from' => CalcBonusGL::tableName() . ' AS CGL',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CGL.USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CGL.CREATED_AT ASC, CGL.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '管理奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusGL;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceDownGlList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '管理奖向下追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusGL::lists($this->condition, $this->params, [
+            'select' => 'CGL.*',
+            'from' => CalcBonusGL::tableName() . ' AS CGL',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CGL.USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CGL.CREATED_AT ASC, CGL.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '管理奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 201 - 201
backendApi/modules/v1/models/lists/bonus/TraceDownGxList.php

@@ -1,202 +1,202 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusGX;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceDownGxList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '共享奖向下追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusGX::lists($this->condition, $this->params, [
-            'select' => 'CGX.*',
-            'from' => CalcBonusGX::tableName() . ' AS CGX',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CGX.USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CGX.CREATED_AT ASC, CGX.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfo($value['FROM_USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
-                unset($showFromInfo);
-
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '共享奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-//                'DEEP' => [
-//                    'header' => '紧缩代数',
-//                    'headerOther' => [
-//                        'width' => '80',
-//                    ],
-//                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusGX;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceDownGxList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '共享奖向下追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusGX::lists($this->condition, $this->params, [
+            'select' => 'CGX.*',
+            'from' => CalcBonusGX::tableName() . ' AS CGX',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CGX.USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CGX.CREATED_AT ASC, CGX.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfo($value['FROM_USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
+                unset($showFromInfo);
+
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '共享奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+//                'DEEP' => [
+//                    'header' => '紧缩代数',
+//                    'headerOther' => [
+//                        'width' => '80',
+//                    ],
+//                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 182 - 182
backendApi/modules/v1/models/lists/bonus/TraceDownQyList.php

@@ -1,183 +1,183 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\PerfOrder;
-use common\models\Period;
-use common\models\Region;
-use common\models\User;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceDownQyList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '团队奖向下追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-//        $periodNum = $this->others['periodNum'];
-        $this->listData = PerfOrder::lists($this->condition, $this->params, [
-            'select' => 'PO.PERIOD_NUM,PO.USER_ID,U.USER_NAME,U.REAL_NAME,PO.LAST_STATUS,PO.LAST_DEC_LV,PO.LAST_EMP_LV,PO.DEC_TYPE,PO.DEC_AMOUNT,PO.PV,PO.CALC_MONTH',
-            'from' => PerfOrder::tableName() . ' AS PO',
-            'join' => [
-                ['LEFT JOIN', User::tableName() . ' AS U', 'PO.USER_ID=U.ID'],
-            ],
-            'yearMonth' => $yearMonth,
-            'orderBy' => 'U.ID ASC',
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        $decConfig = Cache::getDecLevelConfig();
-        $empConfig = Cache::getEmpLevelConfig();
-        if ($this->listData['list']) {
-            foreach ($this->listData['list'] as $key => $value) {
-                $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = $decConfig[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = $empConfig[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $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 = [
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时会员状态',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-//                'LOCATION' => [
-//                    'header' => '市场',
-//                    'headerOther' => [
-//                        'width' => '100',
-//                    ],
-//                ],
-                'DEC_TYPE' => [
-                    'header' => '报单类型',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                    'value' => function($row) {
-                        $decType = [
-                            'ZC'=> '首购单',
-                            'YH'=> '优惠单',
-                            'ZG'=> '增购单',
-                            'LS'=> '零售单',
-                            'FX'=> '复销单',
-                        ];
-                        return $decType[$row['DEC_TYPE']];
-                    },
-                ],
-                'DEC_AMOUNT' => [
-                    'header' => '报单金额',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['DEC_AMOUNT'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                        'prop'=>'DEC_AMOUNT',
-                    ],
-                ],
-                'PV' => [
-                    'header' => '报单PV',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                        'prop'=>'PV',
-                    ],
-                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\PerfOrder;
+use common\models\Period;
+use common\models\Region;
+use common\models\User;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceDownQyList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '团队奖向下追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+//        $periodNum = $this->others['periodNum'];
+        $this->listData = PerfOrder::lists($this->condition, $this->params, [
+            'select' => 'PO.PERIOD_NUM,PO.USER_ID,U.USER_NAME,U.REAL_NAME,PO.LAST_STATUS,PO.LAST_DEC_LV,PO.LAST_EMP_LV,PO.DEC_TYPE,PO.DEC_AMOUNT,PO.PV,PO.CALC_MONTH',
+            'from' => PerfOrder::tableName() . ' AS PO',
+            'join' => [
+                ['LEFT JOIN', User::tableName() . ' AS U', 'PO.USER_ID=U.ID'],
+            ],
+            'yearMonth' => $yearMonth,
+            'orderBy' => 'U.ID ASC',
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        $decConfig = Cache::getDecLevelConfig();
+        $empConfig = Cache::getEmpLevelConfig();
+        if ($this->listData['list']) {
+            foreach ($this->listData['list'] as $key => $value) {
+                $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = $decConfig[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = $empConfig[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $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 = [
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时会员状态',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+//                'LOCATION' => [
+//                    'header' => '市场',
+//                    'headerOther' => [
+//                        'width' => '100',
+//                    ],
+//                ],
+                'DEC_TYPE' => [
+                    'header' => '报单类型',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                    'value' => function($row) {
+                        $decType = [
+                            'ZC'=> '首购单',
+                            'YH'=> '优惠单',
+                            'ZG'=> '增购单',
+                            'LS'=> '零售单',
+                            'FX'=> '复销单',
+                        ];
+                        return $decType[$row['DEC_TYPE']];
+                    },
+                ],
+                'DEC_AMOUNT' => [
+                    'header' => '报单金额',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['DEC_AMOUNT'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop'=>'DEC_AMOUNT',
+                    ],
+                ],
+                'PV' => [
+                    'header' => '报单PV',
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV'],
+                        ]))->result();
+                    },
+                    'headerOther' => [
+                        'width' => '150',
+                        'prop'=>'PV',
+                    ],
+                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
 }

+ 201 - 201
backendApi/modules/v1/models/lists/bonus/TraceDownTgList.php

@@ -1,202 +1,202 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusTG;
-use common\models\CalcBonusYC;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceDownTgList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '推广奖向下追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusTG::lists($this->condition, $this->params, [
-            'select' => 'CTG.*',
-            'from' => CalcBonusTG::tableName() . ' AS CTG',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CTG.USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CTG.CREATED_AT ASC, CTG.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '推广奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusTG;
+use common\models\CalcBonusYC;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceDownTgList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '推广奖向下追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusTG::lists($this->condition, $this->params, [
+            'select' => 'CTG.*',
+            'from' => CalcBonusTG::tableName() . ' AS CTG',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CTG.USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CTG.CREATED_AT ASC, CTG.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '推广奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 202 - 202
backendApi/modules/v1/models/lists/bonus/TraceDownXfList.php

@@ -1,203 +1,203 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusTG;
-use common\models\CalcBonusXF;
-use common\models\CalcBonusYC;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceDownXfList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '消费奖向下追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusTG::lists($this->condition, $this->params, [
-            'select' => 'CXF.*',
-            'from' => CalcBonusXF::tableName() . ' AS CXF',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CXF.USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CXF.CREATED_AT ASC, CXF.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '消费奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusTG;
+use common\models\CalcBonusXF;
+use common\models\CalcBonusYC;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceDownXfList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '消费奖向下追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusTG::lists($this->condition, $this->params, [
+            'select' => 'CXF.*',
+            'from' => CalcBonusXF::tableName() . ' AS CXF',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CXF.USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CXF.CREATED_AT ASC, CXF.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '消费奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 165 - 165
backendApi/modules/v1/models/lists/bonus/TraceDownYcList.php

@@ -1,166 +1,166 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusYC;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceDownYcList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '荣衔奖向下追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusYC::lists($this->condition, $this->params, [
-            'select' => 'CBY.*',
-            'from' => CalcBonusYC::tableName() . ' AS CBY',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CBY.USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CBY.DEEP ASC, CBY.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'BONUS_TYPE' => [
-                    'header' => '奖金类型',
-                    'value' => function($row) {
-                        return CalcBonusYC::BONUS_TYPE_NAME[$row['BONUS_TYPE']] ?? '未知';
-                    },
-                    'headerOther' => ['width' => '110'],
-                ],
-                'AMOUNT' => [
-                    'header' => '提供荣衔奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-//                'DEEP' => [
-//                    'header' => '紧缩代数',
-//                    'headerOther' => [
-//                        'width' => '80',
-//                    ],
-//                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusYC;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceDownYcList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '荣衔奖向下追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusYC::lists($this->condition, $this->params, [
+            'select' => 'CBY.*',
+            'from' => CalcBonusYC::tableName() . ' AS CBY',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CBY.USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CBY.DEEP ASC, CBY.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'BONUS_TYPE' => [
+                    'header' => '奖金类型',
+                    'value' => function($row) {
+                        return CalcBonusYC::BONUS_TYPE_NAME[$row['BONUS_TYPE']] ?? '未知';
+                    },
+                    'headerOther' => ['width' => '110'],
+                ],
+                'AMOUNT' => [
+                    'header' => '提供荣衔奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+//                'DEEP' => [
+//                    'header' => '紧缩代数',
+//                    'headerOther' => [
+//                        'width' => '80',
+//                    ],
+//                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 200 - 200
backendApi/modules/v1/models/lists/bonus/TraceDownYjList.php

@@ -1,201 +1,201 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusYJ;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceDownYjList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '业绩奖向下追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusYJ::lists($this->condition, $this->params, [
-            'select' => 'CYJ.*',
-            'from' => CalcBonusYJ::tableName() . ' AS CYJ',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CYJ.USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CYJ.CREATED_AT ASC, CYJ.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '业绩奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusYJ;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceDownYjList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '业绩奖向下追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusYJ::lists($this->condition, $this->params, [
+            'select' => 'CYJ.*',
+            'from' => CalcBonusYJ::tableName() . ' AS CYJ',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CYJ.USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CYJ.CREATED_AT ASC, CYJ.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['FROM_USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_FROM_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_FROM_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_FROM_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '业绩奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 206 - 206
backendApi/modules/v1/models/lists/bonus/TraceUpBdList.php

@@ -1,207 +1,207 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusBD;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceUpBdList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '服务奖向上追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusBD::lists($this->condition, $this->params, [
-            'select' => 'CBB.*',
-            'from' => CalcBonusBD::tableName() . ' AS CBB',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CBB.FROM_USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CBB.CREATED_AT ASC, CBB.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '提供服务奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-//                'DEEP' => [
-//                    'header' => '紧缩代数',
-//                    'headerOther' => [
-//                        'width' => '80',
-//                    ],
-//                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusBD;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceUpBdList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '服务奖向上追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusBD::lists($this->condition, $this->params, [
+            'select' => 'CBB.*',
+            'from' => CalcBonusBD::tableName() . ' AS CBB',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CBB.FROM_USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CBB.CREATED_AT ASC, CBB.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '提供服务奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+//                'DEEP' => [
+//                    'header' => '紧缩代数',
+//                    'headerOther' => [
+//                        'width' => '80',
+//                    ],
+//                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 206 - 206
backendApi/modules/v1/models/lists/bonus/TraceUpGlList.php

@@ -1,207 +1,207 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusGL;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceUpGlList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '管理奖向上追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusGL::lists($this->condition, $this->params, [
-            'select' => 'CGL.*',
-            'from' => CalcBonusGL::tableName() . ' AS CGL',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CGL.FROM_USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CGL.CREATED_AT ASC, CGL.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '提供管理奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-//                'DEEP' => [
-//                    'header' => '紧缩代数',
-//                    'headerOther' => [
-//                        'width' => '80',
-//                    ],
-//                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusGL;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceUpGlList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '管理奖向上追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusGL::lists($this->condition, $this->params, [
+            'select' => 'CGL.*',
+            'from' => CalcBonusGL::tableName() . ' AS CGL',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CGL.FROM_USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CGL.CREATED_AT ASC, CGL.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '提供管理奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+//                'DEEP' => [
+//                    'header' => '紧缩代数',
+//                    'headerOther' => [
+//                        'width' => '80',
+//                    ],
+//                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 206 - 206
backendApi/modules/v1/models/lists/bonus/TraceUpGxList.php

@@ -1,207 +1,207 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusGX;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceUpGxList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '共享奖向上追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusGX::lists($this->condition, $this->params, [
-            'select' => 'CGX.*',
-            'from' => CalcBonusGX::tableName() . ' AS CGX',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CGX.FROM_USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CGX.CREATED_AT ASC, CGX.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '共享奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-//                'DEEP' => [
-//                    'header' => '紧缩代数',
-//                    'headerOther' => [
-//                        'width' => '80',
-//                    ],
-//                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusGX;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceUpGxList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '共享奖向上追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusGX::lists($this->condition, $this->params, [
+            'select' => 'CGX.*',
+            'from' => CalcBonusGX::tableName() . ' AS CGX',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CGX.FROM_USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CGX.CREATED_AT ASC, CGX.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '共享奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+//                'DEEP' => [
+//                    'header' => '紧缩代数',
+//                    'headerOther' => [
+//                        'width' => '80',
+//                    ],
+//                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 306 - 306
backendApi/modules/v1/models/lists/bonus/TraceUpQyList.php

@@ -1,307 +1,307 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceUpQyList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '团队奖向上追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $userId = $this->others['userId'];
-        $periodNum = $this->others['periodNum'];
-        $data = UserNetwork::getAllParentFromPeriodWithPage($userId, $periodNum);
-        if (isset($data['list']) && $data['list']) {
-            $decTotal = CalcCache::nowPeriodPerf($userId, $periodNum);
-            foreach ($data['list'] as $key => $value) {
-                $perfPeriod = PerfPeriod::findOneAsArray('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$value['USER_ID'],':PERIOD_NUM'=>$periodNum]);
-                $data['list'][$key]['PERIOD_NUM'] = $perfPeriod['PERIOD_NUM'];
-                $data['list'][$key]['DEC_TOTAL'] = $decTotal['PV_PCS_ZC'] + $decTotal['PV_PCS_ZG'] +$decTotal['PV_LS_TOUCH'];
-                $data['list'][$key]['USER_NAME'] = Info::getUserNameByUserId($value['USER_ID']);
-                $data['list'][$key]['REAL_NAME'] = Info::getUserRealNameByUserId($value['USER_ID']);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$perfPeriod['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$perfPeriod['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$perfPeriod['LAST_STATUS']]['label'] ?? '';
-                $data['list'][$key]['PV_1L_TOUCH'] = $perfPeriod['PV_1L_TOUCH'];
-                $data['list'][$key]['PV_2L_TOUCH'] = $perfPeriod['PV_2L_TOUCH'];
-                $data['list'][$key]['PV_3L_TOUCH'] = $perfPeriod['PV_3L_TOUCH'];
-                $data['list'][$key]['PV_4L_TOUCH'] = $perfPeriod['PV_4L_TOUCH'];
-                $data['list'][$key]['PV_5L_TOUCH'] = $perfPeriod['PV_5L_TOUCH'];
-                $data['list'][$key]['SURPLUS_1L'] = $perfPeriod['SURPLUS_1L'];
-                $data['list'][$key]['SURPLUS_2L'] = $perfPeriod['SURPLUS_2L'];
-                $data['list'][$key]['SURPLUS_3L'] = $perfPeriod['SURPLUS_3L'];
-                $data['list'][$key]['SURPLUS_4L'] = $perfPeriod['SURPLUS_4L'];
-                $data['list'][$key]['SURPLUS_5L'] = $perfPeriod['SURPLUS_5L'];
-                $data['list'][$key]['CALC_MONTH'] = $perfPeriod['CALC_MONTH'];
-                //区域业绩
-                $pervSurplusPerf = CalcCache::surplusPerf($value['USER_ID'], $periodNum);
-                $data['list'][$key]['QY_1L'] = $data['list'][$key]['PV_1L_TOUCH'] + $pervSurplusPerf['SURPLUS_1L'];
-                $data['list'][$key]['QY_2L'] = $data['list'][$key]['PV_2L_TOUCH'] + $pervSurplusPerf['SURPLUS_2L'];
-                $data['list'][$key]['QY_3L'] = $data['list'][$key]['PV_3L_TOUCH'] + $pervSurplusPerf['SURPLUS_3L'];
-                $data['list'][$key]['QY_4L'] = $data['list'][$key]['PV_4L_TOUCH'] + $pervSurplusPerf['SURPLUS_4L'];
-                $data['list'][$key]['QY_5L'] = $data['list'][$key]['PV_5L_TOUCH'] + $pervSurplusPerf['SURPLUS_5L'];
-                unset($bonus,$bigLocation);
-            }
-        } else {
-            $data['list'] = [];
-        }
-        $this->listData = $data;
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                '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']
-                    ],
-                ],
-                'LOCATION' => [
-                    'header' => '市场',
-                    'headerOther' => [
-                        'width' => '100',
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'DEC_TOTAL' => [
-                    'header' => '报单总积分',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['DEC_TOTAL'],
-                        ]))->result();
-                    },
-                ],
-                'PV_1L_TOUCH' => [
-                    'header' => '一市场新增业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_1L_TOUCH'],
-                        ]))->result();
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
-                    ]
-                ],
-                'QY_1L' => [
-                    'header' => '一市场区域业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['QY_1L'],
-                        ]))->result();
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
-                    ]
-                ],
-                'SURPLUS_1L' => [
-                    'header' => '一市场结余业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['SURPLUS_1L'],
-                        ]))->result();
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
-                    ]
-                ],
-                'PV_2L_TOUCH' => [
-                    'header' => '二市场新增业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_2L_TOUCH'],
-                        ]))->result();
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
-                    ]
-                ],
-                'QY_2L' => [
-                    'header' => '二市场区域业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['QY_2L'],
-                        ]))->result();
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
-                    ]
-                ],
-                'SURPLUS_2L' => [
-                    'header' => '二市场结余业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['SURPLUS_2L'],
-                        ]))->result();
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
-                    ]
-                ],
-                'PV_3L_TOUCH' => [
-                    'header' => '三市场新增业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['PV_3L_TOUCH'],
-                        ]))->result();
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
-                    ]
-                ],
-                'QY_3L' => [
-                    'header' => '三市场区域业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['QY_3L'],
-                        ]))->result();
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
-                    ]
-                ],
-                'SURPLUS_3L' => [
-                    'header' => '三市场结余业绩',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['SURPLUS_3L'],
-                        ]))->result();
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
-                    ]
-                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
-    /**
-     * 校验大区
-     * @param $big
-     * @param $loc
-     * @param $num
-     * @return bool
-     */
-    private function _chkBig($big, $loc, $num){
-        return $loc == $num && $big != $loc;
-    }
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceUpQyList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '团队奖向上追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $userId = $this->others['userId'];
+        $periodNum = $this->others['periodNum'];
+        $data = UserNetwork::getAllParentFromPeriodWithPage($userId, $periodNum);
+        if (isset($data['list']) && $data['list']) {
+            $decTotal = CalcCache::nowPeriodPerf($userId, $periodNum);
+            foreach ($data['list'] as $key => $value) {
+                $perfPeriod = PerfPeriod::findOneAsArray('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>$value['USER_ID'],':PERIOD_NUM'=>$periodNum]);
+                $data['list'][$key]['PERIOD_NUM'] = $perfPeriod['PERIOD_NUM'];
+                $data['list'][$key]['DEC_TOTAL'] = $decTotal['PV_PCS_ZC'] + $decTotal['PV_PCS_ZG'] +$decTotal['PV_LS_TOUCH'];
+                $data['list'][$key]['USER_NAME'] = Info::getUserNameByUserId($value['USER_ID']);
+                $data['list'][$key]['REAL_NAME'] = Info::getUserRealNameByUserId($value['USER_ID']);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$perfPeriod['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$perfPeriod['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$perfPeriod['LAST_STATUS']]['label'] ?? '';
+                $data['list'][$key]['PV_1L_TOUCH'] = $perfPeriod['PV_1L_TOUCH'];
+                $data['list'][$key]['PV_2L_TOUCH'] = $perfPeriod['PV_2L_TOUCH'];
+                $data['list'][$key]['PV_3L_TOUCH'] = $perfPeriod['PV_3L_TOUCH'];
+                $data['list'][$key]['PV_4L_TOUCH'] = $perfPeriod['PV_4L_TOUCH'];
+                $data['list'][$key]['PV_5L_TOUCH'] = $perfPeriod['PV_5L_TOUCH'];
+                $data['list'][$key]['SURPLUS_1L'] = $perfPeriod['SURPLUS_1L'];
+                $data['list'][$key]['SURPLUS_2L'] = $perfPeriod['SURPLUS_2L'];
+                $data['list'][$key]['SURPLUS_3L'] = $perfPeriod['SURPLUS_3L'];
+                $data['list'][$key]['SURPLUS_4L'] = $perfPeriod['SURPLUS_4L'];
+                $data['list'][$key]['SURPLUS_5L'] = $perfPeriod['SURPLUS_5L'];
+                $data['list'][$key]['CALC_MONTH'] = $perfPeriod['CALC_MONTH'];
+                //区域业绩
+                $pervSurplusPerf = CalcCache::surplusPerf($value['USER_ID'], $periodNum);
+                $data['list'][$key]['QY_1L'] = $data['list'][$key]['PV_1L_TOUCH'] + $pervSurplusPerf['SURPLUS_1L'];
+                $data['list'][$key]['QY_2L'] = $data['list'][$key]['PV_2L_TOUCH'] + $pervSurplusPerf['SURPLUS_2L'];
+                $data['list'][$key]['QY_3L'] = $data['list'][$key]['PV_3L_TOUCH'] + $pervSurplusPerf['SURPLUS_3L'];
+                $data['list'][$key]['QY_4L'] = $data['list'][$key]['PV_4L_TOUCH'] + $pervSurplusPerf['SURPLUS_4L'];
+                $data['list'][$key]['QY_5L'] = $data['list'][$key]['PV_5L_TOUCH'] + $pervSurplusPerf['SURPLUS_5L'];
+                unset($bonus,$bigLocation);
+            }
+        } else {
+            $data['list'] = [];
+        }
+        $this->listData = $data;
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                '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']
+                    ],
+                ],
+                'LOCATION' => [
+                    'header' => '市场',
+                    'headerOther' => [
+                        'width' => '100',
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'DEC_TOTAL' => [
+                    'header' => '报单总积分',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['DEC_TOTAL'],
+                        ]))->result();
+                    },
+                ],
+                'PV_1L_TOUCH' => [
+                    'header' => '一市场新增业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_1L_TOUCH'],
+                        ]))->result();
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
+                    ]
+                ],
+                'QY_1L' => [
+                    'header' => '一市场区域业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['QY_1L'],
+                        ]))->result();
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
+                    ]
+                ],
+                'SURPLUS_1L' => [
+                    'header' => '一市场结余业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['SURPLUS_1L'],
+                        ]))->result();
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
+                    ]
+                ],
+                'PV_2L_TOUCH' => [
+                    'header' => '二市场新增业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_2L_TOUCH'],
+                        ]))->result();
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
+                    ]
+                ],
+                'QY_2L' => [
+                    'header' => '二市场区域业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['QY_2L'],
+                        ]))->result();
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
+                    ]
+                ],
+                'SURPLUS_2L' => [
+                    'header' => '二市场结余业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['SURPLUS_2L'],
+                        ]))->result();
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
+                    ]
+                ],
+                'PV_3L_TOUCH' => [
+                    'header' => '三市场新增业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['PV_3L_TOUCH'],
+                        ]))->result();
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
+                    ]
+                ],
+                'QY_3L' => [
+                    'header' => '三市场区域业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['QY_3L'],
+                        ]))->result();
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
+                    ]
+                ],
+                'SURPLUS_3L' => [
+                    'header' => '三市场结余业绩',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['SURPLUS_3L'],
+                        ]))->result();
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border'],
+                    ]
+                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
+    /**
+     * 校验大区
+     * @param $big
+     * @param $loc
+     * @param $num
+     * @return bool
+     */
+    private function _chkBig($big, $loc, $num){
+        return $loc == $num && $big != $loc;
+    }
 }

+ 206 - 206
backendApi/modules/v1/models/lists/bonus/TraceUpTgList.php

@@ -1,207 +1,207 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusTG;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceUpTgList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '推广奖向上追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusTG::lists($this->condition, $this->params, [
-            'select' => 'CTG.*',
-            'from' => CalcBonusTG::tableName() . ' AS CTG',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CTG.FROM_USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CTG.CREATED_AT ASC, CTG.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '提供推广奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-//                'DEEP' => [
-//                    'header' => '紧缩代数',
-//                    'headerOther' => [
-//                        'width' => '80',
-//                    ],
-//                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusTG;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceUpTgList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '推广奖向上追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusTG::lists($this->condition, $this->params, [
+            'select' => 'CTG.*',
+            'from' => CalcBonusTG::tableName() . ' AS CTG',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CTG.FROM_USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CTG.CREATED_AT ASC, CTG.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '提供推广奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+//                'DEEP' => [
+//                    'header' => '紧缩代数',
+//                    'headerOther' => [
+//                        'width' => '80',
+//                    ],
+//                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 206 - 206
backendApi/modules/v1/models/lists/bonus/TraceUpXfList.php

@@ -1,207 +1,207 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusTG;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceUpXfList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '消费奖向上追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusTG::lists($this->condition, $this->params, [
-            'select' => 'CXF.*',
-            'from' => CalcBonusTG::tableName() . ' AS CXF',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CXF.FROM_USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CXF.CREATED_AT ASC, CXF.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '提供消费奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-//                'DEEP' => [
-//                    'header' => '紧缩代数',
-//                    'headerOther' => [
-//                        'width' => '80',
-//                    ],
-//                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusTG;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceUpXfList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '消费奖向上追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusTG::lists($this->condition, $this->params, [
+            'select' => 'CXF.*',
+            'from' => CalcBonusTG::tableName() . ' AS CXF',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CXF.FROM_USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CXF.CREATED_AT ASC, CXF.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '提供消费奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+//                'DEEP' => [
+//                    'header' => '紧缩代数',
+//                    'headerOther' => [
+//                        'width' => '80',
+//                    ],
+//                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 206 - 206
backendApi/modules/v1/models/lists/bonus/TraceUpYcList.php

@@ -1,207 +1,207 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusYC;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceUpYcList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '荣衔奖向上追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusYC::lists($this->condition, $this->params, [
-            'select' => 'CBY.*',
-            'from' => CalcBonusYC::tableName() . ' AS CBY',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CBY.FROM_USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CBY.DEEP ASC, CBY.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '荣衔奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-//                'DEEP' => [
-//                    'header' => '紧缩代数',
-//                    'headerOther' => [
-//                        'width' => '80',
-//                    ],
-//                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusYC;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceUpYcList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '荣衔奖向上追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusYC::lists($this->condition, $this->params, [
+            'select' => 'CBY.*',
+            'from' => CalcBonusYC::tableName() . ' AS CBY',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CBY.FROM_USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CBY.DEEP ASC, CBY.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '荣衔奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+//                'DEEP' => [
+//                    'header' => '紧缩代数',
+//                    'headerOther' => [
+//                        'width' => '80',
+//                    ],
+//                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 206 - 206
backendApi/modules/v1/models/lists/bonus/TraceUpYjList.php

@@ -1,207 +1,207 @@
-<?php
-namespace backendApi\modules\v1\models\lists\bonus;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\bonus\CalcCache;
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\column\Price;
-use common\libs\dataList\column\YesNo;
-use common\libs\dataList\DataListInterface;
-use common\models\CalcBonus;
-use common\models\CalcBonusYJ;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Region;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use common\models\Withdraw;
-use Yii;
-
-class TraceUpYjList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '业绩奖向上追溯';
-    }
-
-    /**
-     * 列表筛选到的数据
-     * @throws \yii\base\Exception
-     */
-    public function dataHandle()
-    {
-        $yearMonth = $this->others['yearMonth'];
-        $data = CalcBonusYJ::lists($this->condition, $this->params, [
-            'select' => 'CYJ.*',
-            'from' => CalcBonusYJ::tableName() . ' AS CYJ',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CYJ.FROM_USER_ID=UI.USER_ID'],
-            ],
-            'orderBy' => 'CYJ.CREATED_AT ASC, CYJ.ID ASC',
-            'yearMonth' => $yearMonth,
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        if ($data['list']) {
-            foreach ($data['list'] as $key => $value) {
-                $userInfo = Info::baseInfoZh($value['USER_ID']);
-                $data['list'][$key] = array_merge($userInfo, $value);
-                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
-                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
-            }
-        }
-        $this->listData = $data;
-
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        if(!$this->columns){
-            $this->columns = [
-                'PERIOD_NUM' => [
-                    'header' => '结算期数',
-                ],
-                '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']
-                    ],
-                ],
-                'LAST_STATUS_NAME' => [
-                    'header' => '结算时状态',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                ],
-                'LAST_EMP_LV_NAME' => [
-                    'header' => '结算时会员聘级',
-                    'headerOther' => [
-                        'width' => '140',
-                    ],
-                ],
-                'AMOUNT' => [
-                    'header' => '提供业绩奖金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['AMOUNT'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'ORI_BONUS' => [
-                    'header' => '原金额',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['ORI_BONUS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'RECONSUME_POINTS' => [
-                    'header' => '复消积分',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['RECONSUME_POINTS'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-                'MANAGE_TAX' => [
-                    'header' => '管理费',
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['MANAGE_TAX'],
-                        ]))->result();
-                    },
-                    'valueOther' => function($row){
-                        return [
-                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                        ];
-                    },
-                ],
-//                'DEEP' => [
-//                    'header' => '紧缩代数',
-//                    'headerOther' => [
-//                        'width' => '80',
-//                    ],
-//                ],
-                'CALC_MONTH' => [
-                    'header' => '结算月',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [];
-        }
-        return $this->filterTypes;
-    }
-
+<?php
+namespace backendApi\modules\v1\models\lists\bonus;
+
+use backendApi\modules\v1\models\Admin;
+use common\helpers\bonus\CalcCache;
+use common\helpers\Cache;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\libs\dataList\column\Price;
+use common\libs\dataList\column\YesNo;
+use common\libs\dataList\DataListInterface;
+use common\models\CalcBonus;
+use common\models\CalcBonusYJ;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\Period;
+use common\models\Region;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use common\models\Withdraw;
+use Yii;
+
+class TraceUpYjList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '业绩奖向上追溯';
+    }
+
+    /**
+     * 列表筛选到的数据
+     * @throws \yii\base\Exception
+     */
+    public function dataHandle()
+    {
+        $yearMonth = $this->others['yearMonth'];
+        $data = CalcBonusYJ::lists($this->condition, $this->params, [
+            'select' => 'CYJ.*',
+            'from' => CalcBonusYJ::tableName() . ' AS CYJ',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CYJ.FROM_USER_ID=UI.USER_ID'],
+            ],
+            'orderBy' => 'CYJ.CREATED_AT ASC, CYJ.ID ASC',
+            'yearMonth' => $yearMonth,
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        if ($data['list']) {
+            foreach ($data['list'] as $key => $value) {
+                $userInfo = Info::baseInfoZh($value['USER_ID']);
+                $data['list'][$key] = array_merge($userInfo, $value);
+                $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
+                $data['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
+            }
+        }
+        $this->listData = $data;
+
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        if(!$this->columns){
+            $this->columns = [
+                'PERIOD_NUM' => [
+                    'header' => '结算期数',
+                ],
+                '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']
+                    ],
+                ],
+                'LAST_STATUS_NAME' => [
+                    'header' => '结算时状态',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                ],
+                'LAST_EMP_LV_NAME' => [
+                    'header' => '最新聘级',
+                    'headerOther' => [
+                        'width' => '140',
+                    ],
+                ],
+                'AMOUNT' => [
+                    'header' => '提供业绩奖金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['AMOUNT'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'ORI_BONUS' => [
+                    'header' => '原金额',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['ORI_BONUS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'RECONSUME_POINTS' => [
+                    'header' => '复消积分',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['RECONSUME_POINTS'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+                'MANAGE_TAX' => [
+                    'header' => '管理费',
+                    'headerOther' => [
+                        'width' => '150',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['MANAGE_TAX'],
+                        ]))->result();
+                    },
+                    'valueOther' => function($row){
+                        return [
+                            'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
+                        ];
+                    },
+                ],
+//                'DEEP' => [
+//                    'header' => '紧缩代数',
+//                    'headerOther' => [
+//                        'width' => '80',
+//                    ],
+//                ],
+                'CALC_MONTH' => [
+                    'header' => '结算月',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [];
+        }
+        return $this->filterTypes;
+    }
+
 }

+ 2 - 0
backendApi/modules/v1/models/lists/shop/DecOrderList.php

@@ -45,6 +45,7 @@ class DecOrderList extends \common\libs\dataList\DataList implements DataListInt
      */
     public function getColumn(){
         $decLevelConfig = Cache::getDecLevelConfig();
+
         if(!$this->columns){
             $this->columns = [
                 'ID' => null,
@@ -82,6 +83,7 @@ class DecOrderList extends \common\libs\dataList\DataList implements DataListInt
                         'width' => '110',
                     ],
                     'value' => function($row) use($decLevelConfig) {
+
                         return $decLevelConfig[$row['DEC_LV']]['LEVEL_NAME'];
                     },
                     'valueOther' => [

+ 623 - 623
backendApi/modules/v1/models/lists/user/IndexList.php

@@ -1,624 +1,624 @@
-<?php
-namespace backendApi\modules\v1\models\lists\user;
-
-use common\helpers\Cache;
-use common\helpers\http\BackendToFrontendApi;
-use common\helpers\user\Info;
-use common\libs\dataList\DataListInterface;
-use common\models\DecRole;
-use common\models\OpenBank;
-use common\models\Region;
-use common\models\User;
-use common\models\UserInfo;
-use common\libs\dataList\column\DateTime;
-use common\libs\dataList\column\YesNo;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use Yii;
-
-class IndexList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return '会员列表';
-    }
-
-    /**
-     * 列表筛选到的数据
-     */
-    public function dataHandle()
-    {
-        $this->condition .= ' AND UN.USER_ID=UI.USER_ID AND UN.PARENT_UID=UI.CON_UID';
-        $this->listData = User::lists($this->condition, $this->params, [
-            'select' => 'U.*,
-                UI.USER_ID, UI.ZC_PV, UI.CON_UID, UI.REC_UID, UI.CON_NUM, UI.REC_NUM, UI.NETWORK_DEEP, 
-                UI.RELATION_DEEP, UI.SYSTEM_ID, UI.IS_GROUP_LEADER, UI.IS_SYSTEM_LEADER, UI.IS_TEAM, UI.IS_BIND, 
-                UI.IS_TEAM_MAIN, UI.IS_BIND_MAIN, UI.IS_AUTO_WITHDRAW, UI.CLOSE_LOGIN, UI.REG_TYPE, UI.SHOULD_REG_TYPE, 
-                UI.REG_NAME, UI.CREDIT_CODE, UI.PREMISES, UI.LEGAL_PERSON, UI.REG_EXPIRES, UI.STORE_TYPE, UI.INVOICE_BALANCE, 
-                UI.HIGHEST_EMP_LV, UI.CLOSE_LOGIN_AT, UI.PULLED_AT, 
-                UI.GROUP_LEADER_AT, UI.ALLOW_TRANSFER, UI.ALLOW_RECONSUME_SMS, UI.ALLOW_RECONSUME_SMS_TO, 
-                UI.HIGHEST_EMP_LV_PERIOD, UI.TRANSFER_PROP, UI.LOGIN_NUMS, UI.FAIL_NUMS, UI.LAST_LOGIN_IP, 
-                UI.LAST_LOGIN_AT, UI.SHOW_EMP_LV,UN.RELATIVE_LOCATION,
-                CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME,
-                RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,
-                DU.USER_NAME DEC_USER_NAME
-                ',
-            'orderBy' => 'UI.CREATED_AT DESC, UI.ID DESC',
-            'from' => User::tableName() . ' AS U',
-            'join' => [
-                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'UI.USER_ID=U.ID'],
-                ['LEFT JOIN', UserNetwork::tableName() . ' AS UN', 'UI.USER_ID=UN.USER_ID'],
-                ['LEFT JOIN', User::tableName() . ' AS CU', 'UI.CON_UID=CU.ID'],
-                ['LEFT JOIN', User::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
-                ['LEFT JOIN', User::tableName() . ' AS DU', 'U.DEC_ID=DU.ID'],
-            ],
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        foreach ($this->listData['list'] as $key => $value) {
-            // 后台访问前台的请求参数
-            if (!$this->isExport && Yii::$app->user->validateAdminAction('user', 'login-to-frontend')) {
-                $urlParams = BackendToFrontendApi::paramsFormat(['id' => $value['USER_ID']]);
-                $urlParamStr = '';
-                foreach ($urlParams as $pKey => $pValue) {
-                    $urlParamStr .= $pKey . '=' . $pValue . '&';
-                }
-                $urlParamStr = substr($urlParamStr, 0, -1);
-                $this->listData['list'][$key]['BTF_URL'] = $urlParamStr;
-            } else {
-                $this->listData['list'][$key]['BTF_URL'] = null;
-            }
-        }
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        $decLevelConfig = Cache::getDecLevelConfig();
-        $empLevelConfig = Cache::getEmpLevelConfig();
-        $decRoleConfig = DecRole::getAllData();
-        $systemConfig = UserSystem::getAllSystems();
-        $openBankConfig = OpenBank::getAllOpenBank();
-        $regionConfig = Cache::getRegionConfig();
-        if(!$this->columns){
-            $this->columns = [
-                'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
-                'BTF_URL' => null,
-                'USER_NAME' => [
-                    'header' => '会员编号',
-                    'headerOther' => ['width' => '150'],
-                ],
-                'REAL_NAME' => [
-                    'header' => '会员姓名',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
-                    ],
-                ],
-                'LOGIN_STATUS_NAME' => [
-                    'header' => '登录状态',
-                    'value' => function($row) {
-                        return $row['ALLOW_LOGIN'] == 1 ? '允许登录' : '禁止登录';
-                    },
-                    'headerOther' => ['width' => '110'],
-                ],
-                'STATUS' => [
-                    'header' => '状态',
-                    'value' => function($row) {
-                        return $row['STATUS'] == 1 ? '激活' : '锁定';
-                    },
-                    'headerOther' => ['width' => '110'],
-                ],
-                'ALLOW_LOGIN' => ['header' => '筛选允许登录','hidden'=>true],
-                'CREATED_AT' => [
-                    'header' => '加入日期',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['CREATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-                'PERIOD_AT' => '加入期数',
-                'DEC_LV_NAME' => [
-                    'header' => '实时会员级别',
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                    'value' => function($row) use($decLevelConfig) {
-                        return $decLevelConfig[$row['DEC_LV']]['LEVEL_NAME'];
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
-                    ],
-                ],
-                'DEC_LV_UPDATED_AT' => [
-                    'header' => '实时调整日期',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['DEC_LV_UPDATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-                'LAST_DEC_LV_NAME' => [
-                    'header' => '结算时会员级别',
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                    'value' => function($row) use($decLevelConfig) {
-                        if (!$row['LAST_DEC_LV']) {
-                            return $decLevelConfig[$row['DEC_LV']]['LEVEL_NAME'];
-                        } else {
-                            return $decLevelConfig[$row['LAST_DEC_LV']]['LEVEL_NAME'];
-                        }
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
-                    ],
-                ],
-                'EMP_LV_NAME' => [
-                    'header' => '实时聘级',
-                    'headerOther' => [
-                        'width' => '130',
-                    ],
-                    'value' => function($row) use($empLevelConfig) {
-                        return isset($empLevelConfig[$row['EMP_LV']])?$empLevelConfig[$row['EMP_LV']]['LEVEL_NAME']:'';
-                    },
-                    'valueOther' => [
-                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
-                    ],
-                ],
-//                'HIGHEST_EMP_LV_NAME' => [
-//                    'header' => '历史最高聘级',
-//                    'value' => function($row) use($empLevelConfig) {
-//                        if (!$row['HIGHEST_EMP_LV']){
-//                            return $empLevelConfig[$row['EMP_LV']]['LEVEL_NAME'];
-//                        } else {
-//                            return $empLevelConfig[$row['HIGHEST_EMP_LV']]['LEVEL_NAME'];
-//                        }
-//                    },
-//                    'headerOther' => ['width' => '130'],
-//                ],
-//                'HIGHEST_EMP_LV_PERIOD' => [
-//                    'header' => '首次达到历史最高聘级的期数',
-//                    'headerOther' => ['width' => '210'],
-//                ],
-                'REC_USER_NAME' => [
-                    'header' => '推荐编号',
-                    'headerOther' => ['width' => '150'],
-                ],
-                'REC_REAL_NAME' => [
-                    'header' => '推荐姓名',
-                    'headerOther' => ['width' => '100'],
-                ],
-                'CON_USER_NAME' => [
-                    'header' => '安置编号',
-                    'headerOther' => ['width' => '150'],
-                ],
-                'CON_REAL_NAME' => [
-                    'header' => '安置姓名',
-                    'headerOther' => ['width' => '100'],
-                ],
-                'RELATIVE_LOCATION' => [
-                    'header' => '安置区域',
-                    'headerOther' => ['width' => '100'],
-                ],
-                'ID_TYPE' => [
-                    'header' => '证件类型',
-                    'value' => function($row) {
-                        return $row['ID_TYPE'] == 0 ? '身份证' : '';
-                    },
-                ],
-                'ID_CARD' => [
-                    'header' => '证件号码',
-                    'value' => function($row) {
-                        return "\t".$row['ID_CARD'];
-                    },
-                    'headerOther' => ['width' => '180'],
-                ],
-//                'SPOUSE_NAME' => [
-//                    'header' => '配偶姓名',
-//                    'headerOther' => ['width' => '100'],
-//                ],
-//                'SPOUSE_IDCARD' => [
-//                    'header' => '配偶身份证号',
-//                    'value' => function($row) {
-//                        return "\t".$row['SPOUSE_IDCARD'];
-//                    },
-//                    'headerOther' => ['width' => '180'],
-//                ],
-//                'SYSTEM_NAME' => [
-//                    'header' => '体系名称',
-//                    'headerOther' => ['width' => '150'],
-//                    'value' => function($row) use($systemConfig) {
-//                        return $systemConfig[$row['SYSTEM_ID']]['SYSTEM_NAME'] ?? '';
-//                    },
-//                ],
-                'MOBILE' => [
-                    'header' => '手机号码',
-                    'value' => function($row) {
-                        return "\t".$row['MOBILE'];
-                    },
-                    'headerOther' => ['width' => '120'],
-                ],
-                'TEL' => [
-                    'header' => '备用手机号码',
-                    'value' => function($row) {
-                        return "\t".$row['TEL'];
-                    },
-                    'headerOther' => ['width' => '120'],
-                ],
-                'DEC_USER_NAME' => [
-                    'header' => '所属报单中心编号',
-                    'headerOther' => ['width' => '150'],
-                ],
-                'IS_DEC' => [
-                    'header' => '是否报单中心',
-                    'value' => function($row) {
-                        return (new YesNo([
-                            'value' => $row['IS_DEC'],
-                        ]))->result();
-                    },
-                    'headerOther' => function($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function($row) {
-                        return [
-                            'tag'=>['type'=>(isset($row['IS_DEC']) && $row['IS_DEC'] )? 'success' : 'info', 'size' => 'small']
-                        ];
-                    },
-                ],
-                'IS_STUDIO' => [
-                    'header' => '是否工作室',
-                    'value' => function($row) {
-                        return (new YesNo([
-                            'value' => $row['IS_STUDIO'],
-                        ]))->result();
-                    },
-                    'headerOther' => function($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function($row) {
-                        return [
-                            'tag'=>['type'=>(isset($row['IS_STUDIO']) && $row['IS_STUDIO'] )? 'success' : 'info', 'size' => 'small']
-                        ];
-                    },
-                ],
-                'IS_ATLAS' => [
-                    'header' => '是否显示图谱',
-                    'value' => function($row) {
-                        return (new YesNo([
-                            'value' => $row['IS_ATLAS'],
-                        ]))->result();
-                    },
-                    'headerOther' => function($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function($row) {
-                        return [
-                            'tag'=>['type'=>(isset($row['IS_ATLAS']) && $row['IS_ATLAS'] )? 'success' : 'info', 'size' => 'small']
-                        ];
-                    },
-                ],
-                'IS_RECHARGE' => [
-                    'header' => '是否显示充值',
-                    'value' => function($row) {
-                        return (new YesNo([
-                            'value' => $row['IS_RECHARGE'],
-                        ]))->result();
-                    },
-                    'headerOther' => function($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function($row) {
-                        return [
-                            'tag'=>['type'=>(isset($row['IS_RECHARGE']) && $row['IS_RECHARGE'] )? 'success' : 'info', 'size' => 'small']
-                        ];
-                    },
-                ],
-                'DEC_ROLE_NAME' => [
-                    'header' => '报单中心级别',
-                    'headerOther' => ['width' => '110'],
-                    'value' => function($row) use($decRoleConfig) {
-                        return $decRoleConfig[$row['DEC_ROLE_ID']]['ROLE_NAME'] ?? '';
-                    },
-                ],
-                'OPEN_BANK_NAME' => [
-                    'header' => '开户银行',
-                    'headerOther' => ['width' => '110'],
-                    'value' => function($row) use($openBankConfig) {
-                        return $openBankConfig[$row['OPEN_BANK']]['BANK_NAME'] ?? '';
-                    },
-                ],
-                'BANK_AREA' => [
-                    'header' => '银行地区',
-                    'value' => function($row) use($regionConfig) {
-                        $province = $regionConfig[$row['BANK_PROVINCE']]['REGION_NAME'] ?? '';
-                        $city = $regionConfig[$row['BANK_CITY']]['REGION_NAME'] ?? '';
-                        $county = $regionConfig[$row['BANK_COUNTY']]['REGION_NAME'] ?? '';
-                        return $province.$city.$county;
-                    },
-                    'showValue' => function($row) use($regionConfig) {
-                        $province = $regionConfig[$row['BANK_PROVINCE']]['REGION_NAME'] ?? '';
-                        $city = $regionConfig[$row['BANK_CITY']]['REGION_NAME'] ?? '';
-                        $county = $regionConfig[$row['BANK_COUNTY']]['REGION_NAME'] ?? '';
-                        return '<div class="addr" title='.$province.$city.$county.'>'.$province.$city.$county.'</div>';
-                    },
-                    'headerOther' => [
-                        'width' => '200'
-                    ],
-                ],
-                'BANK_ADDRESS' => [
-                    'header' => '开户地址',
-                    'headerOther' => ['width' => '250'],
-                    'showValue' => function($row) {
-                        return '<div class="addr" title='.$row['BANK_ADDRESS'].'>'.$row['BANK_ADDRESS'].'</div>';
-                    },
-                ],
-                'BANK_NO' => [
-                    'header' => '银行帐号',
-                    'headerOther' => ['width' => '220'],
-                    'value' => function($row) {
-                        return "\t".$row['BANK_NO'];
-                    },
-                ],
-                'SEX' => '性别',
-                'NATION_NAME' => [
-                    'header' => '民族',
-                    'value' => function($row) {
-                        return \Yii::$app->params['nation'][$row['NATION']]['name'] ?? '';
-                    },
-                ],
-                'AREA' => [
-                    'header' => '常用地址',
-                    'value' => function($row) use($regionConfig) {
-                        $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
-                        $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
-                        $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
-                        return $province.$city.$county;
-                    },
-                    'showValue' => function($row) {
-                        $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
-                        $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
-                        $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
-                        return '<div class="addr" title='.$province.$city.$county.'>'.$province.$city.$county.'</div>';
-                    },
-                    'headerOther' => [
-                        'width' => '200'
-                    ],
-                ],
-                'ADDRESS' => [
-                    'header' => '身份证地址',
-                    'value' => function($row) {
-                        return $row['ADDRESS'];
-                    },
-                    'showValue' => function($row) {
-                        return '<div class="addr" title='.$row['ADDRESS'].'>'.$row['ADDRESS'].'</div>';
-                    },
-                    'headerOther' => ['width' => '250'],
-                ],
-//                'IS_AUTO_WITHDRAW' => [
-//                    'header' => '提现方式',
-//                    'value' => function($row) {
-//                        return $row['IS_AUTO_WITHDRAW']==0?'手动':'自动';
-//                    },
-//                ],
-                'VERIFIED' => [
-                    'header' => '实名认证',
-                    'value' => function($row) {
-                        return (new YesNo([
-                            'value' => $row['VERIFIED'],
-                        ]))->result();
-                    },
-                    'headerOther' => function($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function($row) {
-                        return [
-                            'tag'=>['type'=>(isset($row['VERIFIED']) && $row['VERIFIED']) ? 'success' : 'info', 'size' => 'small']
-                        ];
-                    },
-                ],
-                'VERIFIED_AT' => [
-                    'header' => '实名认证日期',
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['VERIFIED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-//                'IS_DIRECT_SELLER' => [
-//                    'header' => '是否直销员',
-//                    'value' => function($row) {
-//                        return (new YesNo([
-//                            'value' => $row['IS_DIRECT_SELLER'],
-//                        ]))->result();
-//                    },
-//                    'valueOther' => function($row) {
-//                        return [
-//                            'tag'=>['type'=>(isset($row['IS_DIRECT_SELLER']) && $row['IS_DIRECT_SELLER']) ? 'success' : 'info', 'size' => 'small']
-//                        ];
-//                    },
-//                    'headerOther' => function($row) {
-//                        return [
-//                            'width' => '120',
-//                        ];
-//                    },
-//                ],
-//                'IS_SYSTEM_LEADER' => [
-//                    'header' => '是否体系领导人',
-//                    'value' => function($row) {
-//                        return (new YesNo([
-//                            'value' => $row['IS_SYSTEM_LEADER'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => function($row) {
-//                        return [
-//                            'width' => '120',
-//                        ];
-//                    },
-//                    'valueOther' => function($row) {
-//                        return [
-//                            'tag'=>['type'=>(isset($row['IS_SYSTEM_LEADER']) && $row['IS_SYSTEM_LEADER']) ? 'success' : 'info', 'size' => 'small']
-//                        ];
-//                    },
-//                ],
-//                'IS_GROUP_LEADER' => [
-//                    'header' => '是否团队领导人',
-//                    'value' => function($row) {
-//                        return (new YesNo([
-//                            'value' => $row['IS_GROUP_LEADER'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => function($row) {
-//                        return [
-//                            'width' => '120',
-//                        ];
-//                    },
-//                    'valueOther' => function($row) {
-//                        return [
-//                            'tag'=>['type'=>(isset($row['IS_GROUP_LEADER']) && $row['IS_GROUP_LEADER'] ) ? 'success' : 'info', 'size' => 'small']
-//                        ];
-//                    },
-//                ],
-                'BIRTHDAY' => [
-                    'header' => '生日',
-                    'value' => function($row) {
-                        return date('Y-m-d', strtotime($row['BIRTHDAY']));
-                    },
-                    'headerOther' => ['width' => '110'],
-                ],
-                'ALLOW_TRANSFER' => [
-                    'header' => '转账功能开启',
-                    'value' => function($row) {
-                        return $row['ALLOW_TRANSFER'] == 1 ? '开启' : '关闭';
-                    },
-                    'headerOther' => function($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function($row) {
-                        return [
-                            'tag'=>['type'=>(isset($row['ALLOW_TRANSFER']) && $row['ALLOW_TRANSFER']) ? 'success' : 'info', 'size' => 'small']
-                        ];
-                    },
-                ],
-                'DEC_CLOSED' => [
-                    'header' => '是否关闭报单',
-                    'value' => function($row) {
-                        return (new YesNo([
-                            'value' => $row['DEC_CLOSED'],
-                        ]))->result();
-                    },
-                    'headerOther' => function($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function($row) {
-                        return [
-                            'tag'=>['type'=>(isset($row['DEC_CLOSED']) && $row['DEC_CLOSED']) ? 'info' : 'success', 'size' => 'small']
-                        ];
-                    },
-                ],
-                'IS_MODIFY_PASSWORD' => [
-                    'header' => '密码修改状态',
-                    'value' => function($row) {
-                        return $row['IS_MODIFY_PASSWORD'] == 1 ? '开启' : '关闭';
-                    },
-                    'headerOther' => function($row) {
-                        return [
-                            'width' => '120',
-                        ];
-                    },
-                    'valueOther' => function($row) {
-                        return [
-                            'tag'=>['type'=>(isset($row['IS_MODIFY_PASSWORD']) && $row['IS_MODIFY_PASSWORD'] )? 'success' : 'info', 'size' => 'small']
-                        ];
-                    },
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [
-                'USER_NAME'=> ['name'=> '会员编号'],
-                'REAL_NAME'=> ['name'=> '会员姓名'],
-//                'ALLOW_LOGIN'=> ['name'=> '允许登录', 'other'=> 'yesOrNo'],
-                'CREATED_AT'=> ['name'=> '加入日期', 'other'=> 'date'],
-                'PERIOD_AT'=> ['name'=> '加入期数'],
-                'DEC_LV_NAME'=> ['name'=> '实时会员级别', 'other'=> 'decLevel'],
-//                'DEC_LV_UPDATED_AT'=> ['name'=> '实时调整日期', 'other'=> 'date'],
-//                'LAST_DEC_LV_NAME'=> ['name'=> '结算时会员级别', 'other'=> 'decLevel'],
-                'EMP_LV_NAME'=> ['name'=> '实时聘级', 'other'=> 'empLevel'],
-//                'HIGHEST_EMP_LV_NAME'=> ['name'=> '历史最高聘级', 'other'=> 'empLevel'],
-//                'HIGHEST_EMP_LV_PERIOD'=> ['name'=> '首次达到历史最高聘级的期数'],
-                'REC_USER_NAME'=> ['name'=> '推荐编号'],
-                'CON_USER_NAME'=> ['name'=> '安置编号'],
-                //'ID_TYPE'=> ['name'=> '证件类型', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> '身份证']]],
-                'ID_CARD'=> ['name'=> '证件号码'],
-//                'SPOUSE_NAME'=> ['name'=> '配偶姓名'],
-//                'SPOUSE_IDCARD'=> ['name'=> '配偶身份证号'],
-//                'SYSTEM_NAME'=> ['name'=> '体系名称', 'other'=> 'systems'],
-//                'SUB_COM_NAME'=> ['name'=> '所属分公司', 'other'=> 'subCompany'],
-                'MOBILE'=> ['name'=> '手机号码'],
-//                'TEL'=> ['name'=> '备用手机号码'],
-                'DEC_USER_NAME'=> ['name'=> '所属报单中心编号'],
-                'IS_DEC'=> ['name'=> '是否报单中心', 'other'=> 'yesOrNo'],
-                'IS_STUDIO'=> ['name'=> '是否工作室', 'other'=> 'yesOrNo'],
-                'DEC_ROLE_NAME'=> ['name'=> '报单中心级别', 'other'=> 'decRole'],
-//                'OPEN_BANK_NAME'=> ['name'=> '开户银行', 'other'=> 'banks'],
-//                'BANK_AREA'=> ['name'=> '银行地区', 'other'=> 'area'],
-//                'BANK_ADDRESS'=> ['name'=> '开户地址'],
-//                'BANK_NO'=> ['name'=> '银行账号'],
-//                'SEX'=> ['name'=> '性别', 'other'=> 'sex'],
-//                'NATION_NAME'=> ['name'=> '民族', 'other'=> 'nations'],
-                'AREA'=> ['name'=> '常用地址', 'other'=> 'area'],
-                'STATUS'=> ['name'=> '激活状态', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> '锁定'],['id'=> 1, 'name'=> '激活']]],
-//                'ADDRESS'=> ['name'=> '身份证地址'],
-//                'IS_AUTO_WITHDRAW'=> [
-//                    'isUserTable'=> false,
-//                    'name'=> '提现方式',
-//                    'other'=> 'select',
-//                    'selectData'=> [['id'=> 0, 'name'=> '手动'], ['id'=> 1, 'name'=> '自动']]
-//                ],
-//                'VERIFIED'=> ['name'=> '实名认证', 'other'=> 'yesOrNo'],
-//                'VERIFIED_AT'=> ['name'=> '实名认证日期', 'other'=> 'date'],
-//                'IS_DIRECT_SELLER'=> ['name'=> '是否直销员', 'other'=> 'yesOrNo'],
-//                'IS_SYSTEM_LEADER'=> ['name'=> '是否体系领导人', 'other'=> 'yesOrNo'],
-//                'IS_GROUP_LEADER'=> ['name'=> '是否团队领导人', 'other'=> 'yesOrNo'],
-//                'ALLOW_TRANSFER'=> ['name'=> '转账功能开启', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> '关闭'],['id'=> 1, 'name'=> '开启']]],
-//                'DEC_CLOSED'=> ['name'=> '是否关闭报单', 'other'=> 'yesOrNo'],
-            ];
-        }
-        return $this->filterTypes;
-    }
+<?php
+namespace backendApi\modules\v1\models\lists\user;
+
+use common\helpers\Cache;
+use common\helpers\http\BackendToFrontendApi;
+use common\helpers\user\Info;
+use common\libs\dataList\DataListInterface;
+use common\models\DecRole;
+use common\models\OpenBank;
+use common\models\Region;
+use common\models\User;
+use common\models\UserInfo;
+use common\libs\dataList\column\DateTime;
+use common\libs\dataList\column\YesNo;
+use common\models\UserNetwork;
+use common\models\UserSystem;
+use Yii;
+
+class IndexList extends \common\libs\dataList\DataList implements DataListInterface
+{
+    /**
+     * 列表名称
+     * @return string
+     */
+    public function getListName(){
+        return '会员列表';
+    }
+
+    /**
+     * 列表筛选到的数据
+     */
+    public function dataHandle()
+    {
+        $this->condition .= ' AND UN.USER_ID=UI.USER_ID AND UN.PARENT_UID=UI.CON_UID';
+        $this->listData = User::lists($this->condition, $this->params, [
+            'select' => 'U.*,
+                UI.USER_ID, UI.ZC_PV, UI.CON_UID, UI.REC_UID, UI.CON_NUM, UI.REC_NUM, UI.NETWORK_DEEP, 
+                UI.RELATION_DEEP, UI.SYSTEM_ID, UI.IS_GROUP_LEADER, UI.IS_SYSTEM_LEADER, UI.IS_TEAM, UI.IS_BIND, 
+                UI.IS_TEAM_MAIN, UI.IS_BIND_MAIN, UI.IS_AUTO_WITHDRAW, UI.CLOSE_LOGIN, UI.REG_TYPE, UI.SHOULD_REG_TYPE, 
+                UI.REG_NAME, UI.CREDIT_CODE, UI.PREMISES, UI.LEGAL_PERSON, UI.REG_EXPIRES, UI.STORE_TYPE, UI.INVOICE_BALANCE, 
+                UI.HIGHEST_EMP_LV, UI.CLOSE_LOGIN_AT, UI.PULLED_AT, 
+                UI.GROUP_LEADER_AT, UI.ALLOW_TRANSFER, UI.ALLOW_RECONSUME_SMS, UI.ALLOW_RECONSUME_SMS_TO, 
+                UI.HIGHEST_EMP_LV_PERIOD, UI.TRANSFER_PROP, UI.LOGIN_NUMS, UI.FAIL_NUMS, UI.LAST_LOGIN_IP, 
+                UI.LAST_LOGIN_AT, UI.SHOW_EMP_LV,UN.RELATIVE_LOCATION,
+                CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME,
+                RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,
+                DU.USER_NAME DEC_USER_NAME
+                ',
+            'orderBy' => 'UI.CREATED_AT DESC, UI.ID DESC',
+            'from' => User::tableName() . ' AS U',
+            'join' => [
+                ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'UI.USER_ID=U.ID'],
+                ['LEFT JOIN', UserNetwork::tableName() . ' AS UN', 'UI.USER_ID=UN.USER_ID'],
+                ['LEFT JOIN', User::tableName() . ' AS CU', 'UI.CON_UID=CU.ID'],
+                ['LEFT JOIN', User::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
+                ['LEFT JOIN', User::tableName() . ' AS DU', 'U.DEC_ID=DU.ID'],
+            ],
+            'page' => $this->page,
+            'pageSize' => $this->pageSize,
+        ]);
+        foreach ($this->listData['list'] as $key => $value) {
+            // 后台访问前台的请求参数
+            if (!$this->isExport && Yii::$app->user->validateAdminAction('user', 'login-to-frontend')) {
+                $urlParams = BackendToFrontendApi::paramsFormat(['id' => $value['USER_ID']]);
+                $urlParamStr = '';
+                foreach ($urlParams as $pKey => $pValue) {
+                    $urlParamStr .= $pKey . '=' . $pValue . '&';
+                }
+                $urlParamStr = substr($urlParamStr, 0, -1);
+                $this->listData['list'][$key]['BTF_URL'] = $urlParamStr;
+            } else {
+                $this->listData['list'][$key]['BTF_URL'] = null;
+            }
+        }
+    }
+
+    /**
+     * 要展示和导出的所有字段
+     * @return array
+     */
+    public function getColumn(){
+        $decLevelConfig = Cache::getDecLevelConfig();
+        $empLevelConfig = Cache::getEmpLevelConfig();
+        $decRoleConfig = DecRole::getAllData();
+        $systemConfig = UserSystem::getAllSystems();
+        $openBankConfig = OpenBank::getAllOpenBank();
+        $regionConfig = Cache::getRegionConfig();
+        if(!$this->columns){
+            $this->columns = [
+                'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
+                'BTF_URL' => null,
+                'USER_NAME' => [
+                    'header' => '会员编号',
+                    'headerOther' => ['width' => '150'],
+                ],
+                'REAL_NAME' => [
+                    'header' => '会员姓名',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                    'valueOther' => [
+                        'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
+                    ],
+                ],
+                'LOGIN_STATUS_NAME' => [
+                    'header' => '登录状态',
+                    'value' => function($row) {
+                        return $row['ALLOW_LOGIN'] == 1 ? '允许登录' : '禁止登录';
+                    },
+                    'headerOther' => ['width' => '110'],
+                ],
+                'STATUS' => [
+                    'header' => '状态',
+                    'value' => function($row) {
+                        return $row['STATUS'] == 1 ? '激活' : '锁定';
+                    },
+                    'headerOther' => ['width' => '110'],
+                ],
+                'ALLOW_LOGIN' => ['header' => '筛选允许登录','hidden'=>true],
+                'CREATED_AT' => [
+                    'header' => '加入日期',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['CREATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+                'PERIOD_AT' => '加入期数',
+                'DEC_LV_NAME' => [
+                    'header' => '实时会员级别',
+                    'headerOther' => [
+                        'width' => '110',
+                    ],
+                    'value' => function($row) use($decLevelConfig) {
+                        return $decLevelConfig[$row['DEC_LV']]['LEVEL_NAME'];
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
+                    ],
+                ],
+                'DEC_LV_UPDATED_AT' => [
+                    'header' => '实时调整日期',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['DEC_LV_UPDATED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+                'LAST_DEC_LV_NAME' => [
+                    'header' => '结算时会员级别',
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                    'value' => function($row) use($decLevelConfig) {
+                        if (!$row['LAST_DEC_LV']) {
+                            return $decLevelConfig[$row['DEC_LV']]['LEVEL_NAME'];
+                        } else {
+                            return $decLevelConfig[$row['LAST_DEC_LV']]['LEVEL_NAME'];
+                        }
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
+                    ],
+                ],
+                'EMP_LV_NAME' => [
+                    'header' => '最高聘级',
+                    'headerOther' => [
+                        'width' => '130',
+                    ],
+                    'value' => function($row) use($empLevelConfig) {
+                        return isset($empLevelConfig[$row['EMP_LV']])?$empLevelConfig[$row['EMP_LV']]['LEVEL_NAME']:'';
+                    },
+                    'valueOther' => [
+                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
+                    ],
+                ],
+//                'HIGHEST_EMP_LV_NAME' => [
+//                    'header' => '历史最高聘级',
+//                    'value' => function($row) use($empLevelConfig) {
+//                        if (!$row['HIGHEST_EMP_LV']){
+//                            return $empLevelConfig[$row['EMP_LV']]['LEVEL_NAME'];
+//                        } else {
+//                            return $empLevelConfig[$row['HIGHEST_EMP_LV']]['LEVEL_NAME'];
+//                        }
+//                    },
+//                    'headerOther' => ['width' => '130'],
+//                ],
+//                'HIGHEST_EMP_LV_PERIOD' => [
+//                    'header' => '首次达到历史最高聘级的期数',
+//                    'headerOther' => ['width' => '210'],
+//                ],
+                'REC_USER_NAME' => [
+                    'header' => '推荐编号',
+                    'headerOther' => ['width' => '150'],
+                ],
+                'REC_REAL_NAME' => [
+                    'header' => '推荐姓名',
+                    'headerOther' => ['width' => '100'],
+                ],
+                'CON_USER_NAME' => [
+                    'header' => '安置编号',
+                    'headerOther' => ['width' => '150'],
+                ],
+                'CON_REAL_NAME' => [
+                    'header' => '安置姓名',
+                    'headerOther' => ['width' => '100'],
+                ],
+                'RELATIVE_LOCATION' => [
+                    'header' => '安置区域',
+                    'headerOther' => ['width' => '100'],
+                ],
+                'ID_TYPE' => [
+                    'header' => '证件类型',
+                    'value' => function($row) {
+                        return $row['ID_TYPE'] == 0 ? '身份证' : '';
+                    },
+                ],
+                'ID_CARD' => [
+                    'header' => '证件号码',
+                    'value' => function($row) {
+                        return "\t".$row['ID_CARD'];
+                    },
+                    'headerOther' => ['width' => '180'],
+                ],
+//                'SPOUSE_NAME' => [
+//                    'header' => '配偶姓名',
+//                    'headerOther' => ['width' => '100'],
+//                ],
+//                'SPOUSE_IDCARD' => [
+//                    'header' => '配偶身份证号',
+//                    'value' => function($row) {
+//                        return "\t".$row['SPOUSE_IDCARD'];
+//                    },
+//                    'headerOther' => ['width' => '180'],
+//                ],
+//                'SYSTEM_NAME' => [
+//                    'header' => '体系名称',
+//                    'headerOther' => ['width' => '150'],
+//                    'value' => function($row) use($systemConfig) {
+//                        return $systemConfig[$row['SYSTEM_ID']]['SYSTEM_NAME'] ?? '';
+//                    },
+//                ],
+                'MOBILE' => [
+                    'header' => '手机号码',
+                    'value' => function($row) {
+                        return "\t".$row['MOBILE'];
+                    },
+                    'headerOther' => ['width' => '120'],
+                ],
+                'TEL' => [
+                    'header' => '备用手机号码',
+                    'value' => function($row) {
+                        return "\t".$row['TEL'];
+                    },
+                    'headerOther' => ['width' => '120'],
+                ],
+                'DEC_USER_NAME' => [
+                    'header' => '所属报单中心编号',
+                    'headerOther' => ['width' => '150'],
+                ],
+                'IS_DEC' => [
+                    'header' => '是否报单中心',
+                    'value' => function($row) {
+                        return (new YesNo([
+                            'value' => $row['IS_DEC'],
+                        ]))->result();
+                    },
+                    'headerOther' => function($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function($row) {
+                        return [
+                            'tag'=>['type'=>(isset($row['IS_DEC']) && $row['IS_DEC'] )? 'success' : 'info', 'size' => 'small']
+                        ];
+                    },
+                ],
+                'IS_STUDIO' => [
+                    'header' => '是否工作室',
+                    'value' => function($row) {
+                        return (new YesNo([
+                            'value' => $row['IS_STUDIO'],
+                        ]))->result();
+                    },
+                    'headerOther' => function($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function($row) {
+                        return [
+                            'tag'=>['type'=>(isset($row['IS_STUDIO']) && $row['IS_STUDIO'] )? 'success' : 'info', 'size' => 'small']
+                        ];
+                    },
+                ],
+                'IS_ATLAS' => [
+                    'header' => '是否显示图谱',
+                    'value' => function($row) {
+                        return (new YesNo([
+                            'value' => $row['IS_ATLAS'],
+                        ]))->result();
+                    },
+                    'headerOther' => function($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function($row) {
+                        return [
+                            'tag'=>['type'=>(isset($row['IS_ATLAS']) && $row['IS_ATLAS'] )? 'success' : 'info', 'size' => 'small']
+                        ];
+                    },
+                ],
+                'IS_RECHARGE' => [
+                    'header' => '是否显示充值',
+                    'value' => function($row) {
+                        return (new YesNo([
+                            'value' => $row['IS_RECHARGE'],
+                        ]))->result();
+                    },
+                    'headerOther' => function($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function($row) {
+                        return [
+                            'tag'=>['type'=>(isset($row['IS_RECHARGE']) && $row['IS_RECHARGE'] )? 'success' : 'info', 'size' => 'small']
+                        ];
+                    },
+                ],
+                'DEC_ROLE_NAME' => [
+                    'header' => '报单中心级别',
+                    'headerOther' => ['width' => '110'],
+                    'value' => function($row) use($decRoleConfig) {
+                        return $decRoleConfig[$row['DEC_ROLE_ID']]['ROLE_NAME'] ?? '';
+                    },
+                ],
+                'OPEN_BANK_NAME' => [
+                    'header' => '开户银行',
+                    'headerOther' => ['width' => '110'],
+                    'value' => function($row) use($openBankConfig) {
+                        return $openBankConfig[$row['OPEN_BANK']]['BANK_NAME'] ?? '';
+                    },
+                ],
+                'BANK_AREA' => [
+                    'header' => '银行地区',
+                    'value' => function($row) use($regionConfig) {
+                        $province = $regionConfig[$row['BANK_PROVINCE']]['REGION_NAME'] ?? '';
+                        $city = $regionConfig[$row['BANK_CITY']]['REGION_NAME'] ?? '';
+                        $county = $regionConfig[$row['BANK_COUNTY']]['REGION_NAME'] ?? '';
+                        return $province.$city.$county;
+                    },
+                    'showValue' => function($row) use($regionConfig) {
+                        $province = $regionConfig[$row['BANK_PROVINCE']]['REGION_NAME'] ?? '';
+                        $city = $regionConfig[$row['BANK_CITY']]['REGION_NAME'] ?? '';
+                        $county = $regionConfig[$row['BANK_COUNTY']]['REGION_NAME'] ?? '';
+                        return '<div class="addr" title='.$province.$city.$county.'>'.$province.$city.$county.'</div>';
+                    },
+                    'headerOther' => [
+                        'width' => '200'
+                    ],
+                ],
+                'BANK_ADDRESS' => [
+                    'header' => '开户地址',
+                    'headerOther' => ['width' => '250'],
+                    'showValue' => function($row) {
+                        return '<div class="addr" title='.$row['BANK_ADDRESS'].'>'.$row['BANK_ADDRESS'].'</div>';
+                    },
+                ],
+                'BANK_NO' => [
+                    'header' => '银行帐号',
+                    'headerOther' => ['width' => '220'],
+                    'value' => function($row) {
+                        return "\t".$row['BANK_NO'];
+                    },
+                ],
+                'SEX' => '性别',
+                'NATION_NAME' => [
+                    'header' => '民族',
+                    'value' => function($row) {
+                        return \Yii::$app->params['nation'][$row['NATION']]['name'] ?? '';
+                    },
+                ],
+                'AREA' => [
+                    'header' => '常用地址',
+                    'value' => function($row) use($regionConfig) {
+                        $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
+                        $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
+                        $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
+                        return $province.$city.$county;
+                    },
+                    'showValue' => function($row) {
+                        $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
+                        $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
+                        $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
+                        return '<div class="addr" title='.$province.$city.$county.'>'.$province.$city.$county.'</div>';
+                    },
+                    'headerOther' => [
+                        'width' => '200'
+                    ],
+                ],
+                'ADDRESS' => [
+                    'header' => '身份证地址',
+                    'value' => function($row) {
+                        return $row['ADDRESS'];
+                    },
+                    'showValue' => function($row) {
+                        return '<div class="addr" title='.$row['ADDRESS'].'>'.$row['ADDRESS'].'</div>';
+                    },
+                    'headerOther' => ['width' => '250'],
+                ],
+//                'IS_AUTO_WITHDRAW' => [
+//                    'header' => '提现方式',
+//                    'value' => function($row) {
+//                        return $row['IS_AUTO_WITHDRAW']==0?'手动':'自动';
+//                    },
+//                ],
+                'VERIFIED' => [
+                    'header' => '实名认证',
+                    'value' => function($row) {
+                        return (new YesNo([
+                            'value' => $row['VERIFIED'],
+                        ]))->result();
+                    },
+                    'headerOther' => function($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function($row) {
+                        return [
+                            'tag'=>['type'=>(isset($row['VERIFIED']) && $row['VERIFIED']) ? 'success' : 'info', 'size' => 'small']
+                        ];
+                    },
+                ],
+                'VERIFIED_AT' => [
+                    'header' => '实名认证日期',
+                    'value' => function($row) {
+                        return (new DateTime([
+                            'value' => $row['VERIFIED_AT'],
+                        ]))->result();
+                    },
+                    'headerOther' => ['width' => '170'],
+                ],
+//                'IS_DIRECT_SELLER' => [
+//                    'header' => '是否直销员',
+//                    'value' => function($row) {
+//                        return (new YesNo([
+//                            'value' => $row['IS_DIRECT_SELLER'],
+//                        ]))->result();
+//                    },
+//                    'valueOther' => function($row) {
+//                        return [
+//                            'tag'=>['type'=>(isset($row['IS_DIRECT_SELLER']) && $row['IS_DIRECT_SELLER']) ? 'success' : 'info', 'size' => 'small']
+//                        ];
+//                    },
+//                    'headerOther' => function($row) {
+//                        return [
+//                            'width' => '120',
+//                        ];
+//                    },
+//                ],
+//                'IS_SYSTEM_LEADER' => [
+//                    'header' => '是否体系领导人',
+//                    'value' => function($row) {
+//                        return (new YesNo([
+//                            'value' => $row['IS_SYSTEM_LEADER'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => function($row) {
+//                        return [
+//                            'width' => '120',
+//                        ];
+//                    },
+//                    'valueOther' => function($row) {
+//                        return [
+//                            'tag'=>['type'=>(isset($row['IS_SYSTEM_LEADER']) && $row['IS_SYSTEM_LEADER']) ? 'success' : 'info', 'size' => 'small']
+//                        ];
+//                    },
+//                ],
+//                'IS_GROUP_LEADER' => [
+//                    'header' => '是否团队领导人',
+//                    'value' => function($row) {
+//                        return (new YesNo([
+//                            'value' => $row['IS_GROUP_LEADER'],
+//                        ]))->result();
+//                    },
+//                    'headerOther' => function($row) {
+//                        return [
+//                            'width' => '120',
+//                        ];
+//                    },
+//                    'valueOther' => function($row) {
+//                        return [
+//                            'tag'=>['type'=>(isset($row['IS_GROUP_LEADER']) && $row['IS_GROUP_LEADER'] ) ? 'success' : 'info', 'size' => 'small']
+//                        ];
+//                    },
+//                ],
+                'BIRTHDAY' => [
+                    'header' => '生日',
+                    'value' => function($row) {
+                        return date('Y-m-d', strtotime($row['BIRTHDAY']));
+                    },
+                    'headerOther' => ['width' => '110'],
+                ],
+                'ALLOW_TRANSFER' => [
+                    'header' => '转账功能开启',
+                    'value' => function($row) {
+                        return $row['ALLOW_TRANSFER'] == 1 ? '开启' : '关闭';
+                    },
+                    'headerOther' => function($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function($row) {
+                        return [
+                            'tag'=>['type'=>(isset($row['ALLOW_TRANSFER']) && $row['ALLOW_TRANSFER']) ? 'success' : 'info', 'size' => 'small']
+                        ];
+                    },
+                ],
+                'DEC_CLOSED' => [
+                    'header' => '是否关闭报单',
+                    'value' => function($row) {
+                        return (new YesNo([
+                            'value' => $row['DEC_CLOSED'],
+                        ]))->result();
+                    },
+                    'headerOther' => function($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function($row) {
+                        return [
+                            'tag'=>['type'=>(isset($row['DEC_CLOSED']) && $row['DEC_CLOSED']) ? 'info' : 'success', 'size' => 'small']
+                        ];
+                    },
+                ],
+                'IS_MODIFY_PASSWORD' => [
+                    'header' => '密码修改状态',
+                    'value' => function($row) {
+                        return $row['IS_MODIFY_PASSWORD'] == 1 ? '开启' : '关闭';
+                    },
+                    'headerOther' => function($row) {
+                        return [
+                            'width' => '120',
+                        ];
+                    },
+                    'valueOther' => function($row) {
+                        return [
+                            'tag'=>['type'=>(isset($row['IS_MODIFY_PASSWORD']) && $row['IS_MODIFY_PASSWORD'] )? 'success' : 'info', 'size' => 'small']
+                        ];
+                    },
+                ],
+            ];
+        }
+        return $this->columns;
+    }
+
+    /**
+     * 前台用于筛选的类型集合
+     * @return mixed
+     */
+    public function getFilterTypes()
+    {
+        if(!$this->filterTypes){
+            $this->filterTypes = [
+                'USER_NAME'=> ['name'=> '会员编号'],
+                'REAL_NAME'=> ['name'=> '会员姓名'],
+//                'ALLOW_LOGIN'=> ['name'=> '允许登录', 'other'=> 'yesOrNo'],
+                'CREATED_AT'=> ['name'=> '加入日期', 'other'=> 'date'],
+                'PERIOD_AT'=> ['name'=> '加入期数'],
+                'DEC_LV_NAME'=> ['name'=> '实时会员级别', 'other'=> 'decLevel'],
+//                'DEC_LV_UPDATED_AT'=> ['name'=> '实时调整日期', 'other'=> 'date'],
+//                'LAST_DEC_LV_NAME'=> ['name'=> '结算时会员级别', 'other'=> 'decLevel'],
+                'EMP_LV_NAME'=> ['name'=> '最高聘级', 'other'=> 'empLevel'],
+//                'HIGHEST_EMP_LV_NAME'=> ['name'=> '历史最高聘级', 'other'=> 'empLevel'],
+//                'HIGHEST_EMP_LV_PERIOD'=> ['name'=> '首次达到历史最高聘级的期数'],
+                'REC_USER_NAME'=> ['name'=> '推荐编号'],
+                'CON_USER_NAME'=> ['name'=> '安置编号'],
+                //'ID_TYPE'=> ['name'=> '证件类型', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> '身份证']]],
+                'ID_CARD'=> ['name'=> '证件号码'],
+//                'SPOUSE_NAME'=> ['name'=> '配偶姓名'],
+//                'SPOUSE_IDCARD'=> ['name'=> '配偶身份证号'],
+//                'SYSTEM_NAME'=> ['name'=> '体系名称', 'other'=> 'systems'],
+//                'SUB_COM_NAME'=> ['name'=> '所属分公司', 'other'=> 'subCompany'],
+                'MOBILE'=> ['name'=> '手机号码'],
+//                'TEL'=> ['name'=> '备用手机号码'],
+                'DEC_USER_NAME'=> ['name'=> '所属报单中心编号'],
+                'IS_DEC'=> ['name'=> '是否报单中心', 'other'=> 'yesOrNo'],
+                'IS_STUDIO'=> ['name'=> '是否工作室', 'other'=> 'yesOrNo'],
+                'DEC_ROLE_NAME'=> ['name'=> '报单中心级别', 'other'=> 'decRole'],
+//                'OPEN_BANK_NAME'=> ['name'=> '开户银行', 'other'=> 'banks'],
+//                'BANK_AREA'=> ['name'=> '银行地区', 'other'=> 'area'],
+//                'BANK_ADDRESS'=> ['name'=> '开户地址'],
+//                'BANK_NO'=> ['name'=> '银行账号'],
+//                'SEX'=> ['name'=> '性别', 'other'=> 'sex'],
+//                'NATION_NAME'=> ['name'=> '民族', 'other'=> 'nations'],
+                'AREA'=> ['name'=> '常用地址', 'other'=> 'area'],
+                'STATUS'=> ['name'=> '激活状态', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> '锁定'],['id'=> 1, 'name'=> '激活']]],
+//                'ADDRESS'=> ['name'=> '身份证地址'],
+//                'IS_AUTO_WITHDRAW'=> [
+//                    'isUserTable'=> false,
+//                    'name'=> '提现方式',
+//                    'other'=> 'select',
+//                    'selectData'=> [['id'=> 0, 'name'=> '手动'], ['id'=> 1, 'name'=> '自动']]
+//                ],
+//                'VERIFIED'=> ['name'=> '实名认证', 'other'=> 'yesOrNo'],
+//                'VERIFIED_AT'=> ['name'=> '实名认证日期', 'other'=> 'date'],
+//                'IS_DIRECT_SELLER'=> ['name'=> '是否直销员', 'other'=> 'yesOrNo'],
+//                'IS_SYSTEM_LEADER'=> ['name'=> '是否体系领导人', 'other'=> 'yesOrNo'],
+//                'IS_GROUP_LEADER'=> ['name'=> '是否团队领导人', 'other'=> 'yesOrNo'],
+//                'ALLOW_TRANSFER'=> ['name'=> '转账功能开启', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> '关闭'],['id'=> 1, 'name'=> '开启']]],
+//                'DEC_CLOSED'=> ['name'=> '是否关闭报单', 'other'=> 'yesOrNo'],
+            ];
+        }
+        return $this->filterTypes;
+    }
 }

+ 13 - 1
backendEle/src/router/index.js

@@ -667,6 +667,18 @@ export const constantRouterMap = [
     component: layout,
     redirect: '/bonus/period',
     children: [
+      {
+        path: '/bonus/prepare-period',
+        component: _import('bonus/prepare-period'),
+        name: 'bonus_prepare-period',
+        meta: {
+          title: '预算月业绩',
+          breadcrumb: [
+            {title: '首页', path: '/dashboard/index'},
+            {title: '奖金管理', path: '/bonus/period'},
+          ],
+        },
+      },
       {
         path: '/bonus/period',
         component: _import('bonus/period'),
@@ -771,7 +783,7 @@ export const constantRouterMap = [
         component: _import('bonus/flow-exchange'),
         name: 'bonus_flow-exchange',
         meta: {
-          title: '兑换积分流水',
+          title: '兑换点数流水',
           breadcrumb: [
             {title: '首页', path: '/dashboard/index'},
             {title: '奖金管理', path: '/bonus/period'},

+ 253 - 253
backendEle/src/utils/network.js

@@ -1,253 +1,253 @@
-import {ACCESS_TOKEN_PREFIX} from './config'
-import userInfo from './userInfo'
-import tool from './tool'
-import axiosObj from './axiosPlugin'
-import ElementUI from 'element-ui'
-import baseInfo from './baseInfo'
-
-const updateToken = function (callback, errorBack) {
-  if (!userInfo.hasLogin()) {
-    //console.log('尚未登录');
-    //userInfo.clear();
-    errorBack('E40004')
-    return false
-  }
-  // 比较本地accessToken是否还有效
-  if (userInfo.accessToken() && userInfo.accessTokenExpiresIn() && parseInt(userInfo.accessTokenExpiresIn()) + parseInt(userInfo.accessTokenUpdateAt()) - 30 > parseInt(tool.getTimestamp())) {
-    // 有效
-    //console.log('accessToken有效');
-    callback(userInfo.accessToken())
-    return true
-  } else {
-    // 已失效,去更新
-    let refreshToken = userInfo.refreshToken()
-    let refreshTokenExpiresIn = userInfo.refreshTokenExpiresIn()
-    let refreshTokenUpdateAt = userInfo.refreshTokenUpdateAt()
-    if (refreshToken && refreshTokenExpiresIn && parseInt(refreshTokenExpiresIn) - 30 + parseInt(refreshTokenUpdateAt) > parseInt(tool.getTimestamp())) {
-      // 有效,去更新
-      axiosObj.get(`oauth/refresh-token?refresh-token=${refreshToken}`).then(response => {
-        // 更新本地accessToken
-        userInfo.accessToken(response.accessToken)
-        userInfo.accessTokenExpiresIn(response.accessTokenExpiresIn)
-        userInfo.accessTokenUpdateAt(response.accessTokenUpdateAt)
-        userInfo.refreshToken(response.refreshToken)
-        userInfo.refreshTokenExpiresIn(response.refreshTokenExpiresIn)
-        userInfo.refreshTokenUpdateAt(response.refreshTokenUpdateAt)
-        // 成功
-        //console.log('accessToken更新成功,refreshToken更新为:'+userInfo.refreshToken());
-        //console.log('accessToken更新成功,refreshToken的更新时间为:'+tool.formatDate(userInfo.refreshTokenUpdateAt()));
-        //console.log('accessToken更新成功,refreshToken的有效时间为:'+userInfo.refreshTokenExpiresIn());
-        callback(userInfo.accessToken())
-        return true
-      }).catch(error => {
-        //userInfo.clear();
-        //console.log(error);
-        errorBack('E40001')
-        return false
-      })
-    } else {
-      //console.log('refreshToken已失效');
-      userInfo.clear()
-      // 失效
-      errorBack('E40003')
-      return false
-    }
-  }
-}
-
-const network = {
-  loginGetAccessToken(adminName, password, verifyCode, pageId) {
-    let promise = new Promise((resolve, reject) => {
-      // if(userInfo.hasLogin()){
-      //     reject('E40005');
-      //     return false;
-      // }
-      axiosObj.post(`oauth/login?page_id=${pageId}`, {
-        LoginForm: {
-          adminName,
-          password,
-          verifyCode,
-        }
-      }).then(response => {
-        // 更新本地accessToken
-        userInfo.updateLoginAllInfo(response)
-        // 成功
-        resolve(response)
-      }).catch(error => {
-        //console.log('登录获取数据错误');
-        userInfo.clear()
-        reject(error)
-      })
-    })
-    return promise
-  },
-  updateToken() {
-    let promise = new Promise((resolve, reject) => {
-      updateToken(function (accessToken) {
-        resolve(accessToken)
-      }, function (error) {
-        reject(error)
-      })
-    })
-    return promise
-  },
-  getUserInfo() {
-    let promise = new Promise((resolve, reject) => {
-      updateToken(function (accessToken) {
-        axiosObj.get(`oauth/info`, {
-          headers: {
-            'Authorization': ACCESS_TOKEN_PREFIX + accessToken,
-          }
-        }).then(response => {
-          // 更新本地userInfo
-          userInfo.userId(response.ID)
-          userInfo.adminName(response.ADMIN_NAME)
-          userInfo.baseData({roleId: response.ROLE_ID})
-          // 成功
-          resolve(response)
-        }).catch(error => {
-          reject(error)
-        })
-      }, function (error) {
-        reject(error)
-      })
-    })
-    return promise
-  },
-  getBaseInfo() {
-    let promise = new Promise((resolve, reject) => {
-      updateToken(function (accessToken) {
-        axiosObj.get(`site/base-info`, {
-          headers: {
-            'Authorization': ACCESS_TOKEN_PREFIX + accessToken,
-          }
-        }).then(response => {
-          // 更新本地baseInfo
-          baseInfo.set(response)
-          // 成功
-          resolve(response)
-        }).catch(error => {
-          reject(error)
-        })
-      }, function (error) {
-        reject(error)
-      })
-    })
-    return promise
-  },
-  getData(route, data = null) {
-    if (data === null) {
-      data = {}
-    }
-    let promise = new Promise((resolve, reject) => {
-      updateToken(function (accessToken) {
-        axiosObj.get(`${route}`, {
-          params: data,
-          headers: {
-            'Authorization': ACCESS_TOKEN_PREFIX + accessToken,
-          }
-        }).then(response => {
-          // 成功
-          resolve(response)
-        }).catch(error => {
-          error = tool.errorHandle(error)
-          ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
-          reject(error)
-        })
-      }, function (error) {
-        error = tool.errorHandle(error)
-        ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
-        reject(error)
-      })
-    })
-    return promise
-  },
-  postData(route, data) {
-    let promise = new Promise((resolve, reject) => {
-      updateToken(function (accessToken) {
-        axiosObj.post(`${route}`, data, {
-          headers: {
-            'Authorization': ACCESS_TOKEN_PREFIX + accessToken,
-          }
-        }).then(response => {
-          // 成功
-          resolve(response)
-        }).catch(error => {
-          error = tool.errorHandle(error)
-          ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
-          reject(error)
-        })
-      }, function (error) {
-        error = tool.errorHandle(error)
-        ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
-        reject(error)
-      })
-    })
-    return promise
-  },
-  getPageData(obj, path, page = null, pageSize = null, data = null, callback = null, isLoading = null, percentFieldName = null) {
-    if (isLoading === false) {
-      obj.loading = isLoading
-    } else {
-      obj.loading = true
-    }
-    if (page === null) page = 1
-    if (pageSize === null) pageSize = 20
-    let paramsData = {
-      page: page,
-      pageSize: pageSize,
-    }
-    if (data === null || tool.isEmptyObject(data)) {
-      // 查看地址栏中的内容,如果有内容则把地址栏中的参数给拿到
-      if(window.location.href.indexOf('filter') !== -1){
-        let nowUrl = tool.parseURL(window.location.href)
-        if(nowUrl.params.filter){
-          data = JSON.parse(unescape(nowUrl.params.filter))
-          if(obj.filterModel){
-            obj.filterModel = data
-          }
-        }
-      }
-    }
-    paramsData = Object.assign(paramsData, data)
-    network.getData(path, paramsData).then(response => {
-      obj.tableData = response.list
-      obj.tableHeaders = response.columnsShow ? response.columnsShow : []
-      obj.loading = false
-      obj.currentPage = page
-      obj.totalPages = parseInt(response.totalPages)
-      obj.totalCount = parseInt(response.totalCount)
-      obj.pageSize = pageSize
-      if (percentFieldName !== null) {
-        if(percentFieldName.length > 0){
-          for(let i in obj.tableData){
-            for(let j in percentFieldName){
-              obj.$set(obj.percentList[percentFieldName[j]], obj.tableData[i].ID, obj.tableData[i][percentFieldName[j]])
-            }
-          }
-        }
-      }
-      if (callback !== null) {
-        callback(response)
-      }
-    }).catch(response => {
-      obj.loading = false
-    })
-  },
-  getDaysDiff() {
-    let promise = new Promise((resolve, reject) => {
-      axiosObj.get(`site/days-diff`).then(response => {
-        // 更新本地baseInfo
-        baseInfo.setDaysDiff(response.daysDiff)
-        // 成功
-        resolve(response)
-      }).catch(error => {
-        reject(error)
-      })
-    })
-    return promise
-  }
-
-}
-
-export default network
+import {ACCESS_TOKEN_PREFIX} from './config'
+import userInfo from './userInfo'
+import tool from './tool'
+import axiosObj from './axiosPlugin'
+import ElementUI from 'element-ui'
+import baseInfo from './baseInfo'
+
+const updateToken = function (callback, errorBack) {
+  if (!userInfo.hasLogin()) {
+    //console.log('尚未登录');
+    //userInfo.clear();
+    errorBack('E40004')
+    return false
+  }
+  // 比较本地accessToken是否还有效
+  if (userInfo.accessToken() && userInfo.accessTokenExpiresIn() && parseInt(userInfo.accessTokenExpiresIn()) + parseInt(userInfo.accessTokenUpdateAt()) - 30 > parseInt(tool.getTimestamp())) {
+    // 有效
+    //console.log('accessToken有效');
+    callback(userInfo.accessToken())
+    return true
+  } else {
+    // 已失效,去更新
+    let refreshToken = userInfo.refreshToken()
+    let refreshTokenExpiresIn = userInfo.refreshTokenExpiresIn()
+    let refreshTokenUpdateAt = userInfo.refreshTokenUpdateAt()
+    if (refreshToken && refreshTokenExpiresIn && parseInt(refreshTokenExpiresIn) - 30 + parseInt(refreshTokenUpdateAt) > parseInt(tool.getTimestamp())) {
+      // 有效,去更新
+      axiosObj.get(`oauth/refresh-token?refresh-token=${refreshToken}`).then(response => {
+        // 更新本地accessToken
+        userInfo.accessToken(response.accessToken)
+        userInfo.accessTokenExpiresIn(response.accessTokenExpiresIn)
+        userInfo.accessTokenUpdateAt(response.accessTokenUpdateAt)
+        userInfo.refreshToken(response.refreshToken)
+        userInfo.refreshTokenExpiresIn(response.refreshTokenExpiresIn)
+        userInfo.refreshTokenUpdateAt(response.refreshTokenUpdateAt)
+        // 成功
+        //console.log('accessToken更新成功,refreshToken更新为:'+userInfo.refreshToken());
+        //console.log('accessToken更新成功,refreshToken的更新时间为:'+tool.formatDate(userInfo.refreshTokenUpdateAt()));
+        //console.log('accessToken更新成功,refreshToken的有效时间为:'+userInfo.refreshTokenExpiresIn());
+        callback(userInfo.accessToken())
+        return true
+      }).catch(error => {
+        //userInfo.clear();
+        //console.log(error);
+        errorBack('E40001')
+        return false
+      })
+    } else {
+      //console.log('refreshToken已失效');
+      userInfo.clear()
+      // 失效
+      errorBack('E40003')
+      return false
+    }
+  }
+}
+
+const network = {
+  loginGetAccessToken(adminName, password, verifyCode, pageId) {
+    let promise = new Promise((resolve, reject) => {
+      // if(userInfo.hasLogin()){
+      //     reject('E40005');
+      //     return false;
+      // }
+      axiosObj.post(`oauth/login?page_id=${pageId}`, {
+        LoginForm: {
+          adminName,
+          password,
+          verifyCode,
+        }
+      }).then(response => {
+        // 更新本地accessToken
+        userInfo.updateLoginAllInfo(response)
+        // 成功
+        resolve(response)
+      }).catch(error => {
+        //console.log('登录获取数据错误');
+        userInfo.clear()
+        reject(error)
+      })
+    })
+    return promise
+  },
+  updateToken() {
+    let promise = new Promise((resolve, reject) => {
+      updateToken(function (accessToken) {
+        resolve(accessToken)
+      }, function (error) {
+        reject(error)
+      })
+    })
+    return promise
+  },
+  getUserInfo() {
+    let promise = new Promise((resolve, reject) => {
+      updateToken(function (accessToken) {
+        axiosObj.get(`oauth/info`, {
+          headers: {
+            'Authorization': ACCESS_TOKEN_PREFIX + accessToken,
+          }
+        }).then(response => {
+          // 更新本地userInfo
+          userInfo.userId(response.ID)
+          userInfo.adminName(response.ADMIN_NAME)
+          userInfo.baseData({roleId: response.ROLE_ID})
+          // 成功
+          resolve(response)
+        }).catch(error => {
+          reject(error)
+        })
+      }, function (error) {
+        reject(error)
+      })
+    })
+    return promise
+  },
+  getBaseInfo() {
+    let promise = new Promise((resolve, reject) => {
+      updateToken(function (accessToken) {
+        axiosObj.get(`site/base-info`, {
+          headers: {
+            'Authorization': ACCESS_TOKEN_PREFIX + accessToken,
+          }
+        }).then(response => {
+          // 更新本地baseInfo
+          baseInfo.set(response)
+          // 成功
+          resolve(response)
+        }).catch(error => {
+          reject(error)
+        })
+      }, function (error) {
+        reject(error)
+      })
+    })
+    return promise
+  },
+  getData(route, data = null) {
+    if (data === null) {
+      data = {}
+    }
+    let promise = new Promise((resolve, reject) => {
+      updateToken(function (accessToken) {
+        axiosObj.get(`${route}`, {
+          params: data,
+          headers: {
+            'Authorization': ACCESS_TOKEN_PREFIX + accessToken,
+          }
+        }).then(response => {
+          // 成功
+          resolve(response)
+        }).catch(error => {
+          error = tool.errorHandle(error)
+          ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
+          reject(error)
+        })
+      }, function (error) {
+        error = tool.errorHandle(error)
+        ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
+        reject(error)
+      })
+    })
+    return promise
+  },
+  postData(route, data) {
+    let promise = new Promise((resolve, reject) => {
+      updateToken(function (accessToken) {
+        axiosObj.post(`${route}`, data, {
+          headers: {
+            'Authorization': ACCESS_TOKEN_PREFIX + accessToken,
+          }
+        }).then(response => {
+          // 成功
+          resolve(response)
+        }).catch(error => {
+          error = tool.errorHandle(error)
+          ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
+          reject(error)
+        })
+      }, function (error) {
+        error = tool.errorHandle(error)
+        ElementUI.Message({type: 'error', message: error.message, showClose: true, duration: 0})
+        reject(error)
+      })
+    })
+    return promise
+  },
+  getPageData(obj, path, page = null, pageSize = null, data = null, callback = null, isLoading = null, percentFieldName = null) {
+    if (isLoading === false) {
+      obj.loading = isLoading
+    } else {
+      obj.loading = true
+    }
+    if (page === null) page = 1
+    if (pageSize === null) pageSize = 20
+    let paramsData = {
+      page: page,
+      pageSize: pageSize,
+    }
+    if (data === null || tool.isEmptyObject(data)) {
+      // 查看地址栏中的内容,如果有内容则把地址栏中的参数给拿到
+      if(window.location.href.indexOf('filter') !== -1){
+        let nowUrl = tool.parseURL(window.location.href)
+        if(nowUrl.params.filter){
+          data = JSON.parse(unescape(nowUrl.params.filter))
+          if(obj.filterModel){
+            obj.filterModel = data
+          }
+        }
+      }
+    }
+    paramsData = Object.assign(paramsData, data)
+    network.getData(path, paramsData).then(response => {
+      obj.tableData = response.list
+      obj.tableHeaders = response.columnsShow ? response.columnsShow : []
+      obj.loading = false
+      obj.currentPage = page
+      obj.totalPages = parseInt(response.totalPages)
+      obj.totalCount = parseInt(response.totalCount)
+      obj.pageSize = pageSize
+      if (percentFieldName !== null) {
+        if(percentFieldName.length > 0){
+          for(let i in obj.tableData){
+            for(let j in percentFieldName){
+              obj.$set(obj.percentList[percentFieldName[j]], obj.tableData[i].ID, obj.tableData[i][percentFieldName[j]])
+            }
+          }
+        }
+      }
+      if (callback !== null) {
+        callback(response)
+      }
+    }).catch(response => {
+      obj.loading = false
+    })
+  },
+  getDaysDiff() {
+    let promise = new Promise((resolve, reject) => {
+      axiosObj.get(`site/days-diff`).then(response => {
+        // 更新本地baseInfo
+        baseInfo.setDaysDiff(response.daysDiff)
+        // 成功
+        resolve(response)
+      }).catch(error => {
+        reject(error)
+      })
+    })
+    return promise
+  }
+
+}
+
+export default network

+ 212 - 0
backendEle/src/views/bonus/prepare-period.vue

@@ -0,0 +1,212 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <el-table :data="tableData" stripe style="width: 100%;" @selection-change="handleSelectionChange"
+                :height="tool.getTableHeight()">
+        <el-table-column prop="PERIOD_NUM" label="期数">
+          <template slot-scope="scope">
+            <el-tag type="" size="small" class="no-border">{{scope.row.PERIOD_NUM}}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="所在结算月" width="100">
+          <template slot-scope="scope">
+            <el-tag type="warning" size="small" class="no-border">{{scope.row.CALC_YEAR}}-{{scope.row.CALC_MONTH}}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="时间范围" width="260">
+          <template slot-scope="scope">
+            应开始于:{{tool.formatDate(scope.row.START_TIME)}}<br/>
+            应结束于:{{tool.formatDate(scope.row.END_TIME)}}
+          </template>
+        </el-table-column>
+        <el-table-column label="业绩单进度" width="90">
+          <template slot-scope="scope">
+            <el-progress type="circle" :percentage="Number.parseInt(percentList['PERF_PERCENT'][scope.row.ID])"
+                         :width="50" :stroke-width="3"></el-progress>
+          </template>
+        </el-table-column>
+        <el-table-column label="生成业绩单时间" width="210">
+          <template slot-scope="scope">
+            开始:{{tool.formatDate(scope.row.PERF_STARTED_AT)}}<br>
+            完成:{{tool.formatDate(scope.row.PERFED_AT)}}
+          </template>
+        </el-table-column>
+        <el-table-column fixed="right" label="操作" width="180">
+          <template slot-scope="scope">
+            <el-dropdown size="small" trigger="click" v-if="scope.row.BUTTON_IS_CAN">
+              <el-button type="primary" size="small" @click.stop="">
+                操作该数据<i class="el-icon-arrow-down el-icon--right"></i>
+              </el-button>
+              <el-dropdown-menu slot="dropdown">
+                <el-dropdown-item @click.native="perfHandle(scope.row)"
+                                  v-if="scope.row.IS_PERFING === '0' && scope.row.IS_CAN_PERF && permission.hasPermission(`bonus/prepare-perf-period`)">
+                  生成预计算月业绩单
+                </el-dropdown-item>
+                <el-dropdown-item @click.native="perfHandle(scope.row)"
+                                  v-if="scope.row.IS_PERFING === '1' && scope.row.IS_CAN_PERF && permission.hasPermission(`bonus/prepare-perf-period`)">
+                  强制生成预计算月业绩单
+                </el-dropdown-item>
+              </el-dropdown-menu>
+            </el-dropdown>
+          </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 Vue from 'vue'
+  import {BONUS_WEBSOCKET_HOST} from '@/utils/config'
+  import userInfo from '@/utils/userInfo'
+  import network from './../../utils/network'
+  import tool from './../../utils/tool'
+  import store from '@/utils/vuexStore'
+  import FilterUser from '@/components/FilterUser'
+  import permission from '@/utils/permission'
+  import Pagination from '@/components/Pagination'
+  import filterHelper from '../../utils/filterHelper'
+
+  export default {
+    name: 'bonus_prepare-period',
+    components: {FilterUser,Pagination},
+    created() {
+      let wsServer = BONUS_WEBSOCKET_HOST
+      let webSocket = new WebSocket(wsServer)
+      webSocket.onopen = function (evt) {
+        let userId = userInfo.userId()
+        let sendData = {app: 'admin', userId: userId}
+        webSocket.send(JSON.stringify(sendData))
+      }
+      webSocket.onmessage = (env) => {
+        let data = JSON.parse(env.data)
+        if (data.handle === 'adminAsyncPercent') {
+          this.onMessageCallback(data)
+        }
+      }
+    },
+    mounted() {
+      this.getData(this.currentPage, this.pageSize)
+      store.state.socket.onMessageCallback = this.onMessageCallback
+    },
+    data() {
+      return {
+        tableData: null,
+        loading: true,
+        multipleSelection: [],
+        currentPage: 1,
+        totalPages: 1,
+        totalCount: 1,
+        pageSize: 10,
+        tool: tool,
+        permission: permission,
+        filterTypes: {
+          'periodNum': {isUserTable: false, name: '期数'},
+          'year': {isUserTable: false, name: '所在结算年'},
+          'month': {isUserTable: false, name: '所在结算月'},
+          'startTime': {isUserTable: false, name: '期数开始时间', other: 'date'},
+          'endTime': {isUserTable: false, name: '期数结束时间', other: 'date'},
+          'closedAt': {isUserTable: false, name: '封期时间', other: 'date'},
+          'perfStartedAt': {isUserTable: false, name: '生成业绩单开始时间', other: 'date'},
+          'perfedAt': {isUserTable: false, name: '生成业绩单结束时间', other: 'date'},
+          'calStartedAt': {isUserTable: false, name: '结算开始时间', other: 'date'},
+          'calculatedAt': {isUserTable: false, name: '结算结束时间', other: 'date'},
+          'sendStartedAt': {isUserTable: false, name: '挂网开始时间', other: 'date'},
+          'sentAt': {isUserTable: false, name: '挂网结束时间', other: 'date'},
+        },
+        filterModel: {},
+        percentList: {
+          'PERF_PERCENT': {},
+          'CALC_PERCENT': {},
+          'SENT_PERCENT': {},
+        },
+      }
+    },
+    methods: {
+      closeHandle(row) {
+        this.$confirm('确定对当前期进行手动封期操作?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          return network.getData(`bonus/close-period/${row.PERIOD_NUM}`)
+        }).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.getData(this.currentPage, this.pageSize)
+        }).catch(response => {
+        })
+      },
+      calcHandle(row) {
+        this.$confirm('确定对当前期进行结算操作?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          return network.getData(`bonus/calc-period/${row.PERIOD_NUM}`)
+        }).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.getData(this.currentPage, this.pageSize)
+        }).catch(response => {
+        })
+      },
+      perfHandle(row) {
+        this.$confirm('确定进行预计算业绩吗?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          return network.getData(`bonus/prepare-perf-period/${row.PERIOD_NUM}`)
+        }).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.getData(this.currentPage, this.pageSize)
+        }).catch(response => {
+        })
+      },
+      handleSelectionChange(val) {
+        this.multipleSelection = val
+      },
+      handleCurrentChange(page) {
+        this.getData(page, this.pageSize)
+      },
+      handleSizeChange(pageSize) {
+        this.getData(this.currentPage, pageSize)
+      },
+      handleFilterUser(filterData) {
+        filterHelper.handleFilterUser(this, filterData)
+      },
+      handleFilter() {
+        this.getData()
+      },
+      getData(page, pageSize) {
+        let filterData = this.filterModel
+        let vueObj = this
+        network.getPageData(this, 'bonus/prepare-period', page, pageSize, filterData, function (response) {
+          vueObj.allData = response
+        }, null, ['PERF_PERCENT', 'CALC_PERCENT', 'SENT_PERCENT'])
+      },
+      onMessageCallback(data) {
+        if (data) {
+          if (data.other && data.other.MODEL === 'PERIOD' && data.other.ID) {
+            this.$set(this.percentList[data.other.FIELD], data.other.ID, data.percent)
+          }
+          if (data.other && data.other.MODEL === 'PERIOD' && data.percent === 100) {
+            this.getData(this.currentPage, this.pageSize)
+          }
+        }
+      },
+    }
+  }
+</script>

+ 1 - 1
backendEle/src/views/config/transfer.vue

@@ -96,7 +96,7 @@
         },
         loading: true,
         submitButtonStat: false,
-        allWallet:{'bonus':'会员账户','cash':'现金钱包'}
+        allWallet:{'bonus':'会员账户','cash':'现金钱包','point':'复消积分'}
       }
     },
     methods: {

+ 4 - 1
backendEle/src/views/finance/change-balance-opt.vue

@@ -90,6 +90,9 @@
     components: {LeoExcelUploader},
     mounted() {
       network.getData('finance/change-balance-type').then(response => {
+        console.log('response',response);
+        console.log('response.type:',response.type);
+        console.log('response.dealTypes:',response.dealTypes);
         this.type = response.type
         this.dealTypes = response.dealTypes
         this.loading = false
@@ -191,4 +194,4 @@
 
 <style scoped>
 
-</style>
+</style>

+ 181 - 181
backendEle/src/views/reconsume/pool-list.vue

@@ -1,181 +1,181 @@
-<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 :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 : ''">
-          <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-if="scope.row[tableHeader.index].other.progress" >
-              <el-progress type="circle" :percentage="Number.parseInt(percentList['MOVE_PERCENT'][scope.row.ID])"
-                           :width="50"
-                           :stroke-width="3"></el-progress>
-            </template>
-            <template v-else>
-              <div v-html="scope.row[tableHeader.index].value"></div>
-            </template>
-          </template>
-        </el-table-column>
-        <el-table-column label="操作" width="150" v-if="tableHeaders">
-          <template slot-scope="scope">
-            <el-button type="primary" size="small" @click.native="handleChangeUserName(scope.row.USER_NAME.value)" v-show="permission.hasPermission(`reconsume/change-audit-add`)">调整复销池余额</el-button>
-          </template>
-        </el-table-column>
-      </el-table>
-      <div class="white-box-footer">
-        <el-button type="primary" size="small" @click="handleChange" icon="el-icon-plus" v-show="permission.hasPermission(`reconsume/change-audit-add`)">申请调整复销池余额</el-button>
-        <el-button type="primary" size="small" @click="handleDeduct" icon="el-icon-plus" v-show="permission.hasPermission(`reconsume/deduct-audit-add`)">手动扣除月复销</el-button>
-        <el-button type="success" size="small" @click="handleExport"
-                   v-show="permission.hasPermission(`reconsume/pool-list-export`)">导出Excel
-        </el-button>
-        <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 FilterUser from '@/components/FilterUser'
-import baseInfo from '@/utils/baseInfo'
-import Pagination from '@/components/Pagination'
-import permission from '@/utils/permission'
-import filterHelper from '../../utils/filterHelper'
-
-export default {
-  name: 'reconsume_pool-list',
-  components: {FilterUser,Pagination},
-  mounted () {
-    this.getData()
-  },
-  data () {
-    return {
-      tableHeaders: null,
-      allData: null,
-      tableData: null,
-      loading: true,
-      multipleSelection: [],
-      currentPage: 1,
-      totalPages: 1,
-      totalCount: 1,
-      pageSize: 20,
-      tool: tool,
-      permission: permission,
-      filterTypes: {
-        'USER_NAME': {isUserTable: true, name: '会员编号'},
-        'REAL_NAME': {isUserTable: true, name: '会员姓名'},
-        'STATUS': {isUserTable: true, name: '会员状态', other: 'status'},
-        'DEC_LV': {isUserTable: true, name: '实时会员级别', other: 'decLevel'},
-        'LAST_DEC_LV': {isUserTable: true, name: '结算时会员级别', other: 'decLevel'},
-        'EMP_LV': {isUserTable: true, name: '实时聘级', other: 'empLevel'},
-        'UNUSED_PV': {isUserTable: false, name: '复销池余额'},
-        'UNUSED_MONTH': {isUserTable: false, name: '赠送优惠期剩余月数'},
-        'CREATED_AT': {isUserTable: true, name: '加入时间', other: 'date'},
-        'PERIOD_AT': {isUserTable: true, name: '加入期数'},
-      },
-      filterModel: {},
-      baseInfo: baseInfo,
-    }
-  },
-  methods: {
-    handleSelectionChange (val) {
-      this.multipleSelection = val
-    },
-    handleCurrentChange (page) {
-      this.getData(page, this.pageSize)
-    },
-    handleSizeChange (pageSize) {
-      this.getData(this.currentPage, pageSize)
-    },
-    handlePass(row){
-      this.$confirm('确定要为该会员扣除复销并设为合格吗?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        return network.postData(`reconsume/deduct`, {
-          userName: row.USER_NAME.value,
-          isPass: true,
-        })
-      }).then(response => {
-        this.$message({
-          message: response,
-          type: 'success'
-        })
-        this.getData(this.currentPage, this.pageSize)
-      }).catch(response => {
-
-      })
-    },
-    handleNotPass(row){
-      this.$confirm('确定要为该会员扣除复销并设为不合格吗?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        return network.postData(`reconsume/deduct`, {
-          userName: row.USER_NAME.value,
-          isPass: false,
-        })
-      }).then(response => {
-        this.$message({
-          message: response,
-          type: 'success'
-        })
-        this.getData(this.currentPage, this.pageSize)
-      }).catch(response => {
-
-      })
-    },
-    handleDeduct() {
-      this.$router.push(`/reconsume/deduct-audit-add`)
-    },
-    handleChangeUserName(userName) {
-      this.$router.push({path:`/reconsume/change-audit-add/${userName}`})
-    },
-    handleChange() {
-      this.$router.push({path:`/reconsume/change-audit-add`})
-    },
-    handleFilterUser(filterData) {
-      filterHelper.handleFilterUser(this, filterData)
-    },
-    handleFilter() {
-      this.getData()
-    },
-    getData(page, pageSize) {
-      let filterData = this.filterModel
-      let vueObj=this
-      network.getPageData(this, 'reconsume/pool-list', page, pageSize, filterData, function (response) {
-        vueObj.allData = response
-        vueObj.filterTypes = response.filterTypes
-      })
-    },
-    handleExport(){
-      this.$confirm(`确定要导出当前数据吗?`, '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        return network.getData(`reconsume/pool-list-export`, this.filterModel)
-      }).then(response => {
-        this.$message({
-          message: response,
-          type: 'success'
-        })
-      }).catch(response => {
-
-      })
-    },
-  }
-}
-
-</script>
-
-<style scoped>
-
-</style>
+<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 :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 : ''">
+          <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-if="scope.row[tableHeader.index].other.progress" >
+              <el-progress type="circle" :percentage="Number.parseInt(percentList['MOVE_PERCENT'][scope.row.ID])"
+                           :width="50"
+                           :stroke-width="3"></el-progress>
+            </template>
+            <template v-else>
+              <div v-html="scope.row[tableHeader.index].value"></div>
+            </template>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作" width="150" v-if="tableHeaders">
+          <template slot-scope="scope">
+            <el-button type="primary" size="small" @click.native="handleChangeUserName(scope.row.USER_NAME.value)" v-show="permission.hasPermission(`reconsume/change-audit-add`)">调整复销池余额</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="white-box-footer">
+        <el-button type="primary" size="small" @click="handleChange" icon="el-icon-plus" v-show="permission.hasPermission(`reconsume/change-audit-add`)">申请调整复销池余额</el-button>
+        <el-button type="primary" size="small" @click="handleDeduct" icon="el-icon-plus" v-show="permission.hasPermission(`reconsume/deduct-audit-add`)">手动扣除月复销</el-button>
+        <el-button type="success" size="small" @click="handleExport"
+                   v-show="permission.hasPermission(`reconsume/pool-list-export`)">导出Excel
+        </el-button>
+        <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 FilterUser from '@/components/FilterUser'
+import baseInfo from '@/utils/baseInfo'
+import Pagination from '@/components/Pagination'
+import permission from '@/utils/permission'
+import filterHelper from '../../utils/filterHelper'
+
+export default {
+  name: 'reconsume_pool-list',
+  components: {FilterUser,Pagination},
+  mounted () {
+    this.getData()
+  },
+  data () {
+    return {
+      tableHeaders: null,
+      allData: null,
+      tableData: null,
+      loading: true,
+      multipleSelection: [],
+      currentPage: 1,
+      totalPages: 1,
+      totalCount: 1,
+      pageSize: 20,
+      tool: tool,
+      permission: permission,
+      filterTypes: {
+        'USER_NAME': {isUserTable: true, name: '会员编号'},
+        'REAL_NAME': {isUserTable: true, name: '会员姓名'},
+        'STATUS': {isUserTable: true, name: '会员状态', other: 'status'},
+        'DEC_LV': {isUserTable: true, name: '实时会员级别', other: 'decLevel'},
+        'LAST_DEC_LV': {isUserTable: true, name: '结算时会员级别', other: 'decLevel'},
+        'EMP_LV': {isUserTable: true, name: '实时聘级', other: 'empLevel'},
+        'UNUSED_PV': {isUserTable: false, name: '复销池余额'},
+        'UNUSED_MONTH': {isUserTable: false, name: '赠送优惠期剩余月数'},
+        'CREATED_AT': {isUserTable: true, name: '加入时间', other: 'date'},
+        'PERIOD_AT': {isUserTable: true, name: '加入期数'},
+      },
+      filterModel: {},
+      baseInfo: baseInfo,
+    }
+  },
+  methods: {
+    handleSelectionChange (val) {
+      this.multipleSelection = val
+    },
+    handleCurrentChange (page) {
+      this.getData(page, this.pageSize)
+    },
+    handleSizeChange (pageSize) {
+      this.getData(this.currentPage, pageSize)
+    },
+    handlePass(row){
+      this.$confirm('确定要为该会员扣除复销并设为合格吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return network.postData(`reconsume/deduct`, {
+          userName: row.USER_NAME.value,
+          isPass: true,
+        })
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      }).catch(response => {
+
+      })
+    },
+    handleNotPass(row){
+      this.$confirm('确定要为该会员扣除复销并设为不合格吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return network.postData(`reconsume/deduct`, {
+          userName: row.USER_NAME.value,
+          isPass: false,
+        })
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      }).catch(response => {
+
+      })
+    },
+    handleDeduct() {
+      this.$router.push(`/reconsume/deduct-audit-add`)
+    },
+    handleChangeUserName(userName) {
+      this.$router.push({path:`/reconsume/change-audit-add/${userName}`})
+    },
+    handleChange() {
+      this.$router.push({path:`/reconsume/change-audit-add`})
+    },
+    handleFilterUser(filterData) {
+      filterHelper.handleFilterUser(this, filterData)
+    },
+    handleFilter() {
+      this.getData()
+    },
+    getData(page, pageSize) {
+      let filterData = this.filterModel
+      let vueObj=this
+      network.getPageData(this, 'reconsume/pool-list', page, pageSize, filterData, function (response) {
+        vueObj.allData = response
+        vueObj.filterTypes = response.filterTypes
+      })
+    },
+    handleExport(){
+      this.$confirm(`确定要导出当前数据吗?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return network.getData(`reconsume/pool-list-export`, this.filterModel)
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+      }).catch(response => {
+
+      })
+    },
+  }
+}
+
+</script>
+
+<style scoped>
+
+</style>

+ 1 - 0
backendEle/src/views/shop/dec-order-list.vue

@@ -100,6 +100,7 @@
         }).then(() => {
           return network.getData(`shop/dec-order-list-export`, this.filterModel)
         }).then(response => {
+
           this.$message({
             message: response,
             type: 'success'

+ 846 - 845
backendEle/src/views/user/index.vue

@@ -1,847 +1,848 @@
-<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 ref="wrapper" :data="tableData" stripe style="width: 100%;" @selection-change="handleSelectionChange"
-                :height="tool.getTableHeight()">
-        <el-table-column fixed type="selection" width="55" v-if="tableHeaders"></el-table-column>
-        <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header"
-                         :width="tableHeader.other.width ? tableHeader.other.width : ''" :fixed="tableHeader.index=='USER_NAME' || tableHeader.index=='REAL_NAME' ?true:false">
-          <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>
-              <template v-if="tableHeader.index === 'USER_NAME'">
-                <el-dropdown v-if="permission.hasPermission(`user/login-to-frontend`)">
-  <span class="el-dropdown-link">
-    {{scope.row.USER_NAME.value}} <i class="el-icon-arrow-down el-icon--right"></i>
-  </span>
-                  <el-dropdown-menu slot="dropdown">
-                    <el-dropdown-item command="login" v-show="scope.row.BTF_URL !== null">
-                      <a :href="`${frontendServer}/#/login-by-backend?${scope.row.BTF_URL}`" target="_blank"
-                         style="color:#606266;">快速登录</a>
-                    </el-dropdown-item>
-                  </el-dropdown-menu>
-                </el-dropdown>
-                <el-tag type="primary" size="small" class="no-border"
-                        v-if="!permission.hasPermission(`user/login-to-frontend`)">{{scope.row.USER_NAME.value}}
-                </el-tag>
-              </template>
-              <template v-else>
-                <div v-html="scope.row[tableHeader.index].value"></div>
-              </template>
-            </template>
-          </template>
-        </el-table-column>
-        <el-table-column fixed="right" label="操作" width="180">
-          <template slot-scope="scope">
-            <el-dropdown size="small" trigger="click">
-              <el-button type="primary" size="small" @click.stop="">
-                操作该数据<i class="el-icon-arrow-down el-icon--right"></i>
-              </el-button>
-              <el-dropdown-menu slot="dropdown">
-                <el-dropdown-item @click.native="handleModifyPassword(scope.row)"
-                                  v-if="permission.hasPermission(`user/modify-password`)">修改密码
-                </el-dropdown-item>
-                <el-dropdown-item @click.native="handleModifyProfile(scope.row)"
-                                  v-if="permission.hasPermission(`user/modify-profile`)">修改个人资料
-                </el-dropdown-item>
-                <el-dropdown-item @click.native="handleStatusActive(scope.row)" v-if="permission.hasPermission(`user/modify-status`)">状态激活 </el-dropdown-item>
-                <el-dropdown-item @click.native="handleStatusLock(scope.row)" v-if="permission.hasPermission(`user/modify-status`)">状态锁定 </el-dropdown-item>
-                <el-dropdown-item @click.native="handleIsModifyPassword(scope.row, 1)" v-if="permission.hasPermission(`user/is-modify-password-status`)">开启密码修改</el-dropdown-item>
-                <el-dropdown-item @click.native="handleIsModifyPassword(scope.row, 0)" v-if="permission.hasPermission(`user/is-modify-password-status`)">关闭密码修改</el-dropdown-item>
-              </el-dropdown-menu>
-            </el-dropdown>
-          </template>
-        </el-table-column>
-      </el-table>
-      <div class="white-box-footer">
-        <!--<el-dropdown size="small" trigger="click"-->
-                     <!--v-show="permission.hasPermission(`user/close-login`)||permission.hasPermission(`user/close-area-login`)||permission.hasPermission(`user/batch-close-login`)">-->
-          <!--<el-button type="primary" size="small" @click.stop="">-->
-            <!--登录管理<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
-          <!--</el-button>-->
-          <!--<el-dropdown-menu slot="dropdown">-->
-            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(1)"-->
-                              <!--v-show="permission.hasPermission(`user/batch-close-login`)">按指定会员管理登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(2)"-->
-                              <!--v-show="permission.hasPermission(`user/close-login`)">按开拓网络管理登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(3)"-->
-                              <!--v-show="permission.hasPermission(`user/close-login`)">按安置网络管理登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(4)"-->
-                              <!--v-show="permission.hasPermission(`user/close-login`)">按会员体系管理登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(5)"-->
-                              <!--v-show="permission.hasPermission(`user/close-area-login`)">按省份地区管理登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeLogin" @click.native="handleCloseLogin(1, 1)" v-show="false">禁止商城系统登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="allowLogin" @click.native="handleCloseLogin(0, 1)" v-show="false">允许商城系统登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeLogin" @click.native="handleCloseLogin(1, 2)" v-show="false">禁止结算系统登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="allowLogin" @click.native="handleCloseLogin(0, 2)" v-show="false">允许结算系统登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeLogin" @click.native="handleCloseLogin(1, 3)" v-show="false">全部禁止登录-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="allowLogin" @click.native="handleCloseLogin(0, 3)" v-show="false">全部允许登录-->
-            <!--</el-dropdown-item>-->
-          <!--</el-dropdown-menu>-->
-        <!--</el-dropdown>-->
-        <!--<el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-group`)">-->
-          <!--<el-button type="primary" size="small" @click.stop="">-->
-            <!--团队管理<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
-          <!--</el-button>-->
-          <!--<el-dropdown-menu slot="dropdown">-->
-            <!--<el-dropdown-item command="isGroup" @click.native="handleGroupManage(true)">设为团队领导人</el-dropdown-item>-->
-            <!--<el-dropdown-item command="notGroup" @click.native="handleGroupManage(false)">取消团队领导人-->
-            <!--</el-dropdown-item>-->
-          <!--</el-dropdown-menu>-->
-        <!--</el-dropdown>-->
-        <el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-dec`)">
-          <el-button type="primary" size="small" @click.stop="">
-            报单中心管理<i class="el-icon-arrow-down el-icon--right"></i>
-          </el-button>
-          <el-dropdown-menu slot="dropdown">
-            <el-dropdown-item command="isDec" @click.native="handleIsDecManage(true)">设为报单中心</el-dropdown-item>
-            <el-dropdown-item command="notDec" @click.native="handleIsDecManage(false)">取消报单中心
-            </el-dropdown-item>
-          </el-dropdown-menu>
-        </el-dropdown>
-
-        <el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-studio`)">
-          <el-button type="primary" size="small" @click.stop="">
-            工作室管理<i class="el-icon-arrow-down el-icon--right"></i>
-          </el-button>
-          <el-dropdown-menu slot="dropdown">
-            <el-dropdown-item command="isStudio" @click.native="handleIsStudioManage(true)">设为工作室</el-dropdown-item>
-            <el-dropdown-item command="notStudio" @click.native="handleIsStudioManage(false)">取消工作室
-            </el-dropdown-item>
-          </el-dropdown-menu>
-        </el-dropdown>
-
-        <el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-atlas`)">
-          <el-button type="primary" size="small" @click.stop="">
-            图谱管理<i class="el-icon-arrow-down el-icon--right"></i>
-          </el-button>
-          <el-dropdown-menu slot="dropdown">
-            <el-dropdown-item command="isAtlas" @click.native="handleIsAtlasManage(true)">显示图谱</el-dropdown-item>
-            <el-dropdown-item command="notAtlas" @click.native="handleIsAtlasManage(false)">隐藏图谱
-            </el-dropdown-item>
-          </el-dropdown-menu>
-        </el-dropdown>
-
-        <el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-recharge`)">
-          <el-button type="primary" size="small" @click.stop="">
-            充值管理<i class="el-icon-arrow-down el-icon--right"></i>
-          </el-button>
-          <el-dropdown-menu slot="dropdown">
-            <el-dropdown-item command="isAtlas" @click.native="handleIsRechargeManage(true)">显示充值</el-dropdown-item>
-            <el-dropdown-item command="notAtlas" @click.native="handleIsRechargeManage(false)">隐藏充值
-            </el-dropdown-item>
-          </el-dropdown-menu>
-        </el-dropdown>
-        <!--<el-dropdown size="small" trigger="click"-->
-                     <!--v-show="permission.hasPermission(`user/close-dec`)||permission.hasPermission(`user/close-area-dec`)||permission.hasPermission(`user/batch-close-dec`)">-->
-          <!--<el-button type="primary" size="small" @click.stop="">-->
-            <!--报单管理<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
-          <!--</el-button>-->
-          <!--<el-dropdown-menu slot="dropdown">-->
-            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(1)"-->
-                              <!--v-show="permission.hasPermission(`user/batch-close-dec`)">按指定会员管理报单-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(2)"-->
-                              <!--v-show="permission.hasPermission(`user/close-dec`)">按开拓网络管理报单-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(3)"-->
-                              <!--v-show="permission.hasPermission(`user/close-dec`)">按安置网络管理报单-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(4)"-->
-                              <!--v-show="permission.hasPermission(`user/close-dec`)">按会员体系管理报单-->
-            <!--</el-dropdown-item>-->
-            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(5)"-->
-                              <!--v-show="permission.hasPermission(`user/close-area-dec`)">按省份地区管理报单-->
-            <!--</el-dropdown-item>-->
-          <!--</el-dropdown-menu>-->
-        <!--</el-dropdown>-->
-        <el-button type="success" size="small" @click="handleExport"
-                   v-show="permission.hasPermission(`user/index-export`)">导出Excel
-        </el-button>
-        <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange"
-                    @current-change="handleCurrentChange"></pagination>
-      </div>
-    </div>
-    <el-dialog :title="formModifyPassword.typeName" :visible.sync="dialogModifyPasswordVisible" width="50%">
-      <el-form ref="form" :model="formModifyPassword" label-width="120px" class="form-dialog">
-        <el-form-item label="类型">
-          <el-select v-model="formModifyPassword.passwordType" placeholder="请选择类型">
-            <el-option v-for="(item,key) in passwordType" :label="item.label" :value="item.type"
-                       :key="key"></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="密码">
-          <el-input placeholder="密码" v-model="formModifyPassword.password">
-          </el-input>
-        </el-form-item>
-        <!--<el-form-item label="备注">-->
-          <!--<el-input type="text" :rows="2" placeholder="备注" v-model="formModifyPassword.remark">-->
-          <!--</el-input>-->
-        <!--</el-form-item>-->
-        <el-form-item>
-          <el-button type="primary" @click="handleModifyPasswordSubmit" :loading="submitPasswordButtonStat">提交</el-button>
-        </el-form-item>
-      </el-form>
-    </el-dialog>
-
-    <el-dialog :title="formModifyProfile.typeName" :visible.sync="dialogModifyProfileVisible" width="50%">
-      <el-form ref="form" :model="formModifyProfile" label-width="120px" class="form-dialog">
-        <el-form-item label="民族">
-          <el-select v-model="formModifyProfile.nation" placeholder="请选择民族">
-            <el-option v-for="(item,index) in allNation" :key="index" :label="item.name"
-                       :value="item.id"></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="会员姓名">
-          <el-input v-model="formModifyProfile.realName"></el-input>
-        </el-form-item>
-        <el-form-item label="身份证号">
-          <el-input v-model="formModifyProfile.idCard"></el-input>
-        </el-form-item>
-        <el-form-item label="手机号">
-          <el-input v-model="formModifyProfile.mobile"></el-input>
-        </el-form-item>
-        <el-form-item label="银行名称">
-          <el-select v-model="formModifyProfile.openBank" placeholder="请选择银行名称">
-            <el-option v-for="(item,index) in allOpenBank" :key="index" :label="item.BANK_NAME"
-                       :value="item.BANK_CODE"></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="开户行地址">
-          <el-input v-model="formModifyProfile.bankAddress"></el-input>
-        </el-form-item>
-        <el-form-item label="银行帐号">
-          <el-input v-model="formModifyProfile.bankNo"></el-input>
-        </el-form-item>
-        <el-form-item>
-          <el-button type="primary" @click="handleModifyProfileSubmit" :loading="submitProfileButtonStat">提交</el-button>
-        </el-form-item>
-      </el-form>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-  import network from './../../utils/network'
-  import tool from './../../utils/tool'
-  import {FRONTEND_SERVER} from '@/utils/config'
-  import baseInfo from '@/utils/baseInfo'
-  import FilterUser from '../../components/FilterUser'
-  import store from './../../utils/vuexStore'
-  import permission from '@/utils/permission'
-  import Pagination from '@/components/Pagination'
-  import filterHelper from '../../utils/filterHelper'
-
-  export default {
-    name: 'user_index',
-    components: {FilterUser, Pagination},
-    mounted() {
-      let _this = this
-      if (permission.hasPermission(`user/close-login`) || permission.hasPermission(`user/close-area-login`) || permission.hasPermission(`user/batch-close-login`)) {
-        network.getData('user/close-login-get').then(response => {
-          _this.apps = response.apps
-          _this.closeSwitch = response.closeSwitch
-          if (permission.hasPermission(`user/close-dec`) || permission.hasPermission(`user/close-area-dec`) || permission.hasPermission(`user/batch-close-dec`)) {
-            network.getData('user/close-dec-get').then(response => {
-              _this.closeDecSwitch = response.closeSwitch
-              _this.getData()
-            }).catch(error => {
-            })
-          } else {
-            _this.getData()
-          }
-        }).catch(error => {
-        })
-      } else {
-        if (permission.hasPermission(`user/close-dec`) || permission.hasPermission(`user/close-area-dec`) || permission.hasPermission(`user/batch-close-dec`)) {
-          network.getData('user/close-dec-get').then(response => {
-            _this.closeDecSwitch = response.closeSwitch
-            _this.getData()
-          }).catch(error => {
-          })
-        } else {
-          _this.getData()
-        }
-      }
-      store.state.socket.onMessageCallback = this.onMessageCallback
-    },
-    data() {
-      return {
-        tableHeaders: null,
-        tableData: null,
-        loading: true,
-        multipleSelection: [],
-        currentPage: 1,
-        totalPages: 1,
-        totalCount: 1,
-        pageSize: 20,
-        frontendServer: FRONTEND_SERVER,
-        baseDecLevels: baseInfo.decLevels(),
-        baseEmpLevels: baseInfo.empLevels(),
-        tool: tool,
-        permission: permission,
-        filterTypes: null,
-        filterModel: {},
-        dialogVisible: false,
-        formCloseLogin: {
-          userName: null,
-          typeName: '登录管理',
-          type: null,
-          isClose: 0,
-          remark: '',
-          areaSelected: null,
-        },
-        regionDataPlus: store.state.regionInfo.regionData,
-        apps: null,
-        closeSwitch: null,
-        submitButtonStat: false,
-        dialogDecVisible: false,
-        dialogModifyPasswordVisible: false,
-        dialogModifyProfileVisible: false,
-        formCloseDec: {
-          userName: null,
-          typeName: '管理报单',
-          type: null,
-          isClose: 0,
-          remark: '',
-          areaSelected: null,
-        },
-        formModifyPassword: {
-            userId:'',
-            password: '',
-            typeName: '修改密码',
-            passwordType: 'password',
-            // remark: '',
-        },
-        formModifyProfile: {
-            userId:'',
-            typeName: '修改个人资料',
-            nation: '',
-            realName: '',
-            idCard: '',
-            mobile: '',
-            openBank: '',
-            bankAddress: '',
-            bankNo: '',
-        },
-        passwordType: [
-            {
-                type:"password",
-                label:"登录密码"
-            },
-            {
-                type:"payPassword",
-                label:"支付密码"
-            },
-        ],
-        allOpenBank:null,
-        allNation:null,
-        submitDecButtonStat: false,
-        submitPasswordButtonStat: false,
-        submitProfileButtonStat: false,
-        transferPropForm: {
-          userIds: [],
-          allowTransfer: true,
-          transferProp: 100,
-          withdrawProp: 0,
-          remark: '',
-        },
-        closeUserData: null,
-      }
-    },
-    methods: {
+<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 ref="wrapper" :data="tableData" stripe style="width: 100%;" @selection-change="handleSelectionChange"
+                :height="tool.getTableHeight()">
+        <el-table-column fixed type="selection" width="55" v-if="tableHeaders"></el-table-column>
+        <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header"
+                         :width="tableHeader.other.width ? tableHeader.other.width : ''" :fixed="tableHeader.index=='USER_NAME' || tableHeader.index=='REAL_NAME' ?true:false">
+          <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>
+              <template v-if="tableHeader.index === 'USER_NAME'">
+                <el-dropdown v-if="permission.hasPermission(`user/login-to-frontend`)">
+  <span class="el-dropdown-link">
+    {{scope.row.USER_NAME.value}} <i class="el-icon-arrow-down el-icon--right"></i>
+  </span>
+                  <el-dropdown-menu slot="dropdown">
+                    <el-dropdown-item command="login" v-show="scope.row.BTF_URL !== null">
+                      <a :href="`${frontendServer}/#/login-by-backend?${scope.row.BTF_URL}`" target="_blank"
+                         style="color:#606266;">快速登录</a>
+                    </el-dropdown-item>
+                  </el-dropdown-menu>
+                </el-dropdown>
+                <el-tag type="primary" size="small" class="no-border"
+                        v-if="!permission.hasPermission(`user/login-to-frontend`)">{{scope.row.USER_NAME.value}}
+                </el-tag>
+              </template>
+              <template v-else>
+                <div v-html="scope.row[tableHeader.index].value"></div>
+              </template>
+            </template>
+          </template>
+        </el-table-column>
+        <el-table-column fixed="right" label="操作" width="180">
+          <template slot-scope="scope">
+            <el-dropdown size="small" trigger="click">
+              <el-button type="primary" size="small" @click.stop="">
+                操作该数据<i class="el-icon-arrow-down el-icon--right"></i>
+              </el-button>
+              <el-dropdown-menu slot="dropdown">
+                <el-dropdown-item @click.native="handleModifyPassword(scope.row)"
+                                  v-if="permission.hasPermission(`user/modify-password`)">修改密码
+                </el-dropdown-item>
+                <el-dropdown-item @click.native="handleModifyProfile(scope.row)"
+                                  v-if="permission.hasPermission(`user/modify-profile`)">修改个人资料
+                </el-dropdown-item>
+                <el-dropdown-item @click.native="handleStatusActive(scope.row)" v-if="permission.hasPermission(`user/modify-status`)">状态激活 </el-dropdown-item>
+                <el-dropdown-item @click.native="handleStatusLock(scope.row)" v-if="permission.hasPermission(`user/modify-status`)">状态锁定 </el-dropdown-item>
+                <el-dropdown-item @click.native="handleIsModifyPassword(scope.row, 1)" v-if="permission.hasPermission(`user/is-modify-password-status`)">开启密码修改</el-dropdown-item>
+                <el-dropdown-item @click.native="handleIsModifyPassword(scope.row, 0)" v-if="permission.hasPermission(`user/is-modify-password-status`)">关闭密码修改</el-dropdown-item>
+              </el-dropdown-menu>
+            </el-dropdown>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="white-box-footer">
+        <!--<el-dropdown size="small" trigger="click"-->
+                     <!--v-show="permission.hasPermission(`user/close-login`)||permission.hasPermission(`user/close-area-login`)||permission.hasPermission(`user/batch-close-login`)">-->
+          <!--<el-button type="primary" size="small" @click.stop="">-->
+            <!--登录管理<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
+          <!--</el-button>-->
+          <!--<el-dropdown-menu slot="dropdown">-->
+            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(1)"-->
+                              <!--v-show="permission.hasPermission(`user/batch-close-login`)">按指定会员管理登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(2)"-->
+                              <!--v-show="permission.hasPermission(`user/close-login`)">按开拓网络管理登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(3)"-->
+                              <!--v-show="permission.hasPermission(`user/close-login`)">按安置网络管理登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(4)"-->
+                              <!--v-show="permission.hasPermission(`user/close-login`)">按会员体系管理登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeLogin" @click.native="handleLoginManage(5)"-->
+                              <!--v-show="permission.hasPermission(`user/close-area-login`)">按省份地区管理登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeLogin" @click.native="handleCloseLogin(1, 1)" v-show="false">禁止商城系统登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="allowLogin" @click.native="handleCloseLogin(0, 1)" v-show="false">允许商城系统登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeLogin" @click.native="handleCloseLogin(1, 2)" v-show="false">禁止结算系统登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="allowLogin" @click.native="handleCloseLogin(0, 2)" v-show="false">允许结算系统登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeLogin" @click.native="handleCloseLogin(1, 3)" v-show="false">全部禁止登录-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="allowLogin" @click.native="handleCloseLogin(0, 3)" v-show="false">全部允许登录-->
+            <!--</el-dropdown-item>-->
+          <!--</el-dropdown-menu>-->
+        <!--</el-dropdown>-->
+        <!--<el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-group`)">-->
+          <!--<el-button type="primary" size="small" @click.stop="">-->
+            <!--团队管理<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
+          <!--</el-button>-->
+          <!--<el-dropdown-menu slot="dropdown">-->
+            <!--<el-dropdown-item command="isGroup" @click.native="handleGroupManage(true)">设为团队领导人</el-dropdown-item>-->
+            <!--<el-dropdown-item command="notGroup" @click.native="handleGroupManage(false)">取消团队领导人-->
+            <!--</el-dropdown-item>-->
+          <!--</el-dropdown-menu>-->
+        <!--</el-dropdown>-->
+        <el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-dec`)">
+          <el-button type="primary" size="small" @click.stop="">
+            报单中心管理<i class="el-icon-arrow-down el-icon--right"></i>
+          </el-button>
+          <el-dropdown-menu slot="dropdown">
+            <el-dropdown-item command="isDec" @click.native="handleIsDecManage(true)">设为报单中心</el-dropdown-item>
+            <el-dropdown-item command="notDec" @click.native="handleIsDecManage(false)">取消报单中心
+            </el-dropdown-item>
+          </el-dropdown-menu>
+        </el-dropdown>
+
+        <el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-studio`)">
+          <el-button type="primary" size="small" @click.stop="">
+            工作室管理<i class="el-icon-arrow-down el-icon--right"></i>
+          </el-button>
+          <el-dropdown-menu slot="dropdown">
+            <el-dropdown-item command="isStudio" @click.native="handleIsStudioManage(true)">设为工作室</el-dropdown-item>
+            <el-dropdown-item command="notStudio" @click.native="handleIsStudioManage(false)">取消工作室
+            </el-dropdown-item>
+          </el-dropdown-menu>
+        </el-dropdown>
+
+        <el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-atlas`)">
+          <el-button type="primary" size="small" @click.stop="">
+            图谱管理<i class="el-icon-arrow-down el-icon--right"></i>
+          </el-button>
+          <el-dropdown-menu slot="dropdown">
+            <el-dropdown-item command="isAtlas" @click.native="handleIsAtlasManage(true)">显示图谱</el-dropdown-item>
+            <el-dropdown-item command="notAtlas" @click.native="handleIsAtlasManage(false)">隐藏图谱
+            </el-dropdown-item>
+          </el-dropdown-menu>
+        </el-dropdown>
+
+        <el-dropdown size="small" trigger="click" v-show="permission.hasPermission(`user/is-recharge`)">
+          <el-button type="primary" size="small" @click.stop="">
+            充值管理<i class="el-icon-arrow-down el-icon--right"></i>
+          </el-button>
+          <el-dropdown-menu slot="dropdown">
+            <el-dropdown-item command="isAtlas" @click.native="handleIsRechargeManage(true)">显示充值</el-dropdown-item>
+            <el-dropdown-item command="notAtlas" @click.native="handleIsRechargeManage(false)">隐藏充值
+            </el-dropdown-item>
+          </el-dropdown-menu>
+        </el-dropdown>
+        <!--<el-dropdown size="small" trigger="click"-->
+                     <!--v-show="permission.hasPermission(`user/close-dec`)||permission.hasPermission(`user/close-area-dec`)||permission.hasPermission(`user/batch-close-dec`)">-->
+          <!--<el-button type="primary" size="small" @click.stop="">-->
+            <!--报单管理<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
+          <!--</el-button>-->
+          <!--<el-dropdown-menu slot="dropdown">-->
+            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(1)"-->
+                              <!--v-show="permission.hasPermission(`user/batch-close-dec`)">按指定会员管理报单-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(2)"-->
+                              <!--v-show="permission.hasPermission(`user/close-dec`)">按开拓网络管理报单-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(3)"-->
+                              <!--v-show="permission.hasPermission(`user/close-dec`)">按安置网络管理报单-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(4)"-->
+                              <!--v-show="permission.hasPermission(`user/close-dec`)">按会员体系管理报单-->
+            <!--</el-dropdown-item>-->
+            <!--<el-dropdown-item command="closeDec" @click.native="handleDecManage(5)"-->
+                              <!--v-show="permission.hasPermission(`user/close-area-dec`)">按省份地区管理报单-->
+            <!--</el-dropdown-item>-->
+          <!--</el-dropdown-menu>-->
+        <!--</el-dropdown>-->
+        <el-button type="success" size="small" @click="handleExport"
+                   v-show="permission.hasPermission(`user/index-export`)">导出Excel
+        </el-button>
+        <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange"
+                    @current-change="handleCurrentChange"></pagination>
+      </div>
+    </div>
+    <el-dialog :title="formModifyPassword.typeName" :visible.sync="dialogModifyPasswordVisible" width="50%">
+      <el-form ref="form" :model="formModifyPassword" label-width="120px" class="form-dialog">
+        <el-form-item label="类型">
+          <el-select v-model="formModifyPassword.passwordType" placeholder="请选择类型">
+            <el-option v-for="(item,key) in passwordType" :label="item.label" :value="item.type"
+                       :key="key"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="密码">
+          <el-input placeholder="密码" v-model="formModifyPassword.password">
+          </el-input>
+        </el-form-item>
+        <!--<el-form-item label="备注">-->
+          <!--<el-input type="text" :rows="2" placeholder="备注" v-model="formModifyPassword.remark">-->
+          <!--</el-input>-->
+        <!--</el-form-item>-->
+        <el-form-item>
+          <el-button type="primary" @click="handleModifyPasswordSubmit" :loading="submitPasswordButtonStat">提交</el-button>
+        </el-form-item>
+      </el-form>
+    </el-dialog>
+
+    <el-dialog :title="formModifyProfile.typeName" :visible.sync="dialogModifyProfileVisible" width="50%">
+      <el-form ref="form" :model="formModifyProfile" label-width="120px" class="form-dialog">
+        <el-form-item label="民族">
+          <el-select v-model="formModifyProfile.nation" placeholder="请选择民族">
+            <el-option v-for="(item,index) in allNation" :key="index" :label="item.name"
+                       :value="item.id"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="会员姓名">
+          <el-input v-model="formModifyProfile.realName"></el-input>
+        </el-form-item>
+        <el-form-item label="身份证号">
+          <el-input v-model="formModifyProfile.idCard"></el-input>
+        </el-form-item>
+        <el-form-item label="手机号">
+          <el-input v-model="formModifyProfile.mobile"></el-input>
+        </el-form-item>
+        <el-form-item label="银行名称">
+          <el-select v-model="formModifyProfile.openBank" placeholder="请选择银行名称">
+            <el-option v-for="(item,index) in allOpenBank" :key="index" :label="item.BANK_NAME"
+                       :value="item.BANK_CODE"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="开户行地址">
+          <el-input v-model="formModifyProfile.bankAddress"></el-input>
+        </el-form-item>
+        <el-form-item label="银行帐号">
+          <el-input v-model="formModifyProfile.bankNo"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="handleModifyProfileSubmit" :loading="submitProfileButtonStat">提交</el-button>
+        </el-form-item>
+      </el-form>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import network from './../../utils/network'
+  import tool from './../../utils/tool'
+  import {FRONTEND_SERVER} from '@/utils/config'
+  import baseInfo from '@/utils/baseInfo'
+  import FilterUser from '../../components/FilterUser'
+  import store from './../../utils/vuexStore'
+  import permission from '@/utils/permission'
+  import Pagination from '@/components/Pagination'
+  import filterHelper from '../../utils/filterHelper'
+
+  export default {
+    name: 'user_index',
+    components: {FilterUser, Pagination},
+    mounted() {
+      let _this = this
+      if (permission.hasPermission(`user/close-login`) || permission.hasPermission(`user/close-area-login`) || permission.hasPermission(`user/batch-close-login`)) {
+        network.getData('user/close-login-get').then(response => {
+          _this.apps = response.apps
+          _this.closeSwitch = response.closeSwitch
+          if (permission.hasPermission(`user/close-dec`) || permission.hasPermission(`user/close-area-dec`) || permission.hasPermission(`user/batch-close-dec`)) {
+            network.getData('user/close-dec-get').then(response => {
+              _this.closeDecSwitch = response.closeSwitch
+              _this.getData()
+            }).catch(error => {
+            })
+          } else {
+            _this.getData()
+          }
+        }).catch(error => {
+        })
+      } else {
+        if (permission.hasPermission(`user/close-dec`) || permission.hasPermission(`user/close-area-dec`) || permission.hasPermission(`user/batch-close-dec`)) {
+          network.getData('user/close-dec-get').then(response => {
+            _this.closeDecSwitch = response.closeSwitch
+            _this.getData()
+          }).catch(error => {
+          })
+        } else {
+          _this.getData()
+        }
+      }
+      store.state.socket.onMessageCallback = this.onMessageCallback
+    },
+    data() {
+      return {
+        tableHeaders: null,
+        tableData: null,
+        loading: true,
+        multipleSelection: [],
+        currentPage: 1,
+        totalPages: 1,
+        totalCount: 1,
+        pageSize: 20,
+        frontendServer: FRONTEND_SERVER,
+        baseDecLevels: baseInfo.decLevels(),
+        baseEmpLevels: baseInfo.empLevels(),
+        tool: tool,
+        permission: permission,
+        filterTypes: null,
+        filterModel: {},
+        dialogVisible: false,
+        formCloseLogin: {
+          userName: null,
+          typeName: '登录管理',
+          type: null,
+          isClose: 0,
+          remark: '',
+          areaSelected: null,
+        },
+        regionDataPlus: store.state.regionInfo.regionData,
+        apps: null,
+        closeSwitch: null,
+        submitButtonStat: false,
+        dialogDecVisible: false,
+        dialogModifyPasswordVisible: false,
+        dialogModifyProfileVisible: false,
+        formCloseDec: {
+          userName: null,
+          typeName: '管理报单',
+          type: null,
+          isClose: 0,
+          remark: '',
+          areaSelected: null,
+        },
+        formModifyPassword: {
+            userId:'',
+            password: '',
+            typeName: '修改密码',
+            passwordType: 'password',
+            // remark: '',
+        },
+        formModifyProfile: {
+            userId:'',
+            typeName: '修改个人资料',
+            nation: '',
+            realName: '',
+            idCard: '',
+            mobile: '',
+            openBank: '',
+            bankAddress: '',
+            bankNo: '',
+        },
+        passwordType: [
+            {
+                type:"password",
+                label:"登录密码"
+            },
+            {
+                type:"payPassword",
+                label:"支付密码"
+            },
+        ],
+        allOpenBank:null,
+        allNation:null,
+        submitDecButtonStat: false,
+        submitPasswordButtonStat: false,
+        submitProfileButtonStat: false,
+        transferPropForm: {
+          userIds: [],
+          allowTransfer: true,
+          transferProp: 100,
+          withdrawProp: 0,
+          remark: '',
+        },
+        closeUserData: null,
+      }
+    },
+    methods: {
       handleSelectionChange(val) {
-        this.multipleSelection = val
-      },
-      handleCurrentChange(page) {
-        this.getData(page, this.pageSize)
-      },
-      handleSizeChange(pageSize) {
-        this.getData(this.currentPage, pageSize)
-      },
-      handleAdd() {
-        this.$router.push('/user/user-add')
-      },
-      handleFilterUser(filterData) {
-        filterHelper.handleFilterUser(this, filterData)
-      },
-      handleFilter() {
-        this.getData()
-      },
-      getData(page, pageSize, isLoading = true) {
+
+        this.multipleSelection = val
+      },
+      handleCurrentChange(page) {
+        this.getData(page, this.pageSize)
+      },
+      handleSizeChange(pageSize) {
+        this.getData(this.currentPage, pageSize)
+      },
+      handleAdd() {
+        this.$router.push('/user/user-add')
+      },
+      handleFilterUser(filterData) {
+        filterHelper.handleFilterUser(this, filterData)
+      },
+      handleFilter() {
+        this.getData()
+      },
+      getData(page, pageSize, isLoading = true) {
         network.getPageData(this, 'user/index', page, pageSize, this.filterModel, response => {
-          this.filterTypes = response.filterTypes
-        }, isLoading)
-      },
-      handleGroupManage(isGroup) {
-        if (this.multipleSelection.length < 1) {
-          this.$message({
-            message: '请勾选要操作的会员',
-            type: 'warning'
-          })
-          return
-        }
-        let groupTip = isGroup === true ? '设为团队领导人' : '取消团队领导人'
-        this.$confirm(`确定要对所选会员【${groupTip}】吗?`, '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          let selectedIds = []
-          for (let val of this.multipleSelection) {
-            selectedIds.push(val.USER_ID)
-          }
-          return network.postData(`user/is-group`, {userIds: selectedIds, isGroup: isGroup})
-        }).then(response => {
-          this.$message({
-            message: response,
-            type: 'success'
-          })
-          this.getData(this.currentPage, this.pageSize)
-        }).catch(response => {
-
-        })
-      },
-      handleIsDecManage(isDec) {
-          if (this.multipleSelection.length < 1) {
-              this.$message({
-                  message: '请勾选要操作的会员',
-                  type: 'warning'
-              })
-              return
-          }
-          let isDecTip = isDec === true ? '设为报单中心' : '取消报单中心'
-          this.$confirm(`确定要对所选会员【${isDecTip}】吗?`, '提示', {
-              confirmButtonText: '确定',
-              cancelButtonText: '取消',
-              type: 'warning'
-          }).then(() => {
-              let selectedIds = []
-              for (let val of this.multipleSelection) {
-                  selectedIds.push(val.USER_ID)
-              }
-              return network.postData(`user/is-dec`, {userIds: selectedIds, isDec: isDec})
-          }).then(response => {
-              this.$message({
-                  message: response,
-                  type: 'success'
-              })
-              this.getData(this.currentPage, this.pageSize)
-          }).catch(response => {
-
-          })
-      },
-        handleIsStudioManage(isStudio) {
-            if (this.multipleSelection.length < 1) {
-                this.$message({
-                    message: '请勾选要操作的会员',
-                    type: 'warning'
-                })
-                return
-            }
-            let isStudioTip = isStudio === true ? '设为工作室' : '取消工作室'
-            this.$confirm(`确定要对所选会员【${isStudioTip}】吗?`, '提示', {
-                confirmButtonText: '确定',
-                cancelButtonText: '取消',
-                type: 'warning'
-            }).then(() => {
-                let selectedIds = []
-                for (let val of this.multipleSelection) {
-                    selectedIds.push(val.USER_ID)
-                }
-                return network.postData(`user/is-studio`, {userIds: selectedIds, isStudio: isStudio})
-            }).then(response => {
-                this.$message({
-                    message: response,
-                    type: 'success'
-                })
-                this.getData(this.currentPage, this.pageSize)
-            }).catch(response => {
-
-            })
-        },
-        handleIsAtlasManage(isAtlas) {
-            if (this.multipleSelection.length < 1) {
-                this.$message({
-                    message: '请勾选要操作的会员',
-                    type: 'warning'
-                })
-                return
-            }
-            let isAtlasTip = isAtlas === true ? '显示图谱' : '隐藏图谱'
-            this.$confirm(`确定要对所选会员【${isAtlasTip}】吗?`, '提示', {
-                confirmButtonText: '确定',
-                cancelButtonText: '取消',
-                type: 'warning'
-            }).then(() => {
-                let selectedIds = []
-                for (let val of this.multipleSelection) {
-                    selectedIds.push(val.USER_ID)
-                }
-                return network.postData(`user/is-atlas`, {userIds: selectedIds, isAtlas: isAtlas})
-            }).then(response => {
-                this.$message({
-                    message: response,
-                    type: 'success'
-                })
-                this.getData(this.currentPage, this.pageSize)
-            }).catch(response => {
-
-            })
-        },
-        handleIsRechargeManage(isRecharge) {
-            if (this.multipleSelection.length < 1) {
-                this.$message({
-                    message: '请勾选要操作的会员',
-                    type: 'warning'
-                })
-                return
-            }
-            let isRechargeTip = isRecharge === true ? '显示充值' : '隐藏充值'
-            this.$confirm(`确定要对所选会员【${isRechargeTip}】吗?`, '提示', {
-                confirmButtonText: '确定',
-                cancelButtonText: '取消',
-                type: 'warning'
-            }).then(() => {
-                let selectedIds = []
-                for (let val of this.multipleSelection) {
-                    selectedIds.push(val.USER_ID)
-                }
-                return network.postData(`user/is-recharge`, {userIds: selectedIds, isRecharge: isRecharge})
-            }).then(response => {
-                this.$message({
-                    message: response,
-                    type: 'success'
-                })
-                this.getData(this.currentPage, this.pageSize)
-            }).catch(response => {
-
-            })
-        },
-      getTypeName(type) {
-        switch (type) {
-          case 1:
-            return '按指定会员'
-          case 2:
-            return '按开拓网络'
-          case 3:
-            return '按安置网络'
-          case 4:
-            return '按会员体系'
-          case 5:
-            return '按省份地区'
-          default:
-            return ''
-        }
-      },
-      handleLoginManage(type) {
-        if (type === 2 || type === 3 || type === 4) {
-          if (this.multipleSelection.length > 1) {
-            this.$message({
-              message: '此登录管理不允许勾选多名会员',
-              type: 'warning'
-            })
-            return;
-          } else if (this.multipleSelection.length < 1) {
-            this.$message({
-              message: '请选择会员编号',
-              type: 'warning'
-            })
-            return;
-          }
-        }
-        if (type === 1 && this.multipleSelection.length <= 0) {
-          this.$message({
-            message: '请选择会员编号',
-            type: 'warning'
-          })
-          return;
-        }
-        if (type === 5 && this.multipleSelection.length > 0) {
-          this.$message({
-            message: '按照地区关闭登录无需勾选会员',
-            type: 'warning'
-          })
-          return;
-        }
-        this.formCloseLogin = {
-          userName: null,
-          typeName: '登录管理',
-          type: null,
-          isClose: 0,
-          remark: '',
-          areaSelected: null,
-        },
-          this.formCloseLogin.typeName = this.getTypeName(type) + '管理登录'
-        this.formCloseLogin.type = type
-        this.dialogVisible = true
-      },
-      handleCloseLoginSubmit() {
-        this.submitButtonStat = true
-        // 获取所购选的会员,如果是批量关闭指定会员,则走批量关闭方法
-        if (this.formCloseLogin.type === 1) {
-          this.handleCloseLogin(this.formCloseLogin.isClose, this.formCloseLogin.remark)
-        } else {
-          for (let val of this.multipleSelection) {
-            this.formCloseLogin.userName = val.USER_NAME.value
-          }
-          let path = 'user/close-login'
-          if (this.formCloseLogin.type === 5) {
-            path = 'user/close-area-login'
-          }
-          network.postData(path, this.formCloseLogin).then(response => {
-            this.$message({
-              message: response,
-              type: 'success'
-            })
-            this.getData(this.currentPage, this.pageSize)
-            this.submitButtonStat = false
-            this.dialogVisible = false
-          }).catch(response => {
-            this.submitButtonStat = false
-          })
-        }
-      },
-      handleCloseLogin(isClose, remark = '') {
-        let selectedIds = []
-        for (let val of this.multipleSelection) {
-          selectedIds.push(val.USER_ID)
-        }
-        console.log(selectedIds);
-        network.postData(`user/batch-close-login`, {
-          userIds: selectedIds,
-          isClose: isClose,
-          remark: remark,
-          type: 1,
-        }).then(response => {
-          this.$message({
-            message: response,
-            type: 'success'
-          })
-          this.getData(this.currentPage, this.pageSize)
-          this.submitButtonStat = false
-          this.dialogVisible = false
-        }).catch(response => {
-          this.submitButtonStat = false
-        })
-        // let tipStr = isClose ? '禁止' : '允许'
-        // this.$confirm(`确定要${tipStr}所选会员登录?`, '提示', {
-        //   confirmButtonText: '确定',
-        //   cancelButtonText: '取消',
-        //   type: 'warning'
-        // }).then(() => {
-        //   return network.postData(`user/batch-close-login`, {userIds: selectedIds, isClose: isClose})
-        // }).then(response => {
-        //   this.$message({
-        //     message: response,
-        //     type: 'success'
-        //   })
-        //   this.getData(this.currentPage, this.pageSize)
-        // }).catch(response => {
-        //
-        // })
-      },
-      handleExport() {
-        this.$confirm(`确定要导出当前数据吗?`, '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          return network.getData(`user/index-export`, this.filterModel)
-        }).then(response => {
-          this.$message({
-            message: response,
-            type: 'success'
-          })
-        }).catch(response => {
-
-        })
-      },
-      onMessageCallback(data) {
-        //this.getData(this.currentPage, this.pageSize, false)
-      },
-      handleDecManage(type) {
-        if (type === 2 || type === 3 || type === 4) {
-          if (this.multipleSelection.length > 1) {
-            this.$message({
-              message: '此报单管理不允许勾选多名会员',
-              type: 'warning'
-            })
-            return;
-          } else if (this.multipleSelection.length < 1) {
-            this.$message({
-              message: '请勾选要管理报单的会员',
-              type: 'warning'
-            })
-            return;
-          }
-        }
-        if (type === 1 && this.multipleSelection.length <= 0) {
-          this.$message({
-            message: '请勾选要管理报单的会员',
-            type: 'warning'
-          })
-          return;
-        }
-        if (type === 5 && this.multipleSelection.length > 0) {
-          this.$message({
-            message: '按照地区关闭报单无需勾选会员',
-            type: 'warning'
-          })
-          return;
-        }
-        this.formCloseDec = {
-          userName: null,
-          typeName: '管理报单',
-          type: null,
-          isClose: 0,
-          remark: '',
-          areaSelected: null,
-        },
-          this.formCloseDec.typeName = this.getTypeName(type) + '管理报单'
-        this.formCloseDec.type = type
-        this.dialogDecVisible = true
-      },
-      handleModifyPassword(row){
-        this.formModifyPassword.userId = row.USER_ID;
-        this.dialogModifyPasswordVisible = true
-      },
-      handleModifyProfile(row){
-          this.dialogModifyProfileVisible = true
-          let vueObj = this
-          network.getData('user/profile-get', {id: row.USER_ID}).then(response => {
-              vueObj.formModifyProfile = response.userInfo
-              vueObj.allOpenBank = response.allOpenBank
-              vueObj.allNation = response.allNation
-          })
-      },
-      handleCloseDecSubmit() {
-        this.submitDecButtonStat = true
-        // 获取所购选的会员,如果是批量关闭指定会员,则走批量关闭方法
-        if (this.formCloseDec.type === 1) {
-          this.handleCloseDec(this.formCloseDec.isClose, this.formCloseDec.remark)
-        } else {
-          for (let val of this.multipleSelection) {
-            this.formCloseDec.userName = val.USER_NAME.value
-          }
-          let path = 'user/close-dec'
-          if (this.formCloseDec.type === 5) {
-            path = 'user/close-area-dec'
-          }
-          network.postData(path, this.formCloseDec).then(response => {
-            this.$message({
-              message: response,
-              type: 'success'
-            })
-            this.getData(this.currentPage, this.pageSize)
-            this.submitDecButtonStat = false
-            this.dialogDecVisible = false
-          }).catch(response => {
-            this.submitDecButtonStat = false
-          })
-        }
-      },
-      handleCloseDec(isClose, remark = '') {
-        let selectedIds = []
-        for (let val of this.multipleSelection) {
-          selectedIds.push(val.USER_ID)
-        }
-        network.postData(`user/batch-close-dec`, {
-          userIds: selectedIds,
-          isClose: isClose,
-          remark: remark,
-          type: 1,
-        }).then(response => {
-          this.$message({
-            message: response,
-            type: 'success'
-          })
-          this.getData(this.currentPage, this.pageSize)
-          this.submitDecButtonStat = false
-          this.dialogDecVisible = false
-        }).catch(response => {
-          this.submitDecButtonStat = false
-        })
-      },
-        handleStatusActive(row){
-            network.postData('user/modify-status',{userId:row.USER_ID,status:1}).then(response=>{
-                    this.$message({
-                        message: response,
-                        type: 'success'
-                    })
-                    this.getData(this.currentPage, this.pageSize)
-                })
-        },
-        handleStatusLock(row){
-            network.postData('user/modify-status',{userId:row.USER_ID,status:0}).then(response=>{
-                    this.$message({
-                        message: response,
-                        type: 'success'
-                    })
-                    this.getData(this.currentPage, this.pageSize)
-                })
-        },
-        handleIsModifyPassword(row, status){
-          network.postData('user/is-modify-password-status',{userId:row.USER_ID,status:status}).then(response=>{
-            this.$message({
-              message: response,
-              type: 'success'
-            })
-            this.getData(this.currentPage, this.pageSize)
-          })
-        },
-      handleModifyPasswordSubmit() {
-            this.submitPasswordButtonStat = true
-              let path = 'user/modify-password'
-              network.postData(path, this.formModifyPassword).then(response => {
-                  this.$message({
-                      message: response,
-                      type: 'success'
-                  })
-                  this.getData(this.currentPage, this.pageSize)
-                  this.submitPasswordButtonStat = false
-                  this.dialogModifyPasswordVisible = false
-              }).catch(response => {
-                  this.submitPasswordButtonStat = false
-              })
-        },
-        handleModifyProfileSubmit() {
-            this.submitProfileButtonStat = true
-            let path = 'user/modify-profile'
-            network.postData(path, this.formModifyProfile).then(response => {
-                this.$message({
-                    message: response,
-                    type: 'success'
-                })
-                this.getData(this.currentPage, this.pageSize)
-                this.submitProfileButtonStat = false
-                this.dialogModifyProfileVisible = false
-            }).catch(response => {
-                this.submitProfileButtonStat = false
-            })
-        },
-    }
-  }
-
-</script>
-
+          console.log(response.filterTypes);
+          this.filterTypes = response.filterTypes
+        }, isLoading)
+      },
+      handleGroupManage(isGroup) {
+        if (this.multipleSelection.length < 1) {
+          this.$message({
+            message: '请勾选要操作的会员',
+            type: 'warning'
+          })
+          return
+        }
+        let groupTip = isGroup === true ? '设为团队领导人' : '取消团队领导人'
+        this.$confirm(`确定要对所选会员【${groupTip}】吗?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          let selectedIds = []
+          for (let val of this.multipleSelection) {
+            selectedIds.push(val.USER_ID)
+          }
+          return network.postData(`user/is-group`, {userIds: selectedIds, isGroup: isGroup})
+        }).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.getData(this.currentPage, this.pageSize)
+        }).catch(response => {
+
+        })
+      },
+      handleIsDecManage(isDec) {
+          if (this.multipleSelection.length < 1) {
+              this.$message({
+                  message: '请勾选要操作的会员',
+                  type: 'warning'
+              })
+              return
+          }
+          let isDecTip = isDec === true ? '设为报单中心' : '取消报单中心'
+          this.$confirm(`确定要对所选会员【${isDecTip}】吗?`, '提示', {
+              confirmButtonText: '确定',
+              cancelButtonText: '取消',
+              type: 'warning'
+          }).then(() => {
+              let selectedIds = []
+              for (let val of this.multipleSelection) {
+                  selectedIds.push(val.USER_ID)
+              }
+              return network.postData(`user/is-dec`, {userIds: selectedIds, isDec: isDec})
+          }).then(response => {
+              this.$message({
+                  message: response,
+                  type: 'success'
+              })
+              this.getData(this.currentPage, this.pageSize)
+          }).catch(response => {
+
+          })
+      },
+        handleIsStudioManage(isStudio) {
+            if (this.multipleSelection.length < 1) {
+                this.$message({
+                    message: '请勾选要操作的会员',
+                    type: 'warning'
+                })
+                return
+            }
+            let isStudioTip = isStudio === true ? '设为工作室' : '取消工作室'
+            this.$confirm(`确定要对所选会员【${isStudioTip}】吗?`, '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                let selectedIds = []
+                for (let val of this.multipleSelection) {
+                    selectedIds.push(val.USER_ID)
+                }
+                return network.postData(`user/is-studio`, {userIds: selectedIds, isStudio: isStudio})
+            }).then(response => {
+                this.$message({
+                    message: response,
+                    type: 'success'
+                })
+                this.getData(this.currentPage, this.pageSize)
+            }).catch(response => {
+
+            })
+        },
+        handleIsAtlasManage(isAtlas) {
+            if (this.multipleSelection.length < 1) {
+                this.$message({
+                    message: '请勾选要操作的会员',
+                    type: 'warning'
+                })
+                return
+            }
+            let isAtlasTip = isAtlas === true ? '显示图谱' : '隐藏图谱'
+            this.$confirm(`确定要对所选会员【${isAtlasTip}】吗?`, '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                let selectedIds = []
+                for (let val of this.multipleSelection) {
+                    selectedIds.push(val.USER_ID)
+                }
+                return network.postData(`user/is-atlas`, {userIds: selectedIds, isAtlas: isAtlas})
+            }).then(response => {
+                this.$message({
+                    message: response,
+                    type: 'success'
+                })
+                this.getData(this.currentPage, this.pageSize)
+            }).catch(response => {
+
+            })
+        },
+        handleIsRechargeManage(isRecharge) {
+            if (this.multipleSelection.length < 1) {
+                this.$message({
+                    message: '请勾选要操作的会员',
+                    type: 'warning'
+                })
+                return
+            }
+            let isRechargeTip = isRecharge === true ? '显示充值' : '隐藏充值'
+            this.$confirm(`确定要对所选会员【${isRechargeTip}】吗?`, '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                let selectedIds = []
+                for (let val of this.multipleSelection) {
+                    selectedIds.push(val.USER_ID)
+                }
+                return network.postData(`user/is-recharge`, {userIds: selectedIds, isRecharge: isRecharge})
+            }).then(response => {
+                this.$message({
+                    message: response,
+                    type: 'success'
+                })
+                this.getData(this.currentPage, this.pageSize)
+            }).catch(response => {
+
+            })
+        },
+      getTypeName(type) {
+        switch (type) {
+          case 1:
+            return '按指定会员'
+          case 2:
+            return '按开拓网络'
+          case 3:
+            return '按安置网络'
+          case 4:
+            return '按会员体系'
+          case 5:
+            return '按省份地区'
+          default:
+            return ''
+        }
+      },
+      handleLoginManage(type) {
+        if (type === 2 || type === 3 || type === 4) {
+          if (this.multipleSelection.length > 1) {
+            this.$message({
+              message: '此登录管理不允许勾选多名会员',
+              type: 'warning'
+            })
+            return;
+          } else if (this.multipleSelection.length < 1) {
+            this.$message({
+              message: '请选择会员编号',
+              type: 'warning'
+            })
+            return;
+          }
+        }
+        if (type === 1 && this.multipleSelection.length <= 0) {
+          this.$message({
+            message: '请选择会员编号',
+            type: 'warning'
+          })
+          return;
+        }
+        if (type === 5 && this.multipleSelection.length > 0) {
+          this.$message({
+            message: '按照地区关闭登录无需勾选会员',
+            type: 'warning'
+          })
+          return;
+        }
+        this.formCloseLogin = {
+          userName: null,
+          typeName: '登录管理',
+          type: null,
+          isClose: 0,
+          remark: '',
+          areaSelected: null,
+        },
+          this.formCloseLogin.typeName = this.getTypeName(type) + '管理登录'
+        this.formCloseLogin.type = type
+        this.dialogVisible = true
+      },
+      handleCloseLoginSubmit() {
+        this.submitButtonStat = true
+        // 获取所购选的会员,如果是批量关闭指定会员,则走批量关闭方法
+        if (this.formCloseLogin.type === 1) {
+          this.handleCloseLogin(this.formCloseLogin.isClose, this.formCloseLogin.remark)
+        } else {
+          for (let val of this.multipleSelection) {
+            this.formCloseLogin.userName = val.USER_NAME.value
+          }
+          let path = 'user/close-login'
+          if (this.formCloseLogin.type === 5) {
+            path = 'user/close-area-login'
+          }
+          network.postData(path, this.formCloseLogin).then(response => {
+            this.$message({
+              message: response,
+              type: 'success'
+            })
+            this.getData(this.currentPage, this.pageSize)
+            this.submitButtonStat = false
+            this.dialogVisible = false
+          }).catch(response => {
+            this.submitButtonStat = false
+          })
+        }
+      },
+      handleCloseLogin(isClose, remark = '') {
+        let selectedIds = []
+        for (let val of this.multipleSelection) {
+          selectedIds.push(val.USER_ID)
+        }
+        console.log(selectedIds);
+        network.postData(`user/batch-close-login`, {
+          userIds: selectedIds,
+          isClose: isClose,
+          remark: remark,
+          type: 1,
+        }).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.getData(this.currentPage, this.pageSize)
+          this.submitButtonStat = false
+          this.dialogVisible = false
+        }).catch(response => {
+          this.submitButtonStat = false
+        })
+        // let tipStr = isClose ? '禁止' : '允许'
+        // this.$confirm(`确定要${tipStr}所选会员登录?`, '提示', {
+        //   confirmButtonText: '确定',
+        //   cancelButtonText: '取消',
+        //   type: 'warning'
+        // }).then(() => {
+        //   return network.postData(`user/batch-close-login`, {userIds: selectedIds, isClose: isClose})
+        // }).then(response => {
+        //   this.$message({
+        //     message: response,
+        //     type: 'success'
+        //   })
+        //   this.getData(this.currentPage, this.pageSize)
+        // }).catch(response => {
+        //
+        // })
+      },
+      handleExport() {
+        this.$confirm(`确定要导出当前数据吗?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          return network.getData(`user/index-export`, this.filterModel)
+        }).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+        }).catch(response => {
+
+        })
+      },
+      onMessageCallback(data) {
+        //this.getData(this.currentPage, this.pageSize, false)
+      },
+      handleDecManage(type) {
+        if (type === 2 || type === 3 || type === 4) {
+          if (this.multipleSelection.length > 1) {
+            this.$message({
+              message: '此报单管理不允许勾选多名会员',
+              type: 'warning'
+            })
+            return;
+          } else if (this.multipleSelection.length < 1) {
+            this.$message({
+              message: '请勾选要管理报单的会员',
+              type: 'warning'
+            })
+            return;
+          }
+        }
+        if (type === 1 && this.multipleSelection.length <= 0) {
+          this.$message({
+            message: '请勾选要管理报单的会员',
+            type: 'warning'
+          })
+          return;
+        }
+        if (type === 5 && this.multipleSelection.length > 0) {
+          this.$message({
+            message: '按照地区关闭报单无需勾选会员',
+            type: 'warning'
+          })
+          return;
+        }
+        this.formCloseDec = {
+          userName: null,
+          typeName: '管理报单',
+          type: null,
+          isClose: 0,
+          remark: '',
+          areaSelected: null,
+        },
+          this.formCloseDec.typeName = this.getTypeName(type) + '管理报单'
+        this.formCloseDec.type = type
+        this.dialogDecVisible = true
+      },
+      handleModifyPassword(row){
+        this.formModifyPassword.userId = row.USER_ID;
+        this.dialogModifyPasswordVisible = true
+      },
+      handleModifyProfile(row){
+          this.dialogModifyProfileVisible = true
+          let vueObj = this
+          network.getData('user/profile-get', {id: row.USER_ID}).then(response => {
+              vueObj.formModifyProfile = response.userInfo
+              vueObj.allOpenBank = response.allOpenBank
+              vueObj.allNation = response.allNation
+          })
+      },
+      handleCloseDecSubmit() {
+        this.submitDecButtonStat = true
+        // 获取所购选的会员,如果是批量关闭指定会员,则走批量关闭方法
+        if (this.formCloseDec.type === 1) {
+          this.handleCloseDec(this.formCloseDec.isClose, this.formCloseDec.remark)
+        } else {
+          for (let val of this.multipleSelection) {
+            this.formCloseDec.userName = val.USER_NAME.value
+          }
+          let path = 'user/close-dec'
+          if (this.formCloseDec.type === 5) {
+            path = 'user/close-area-dec'
+          }
+          network.postData(path, this.formCloseDec).then(response => {
+            this.$message({
+              message: response,
+              type: 'success'
+            })
+            this.getData(this.currentPage, this.pageSize)
+            this.submitDecButtonStat = false
+            this.dialogDecVisible = false
+          }).catch(response => {
+            this.submitDecButtonStat = false
+          })
+        }
+      },
+      handleCloseDec(isClose, remark = '') {
+        let selectedIds = []
+        for (let val of this.multipleSelection) {
+          selectedIds.push(val.USER_ID)
+        }
+        network.postData(`user/batch-close-dec`, {
+          userIds: selectedIds,
+          isClose: isClose,
+          remark: remark,
+          type: 1,
+        }).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.getData(this.currentPage, this.pageSize)
+          this.submitDecButtonStat = false
+          this.dialogDecVisible = false
+        }).catch(response => {
+          this.submitDecButtonStat = false
+        })
+      },
+        handleStatusActive(row){
+            network.postData('user/modify-status',{userId:row.USER_ID,status:1}).then(response=>{
+                    this.$message({
+                        message: response,
+                        type: 'success'
+                    })
+                    this.getData(this.currentPage, this.pageSize)
+                })
+        },
+        handleStatusLock(row){
+            network.postData('user/modify-status',{userId:row.USER_ID,status:0}).then(response=>{
+                    this.$message({
+                        message: response,
+                        type: 'success'
+                    })
+                    this.getData(this.currentPage, this.pageSize)
+                })
+        },
+        handleIsModifyPassword(row, status){
+          network.postData('user/is-modify-password-status',{userId:row.USER_ID,status:status}).then(response=>{
+            this.$message({
+              message: response,
+              type: 'success'
+            })
+            this.getData(this.currentPage, this.pageSize)
+          })
+        },
+      handleModifyPasswordSubmit() {
+            this.submitPasswordButtonStat = true
+              let path = 'user/modify-password'
+              network.postData(path, this.formModifyPassword).then(response => {
+                  this.$message({
+                      message: response,
+                      type: 'success'
+                  })
+                  this.getData(this.currentPage, this.pageSize)
+                  this.submitPasswordButtonStat = false
+                  this.dialogModifyPasswordVisible = false
+              }).catch(response => {
+                  this.submitPasswordButtonStat = false
+              })
+        },
+        handleModifyProfileSubmit() {
+            this.submitProfileButtonStat = true
+            let path = 'user/modify-profile'
+            network.postData(path, this.formModifyProfile).then(response => {
+                this.$message({
+                    message: response,
+                    type: 'success'
+                })
+                this.getData(this.currentPage, this.pageSize)
+                this.submitProfileButtonStat = false
+                this.dialogModifyProfileVisible = false
+            }).catch(response => {
+                this.submitProfileButtonStat = false
+            })
+        },
+    }
+  }
+
+</script>

+ 52 - 52
common/components/Controller.php

@@ -1,53 +1,53 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: Leo
- * Date: 2017/9/3
- * Time: 下午3:05
- */
-
-namespace common\components;
-
-
-use common\helpers\Tool;
-use yii\base\ActionEvent;
-use yii\helpers\Json;
-use yii\helpers\Url;
-
-class Controller extends \yii\web\Controller {
-
-    /**
-     * @return array
-     */
-    public function actions() {
-        return [
-            'captcha' =>  [
-                'class' => 'common\helpers\CaptchaAction',
-                'width' => 120,
-                'height' => 40,
-                'padding' => 0,
-                'minLength' => 4,
-                'maxLength' => 4,
-                'offset'=>8,        //设置字符偏移量 有效果
-                'testLimit'=>1,
-            ],
-        ];
-    }
-
-    /**
-     * 不允许直接访问ajax页面
-     * @param $action
-     * @return bool
-     * @throws \yii\web\BadRequestHttpException
-     */
-    protected function checkAjax(&$action){
-        $currentAction = $action->id;
-        if(strpos($currentAction ,'ajax-')===0){
-            if(!\Yii::$app->request->getIsAjax()){
-                throw new \yii\web\BadRequestHttpException('无法完成您的请求');
-            }
-        }
-        return true;
-    }
-
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Leo
+ * Date: 2017/9/3
+ * Time: 下午3:05
+ */
+
+namespace common\components;
+
+
+use common\helpers\Tool;
+use yii\base\ActionEvent;
+use yii\helpers\Json;
+use yii\helpers\Url;
+
+class Controller extends \yii\web\Controller {
+
+    /**
+     * @return array
+     */
+    public function actions() {
+        return [
+            'captcha' =>  [
+                'class' => 'common\helpers\CaptchaAction',
+                'width' => 120,
+                'height' => 40,
+                'padding' => 0,
+                'minLength' => 4,
+                'maxLength' => 4,
+                'offset'=>8,        //设置字符偏移量 有效果
+                'testLimit'=>1,
+            ],
+        ];
+    }
+
+    /**
+     * 不允许直接访问ajax页面
+     * @param $action
+     * @return bool
+     * @throws \yii\web\BadRequestHttpException
+     */
+    protected function checkAjax(&$action){
+        $currentAction = $action->id;
+        if(strpos($currentAction ,'ajax-')===0){
+            if(!\Yii::$app->request->getIsAjax()){
+                throw new \yii\web\BadRequestHttpException('无法完成您的请求');
+            }
+        }
+        return true;
+    }
+
 }

+ 2 - 0
common/components/SwooleAsyncTimer.php

@@ -22,6 +22,7 @@ use common\libs\taskQueue\TaskFunc;
 use common\models\UserInfo;
 use Yii;
 use anlity\swooleAsyncTimer\SwooleAsyncTimerController;
+use common\helpers\bonus\PreparePerfCalc;
 use yii\base\Exception;
 use yii\helpers\Json;
 
@@ -47,6 +48,7 @@ class SwooleAsyncTimer extends SwooleAsyncTimerComponent implements SocketInterf
      */
     public function timerCallback($timerId, $server){
         // 自动封期
+        PreparePerfCalc::instance()->calcStep(); // 预计算月业绩
         AutoClosePeriod::instance()->autoClose();
         // 自动执行任务队列中的任务
         Queue::instance()->consumeTask();

+ 69 - 58
common/config/main.php

@@ -1,58 +1,69 @@
-<?php
-$mainConfig = require_once __DIR__ . '/config.php';
-return [
-    'language' => 'zh-CN',
-    'timeZone' => 'PRC',
-    'aliases' => [
-        '@bower' => '@vendor/bower-asset',
-        '@npm'   => '@vendor/npm-asset',
-//        'anlity/swooleAsyncTimer' => '@backend/runtime/tmp-extensions/yii2-swoole-async-timer',
-    ],
-    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
-    'components' => [
-        'db' => array_merge([
-            'class' => 'yii\db\Connection',
-            'enableSlaves' => false,
-//            'enableSavepoint' => false,
-        ], $mainConfig['db'], $mainConfig['slavesDb']),
-//        'dbShop' => array_merge(['class' => 'yii\db\Connection', 'schemaMap' => ['oci' => 'common\helpers\Schema']], $mainConfig['dbShop']),
-        'dbLog' => array_merge(['class' => 'yii\mongodb\Connection',], $mainConfig['dbLog']),
-        'dbCalc' => array_merge(['class' => 'yii\db\Connection'], $mainConfig['dbCalc']),
-//        'dbShopCalc' => array_merge(['class' => 'yii\db\Connection', 'schemaMap' => ['oci' => 'common\helpers\Schema'],], $mainConfig['dbShopCalc']),
-        'dbNetPoint' => array_merge(['class' => 'yii\db\Connection'], $mainConfig['dbNetPoint']),
-        // 'cache' => [
-        //     //'class' => 'yii\caching\FileCache',
-        //     'class' => 'dcb9\redis\Cache',
-        //     'redis' => $mainConfig['cacheRedis'],
-        // ],
-        'cache' => [
-            'class' => 'yii\redis\Cache',
-            'redis' => $mainConfig['cacheRedis'],
-            // 'redis' => [
-            //     'hostname' => '127.0.0.1',
-            //     'port' => 6379,
-            //     'database' => 0,
-            // ]
-        ],
-        'tokenRedis' => array_merge(['class' => 'yii\redis\Connection'], $mainConfig['tokenRedis']),
-        'redis' => array_merge(['class' => 'yii\redis\Connection'], $mainConfig['otherRedis']),
-        // 'tokenRedis' => array_merge(['class' => 'common\components\Redis'], $mainConfig['tokenRedis']),
-        // 'redis' => array_merge(['class' => 'common\components\Redis'], $mainConfig['otherRedis']),
-        'mailer' => [
-            'class' => 'yii\swiftmailer\Mailer',
-            'viewPath' => '@common/mail',
-            // send all mails to a file by default. You have to set
-            // 'useFileTransport' to false and configure a transport
-            // for the mailer to send real emails.
-            'useFileTransport' => true,
-        ],
-        'swooleAsyncTimer' => [
-            'class' => 'common\components\SwooleAsyncTimer',
-        ],
-    ],
-    'controllerMap' => [
-        'swoole_server' => [
-            'class' => 'anlity\swooleAsyncTimer\SwooleAsyncTimerController',
-        ],
-    ],
-];
+<?php
+$mainConfig = require_once __DIR__ . '/config.php';
+return [
+    'language' => 'zh-CN',
+    'timeZone' => 'PRC',
+    'aliases' => [
+        '@bower' => '@vendor/bower-asset',
+        '@npm'   => '@vendor/npm-asset',
+//        'anlity/swooleAsyncTimer' => '@backend/runtime/tmp-extensions/yii2-swoole-async-timer',
+    ],
+    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
+    'components' => [
+//        'log' => [
+//            'targets' => [
+//                [
+//                    'class' => 'yii\log\FileTarget',
+//                    'levels' => ['error', 'warning', 'info'],
+//                    'categories' => ['yii\db\*', 'app\models\*'],
+//                    'logFile' => '@runtime/logs/sql.log',
+//                ],
+//                'db' => [ 'class' => 'yii\log\FileTarget'],
+//            ],
+//        ],
+        'db' => array_merge([
+            'class' => 'yii\db\Connection',
+            'enableSlaves' => false,
+//            'enableSavepoint' => false,
+        ], $mainConfig['db'], $mainConfig['slavesDb']),
+//        'dbShop' => array_merge(['class' => 'yii\db\Connection', 'schemaMap' => ['oci' => 'common\helpers\Schema']], $mainConfig['dbShop']),
+        'dbLog' => array_merge(['class' => 'yii\mongodb\Connection',], $mainConfig['dbLog']),
+        'dbCalc' => array_merge(['class' => 'yii\db\Connection'], $mainConfig['dbCalc']),
+//        'dbShopCalc' => array_merge(['class' => 'yii\db\Connection', 'schemaMap' => ['oci' => 'common\helpers\Schema'],], $mainConfig['dbShopCalc']),
+        'dbNetPoint' => array_merge(['class' => 'yii\db\Connection'], $mainConfig['dbNetPoint']),
+        // 'cache' => [
+        //     //'class' => 'yii\caching\FileCache',
+        //     'class' => 'dcb9\redis\Cache',
+        //     'redis' => $mainConfig['cacheRedis'],
+        // ],
+        'cache' => [
+            'class' => 'yii\redis\Cache',
+            'redis' => $mainConfig['cacheRedis'],
+            // 'redis' => [
+            //     'hostname' => '127.0.0.1',
+            //     'port' => 6379,
+            //     'database' => 0,
+            // ]
+        ],
+        'tokenRedis' => array_merge(['class' => 'yii\redis\Connection'], $mainConfig['tokenRedis']),
+        'redis' => array_merge(['class' => 'yii\redis\Connection'], $mainConfig['otherRedis']),
+        // 'tokenRedis' => array_merge(['class' => 'common\components\Redis'], $mainConfig['tokenRedis']),
+        // 'redis' => array_merge(['class' => 'common\components\Redis'], $mainConfig['otherRedis']),
+        'mailer' => [
+            'class' => 'yii\swiftmailer\Mailer',
+            'viewPath' => '@common/mail',
+            // send all mails to a file by default. You have to set
+            // 'useFileTransport' to false and configure a transport
+            // for the mailer to send real emails.
+            'useFileTransport' => true,
+        ],
+        'swooleAsyncTimer' => [
+            'class' => 'common\components\SwooleAsyncTimer',
+        ],
+    ],
+    'controllerMap' => [
+        'swoole_server' => [
+            'class' => 'anlity\swooleAsyncTimer\SwooleAsyncTimerController',
+        ],
+    ],
+];

+ 2 - 1
common/config/params.php

@@ -1,6 +1,7 @@
 <?php
 $nationParams = require_once __DIR__ . '/params-nation.php';
 return [
+    'preparePerfLimit' => isset($mainConfig['preparePerfLimit']) ? $mainConfig['preparePerfLimit'] : false,
     'adminEmail' => 'admin@example.com',
     'supportEmail' => 'support@example.com',
     'nation' => $nationParams,
@@ -199,7 +200,7 @@ return [
         ],
         'exchange_points' => [
             'name' => 'bonus',
-            'label' => '兑换积分余额',
+            'label' => '兑换点数余额',
         ]
 //        'cf' => [
 //            'name' => 'cf',

+ 9 - 5
common/helpers/Cache.php

@@ -48,6 +48,9 @@ class Cache
     const USER_INFO_KEY = 'user:baseInfo';
     const USER_NETWORK_PARENTS = 'user:networkParents';
     const USER_RELATION_PARENTS = 'user:relationParents';
+    const PREPARE_USER_NETWORK_PARENTS = 'prepare:user:networkParents';
+    const PREPARE_USER_RELATION_PARENTS = 'prepare:user:relationParents';
+    const PRE_USER_CREATED_AT_LIST = 'prepare:user:createdAtList_';
     const USER_CREATED_AT_LIST = 'user:createdAtList_';
 
     /**
@@ -316,19 +319,20 @@ class Cache
     /**
      * 获取全部安置网络上级
      * @param $userId
+     * @param $isPrepare 是否是预计计算 true为是 则使用预计计算的缓存key
      * @return array|mixed
      */
-    public static function getAllNetworkParents($userId){
-        return UserNetwork::getAllParentsFromRedis($userId);
+    public static function getAllNetworkParents($userId, $isPrepare=false){
+        return UserNetwork::getAllParentsFromRedis($userId, $isPrepare);
     }
 
     /**
      * 获取全部推荐网络的上级
      * @param $userId
+     * @param $isPrepare 是否是预计计算 true为是 则使用预计计算的缓存key
      * @return array|mixed
      */
-    public static function getAllRelationParents($userId){
-        return UserRelation::getAllParentsFromRedis($userId);
+    public static function getAllRelationParents($userId, $isPrepare = false){
+        return UserRelation::getAllParentsFromRedis($userId, $isPrepare);
     }
-
 }

+ 156 - 156
common/helpers/CaptchaAction.php

@@ -1,157 +1,157 @@
-<?php
-namespace common\helpers;
-
-use Yii;
-use yii\helpers\Url;
-use yii\web\Response;
-
-/**
- * 验证码扩展类
- * @author   Leo
- * @copyright  Copyright (c) 2016 (http://www.LeoCode.net)
- */
-class CaptchaAction extends \yii\captcha\CaptchaAction
-{
-
-    const CAPTCHA_CODE = 'ak:captcha_code_%s';
-
-    /**
-     * GD库方式渲染
-     * @param string $code
-     * @return string
-     */
-    protected function renderImageByGD($code)
-    {
-        $this->fontFile = Yii::getAlias('@common/helpers/font/DroidSansMono.ttf');
-        $image = imagecreatetruecolor($this->width, $this->height);
-        $backColor = imagecolorallocate(
-            $image,
-            (int)($this->backColor % 0x1000000 / 0x10000),
-            (int)($this->backColor % 0x10000 / 0x100),
-            $this->backColor % 0x100
-        );
-        imagefilledrectangle($image, 0, 0, $this->width - 1, $this->height - 1, $backColor);
-        imagecolordeallocate($image, $backColor);
-        $this->transparent = true;
-        if ($this->transparent) {
-            imagecolortransparent($image, $backColor);
-        }
-
-        $foreColor = imagecolorallocate(
-            $image,
-            (int)($this->foreColor % 0x1000000 / 0x10000),
-            (int)($this->foreColor % 0x10000 / 0x100),
-            $this->foreColor % 0x100
-        );
-
-        $length = strlen($code);
-        $box = imagettfbbox(30, 0, $this->fontFile, $code);
-        $w = $box[4] - $box[0] + $this->offset * ($length - 1);
-        $h = $box[1] - $box[5];
-        $scale = min(($this->width - $this->padding * 2) / $w, ($this->height - $this->padding * 2) / $h);
-        $x = 10;
-        $y = round($this->height * 27 / 40);
-
-        // 添加彩色乱字符
-        $chartDictionary = 'abcdefghjkmnopqrstuvwxyzABCDEFGHJKMNOPQRSTUVWXYZ2345679';
-        for ($i = 0; $i < 50; $i++) {
-            $chartPosition = rand(0, strlen($chartDictionary));
-            $chartContent = substr($chartDictionary, $chartPosition, 1);
-            $chartColor = imagecolorallocate($image, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255));
-            $chartAngle = rand(-10, 10);
-            imagettftext($image, 10, $chartAngle, rand(0, ($this->width - $this->padding * 2) - 10), rand(0, ($this->height - $this->padding * 2) - 10), $chartColor, $this->fontFile, $chartContent);
-        }
-
-        // 设置文字
-        for ($i = 0; $i < $length; ++$i) {
-            $fontSize = (int)(rand(26, 32) * $scale * 0.8);
-            $angle = rand(-10, 10);
-            $letter = $code[$i];
-            $box = imagettftext($image, $fontSize, $angle, $x, $y, $foreColor, $this->fontFile, $letter);
-            $x = $box[2] + $this->offset;
-        }
-
-        // 验证码添加线条
-        for ($i = 0; $i < 10; $i++) {
-            $lineColor = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
-            imageline($image, rand(0, 2), rand(0, ($this->width - $this->height * 2) - 2), rand(0, ($this->width - $this->padding * 2) - 2), rand(0, ($this->width - $this->height * 2) - 2), $lineColor);
-        }
-
-        // 验证码添加噪点
-        for ($i = 0; $i < 300; $i++) {
-            //设置点的颜色
-            $pointColor = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
-            imagesetpixel($image, rand(0, ($this->width - $this->padding * 2)), rand(0, ($this->width - $this->height * 2) - 10), $pointColor);
-        }
-
-        imagecolordeallocate($image, $foreColor);
-
-        ob_start();
-        imagepng($image);
-        imagedestroy($image);
-
-        return ob_get_clean();
-    }
-
-    /**
-     * Runs the action.
-     */
-    public function run()
-    {
-        if (Yii::$app->request->getQueryParam(self::REFRESH_GET_VAR) !== null) {
-            // AJAX request for regenerating code
-            $code = $this->getVerifyCode(true);
-            Yii::$app->response->format = Response::FORMAT_JSON;
-            return [
-                'hash1' => $this->generateValidationHash($code),
-                'hash2' => $this->generateValidationHash(strtolower($code)),
-                // we add a random 'v' parameter so that FireFox can refresh the image
-                // when src attribute of image tag is changed
-                'url' => Url::to([$this->id, 'v' => uniqid()]),
-            ];
-        } else {
-            $this->setHttpHeaders();
-            Yii::$app->response->format = Response::FORMAT_RAW;
-            return $this->renderImage($this->getVerifyCode(true));
-        }
-    }
-
-    /**
-     * @param bool $regenerate
-     * @return int|mixed|string|null
-     */
-    public function getVerifyCode($regenerate = false)
-    {
-        if ($this->fixedVerifyCode !== null) {
-            return $this->fixedVerifyCode;
-        }
-//        $name = $this->getSessionKey();
-        $pageId = \Yii::$app->request->get('page_id');
-        if( !$pageId ) {
-            throw new \Exception('no page id');
-        }
-
-        $cacheRedis = Yii::$app->cache;
-        $key = sprintf(self::CAPTCHA_CODE, $pageId);
-        if( !$regenerate ) {
-            $code = $cacheRedis->get($key);
-            if ( $code ) return $code;
-        }
-
-        $code = $this->generateVerifyCode();
-        $cacheRedis->set($key, $code, 300);
-
-        return $code;
-    }
-
-    public function validate($input, $caseSensitive)
-    {
-        $code = $this->getVerifyCode();
-        $valid = $caseSensitive ? ($input === $code) : strcasecmp($input, $code) === 0;
-        if ( $valid ) {
-            $this->getVerifyCode(true);
-        }
-
-        return $valid;
-    }
+<?php
+namespace common\helpers;
+
+use Yii;
+use yii\helpers\Url;
+use yii\web\Response;
+
+/**
+ * 验证码扩展类
+ * @author   Leo
+ * @copyright  Copyright (c) 2016 (http://www.LeoCode.net)
+ */
+class CaptchaAction extends \yii\captcha\CaptchaAction
+{
+
+    const CAPTCHA_CODE = 'ak:captcha_code_%s';
+
+    /**
+     * GD库方式渲染
+     * @param string $code
+     * @return string
+     */
+    protected function renderImageByGD($code)
+    {
+        $this->fontFile = Yii::getAlias('@common/helpers/font/DroidSansMono.ttf');
+        $image = imagecreatetruecolor($this->width, $this->height);
+        $backColor = imagecolorallocate(
+            $image,
+            (int)($this->backColor % 0x1000000 / 0x10000),
+            (int)($this->backColor % 0x10000 / 0x100),
+            $this->backColor % 0x100
+        );
+        imagefilledrectangle($image, 0, 0, $this->width - 1, $this->height - 1, $backColor);
+        imagecolordeallocate($image, $backColor);
+        $this->transparent = true;
+        if ($this->transparent) {
+            imagecolortransparent($image, $backColor);
+        }
+
+        $foreColor = imagecolorallocate(
+            $image,
+            (int)($this->foreColor % 0x1000000 / 0x10000),
+            (int)($this->foreColor % 0x10000 / 0x100),
+            $this->foreColor % 0x100
+        );
+
+        $length = strlen($code);
+        $box = imagettfbbox(30, 0, $this->fontFile, $code);
+        $w = $box[4] - $box[0] + $this->offset * ($length - 1);
+        $h = $box[1] - $box[5];
+        $scale = min(($this->width - $this->padding * 2) / $w, ($this->height - $this->padding * 2) / $h);
+        $x = 10;
+        $y = round($this->height * 27 / 40);
+
+        // 添加彩色乱字符
+        $chartDictionary = 'abcdefghjkmnopqrstuvwxyzABCDEFGHJKMNOPQRSTUVWXYZ2345679';
+        for ($i = 0; $i < 50; $i++) {
+            $chartPosition = rand(0, strlen($chartDictionary));
+            $chartContent = substr($chartDictionary, $chartPosition, 1);
+            $chartColor = imagecolorallocate($image, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255));
+            $chartAngle = rand(-10, 10);
+            imagettftext($image, 10, $chartAngle, rand(0, ($this->width - $this->padding * 2) - 10), rand(0, ($this->height - $this->padding * 2) - 10), $chartColor, $this->fontFile, $chartContent);
+        }
+
+        // 设置文字
+        for ($i = 0; $i < $length; ++$i) {
+            $fontSize = (int)(rand(26, 32) * $scale * 0.8);
+            $angle = rand(-10, 10);
+            $letter = $code[$i];
+            $box = imagettftext($image, $fontSize, $angle, $x, $y, $foreColor, $this->fontFile, $letter);
+            $x = $box[2] + $this->offset;
+        }
+
+        // 验证码添加线条
+        for ($i = 0; $i < 10; $i++) {
+            $lineColor = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
+            imageline($image, rand(0, 2), rand(0, ($this->width - $this->height * 2) - 2), rand(0, ($this->width - $this->padding * 2) - 2), rand(0, ($this->width - $this->height * 2) - 2), $lineColor);
+        }
+
+        // 验证码添加噪点
+        for ($i = 0; $i < 300; $i++) {
+            //设置点的颜色
+            $pointColor = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));
+            imagesetpixel($image, rand(0, ($this->width - $this->padding * 2)), rand(0, ($this->width - $this->height * 2) - 10), $pointColor);
+        }
+
+        imagecolordeallocate($image, $foreColor);
+
+        ob_start();
+        imagepng($image);
+        imagedestroy($image);
+
+        return ob_get_clean();
+    }
+
+    /**
+     * Runs the action.
+     */
+    public function run()
+    {
+        if (Yii::$app->request->getQueryParam(self::REFRESH_GET_VAR) !== null) {
+            // AJAX request for regenerating code
+            $code = $this->getVerifyCode(true);
+            Yii::$app->response->format = Response::FORMAT_JSON;
+            return [
+                'hash1' => $this->generateValidationHash($code),
+                'hash2' => $this->generateValidationHash(strtolower($code)),
+                // we add a random 'v' parameter so that FireFox can refresh the image
+                // when src attribute of image tag is changed
+                'url' => Url::to([$this->id, 'v' => uniqid()]),
+            ];
+        } else {
+            $this->setHttpHeaders();
+            Yii::$app->response->format = Response::FORMAT_RAW;
+            return $this->renderImage($this->getVerifyCode(true));
+        }
+    }
+
+    /**
+     * @param bool $regenerate
+     * @return int|mixed|string|null
+     */
+    public function getVerifyCode($regenerate = false)
+    {
+        if ($this->fixedVerifyCode !== null) {
+            return $this->fixedVerifyCode;
+        }
+//        $name = $this->getSessionKey();
+        $pageId = \Yii::$app->request->get('page_id');
+        if( !$pageId ) {
+            throw new \Exception('no page id');
+        }
+
+        $cacheRedis = Yii::$app->cache;
+        $key = sprintf(self::CAPTCHA_CODE, $pageId);
+        if( !$regenerate ) {
+            $code = $cacheRedis->get($key);
+            if ( $code ) return $code;
+        }
+
+        $code = $this->generateVerifyCode();
+        $cacheRedis->set($key, $code, 300);
+
+        return $code;
+    }
+
+    public function validate($input, $caseSensitive)
+    {
+        $code = $this->getVerifyCode();
+        $valid = $caseSensitive ? ($input === $code) : strcasecmp($input, $code) === 0;
+        if ( $valid ) {
+            $this->getVerifyCode(true);
+        }
+
+        return $valid;
+    }
 }

+ 5 - 0
common/helpers/Tool.php

@@ -71,6 +71,11 @@ class Tool {
         }
     }
 
+    // 格式化业绩期
+    public static function formatPreparePerf($perf) {
+        return number_format($perf,2);
+    }
+
     /**
      * 前台业绩格式化
      * @param $perf

+ 23 - 3
common/helpers/bonus/BonusCalc.php

@@ -3233,9 +3233,29 @@ class BonusCalc extends BaseObject {
         $buleStartManageTax = 0;
         $exchangePoints = 0; // 蓝星奖管理奖. 产生的兑换积分
         if( $this->_isCalcMonth ) {
-            //查看是否复消300
-            $monthPerfData = CalcCache::nowMonthPerf($userId, $this->_periodNum);
-            $fxPvStatus = $monthPerfData['PV_PCS_FX'] >= $this->_sysConfig['monthPcsPvFxCondition']['VALUE'];
+            // 查看是否复消300
+            // $monthPerfData = CalcCache::nowMonthPerf($userId, $this->_periodNum);
+            // $monthPerf = $monthPerfData['PV_PCS_FX'];
+            // // $fxPvStatus 改成月报单+复消之和是否300
+            // $decPvInfo = PerfPeriod::findUseSlaves()->select('SUM(PV_PCS_ZC) AS ZC_SUM')
+            // ->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$userId, 'CALC_MONTH'=>$this->_calcYearMonth])
+            // ->asArray()
+            // ->one(); 
+            // $decPv = isset($decPvInfo['ZC_SUM']) && $decPvInfo['ZC_SUM'] > 0 ?  $decPvInfo['ZC_SUM'] : 0;
+            // $totalCheckPv = $monthPerf + $decPv;
+            // $fxPvStatus = $totalCheckPv >= $this->_sysConfig['monthPcsPvFxCondition']['VALUE'];
+            // 逻辑改成,用户此月累计消费总额大于等于配置,取消订单类型的配置
+            $userMonthTotal = PerfMonth::find()
+            ->where(
+                'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', 
+                ['USER_ID'=>$userId, 'CALC_MONTH'=>$this->_calcYearMonth]
+            )
+            ->asArray()
+            ->one();
+            $fxPvStatus = false;
+            if (isset($userMonthTotal['PV_PCS']) && $userMonthTotal['PV_PCS'] >= $this->_sysConfig['monthPcsPvFxCondition']['VALUE']) {
+                $fxPvStatus = true;
+            }
             // BONUS_REAL 字段是发到用户的真实奖金
             if ( $fxPvStatus ) {
                 // 管理奖改成了蓝星奖,但是对于用户来说依旧叫管理奖.字段改成bs.

+ 2 - 2
common/helpers/bonus/PerfCalc.php

@@ -604,6 +604,7 @@ class PerfCalc {
                 unset($data, $decInfo, $sn, $toInfo);
             }
             PerfOrder::batchInsert($insertPerfOrderData);
+
             unset($insertPerfOrderData, $allData, $snArr);
             return $this->loopCalcPeriodPerfByOrderDec($offset + $this->_limit);
         }
@@ -727,7 +728,7 @@ class PerfCalc {
                 unset($data, $baseInfo, $sn, $orderCashAmount, $payPv, $cacheDataKey);
             }
             PerfOrder::batchInsert($insertPerfOrderData);
-
+            
             unset($insertPerfOrderData, $allData, $snArr);
             return $this->loopCalcPerfByFXOrder($offset + $this->_limit);
         }
@@ -843,7 +844,6 @@ class PerfCalc {
                 unset($data, $baseInfo, $sn, $orderCashAmount, $payPv, $cacheDataKey);
             }
             PerfOrder::batchInsert($insertPerfOrderData);
-
             unset($insertPerfOrderData, $allData, $snArr);
             return $this->loopCalcPerfByShopFXOrder($offset + $this->_limit);
         }

+ 1509 - 0
common/helpers/bonus/PrepareCalcCache.php

@@ -0,0 +1,1509 @@
+<?php
+/**
+ * 月结算的时候,周日晚0点进行预计算,此月用户和团队的业绩信息. 让会员参考,进行补业绩使用的缓存key
+ * Created by PhpStorm.
+ * User: leo
+ * Date: 2018/8/2
+ * Time: 上午10:38
+ */
+
+namespace common\helpers\bonus;
+
+use common\helpers\Cache;
+use common\helpers\user\Info;
+use common\models\CalcBonus;
+use common\models\PerfMonth;
+use common\models\Period;
+use common\models\DeclarationLevel;
+use common\models\DecRole;
+use common\models\EmployLevel;
+use common\models\User;
+use common\models\UserBonus;
+use common\models\UserPerf;
+use Yii;
+use common\models\UserInfo;
+use yii\helpers\Json;
+
+class PrepareCalcCache {
+    const LIMIT = 1000;
+
+    const REDIS_KEY_PREFIX_USER = 'prepare:calc:user_';
+    const REDIS_KEY_PREFIX_USER_ACTIVE = 'prepare:calc:userActive_';
+    const REDIS_KEY_PREFIX_USER_INFO = 'prepare:calc:userInfo_';
+    const REDIS_KEY_PREFIX_USER_BONUS = 'prepare:calc:userBonus_';
+    const REDIS_KEY_PREFIX_PERIOD_MONTH_CALC_BONUS = 'prepare:calc:periodMonthCalcBonus_';
+    const REDIS_KEY_PREFIX_USER_PERF = 'prepare:calc:userPerf_';
+    const REDIS_KEY_PREFIX_SURPLUS_PERF = 'prepare:calc:spPerf_';
+    const REDIS_KEY_PREFIX_NOW_PERIOD_PERF = 'prepare:calc:nowPeriodPerf_';
+    const REDIS_KEY_PREFIX_NOW_STANDARD_MONTH_PERF = 'prepare:calc:nowStandardMonthPerf_';
+    const REDIS_KEY_PREFIX_LAST_MONTH_PERF = 'prepare:calc:lastMonthPerf_';
+    const REDIS_KEY_PREFIX_NOW_MONTH_PERF = 'prepare:calc:nowMonthPerf_';
+    const REDIS_KEY_PREFIX_NOW_MONTH_SCORE = 'prepare:calc:nowMonthScore_';
+    const REDIS_KEY_PREFIX_NOW_MONTH_LAST_PERIOD_RECONSUME_POINTS = 'prepare:calc:nowMonthLastPeriodReconsumePoints_';
+    const REDIS_KEY_PREFIX_EMP_NUM_PERF = 'prepare:calc:empLevelNum_';
+    const REDIS_KEY_PREFIX_BONUS = 'prepare:calc:bonus_';
+    const REDIS_KEY_PREFIX_STANDARD_BONUS = 'prepare:calc:standard:bonus_';
+    const REDIS_KEY_PREFIX_YC_BONUS = 'prepare:calc:yc:bonus_';
+    const REDIS_KEY_PREFIX_FW_BONUS = 'prepare:calc:fw:bonus_';
+    const REDIS_KEY_PREFIX_HAS_PERF_USER = 'prepare:calc:hasPerfUser_';
+    const REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER = 'prepare:calc:hasMonthPerfUser_';
+    const REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER = 'prepare:calc:hasStandardMonthPerfUser_';
+    const REDIS_KEY_PREFIX_HAS_BD_USER = 'prepare:calc:hasBDUser_';
+    const REDIS_KEY_PREFIX_HAS_INCOME_USER = 'prepare:calc:hasIncomeUser_';
+    const REDIS_KEY_PREFIX_HAS_BONUS_USER = 'prepare:calc:hasBonusUser_';
+    const REDIS_KEY_PREFIX_HAS_YC_BONUS_USER = 'prepare:calc:hasYcBonusUser_';
+    const REDIS_KEY_PREFIX_HAS_FW_BONUS_USER = 'prepare:calc:hasFwBonusUser_';
+    const REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER = 'prepare:calc:hasMonthBonusUser_';
+    const REDIS_KEY_PREFIX_HAS_PERF_USER_POOL = 'prepare:calc:hasPerfUserPool_';
+    const REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER_POOL = 'prepare:calc:hasMonthPerfUserPool_';
+    const REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER_POOL = 'prepare:calc:hasStandardMonthPerfUserPool_';
+    const REDIS_KEY_PREFIX_HAS_BD_USER_POOL = 'prepare:calc:hasBDUserPool_';
+    const REDIS_KEY_PREFIX_HAS_INCOME_USER_POOL = 'prepare:calc:hasIncomeUserPool_';
+    const REDIS_KEY_PREFIX_HAS_BONUS_USER_POOL = 'prepare:calc:hasBonusUserPool_';
+    const REDIS_KEY_PREFIX_HAS_YC_BONUS_USER_POOL = 'prepare:calc:hasYcBonusUserPool_';
+    const REDIS_KEY_PREFIX_HAS_FW_BONUS_USER_POOL = 'prepare:calc:hasFwBonusUserPool_';
+    const REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER_POOL = 'prepare:calc:hasMonthBonusUserPool_';
+    const REDIS_KEY_PREFIX_HAS_SCORE_USER = 'prepare:calc:hasScoreUser_';
+    const REDIS_KEY_PREFIX_HAS_SCORE_USER_POOL = 'prepare:calc:hasScoreUserPool_';
+    const REDIS_KEY_PREFIX_HAS_LS_PCS_USER = 'prepare:calc:hasLSPCSUser_';
+    const REDIS_KEY_PREFIX_HAS_LS_PCS_USER_POOL = 'prepare:calc:hasLSPCSUserPool_';
+    const REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER = 'prepare:calc:hasCFPercentPCSUser_';
+    const REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER_POOL = 'prepare:calc:hasCFPercentPCSUserPool_';
+    const REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER = 'prepare:calc:hasLXPercentPCSUser_';
+    const REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER_POOL = 'prepare:calc:hasLXPercentPCSUserPool_';
+    const REDIS_KEY_PREFIX_DEC_ROLE_CONFIG = 'prepare:calc:decRoleConfig_';
+    const REDIS_KEY_PREFIX_CF_TOTAL_PERCENT = 'prepare:calc:cfTotalPercent_';
+    const REDIS_KEY_PREFIX_LX_TOTAL_PERCENT = 'prepare:calc:lxTotalPercent_';
+    const REDIS_KEY_PREFIX_USER_INFO_CHILD_ONE_DEEP = 'prepare:calc:userInfo:ChildOneDeep_';
+    const REDIS_KEY_PREFIX_GX_BONUS_DEEP_ONE_LIST_DATA = 'prepare:calc:gxBonusDeepOneListData_';
+    const REDIS_KEY_PREFIX_GX_BONUS_DEEP_TWO_LIST_DATA = 'prepare:calc:gxBonusDeepTwoListData_';
+    const REDIS_KEY_PREFIX_YC_BONUS_LIST_DATA = 'prepare:calc:ycBonusListData_';
+    const REDIS_KEY_PREFIX_FW_BONUS_LIST_DATA = 'prepare:calc:fwBonusListData_';
+
+    //@todo
+    const REDIS_KEY_PREFIX_REPAIR_SURPLUS_PERF = 'prepare:calc:repairSurplusPerf_';
+    const REDIS_KEY_PREFIX_HAS_REPAIR_PERF_USER = 'prepare:calc:hasRepairPerfUser_';
+    const REDIS_KEY_PREFIX_HAS_REPAIR_PERF_USER_POOL = 'prepare:calc:hasRepairPerfPool_';
+
+    //收入的奖金类型
+//    const INCOME_TG_BONUS = 'BONUS_TG';
+//    const INCOME_XF_BONUS = 'BONUS_XF';
+//    const INCOME_YJ_BONUS = 'BONUS_YJ';
+//    const INCOME_QY_BONUS = 'BONUS_QY';
+    const INCOME_QY_BONUS_BD = 'BONUS_QY_BD';
+    const INCOME_QY_BONUS_FX = 'BONUS_QY_FX';
+    const INCOME_BONUS_LIST = [
+//        self::INCOME_TG_BONUS,
+//        self::INCOME_XF_BONUS,
+//        self::INCOME_YJ_BONUS,
+//        self::INCOME_QY_BONUS,
+        self::INCOME_QY_BONUS_BD,
+//        self::INCOME_QY_BONUS_FX,
+    ];
+    const NOT_SEND_BONUS_LIST = [
+        self::INCOME_QY_BONUS_BD,
+        self::INCOME_QY_BONUS_FX,
+    ];
+
+    const FROM_MEANS_BD = 'BD';
+    const FROM_MEANS_FX = 'FX';
+
+    /**
+     * 结算奖金时要清空的缓存
+     * @param $periodNum
+     */
+    public static function clearCalcBonusCache($periodNum) {
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_STANDARD_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_YC_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_YC_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_YC_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_GX_BONUS_DEEP_ONE_LIST_DATA . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_GX_BONUS_DEEP_TWO_LIST_DATA . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_YC_BONUS_LIST_DATA . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_FW_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_FW_BONUS_LIST_DATA . $periodNum);
+    }
+
+    /**
+     * 清网络缓存
+     * 用户的网络是一套,应该用一个缓存,获取最新推荐关系
+     */
+    public static function clearNetCache(){
+        \Yii::$app->redis->del(Cache::PREPARE_USER_NETWORK_PARENTS);
+        \Yii::$app->redis->del(Cache::PREPARE_USER_RELATION_PARENTS);
+    }
+
+    /**
+     * 清空所有临时计算用到的缓存
+     * @param $periodNum
+     */
+    public static function clearAll($periodNum) {
+        //Yii::$app->redis->del(Yii::$app->redis->keys('calc*'));
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_ACTIVE . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_INFO . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_PERIOD_MONTH_CALC_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_SURPLUS_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_NOW_PERIOD_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_NOW_STANDARD_MONTH_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_LAST_MONTH_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_NOW_MONTH_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_NOW_MONTH_SCORE . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_NOW_MONTH_LAST_PERIOD_RECONSUME_POINTS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_EMP_NUM_PERF . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_STANDARD_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_YC_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_FW_BONUS . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_PERF_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_PERF_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BD_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BD_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_INCOME_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_INCOME_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_YC_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_YC_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_SCORE_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_SCORE_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_LS_PCS_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_LS_PCS_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER_POOL . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_DEC_ROLE_CONFIG . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_USER_INFO_CHILD_ONE_DEEP . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_GX_BONUS_DEEP_ONE_LIST_DATA . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_GX_BONUS_DEEP_TWO_LIST_DATA . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_YC_BONUS_LIST_DATA . $periodNum);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_FW_BONUS_LIST_DATA . $periodNum);
+    }
+
+    /**
+     * 会员信息加入缓存
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return bool
+     */
+    public static function addUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+//        echo sprintf("时间:[%s]缓存用户,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
+        // 修复USER_INFO表里面已经没有PERIOD_NUM了
+        $allData = UserInfo::findUseDbCalc()->from(UserInfo::tableName(). 'AS UI')->select('UI.USER_ID,U.STATUS')->leftJoin(User::tableName() . 'AS U', 'U.ID=UI.USER_ID')->where('1=1')->orderBy('UI.RELATION_DEEP DESC,UI.ID DESC')->offset($offset)->limit($limit)->asArray()->all();
+        //$allData = User::findUseDbShopCalc()->select('ID AS USER_ID')->where('PERIOD_AT<=:PERIOD_AT AND IS_UNION=0 AND DELETED=0', [':PERIOD_AT' => $periodNum])->offset($offset)->limit($limit)->asArray()->all();
+        if ($allData) {
+            foreach ($allData as $data) {
+//                if(User::find()->where('ID=:ID',[':ID'=>$data['USER_ID']])->exists()) continue;
+                // 会员ID加入缓存
+                $cacheKey = self::REDIS_KEY_PREFIX_USER . $periodNum;
+                $value = $data['USER_ID'];
+                Yii::$app->redis->rpush($cacheKey, $value);
+                if( $data['STATUS'] == 1 ) {
+                    $activeCacheKey = self::REDIS_KEY_PREFIX_USER_ACTIVE . $periodNum;
+                    Yii::$app->redis->rpush($activeCacheKey, $value);
+                    unset($activeCacheKey);
+                }
+                unset($data, $cacheKey, $value);
+            }
+            unset($allData);
+            return self::addUsers($periodNum, $offset + $limit, $limit);
+        }
+        unset($allData);
+        return true;
+    }
+
+    /**
+     * 获取会员从缓存中
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 获取激活会员从缓存中
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getActiveUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_USER_ACTIVE . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 加入有业绩的会员
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasPerfUsers($userId, $periodNum) {
+        // 先从已存在的会员池里面获取
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_PERF_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_PERF_USER_POOL . $periodNum, $userId, 1);
+            Yii::$app->redis->rpush(self::REDIS_KEY_PREFIX_HAS_PERF_USER . $periodNum, $userId);
+        }
+        unset($userId, $periodNum, $isset);
+    }
+
+    /**
+     * 获取有业绩的会员
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasPerfUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_PERF_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 加入有月业绩的会员
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasMonthPerfUsers($userId, $periodNum) {
+        // 先从已存在的会员池里面获取
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER_POOL . $periodNum, $userId, 1);
+            Yii::$app->redis->rpush(self::REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER . $periodNum, $userId);
+        }
+        unset($userId, $periodNum, $isset);
+    }
+
+    /**
+     * 获取有业绩的会员
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasMonthPerfUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 加入有达标业绩的会员
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasStandardMonthPerfUsers($userId, $periodNum) {
+        // 先从已存在的会员池里面获取
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER_POOL . $periodNum, $userId, 1);
+            Yii::$app->redis->rpush(self::REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER . $periodNum, $userId);
+        }
+        unset($userId, $periodNum, $isset);
+    }
+
+    /**
+     * 获取有达标业绩的会员
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasStandardMonthPerfUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+
+    /**
+     * 加入被报单的会员
+     * @param $userId
+     * @param $periodNum
+     * @param $saveData
+     */
+    public static function addHasBDUsers($userId, $periodNum, $saveData) {
+        // 先从已存在的会员池里面获取
+        $data = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_BD_USER_POOL . $periodNum, $userId);
+        if (!$data) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_BD_USER_POOL . $periodNum, $userId, Json::encode($saveData));
+            Yii::$app->redis->rpush(self::REDIS_KEY_PREFIX_HAS_BD_USER . $periodNum, $userId);
+        }
+        unset($userId, $periodNum, $saveData, $isset);
+    }
+
+    /**
+     * 获取被报单的会员信息
+     * @param $userId
+     * @param $periodNum
+     * @return array
+     */
+    public static function getBDUsersInfo($userId, $periodNum) {
+        $data = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_BD_USER_POOL . $periodNum, $userId);
+        if( !$data ) return [];
+
+        return Json::decode($data, true);
+    }
+
+    /**
+     * 获取被报单的会员
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasBDUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_BD_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 加入有收入的会员
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasIncomeUsers($userId, $periodNum) {
+        // 先从已存在的会员池里面获取
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_INCOME_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_INCOME_USER_POOL . $periodNum, $userId, 1);
+            Yii::$app->redis->rpush(self::REDIS_KEY_PREFIX_HAS_INCOME_USER . $periodNum, $userId);
+        }
+
+        unset($userId, $periodNum, $isset);
+    }
+
+    /**
+     * 获取有收入的会员
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasIncomeUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_INCOME_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 加入有奖金的会员
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasBonusUsers($userId, $periodNum) {
+        // 先从已存在的会员池里面获取
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_BONUS_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_BONUS_USER_POOL . $periodNum, $userId, 1);
+            Yii::$app->redis->rpush(self::REDIS_KEY_PREFIX_HAS_BONUS_USER . $periodNum, $userId);
+        }
+
+        unset($userId, $periodNum, $isset);
+    }
+
+    /**
+     * 获取有奖金的会员
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasBonusUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_BONUS_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 获取有服务奖的会员
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasFwBonusUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+
+    /**
+     * 加入服务奖的会员
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasFwBonusUsers($userId, $periodNum) {
+        // 先从已存在的会员池里面获取
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER_POOL . $periodNum, $userId, 1);
+            Yii::$app->redis->rpush(self::REDIS_KEY_PREFIX_HAS_FW_BONUS_USER . $periodNum, $userId);
+        }
+
+        unset($userId, $periodNum, $isset);
+    }
+
+    /**
+     * 获取有月奖的会员
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasMonthBonusUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+
+    /**
+     * 加入月奖的会员
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasMonthBonusUsers($userId, $periodNum) {
+        // 先从已存在的会员池里面获取
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER_POOL . $periodNum, $userId, 1);
+            Yii::$app->redis->rpush(self::REDIS_KEY_PREFIX_HAS_MONTH_BONUS_USER . $periodNum, $userId);
+        }
+
+        unset($userId, $periodNum, $isset);
+    }
+
+    /**
+     * 保存荣衔奖奖金
+     * @param $userId
+     * @param $periodNum
+     * @param $fwBonus
+     * @param array $fromData
+     */
+    public static function saveFwBonusList($userId, $periodNum, $fwBonus, $fromData=[]) {
+        $userFwBonusData = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_FW_BONUS_LIST_DATA . $periodNum, $userId);
+
+        if( $userFwBonusData ) {
+            $fwBonusData = Json::decode($userFwBonusData, true);
+            $fwBonusData['fwBonus'] += $fwBonus;
+//            $ycBonusData['fromData'][] = $fromData;
+        }else {
+            $fwBonusData = [
+                'fwBonus' => $fwBonus,
+//                'fromData' => [
+//                    $fromData
+//                ]
+            ];
+        }
+        unset($userFwBonusData);
+
+        Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_FW_BONUS_LIST_DATA . $periodNum, $userId, Json::encode($fwBonusData));
+        unset($fwBonusData, $userId, $periodNum, $empBonus, $fromData);
+    }
+
+    /**
+     * 返回服务奖信息
+     * @param $userId
+     * @param $periodNum
+     * @return array
+     */
+    public static function getFwBonusList($userId, $periodNum) {
+        $userYcBonusData = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_FW_BONUS_LIST_DATA . $periodNum, $userId);
+
+        return $userYcBonusData ? Json::decode($userYcBonusData, true) : [];
+    }
+
+    /**
+     * 加入有复销业绩的会员列表
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasScoreUsers($userId, $periodNum) {
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_SCORE_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_SCORE_USER_POOL . $periodNum, $userId, 1);
+            $key = self::REDIS_KEY_PREFIX_HAS_SCORE_USER . $periodNum;
+            Yii::$app->redis->rpush($key, $userId);
+        }
+    }
+
+    /**
+     * 获取有复销业绩的会员列表
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasScoreUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_SCORE_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 加入有零售个人消费的会员列表
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasLSPCSUsers($userId, $periodNum) {
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_LS_PCS_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_LS_PCS_USER_POOL . $periodNum, $userId, 1);
+            $key = self::REDIS_KEY_PREFIX_HAS_LS_PCS_USER . $periodNum;
+            $value = $userId;
+            Yii::$app->redis->rpush($key, $value);
+        }
+    }
+
+    /**
+     * 加入有零售消费的会员列表
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasLSPCSUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_LS_PCS_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 有车房补贴比例的人
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasCFPercentUsers($userId, $periodNum) {
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER_POOL . $periodNum, $userId, 1);
+            $key = self::REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER . $periodNum;
+            $value = $userId;
+            Yii::$app->redis->rpush($key, $value);
+        }
+    }
+
+    /**
+     * 获取有车房补贴的人
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasCFPercentUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_CF_PERCENT_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 有领袖分红的人
+     * @param $userId
+     * @param $periodNum
+     */
+    public static function addHasLXPercentUsers($userId, $periodNum) {
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER_POOL . $periodNum, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER_POOL . $periodNum, $userId, 1);
+            $key = self::REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER . $periodNum;
+            $value = $userId;
+            Yii::$app->redis->rpush($key, $value);
+        }
+    }
+
+    /**
+     * 获取有领袖分红的人
+     * @param $periodNum
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasLXPercentUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_LX_PERCENT_USER . $periodNum, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 通过创建时间获取指定长度的用户列表
+     * @param $userId
+     * @param $limit
+     * @return array|\yii\db\ActiveRecord[]
+     */
+    public static function getUserListByCreatedAtFromDb($userId, $limit)
+    {
+        //查找这个人的CREATED_AT
+        $user = User::findUseDbCalc()->select('ID,CREATED_AT')->where('ID=:ID', ['ID'=>$userId])->asArray()->one();
+        if( !$user ) return [];
+
+        return User::findUseDbCalc()->select('ID,CREATED_AT')->where('ID<:ID AND CREATED_AT<=:CREATED_AT', [
+            'ID'=>$userId,
+            'CREATED_AT' => $user['CREATED_AT']
+        ])->orderBy('CREATED_AT DESC,ID DESC')->limit($limit)->asArray()->all();
+    }
+
+    /**
+     * 通过创建时间获取指定长度的用户列表
+     * @param $userId
+     * @param $limit
+     * @return array|\yii\db\ActiveRecord[]
+     */
+    public static function getAfterUserListByCreatedAtFromDb($userId, $limit)
+    {
+        $cacheKey = Cache::PRE_USER_CREATED_AT_LIST . $limit;
+        $value = Yii::$app->redis->hGet($cacheKey, $userId);
+        if( $value ) {
+            unset($cacheKey);
+            return json_decode($value, true);
+        }
+        unset($value);
+
+        $list = UserInfo::findUseDbCalc()->select('USER_ID')->where('USER_ID>:USER_ID', [
+            'USER_ID'=>$userId,
+        ])->orderBy('USER_ID ASC')->limit($limit)->asArray()->all();
+        if ( $limit == count($list) ) {
+            Yii::$app->redis->hSet($cacheKey, $userId, json_encode($list));
+        }
+
+        unset($cacheKey);
+        return $list;
+    }
+
+    /**
+     * 获取会员信息从缓存
+     * @param $userId
+     * @param $periodNum
+     * @return array
+     * @throws \Exception
+     */
+    public static function getUserInfo($userId, $periodNum) {
+        $key = self::REDIS_KEY_PREFIX_USER_INFO . $periodNum;
+        $data = Yii::$app->redis->hget($key, $userId);
+        if (!$data) {
+            $userInfo = UserInfo::findUseDbCalc()->select('USER_ID,USER_NAME,ZC_AMOUNT,ZC_PV,CON_UID,REC_UID,CON_NUM,REC_NUM,NETWORK_DEEP,RELATION_DEEP,STORE_TYPE,UPDATED_AT,SYSTEM_ID')->where('USER_ID=:USER_ID', [':USER_ID' => $userId])->asArray()->one();
+            if( !$userInfo ) {
+                throw new \Exception('用户信息表数据不存在,userId:'.$userId);
+            }
+            // 在获取商城库的会员的级别信息和是否报单中心的会员
+            $userShopInfo = User::find()->select('REAL_NAME,LAST_DEC_LV,DEC_LV,EMP_LV,IS_DEC,DEC_ID,DEC_ROLE_ID,STATUS,PERIOD_AT,MOBILE,CREATED_AT,SUB_COM_ID,PROVINCE,CITY,COUNTY,DEC_PROVINCE,DEC_CITY,DEC_COUNTY,IS_DIRECT_SELLER,SUB_COM_LEADER')->where('ID=:ID', [':ID' => $userId])->asArray()->one();
+            if ( !$userShopInfo ) {
+                throw new \Exception('用户表数据不存在,userId:'.$userId);
+            }
+            $userInfo['REAL_NAME'] = $userShopInfo['REAL_NAME'];
+//            $userInfo['DEC_LV'] = $userShopInfo['DEC_LV'];
+            //先用last_dec_lv
+            $userInfo['DEC_LV'] = $userShopInfo['LAST_DEC_LV'];
+            $userInfo['EMP_LV'] = $userShopInfo['EMP_LV'];
+            $userInfo['IS_DEC'] = $userShopInfo['IS_DEC'];
+            $userInfo['DEC_ID'] = $userShopInfo['DEC_ID'];
+            $userInfo['DEC_ROLE_ID'] = $userShopInfo['DEC_ROLE_ID'];
+            $userInfo['DEC_PROVINCE'] = $userShopInfo['DEC_PROVINCE'];
+            $userInfo['DEC_CITY'] = $userShopInfo['DEC_CITY'];
+            $userInfo['DEC_COUNTY'] = $userShopInfo['DEC_COUNTY'];
+            $userInfo['STATUS'] = $userShopInfo['STATUS'];
+            $userInfo['PERIOD_NUM'] = $userShopInfo['PERIOD_AT'];
+            $userInfo['MOBILE'] = $userShopInfo['MOBILE'];
+            $userInfo['CREATED_AT'] = $userShopInfo['CREATED_AT'];
+            $userInfo['SUB_COM_ID'] = $userShopInfo['SUB_COM_ID'];
+            $userInfo['PROVINCE'] = $userShopInfo['PROVINCE'];
+            $userInfo['CITY'] = $userShopInfo['CITY'];
+            $userInfo['COUNTY'] = $userShopInfo['COUNTY'];
+            $userInfo['IS_DIRECT_SELLER'] = $userShopInfo['IS_DIRECT_SELLER'];
+            $userInfo['SUB_COM_LEADER'] = $userShopInfo['SUB_COM_LEADER'];
+            $userInfo['REC_USER_NAME'] = isset($userInfo['REC_UID']) && $userInfo['REC_UID'] ? Info::getUserNameByUserId($userInfo['REC_UID']) : '';
+            $userInfo['REC_REAL_NAME'] = isset($userInfo['REC_UID']) && $userInfo['REC_UID'] ? Info::getUserRealNameByUserId($userInfo['REC_UID']) : '';
+            $userInfo['CON_USER_NAME'] = isset($userInfo['CON_UID']) && $userInfo['CON_UID'] ? Info::getUserNameByUserId($userInfo['CON_UID']) : '';
+            $userInfo['CON_REAL_NAME'] = isset($userInfo['CON_UID']) && $userInfo['CON_UID'] ? Info::getUserRealNameByUserId($userInfo['CON_UID']) : '';
+            unset($userShopInfo);
+
+            if (!$userInfo['DEC_LV']) {
+                $userInfo['DEC_LV'] = DeclarationLevel::getDefaultLevelId();
+            }
+            if (!$userInfo['EMP_LV']) {
+                $userInfo['EMP_LV'] = EmployLevel::getDefaultLevelId();
+            }
+            $data = Json::encode($userInfo);
+            Yii::$app->redis->hset($key, $userId, $data);
+            unset($userInfo, $key, $userId, $periodNum);
+        }
+        return $data ? Json::decode($data, true) : [];
+    }
+
+    public static function setUserInfo($userId, $periodNum, $userInfo) {
+        $key = self::REDIS_KEY_PREFIX_USER_INFO . $periodNum;
+        $data = Json::encode($userInfo);
+        Yii::$app->redis->hset($key, $userId, $data);
+        unset($userId, $key, $data, $userInfo, $periodNum);
+        return true;
+    }
+
+    /**
+     * 用户奖金信息
+     * @param $userId
+     * @param $periodNum
+     * @return array|mixed|null|\yii\db\ActiveRecord
+     */
+    public static function LastUserBonus($userId, $periodNum) {
+
+        $cacheKey = self::REDIS_KEY_PREFIX_USER_BONUS . $periodNum;
+        $field = $userId;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $field);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue, true);
+        } else {
+            $value = UserBonus::findUseDbCalc()->select('USER_ID,BONUS_TOTAL')->where('USER_ID=:USER_ID', [
+                'USER_ID'=>$userId
+            ])->asArray()->one();
+
+            \Yii::$app->redis->hset($cacheKey, $field, Json::encode($value));
+        }
+        return $value;
+    }
+
+    /**
+     * 用户奖金信息
+     * @param $userId
+     * @param $periodNum
+     * @param $yearMonth
+     * @return array|mixed|null|\yii\db\ActiveRecord
+     */
+    public static function lastPeriodMonthCalcBonus($userId, $periodNum, $yearMonth) {
+
+        $cacheKey = self::REDIS_KEY_PREFIX_PERIOD_MONTH_CALC_BONUS . $periodNum;
+        $field = $userId;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $field);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue, true);
+        } else {
+            $value = CalcBonus::findUseDbCalc()->select('SUM(ORI_BONUS_QY) AS ORI_BONUS_QY_SUM,SUM(ORI_BONUS_VIP) AS ORI_BONUS_VIP_SUM')->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [
+                'USER_ID'=>$userId,
+                'CALC_MONTH'=>$yearMonth
+            ])->asArray()->one();
+
+            \Yii::$app->redis->hset($cacheKey, $field, Json::encode($value));
+        }
+        return $value;
+    }
+
+
+    /**
+     * 本月往期的复消积分的数据
+     * @param $userId
+     * @param $periodNum
+     * @param $calcYearMonth
+     * @return array|mixed|null|\yii\db\ActiveRecord
+     * @throws \yii\db\Exception
+     */
+    public static function monthLastPeriodReconsumePoints($userId, $periodNum, $calcYearMonth) {
+        $cacheKey = self::REDIS_KEY_PREFIX_NOW_MONTH_LAST_PERIOD_RECONSUME_POINTS . $periodNum;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $userId);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue, true);
+        } else {
+            $value = CalcBonus::findUseDbCalc()->select(["SUM(RECONSUME_POINTS) as RECONSUME_POINTS_SUM"])->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID' => $userId, ':CALC_MONTH'=>$calcYearMonth])->asArray()->one();
+            \Yii::$app->redis->hset($cacheKey, $userId, Json::encode($value));
+        }
+        return $value;
+    }
+
+    /**
+     * 获取结算时这一期的报单中心级别的配置
+     * @param $periodNum
+     * @return array|\yii\db\ActiveRecord[]
+     */
+    public static function getDecRoleConfig($periodNum) {
+        $key = self::REDIS_KEY_PREFIX_DEC_ROLE_CONFIG . $periodNum;
+        Yii::$app->redis->del($key);
+        $data = Yii::$app->redis->get($key);
+        if (!$data) {
+            $data = DecRole::find()->where('1=1')->indexBy('ID')->asArray()->all();
+            $data = Json::encode($data);
+            Yii::$app->redis->set($key, $data);
+        }
+        return $data ? Json::decode($data) : [];
+    }
+
+    /**
+     * 上一期结余业绩
+     * @param $userId
+     * @param $periodNum
+     * @return array|mixed|\yii\db\ActiveRecord|null
+     * @throws \yii\db\Exception
+     */
+    public static function surplusPerf($userId, $periodNum) {
+        $userPerf = self::userPerf($userId, $periodNum);
+        return [
+            'SURPLUS_1L' => $userPerf['SURPLUS_1L'],
+            'SURPLUS_2L' => $userPerf['SURPLUS_2L'],
+            'SURPLUS_3L' => $userPerf['SURPLUS_3L'],
+            'SURPLUS_4L' => $userPerf['SURPLUS_4L'],
+            'SURPLUS_5L' => $userPerf['SURPLUS_5L'],
+            'SURPLUS_1L_ZC' => $userPerf['SURPLUS_1L_ZC'],
+            'SURPLUS_2L_ZC' => $userPerf['SURPLUS_2L_ZC'],
+            'SURPLUS_3L_ZC' => $userPerf['SURPLUS_3L_ZC'],
+            'SURPLUS_4L_ZC' => $userPerf['SURPLUS_4L_ZC'],
+            'SURPLUS_5L_ZC' => $userPerf['SURPLUS_5L_ZC'],
+            'SURPLUS_1L_FX' => $userPerf['SURPLUS_1L_FX'],
+            'SURPLUS_2L_FX' => $userPerf['SURPLUS_2L_FX'],
+            'SURPLUS_3L_FX' => $userPerf['SURPLUS_3L_FX'],
+            'SURPLUS_4L_FX' => $userPerf['SURPLUS_4L_FX'],
+            'SURPLUS_5L_FX' => $userPerf['SURPLUS_5L_FX'],
+            'VIP_SURPLUS_1L_ZC' => $userPerf['VIP_SURPLUS_1L_ZC'],
+            'VIP_SURPLUS_2L_ZC' => $userPerf['VIP_SURPLUS_2L_ZC'],
+            'VIP_SURPLUS_3L_ZC' => $userPerf['VIP_SURPLUS_3L_ZC'],
+            'VIP_SURPLUS_4L_ZC' => $userPerf['VIP_SURPLUS_4L_ZC'],
+            'VIP_SURPLUS_5L_ZC' => $userPerf['VIP_SURPLUS_5L_ZC'],
+            'SURPLUS_LS' => 0,
+        ];
+    }
+
+    /**
+     * 获取repairSurplusPerf
+     * @param $userId
+     * @return int[]|mixed|null
+     */
+    public static function getRepairSurplusPerf($userId) {
+        $cacheKey = self::REDIS_KEY_PREFIX_REPAIR_SURPLUS_PERF;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $userId);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue);
+        }else {
+            $value = [
+                'SURPLUS_1L' => 0,
+                'SURPLUS_2L' => 0,
+                'SURPLUS_3L' => 0,
+                'SURPLUS_4L' => 0,
+                'SURPLUS_5L' => 0,
+            ];
+        }
+
+        return $value;
+    }
+
+    /**
+     * 累加repairSurplusPerf
+     * @param $userId
+     * @param $surplusPerf
+     * @return int[]|mixed|null
+     */
+    public static function setRepairSurplusPerf($userId, $surplusPerf) {
+        $surplusPerfList = self::getRepairSurplusPerf($userId);
+        foreach ($surplusPerfList as $key => $perf) {
+            $thisPerf = $surplusPerf[$key] ?? 0;
+            $surplusPerfList[$key] = $perf + $thisPerf;
+
+            unset($key, $perf, $thisPerf);
+        }
+
+        $cacheKey = self::REDIS_KEY_PREFIX_REPAIR_SURPLUS_PERF;
+        \Yii::$app->redis->hset($cacheKey, $userId, Json::encode($surplusPerfList));
+        self::addHasRepairPerfUsers($userId);
+
+        unset($userId, $cacheKey, $surplusPerf);
+
+        return $surplusPerfList;
+    }
+
+    /**
+     * 加入有往期结余业绩的会员
+     * @param $userId
+     */
+    public static function addHasRepairPerfUsers($userId) {
+        // 先从已存在的会员池里面获取
+        $isset = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_HAS_REPAIR_PERF_USER_POOL, $userId);
+        if (!$isset) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_HAS_REPAIR_PERF_USER_POOL, $userId, 1);
+            Yii::$app->redis->rpush(self::REDIS_KEY_PREFIX_HAS_REPAIR_PERF_USER, $userId);
+        }
+        unset($userId, $isset);
+    }
+
+    /**
+     * 获取有往期结余业绩的会员
+     * @param int $offset
+     * @param int $limit
+     * @return mixed
+     */
+    public static function getHasRepairPerfUsers($offset = 0, $limit = self::LIMIT) {
+        return Yii::$app->redis->lrange(self::REDIS_KEY_PREFIX_HAS_REPAIR_PERF_USER, $offset, ($offset + $limit - 1));
+    }
+
+    /**
+     * 修正业绩缓存清空
+     */
+    public static function clearRepairAllCache() {
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_REPAIR_SURPLUS_PERF);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_REPAIR_PERF_USER);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_HAS_REPAIR_PERF_USER_POOL);
+    }
+
+    /**
+     * 上一期结余业绩
+     * @param $userId
+     * @param $periodNum
+     * @return array|mixed|\yii\db\ActiveRecord|null
+     * @throws \yii\db\Exception
+     */
+    public static function userPerf($userId, $periodNum) {
+        $cacheKey = self::REDIS_KEY_PREFIX_USER_PERF . $periodNum;
+        $field = $userId;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $field);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue);
+        } else {
+            $value = UserPerf::getOneUserPerf($userId);
+            \Yii::$app->redis->hset($cacheKey, $field, Json::encode($value));
+        }
+        return $value;
+    }
+
+    /**
+     * 当前期数的的业绩
+     * @param $userId
+     * @param $periodNum
+     * @param null $perf
+     * @return array|mixed
+     */
+    public static function nowPeriodPerf($userId, $periodNum, $perf = null) {
+        $cacheKey = self::REDIS_KEY_PREFIX_NOW_PERIOD_PERF . $periodNum;
+        $field = $userId;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $field);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue);
+        } else {
+            $value = [
+                'FX_AMOUNT_CASH' => 0,
+                'PV_PCS' => 0,
+                'PV_PSS' => 0,//本期的团队业绩
+                'PV_PCS_ZC' => 0,//注册
+                'PV_PCS_YH' => 0,
+                'PV_PCS_ZG' => 0,//增购
+                'PV_PCS_LS' => 0,
+                'PV_PCS_FX' => 0,
+                'PV_PCS_FX_CASH' => 0,//现金复消
+                'PV_PCS_FX_POINT' => 0,//积分复消
+                'PV_1L' => 0,
+                'PV_1L_TOUCH' => 0,
+                'PV_1L_ZC' => 0,
+                'PV_1L_YH' => 0,
+                'PV_1L_ZG' => 0,
+                'PV_1L_LS' => 0,
+                'PV_1L_FX' => 0,
+                'PV_2L' => 0,
+                'PV_2L_TOUCH' => 0,
+                'PV_2L_ZC' => 0,
+                'PV_2L_YH' => 0,
+                'PV_2L_ZG' => 0,
+                'PV_2L_LS' => 0,
+                'PV_2L_FX' => 0,
+                'PV_3L' => 0,
+                'PV_3L_TOUCH' => 0,
+                'PV_3L_ZC' => 0,
+                'PV_3L_YH' => 0,
+                'PV_3L_ZG' => 0,
+                'PV_3L_LS' => 0,
+                'PV_3L_FX' => 0,
+                'PV_4L' => 0,
+                'PV_4L_TOUCH' => 0,
+                'PV_4L_ZC' => 0,
+                'PV_4L_YH' => 0,
+                'PV_4L_ZG' => 0,
+                'PV_4L_LS' => 0,
+                'PV_4L_FX' => 0,
+                'PV_5L' => 0,
+                'PV_5L_TOUCH' => 0,
+                'PV_5L_ZC' => 0,
+                'PV_5L_YH' => 0,
+                'PV_5L_ZG' => 0,
+                'PV_5L_LS' => 0,
+                'PV_5L_FX' => 0,
+                'PV_LS_TOUCH' => 0,
+                'SURPLUS_1L' => 0,
+                'SURPLUS_2L' => 0,
+                'SURPLUS_3L' => 0,
+                'SURPLUS_4L' => 0,
+                'SURPLUS_5L' => 0,
+                'SURPLUS_1L_ZC' => 0,
+                'SURPLUS_2L_ZC' => 0,
+                'SURPLUS_3L_ZC' => 0,
+                'SURPLUS_4L_ZC' => 0,
+                'SURPLUS_5L_ZC' => 0,
+                'SURPLUS_1L_FX' => 0,
+                'SURPLUS_2L_FX' => 0,
+                'SURPLUS_3L_FX' => 0,
+                'SURPLUS_4L_FX' => 0,
+                'SURPLUS_5L_FX' => 0,
+                'SURPLUS_LS' => 0,
+            ];
+        }
+        if ($perf !== null) {
+            foreach ($perf as $key => $pv) {
+                if (strpos($key, 'SURPLUS') !== false) {
+                    $value[$key] = $pv;
+                } else {
+                    $value[$key] = $pv + $value[$key];
+                }
+            }
+            Yii::$app->redis->hset($cacheKey, $field, Json::encode($value));
+        }
+        return $value;
+    }
+
+    /**
+     * 上个月的业绩
+     * @param $userId
+     * @param $periodNum
+     * @return array|mixed|null|\yii\db\ActiveRecord
+     */
+    public static function lastMonthPerf($userId, $periodNum) {
+        $period = Period::instance();
+        $last = $period->getLastMonth($periodNum);
+        $lastYearMonth = $last['yearMonth'];
+        $cacheKey = self::REDIS_KEY_PREFIX_LAST_MONTH_PERF . $periodNum;
+        $field = $userId;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $field);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue);
+        } else {
+            $value = PerfMonth::getMonthPerf($lastYearMonth, $userId);
+            \Yii::$app->redis->hset($cacheKey, $field, Json::encode($value));
+        }
+        return $value;
+    }
+
+    /**
+     * 当前月的业绩
+     * @param $userId
+     * @param $periodNum
+     * @param $perf
+     * @return array|mixed
+     */
+    public static function nowMonthPerf($userId, $periodNum, $perf = null) {
+        $cacheKey = self::REDIS_KEY_PREFIX_NOW_MONTH_PERF . $periodNum;
+        $field = $userId;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $field);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue);
+        } else {
+            $baseInfo = self::getUserInfo($userId, $periodNum);
+            $value = [
+                'USER_ID' => $userId,
+                'FX_AMOUNT_CASH' => 0,
+                'PV_PCS' => 0,
+                'PV_PCS_FX' => 0,
+                'PV_PSS' => 0,
+                'PV_1L' => 0,
+                'PV_2L' => 0,
+                'PV_3L' => 0,
+                'PV_4L' => 0,
+                'PV_5L' => 0,
+                'VIP_PV_1L_ZC' => 0,
+                'VIP_PV_2L_ZC' => 0,
+                'VIP_PV_3L_ZC' => 0,
+                'VIP_PV_4L_ZC' => 0,
+                'VIP_PV_5L_ZC' => 0,
+                'PV_1L_TOTAL' => 0,
+                'PV_2L_TOTAL' => 0,
+                'PV_3L_TOTAL' => 0,
+                'PV_4L_TOTAL' => 0,
+                'PV_5L_TOTAL' => 0,
+                'PV_PSS_TOTAL' => 0,
+                'DEC_LEVEL' => $baseInfo['DEC_LV'],
+                'EMP_LEVEL' => EmployLevel::getDefaultLevelId(),
+                'CF_PERCENT' => 0,
+                'LX_PERCENT' => 0,
+                'FX_STATUS' => PerfMonth::NEXT_MONTH_FX_FALSE,
+            ];
+        }
+        if ($perf !== null) {
+            foreach ($perf as $key => $item) {
+                $value[$key] = $item;
+            }
+        }
+        Yii::$app->redis->hset($cacheKey, $field, Json::encode($value));
+        return $value;
+    }
+
+    /**
+     * 当前期数的的业绩
+     * @param $userId
+     * @param $periodNum
+     * @param null $perf
+     * @return array|mixed
+     */
+    public static function nowStandardMonthPerf($userId, $periodNum, $perf = null) {
+        $cacheKey = self::REDIS_KEY_PREFIX_NOW_STANDARD_MONTH_PERF . $periodNum;
+        $field = $userId;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $field);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue);
+        } else {
+            $value = [
+                'AMOUNT_PCS' => 0,
+                'AMOUNT_PSS' => 0
+            ];
+        }
+        if ($perf !== null) {
+            foreach ($perf as $key => $pv) {
+                $value[$key] = $pv + $value[$key];
+            }
+            Yii::$app->redis->hset($cacheKey, $field, Json::encode($value));
+        }
+        return $value;
+    }
+
+    /**
+     * 当前月的积分
+     * @param $userId
+     * @param $periodNum
+     * @param $perf
+     * @return array|mixed
+     */
+    public static function nowMonthScore($userId, $periodNum, $perf = null) {
+        $cacheKey = self::REDIS_KEY_PREFIX_NOW_MONTH_SCORE . $periodNum;
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $userId);
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue);
+        } else {
+            $value = [
+                'USER_ID' => $userId,
+                'BASE_SCORE' => 0,
+                'LEVEL_SCORE' => 0,
+                'UPGRADE_SCORE' => 0,
+//                'TOTAL_SCORE' => 0,
+            ];
+        }
+        unset($cacheValue);
+        if ($perf !== null) {
+            foreach ($perf as $key => $item) {
+                $value[$key] = $item;
+//                $value['TOTAL_SCORE'] += $item;
+                unset($key, $item);
+            }
+            Yii::$app->redis->hset($cacheKey, $userId, Json::encode($value));
+        }
+
+        unset($userId, $periodNum, $perf, $cacheKey);
+        return $value;
+    }
+
+    /**
+     * 获取直推的所有子会员
+     * @param $userId
+     * @param $periodNum
+     * @return array
+     */
+    public static function getChildrenOneDeepFromRedis($userId, $periodNum){
+        $key = self::REDIS_KEY_PREFIX_USER_INFO_CHILD_ONE_DEEP . $periodNum;
+        $data = Yii::$app->redis->hget($key, $userId);
+        if(!$data){
+            $list = UserInfo::findUseDbCalc()->select('USER_ID')->where('REC_UID=:REC_UID', [
+                'REC_UID' => $userId
+            ])->asArray()->all();
+            $data = Json::encode($list);
+            unset($list);
+            Yii::$app->redis->hset($key, $userId, $data);
+        }
+        unset($key, $userId, $periodNum);
+        return $data ? Json::decode($data, true) : [];
+    }
+
+    /**
+     * 每个区有多少个什么级别的数量
+     * @param $userId
+     * @param $periodNum
+     * @param null $levelNumArr
+     * @return array|mixed
+     */
+    public static function hasEmpLevelNum($userId,  $periodNum, $levelNumArr = null) {
+        $key = self::REDIS_KEY_PREFIX_EMP_NUM_PERF . $periodNum;
+        $field = $userId;
+        $cacheValue = Yii::$app->redis->hget($key, $field);
+
+        if ($cacheValue) {
+            $value = Json::decode($cacheValue);
+        } else {
+            $allEmpLevel = EmployLevel::getFromCache();
+            $value = [];
+            $relationList = self::getChildrenOneDeepFromRedis($userId, $periodNum);
+            foreach ($relationList as $relationData) {
+                foreach ($allEmpLevel as $level) {
+                    // 从月度业绩表中找到所有下级的各个部门的数量
+                    $value[$relationData['USER_ID']][$level['ID']] = 0;
+                }
+            }
+        }
+        if ($levelNumArr != null) {
+            foreach ($levelNumArr as $departUserId => $item) {
+                foreach ($item as $levelID => $num) {
+                    if( isset($value[$departUserId][$levelID]) ) {
+                        $value[$departUserId][$levelID] += $num;
+                    }else {
+                        $value[$departUserId][$levelID] = $num;
+                    }
+                }
+            }
+        }
+        Yii::$app->redis->hset($key, $field, Json::encode($value));
+
+        if ($levelNumArr == null) return $value;
+    }
+
+    /**
+     * 会员是否本月注册
+     * @param $userId
+     * @param $periodNum
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public static function isMonthJoinFromRedis($userId, $periodNum) {
+        $period = Period::instance();
+        $calcYearMonth = $period->getYearMonth($periodNum);
+        $userInfo = self::getUserInfo($userId, $periodNum);
+        $addYearMonth = $period->getYearMonth($userInfo['PERIOD_NUM']);
+        //当月注册
+        if ($addYearMonth == $calcYearMonth) return true;
+        //上月注册
+        $calcLastYearMonth = $period->getLastMonth($periodNum);
+        if ($addYearMonth == $calcLastYearMonth['yearMonth']) return true;
+        // 未来注册
+        if ($addYearMonth > $calcYearMonth) return true;
+        return false;
+    }
+
+    /**
+     * 服务奖最大比例
+     * @param $userId
+     * @param $periodNum
+     * @param int $percent
+     * @return float|int
+     */
+    public static function fwMaxBonusPercent($userId, $periodNum, $percent=0) {
+        $cacheKey = self::REDIS_KEY_PREFIX_FW_BONUS . $periodNum;
+        $value = Yii::$app->redis->hget($cacheKey, $userId);
+        $maxPercent = floatval($value)>0 ? floatval($value) : 0;
+        if ( $percent > 0 && $percent > $maxPercent ) {
+            $maxPercent = $percent;
+            unset($periodNum, $percent);
+            Yii::$app->redis->hset($cacheKey, $userId, $maxPercent);
+
+            return $maxPercent;
+        }
+
+        unset($userId, $periodNum, $oriBonus, $cacheKey, $value);
+        return $maxPercent;
+    }
+
+    /**
+     * 奖金缓存
+     * @param $userId
+     * @param $periodNum
+     * @param string $bonusType
+     * @param float $oriBonus
+     * @param array $deductData
+     * @return array|mixed
+     */
+    public static function bonus($userId, $periodNum, $bonusType = null, $oriBonus = 0.00, $deductData=[], $fromMeans='') {
+        $cacheKey = self::REDIS_KEY_PREFIX_BONUS . $periodNum;
+        $value = [
+            'BONUS_BD' => 0,
+            'BONUS_TG' => 0,
+            'BONUS_XF' => 0,
+            'BONUS_YJ' => 0,
+            'BONUS_GX' => 0,
+            'BONUS_GL' => 0,
+            'BONUS_QY' => 0,
+            'BONUS_YC' => 0,
+            'BONUS_VIP' => 0,
+            'BONUS_YC_EXTRA' => 0,
+            'ORI_BONUS_BD' => 0,
+            'ORI_BONUS_TG' => 0,
+            'ORI_BONUS_XF' => 0,
+            'ORI_BONUS_YJ' => 0,
+            'ORI_BONUS_YJ_BD' => 0,
+            'ORI_BONUS_YJ_FX' => 0,
+            'ORI_BONUS_GX' => 0,
+            'ORI_BONUS_GL' => 0,
+            'ORI_BONUS_GL_BD' => 0,
+            'ORI_BONUS_GL_FX' => 0,
+            'ORI_BONUS_QY' => 0,
+            'ORI_BONUS_QY_BD' => 0,
+            'ORI_BONUS_QY_FX' => 0,
+            'ORI_BONUS_YC' => 0,
+            'ORI_BONUS_VIP' => 0,
+            'ORI_BONUS_YC_EXTRA' => 0,
+//            'INCOME_TG_TOTAL' => 0,
+//            'INCOME_YJ_TOTAL' => 0,
+//            'INCOME_QY_TOTAL' => 0,
+            'INCOME_TOTAL' => 0,
+            'BONUS_TOTAL' => 0,
+            'RECONSUME_POINTS' => 0,
+            'MANAGE_TAX' => 0,
+
+            //没有用到的
+            'BONUS_FX' => 0,
+            'BONUS_LS' => 0,
+            'BONUS_CF' => 0,
+            'BONUS_LX' => 0,
+            'BONUS_HB' => 0,
+            'BONUS_BT' => 0,
+            'BONUS_BT_PROD' => 0,
+            'BONUS_BT_TOOL' => 0,
+            'DEDUCT_ZR' => 0,
+            'BONUS_FL' => 0,
+        ];
+        // 从 redis 中获取当前的结果
+        $cacheValue = \Yii::$app->redis->hget($cacheKey, $userId);
+        if ($cacheValue) {
+            $cacheValue = Json::decode($cacheValue);
+            $value = $cacheValue;
+        }
+        unset($cacheValue);
+        if ($oriBonus > 0) {
+            $oriBonusType = sprintf('ORI_%s', $bonusType);
+            $value[$oriBonusType] += $oriBonus;
+            if( $fromMeans !== '' ) {
+                $oriBonusMeansType = sprintf('ORI_%s_%s', $bonusType, $fromMeans);
+                $value[$oriBonusMeansType] += $oriBonus;
+            }
+
+            if( !in_array($bonusType, self::NOT_SEND_BONUS_LIST) ) {
+                if( $deductData ) {
+                    $value[$bonusType] += $deductData['surplus'];
+                    $value['RECONSUME_POINTS'] += $deductData['reConsumePoints'];
+                    $value['MANAGE_TAX'] += $deductData['manageTax'];
+                }else {
+                    $value[$bonusType] += $oriBonus;
+                }
+                $value['BONUS_TOTAL'] += $oriBonus;
+            }
+
+            if( in_array($bonusType, self::INCOME_BONUS_LIST) ) {
+                self::addHasIncomeUsers($userId, $periodNum);
+//                if( !in_array($bonusType, self::NOT_SEND_BONUS_LIST) ) {
+//                    $value['INCOME_TOTAL'] += $oriBonus;
+//                }
+            }
+
+            Yii::$app->redis->hset($cacheKey, $userId, Json::encode($value));
+            unset($oriBonusType);
+            self::addHasBonusUsers($userId, $periodNum);
+        }
+        unset($userId, $periodNum, $bonusType, $oriBonus, $deductData, $cacheKey);
+        return $value;
+    }
+
+    public static function standardBonus($userId, $periodNum, $bonus=0.00) {
+        $cacheKey = self::REDIS_KEY_PREFIX_STANDARD_BONUS . $periodNum;
+
+        $value = 0.00;
+        if( $bonus > 0 ) {
+            Yii::$app->redis->hset($cacheKey, $userId, $bonus);
+            $value = $bonus;
+            //加入有奖金的会员中
+            self::addHasBonusUsers($userId, $periodNum);
+        }else {
+            $cacheValue = \Yii::$app->redis->hget($cacheKey, $userId);
+            if ($cacheValue) {
+                $value = $cacheValue;
+            }
+            unset($cacheValue);
+        }
+
+        unset($cacheKey, $userId, $periodNum, $bonus);
+        return $value;
+    }
+
+    /**
+     * 设置车房总系数
+     * @param $periodNum
+     * @param $value
+     */
+    public static function setCFTotalPercent($periodNum, $value) {
+        Yii::$app->redis->set(self::REDIS_KEY_PREFIX_CF_TOTAL_PERCENT . $periodNum, $value);
+    }
+
+    /**
+     * 获得车房总系数
+     * @param $periodNum
+     * @return mixed
+     */
+    public static function getCFTotalPercent($periodNum) {
+        return Yii::$app->redis->get(self::REDIS_KEY_PREFIX_CF_TOTAL_PERCENT . $periodNum);
+    }
+
+    /**
+     * 设置领袖总系数
+     * @param $periodNum
+     * @param $value
+     */
+    public static function setLXTotalPercent($periodNum, $value) {
+        Yii::$app->redis->set(self::REDIS_KEY_PREFIX_LX_TOTAL_PERCENT . $periodNum, $value);
+    }
+
+    /**
+     * 获得领袖总系数
+     * @param $periodNum
+     * @return mixed
+     */
+    public static function getLXTotalPercent($periodNum) {
+        return Yii::$app->redis->get(self::REDIS_KEY_PREFIX_LX_TOTAL_PERCENT . $periodNum);
+    }
+
+
+    /**
+     * 添加上2代共享奖关系
+     * @param $bonusUserId
+     * @param $fromUserId
+     * @param $periodNum
+     * @param $validDeep
+     * @return  boolean
+     */
+    public static function addShareBonusOneRelation($bonusUserId, $fromUserId, $periodNum, $validDeep) {
+        if ($validDeep == 1) {
+            $cacheKey = self::REDIS_KEY_PREFIX_GX_BONUS_DEEP_ONE_LIST_DATA . $periodNum;
+        }else {
+            $cacheKey = self::REDIS_KEY_PREFIX_GX_BONUS_DEEP_TWO_LIST_DATA . $periodNum;
+        }
+        $fromUserDataJson = Yii::$app->redis->hget($cacheKey, $fromUserId);
+
+        $fromUserData = [];
+        if( $fromUserDataJson ) {
+            $fromUserData = Json::decode($fromUserDataJson, true);
+        }
+        unset($fromUserDataJson);
+
+        $fromUserData[] = $bonusUserId;
+
+        Yii::$app->redis->hset($cacheKey, $fromUserId, Json::encode($fromUserData));
+
+        unset($fromUserData, $bonusUserId, $fromUserId, $periodNum);
+
+        return true;
+    }
+
+    /**
+     * 获取上2代共享奖关系
+     * @param $fromUserId
+     * @param $periodNum
+     * @param $validDeep
+     * @return array
+     */
+    public static function getShareBonusOneRelation($fromUserId, $periodNum, $validDeep) {
+        if ($validDeep == 1) {
+            $cacheKey = self::REDIS_KEY_PREFIX_GX_BONUS_DEEP_ONE_LIST_DATA . $periodNum;
+        }else {
+            $cacheKey = self::REDIS_KEY_PREFIX_GX_BONUS_DEEP_TWO_LIST_DATA . $periodNum;
+        }
+        $fromUserDataJson = Yii::$app->redis->hget($cacheKey, $fromUserId);
+
+        $bonusUserData = [];
+        if( $fromUserDataJson ) {
+            $bonusUserData = Json::decode($fromUserDataJson, true);
+        }
+        unset($fromUserDataJson);
+
+        return $bonusUserData;
+    }
+}

+ 1290 - 0
common/helpers/bonus/PreparePerfCalc.php

@@ -0,0 +1,1290 @@
+<?php
+/**
+ * 月结算的时候,周日晚0点进行预计算,此月用户和团队的业绩信息. 让会员参考,进行补业绩
+ * Created by PhpStorm.
+ * User: liyunlong
+ * Date: 2019-01-11
+ * Time: 15:27
+ */
+namespace common\helpers\bonus;
+
+use common\helpers\Cache;
+use common\helpers\Date;
+use common\helpers\Form;
+use common\helpers\snowflake\SnowFake;
+use common\models\DeclarationLevel;
+use common\models\forms\DeclarationForm;
+use common\models\Order;
+use common\models\OrderDec;
+use common\models\OrderShop;
+use common\models\OrderStandard;
+use common\models\PerfCompany;
+use common\models\PerfMonth;
+use common\models\PerfOrder;
+use common\models\PerfPeriod;
+use common\models\PerfStandard;
+use common\models\Period;
+use common\models\DecOrder;
+use common\models\EmployLevel;
+use common\models\PerfActiveUser;
+use common\models\PerfMonthPrepare;
+use common\models\PerfOrderPrepare;
+use common\models\PerfPeriodPrepare;
+use common\models\PeriodPrepare;
+use yii\base\Exception;
+use yii\base\StaticInstanceTrait;
+
+class PreparePerfCalc {
+    use StaticInstanceTrait;
+
+    private $_limit = 1000;
+    private $_handleUserId;
+    private $_companyMonthPerf = 0;
+    private $_cfTotalPercent = 0;
+    private $_lxTotalPercent = 0;
+    private $_sysConfig = [];
+    private $_decLevelConfig = [];
+    private $_empLevelConfig = [];
+    private $_decRoleConfig = [];
+    private $_errors = [];
+    private $_periodNum = 0;
+    private $_periodId;
+    private $_isCalcMonth = 0;
+    private $_calcYear;
+    private $_calcMonth;
+    private $_calcYearMonth;
+    private $_lastCalcYear;
+    private $_lastCalcMonth;
+    private $_lastCalcYearMonth;
+    private $_lastPeriodNum;
+    private $_lastPeriodYear;
+    private $_lastPeriodMonth;
+    private $_lastPeriodYearMonth;
+    private $_lastTime = 0;
+    //pv
+    private $_pvRatio;
+
+    const LOOP_FINISH = 1;
+    const LOOP_CONTINUE = 2;
+
+    const ORDER_PAY_TYPE_CASH = 'cash';
+//    const ORDER_PAY_TYPE_POINT = 'point';
+
+    /**
+     * 获取期数
+     * @return int
+     */
+    public function getPeriodNum() {
+        return $this->_periodNum;
+    }
+
+    /**
+     * 加入错误错误
+     * @param string $attr
+     * @param string $error
+     */
+    public function addError(string $attr, string $error) {
+        $this->_errors[$attr][] = $error;
+    }
+
+    /**
+     * 获取错误信息
+     * @return array
+     */
+    public function getErrors() {
+        return $this->_errors;
+    }
+
+    /**
+     * 计算步骤
+     * @param $periodNum
+     * @param null $handleUserId
+     * @return bool
+     */
+    public function calcStep($periodNum = null, $handleUserId = null) {
+        try {
+            // 先计算是否是结算月,并且是否到了周日0点
+            // 需要将线上的数据perf_order,perf_period两个表的数据同步过来
+            // Period表数据同步过来,只要是结算月的数据
+            $checkPrepare = $this->checkCanCalcPref($periodNum);
+            if ($checkPrepare !== true) {
+                return true;
+            }
+            $this->_errors = [];
+            $this->_handleUserId = $handleUserId;
+            if (empty($periodNum)) {
+                echo('定时器执行预业绩计算 ,内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            }
+            $this->_updatePercent(5);
+            $t1 = microtime(true);
+            // 初始化结算任务
+            $this->initCalcTask($periodNum);
+            $this->_updatePercent(10);
+            // 设置结算状态
+            $this->setCalcStatus('start', $periodNum);
+            // 清空所有本期结算用到的缓存
+            PrepareCalcCache::clearAll($this->_periodNum);
+            // 清空会员推荐和接点关系缓存
+            PrepareCalcCache::clearNetCache();
+            // 清空相关表数据
+            $this->clearTableData();
+            $this->_updatePercent(15);
+            $t2 = microtime(true);
+            echo(date('Y-m-d H:i:s',time()).'初始化、清空缓存及相关数据表完成,耗时:' . round($t2 - $t1, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            // 计算月奖,才需要向缓存中加入按推荐深度的所有用户
+            //修改每一期都缓存所有用户
+            PrepareCalcCache::addUsers($this->_periodNum);
+            $t3 = microtime(true);
+            echo('预计算业绩向缓存中加入用户完成,耗时:' . round($t3 - $t2, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->_updatePercent(20);
+            // 周结,循环向上级计入业绩并加入业绩单
+            $this->loopCalcPeriodPerfByDecOrder();
+            $this->loopCalcPeriodPerfByOrderDec();
+            $t4 = microtime(true);
+            echo('预计算业绩计算周业绩表中的数据完成,耗时:' . round($t4 - $t1, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->_updatePercent(40);
+            // 从会员的复销订单会员计算复销业绩并加入业绩单
+            $this->loopCalcPerfByFXOrder();
+            $this->loopCalcPerfByShopFXOrder();
+            $t5 = microtime(true);
+            echo('预计算业绩计算复销业绩并写入业绩单完成,耗时:' . round($t5 - $t4, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->_updatePercent(60);
+            //本期业绩入库
+            $this->loopWriteNowPerf();
+            $t6 = microtime(true);
+            echo('预计算业绩本期业绩入库完成,耗时:' . round($t6 - $t5, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->_updatePercent(70);
+
+            //计算月业绩表中的数据
+            $this->loopCalcMonthPerfTableData();
+            $t7 = microtime(true);
+            echo('预计算业绩计算月业绩表中的数据完成,耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->_updatePercent(80);
+
+            $t8 = microtime(true);
+            // 计算预计月业绩表的数据,这些数据用户不在前三期非月节点的数据.需要将此期新用户业绩统计一下
+            $this->loopCalcMonthPerfTableDataPrepare();
+  
+            //本月业绩入库
+            $this->loopWriteMonthPerf();
+            $t7 = microtime(true);
+            echo('预计算业绩本月业绩入库完成,耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->_updatePercent(90);
+
+            $t9 = microtime(true);
+
+            $this->_updatePercent(100);
+            $t10 = microtime(true);
+            
+            echo('预计算业绩业绩结算全部完成,共耗时:' . round($t10 - $t9, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+        } catch (\Exception $e) {
+            $this->errorCalcTask();
+            file_put_contents('error_test.txt', var_export([
+                'err' => $e->getMessage()
+            ],true),FILE_APPEND);
+            $this->addError('calc', $e->getMessage());
+            return false;
+        }
+
+        $this->endCalcTask();
+
+        return true;
+    }
+
+    /**
+     * 结算完成
+     * @return bool
+     */
+    public function endCalcTask() {
+        // 更新结算状态
+        $this->setCalcStatus('end');
+    }
+
+    /**
+     * 结算错误
+     */
+    public function errorCalcTask() {
+        // 清空所有本期结算用到的缓存
+        PrepareCalcCache::clearAll($this->_periodNum);
+        // 更新结算状态
+        $this->setCalcStatus('fail');
+    }
+
+    /**
+     * 设置生成业绩单状态
+     * @param $type
+     * start|end|fail
+     */
+    public function setCalcStatus($type, $periodNum = null) {
+        if ($type == 'start') {
+            $this->_lastTime = !empty($periodNum) ? Date::nowTime() : $this->_lastTime;
+            PeriodPrepare::updateAll(['IS_PERFING' => 1, 'IS_PERFED' => Period::PERF_NONE, 'PERF_STARTED_AT' => $this->_lastTime], 'PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum]);
+        } elseif ($type == 'end') {
+            PeriodPrepare::updateAll(['IS_PERFING' => 0, 'IS_PERFED' => Period::PERF_FINISH, 'PERFED_AT' => Date::nowTime()], 'PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum]);
+        } elseif ($type == 'fail') {
+            PeriodPrepare::updateAll(['IS_PERFING' => 0, 'IS_PERFED' => Period::PERF_FAIL, 'PERFED_AT' => 0], 'PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum]);
+        }
+    }
+
+    public function checkCanCalcPref($periodNum = null) {
+        
+        // 先判断时间,现在是周几,如果不是周日,则直接结束
+        // 如果是手动触发,即有业绩期$periodNum变量值,则不校验必须周日0点
+        $w = $h = '';
+        if (empty($periodNum)) {
+            $w = date('w',time());
+            if ($w != '0') {
+                return false;
+            }
+            // 判断是否是周日0点
+            $h = date('H',time());
+            if ($h !=0 ) {
+                return false;
+            }
+        }
+        // 判断此结算周期是否是月结算节点 
+        // 这里 如果定时任务业绩期是nul
+        $periodObj = Period::instance();
+        $periodDataArr = $periodObj->setPeriodNum($periodNum);
+        if ($periodDataArr['IS_MONTH'] != 1) {
+            return false;
+        }
+        // 如果是手动进行计算得月业绩,则不需要判断结算当前状态
+        // 判断此结算周期是否已经进行业绩计算,如果已进行或者进行过,则不能继续执行
+        if (empty($periodNum)) {
+            $prepare = PeriodPrepare::find()
+            ->select('IS_MONTH, IS_PERFING,IS_PERFED')
+            ->where(
+                'PERIOD_NUM=:PERIOD_NUM', 
+                [
+                    'PERIOD_NUM'=>$periodDataArr['PERIOD_NUM']
+                ])
+            ->asArray()
+            ->one();
+            // 如果正在结算或者已计算完,则不进行计算,因为预计计算是定时任务每5秒扫一次,所以不能再触发预计算业绩
+            if ($prepare['IS_PERFING'] == 1 || $prepare['IS_PERFED'] == 1) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * 初始化结算任务
+     * @throws \yii\db\Exception
+     */
+    public function initCalcTask($periodNum = null) {
+        $periodObj = Period::instance();
+        $periodDataArr = $periodObj->setPeriodNum($periodNum);
+        // 限制订单的时间:如果是定时器,则固定为每周日的0点. 如果是手动执行,则是进行异步代码的时间
+        // 这里直接使用后台生成业绩单的时间
+        $this->_lastTime = empty($periodNum)? $periodDataArr['END_TIME'] - 86399: $periodDataArr['END_TIME']; 
+        $this->_periodNum = $periodDataArr['PERIOD_NUM'];
+        $this->_sysConfig = Cache::getSystemConfig();
+        $this->_decLevelConfig = Cache::getDecLevelConfig();
+        $this->_empLevelConfig = Cache::getEmpLevelConfig();
+        $this->_decRoleConfig = PrepareCalcCache::getDecRoleConfig($this->_periodNum);
+        $periodNum = $this->_periodNum;
+        $this->_periodId = $periodDataArr['ID'];
+        $this->_isCalcMonth = $periodObj->isCalcMonth($periodNum);
+        $this->_calcYear = $periodObj->getYear($periodNum);
+        $this->_calcMonth = $periodObj->getMonth($periodNum);
+        $this->_calcYearMonth = $periodObj->getYearMonth($periodNum);
+        $lastYearMonthArr = $periodObj->getLastMonth($periodNum);
+        $this->_lastCalcYear = $lastYearMonthArr['year'];
+        $this->_lastCalcMonth = $lastYearMonthArr['month'];
+        $this->_lastCalcYearMonth = $lastYearMonthArr['yearMonth'];
+        $this->_lastPeriodNum = $periodNum - 1;
+        if (Period::isExistsPeriodNum($this->_lastPeriodNum)) {
+            $this->_lastPeriodYear = $periodObj->getYear($this->_lastPeriodNum);
+            $this->_lastPeriodMonth = $periodObj->getMonth($this->_lastPeriodNum);
+            $this->_lastPeriodYearMonth = $periodObj->getYearMonth($this->_lastPeriodNum);
+        } else {
+            $this->_lastPeriodYear = 0;
+            $this->_lastPeriodMonth = 0;
+            $this->_lastPeriodYearMonth = 0;
+        }
+        $this->_pvRatio = $this->_sysConfig['pvRatio']['VALUE'];
+    }
+
+    /**
+     * 清空相关表数据
+     */
+    public function clearTableData() {
+        // 周业绩
+        PerfPeriodPrepare::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
+        // 业绩单
+        PerfOrderPrepare::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
+        // 月结时要清空的数据
+        if ($this->_isCalcMonth) {
+            // 月业绩表
+            PerfMonthPrepare::pageDeleteAll("CALC_MONTH='{$this->_calcYearMonth}'");
+        }
+    }
+
+    /**
+     * 周结,向上级算业绩,并计入业绩单
+     * @param int $offset
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function loopCalcPeriodPerfByDecOrder($offset = 0) {
+        // 循环获取全部报单
+        $allData = DecOrder::findUseDbCalc()
+        ->select('ID,DEC_SN,ORDER_SN,USER_ID,TYPE,TO_USER_ID,IS_ADMIN,DEC_AMOUNT,DEC_PV,PERIOD_NUM,
+        CALC_MONTH,IS_DEL,P_CALC_MONTH,CREATED_AT,DEC_ID')
+        ->where(
+            "PERIOD_NUM=:PERIOD_NUM AND IS_DEL=0 AND TYPE='ZC'  AND CREATED_AT<=:CREATED_AT", 
+            [':PERIOD_NUM' => $this->_periodNum, ':CREATED_AT' => $this->_lastTime]
+        )
+        ->orderBy('CREATED_AT DESC,ID DESC')
+        ->offset($offset)
+        ->limit($this->_limit)
+        ->asArray()
+        ->all();
+        if ($allData) {
+            $insertPerfOrderData = [];
+            foreach ($allData as $data) {
+                // 是否关停等状态不能拿业绩
+                if (!$this->isHasPerf($data['TO_USER_ID'])) {
+                    continue;
+                }
+                // 给自己增加PCS(个人消费)
+                PrepareCalcCache::nowPeriodPerf($data['TO_USER_ID'], $this->_periodNum, [
+                    'PV_PCS' => $data['DEC_PV'],
+                    'PV_PCS_ZC' => $data['DEC_PV'],
+                ]);
+                // 把该会员加入到能拿到业绩的会员缓存中
+                PrepareCalcCache::addHasPerfUsers($data['TO_USER_ID'], $this->_periodNum);
+                //加入到报单会员中
+                $toInfo = PrepareCalcCache::getUserInfo($data['TO_USER_ID'], $this->_periodNum);
+                PrepareCalcCache::addHasBDUsers($data['TO_USER_ID'], $this->_periodNum, [
+                    'TO_USER_ID' => $data['TO_USER_ID'],
+                    'USER_ID' => $data['USER_ID'],
+                    'DEC_ID' => $data['DEC_ID'],
+                    //考虑可能会移网的情况
+                    'REC_USER_ID' => $toInfo['REC_UID'] ?? '',
+                    'CON_USER_ID' => $toInfo['CON_UID'] ?? '',
+                    'DEC_AMOUNT' => $data['DEC_AMOUNT'],
+                    'DEC_PV' => $data['DEC_PV'],
+                ]);
+                // 给上追加业绩
+                $this->loopNetworkParentDo($data['TO_USER_ID'], function ($parent) use (&$data) {
+                    
+                    // 给上级会员追加本期业绩到缓存中
+                    PrepareCalcCache::nowPeriodPerf($parent['PARENT_UID'], $this->_periodNum, [
+                        'PV_' . $parent['LOCATION'] . 'L' => $data['DEC_PV'],
+                        'PV_' . $parent['LOCATION'] . 'L_TOUCH' => $data['DEC_PV'],
+                        'PV_' . $parent['LOCATION'] . 'L_' . $data['TYPE'] => $data['DEC_PV'],
+                    ]);
+                    // 把该会员加入到能拿到业绩的会员缓存中
+                    PrepareCalcCache::addHasPerfUsers($parent['PARENT_UID'], $this->_periodNum);
+                    unset($parent);
+                });
+                //给推荐关系累计增加业绩
+                $this->loopRelationParentDo($data['TO_USER_ID'], function ($parent) use (&$data) {
+                    // 给上级会员追加本期业绩到缓存中
+                    PrepareCalcCache::nowPeriodPerf($parent['PARENT_UID'], $this->_periodNum, [
+                        'PV_PSS' => $data['DEC_PV'],
+                    ]);
+                    // 把该会员加入到能拿到业绩的会员缓存中
+                    PrepareCalcCache::addHasPerfUsers($parent['PARENT_UID'], $this->_periodNum);
+                    unset($parent);
+                });
+                
+                // 写入业绩单表
+                $decInfo = PrepareCalcCache::getUserInfo($data['USER_ID'], $this->_periodNum);
+                $sn = PerfOrderPrepare::generateSN();
+                $insertPerfOrderData[] = [
+                    'ID' => SnowFake::instance()->generateId(),
+                    'SN' => $sn,
+                    'DEC_SN' => $data['DEC_SN'],
+                    'DEC_TYPE' => strtoupper($data['TYPE']),
+                    'DEC_STATUS' => PerfOrder::STATUS_NORMAL,
+                    'USER_ID' => $data['TO_USER_ID'],
+                    'LAST_REC_USER_NAME' => $toInfo['REC_USER_NAME'],
+                    'LAST_REC_REAL_NAME' => $toInfo['REC_REAL_NAME'],
+                    'LAST_DEC_LV' => $toInfo['DEC_LV'],
+                    'LAST_EMP_LV' => $toInfo['EMP_LV'],
+                    'LAST_STATUS' => $toInfo['STATUS'],
+                    'PV' => $data['DEC_PV'],
+                    'DEC_AMOUNT' => $data['DEC_AMOUNT'],
+                    'LAST_SUB_COM_ID' => $toInfo['SUB_COM_ID'],
+                    'LAST_PROVINCE' => $toInfo['PROVINCE'],
+                    'LAST_CITY' => $toInfo['CITY'],
+                    'LAST_COUNTY' => $toInfo['COUNTY'],
+                    'DEC_USER_ID' => $data['USER_ID'],
+                    'LAST_DEC_DEC_LV' => $decInfo['DEC_LV'],
+                    'LAST_DEC_SUB_COM_ID' => $decInfo['SUB_COM_ID'],
+                    'LAST_DEC_PROVINCE' => $decInfo['DEC_PROVINCE'],
+                    'LAST_DEC_CITY' => $decInfo['DEC_CITY'],
+                    'LAST_DEC_COUNTY' => $decInfo['DEC_COUNTY'],
+                    'PERIOD_NUM' => $this->_periodNum,
+                    'CALC_MONTH' => $this->_calcYearMonth,
+                    'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
+                    'CREATED_AT' => Date::nowTime(),
+                    'CLOSED_AT' => 0,
+                    'ORDER_CREATED_AT' => $data['CREATED_AT'],
+                ];
+                unset($data, $decInfo, $sn, $toInfo);
+            }
+            PerfOrderPrepare::batchInsert($insertPerfOrderData);
+            unset($insertPerfOrderData, $allData, $snArr);
+            return $this->loopCalcPeriodPerfByDecOrder($offset + $this->_limit);
+        }
+        unset($allData);
+        return true;
+    }
+
+    /**
+     * 周结,向上级算业绩,并计入业绩单
+     * @param int $offset
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function loopCalcPeriodPerfByOrderDec($offset = 0) {
+        // 循环获取全部报单
+        $allData = OrderDec::findUseDbCalc()
+        ->select('CREATED_AT,ID,SN,USER_ID,ORDER_TYPE,ORDER_AMOUNT,PV,PAY_AMOUNT,PAY_PV,PERIOD_NUM,PAY_TYPE')
+        ->where(
+            "PERIOD_NUM=:PERIOD_NUM AND IS_DELETE=0 AND ORDER_TYPE=:ORDER_TYPE AND CREATED_AT<=:CREATED_AT", 
+            [':PERIOD_NUM' => $this->_periodNum, ':ORDER_TYPE'=>'ZC', ':CREATED_AT' => $this->_lastTime])
+            ->orderBy('ID DESC')
+            ->offset($offset)
+            ->limit($this->_limit)
+            ->asArray()
+            ->all();
+        if ($allData) {
+            $insertPerfOrderData = [];
+            foreach ($allData as $data) {
+                // 是否关停等状态不能拿业绩
+                if (!$this->isHasPerf($data['USER_ID'])) {
+                    continue;
+                }
+                // 给自己增加PCS(个人消费)
+                PrepareCalcCache::nowPeriodPerf($data['USER_ID'], $this->_periodNum, [
+                    'PV_PCS' => $data['PAY_PV'],
+                    'PV_PCS_ZC' => $data['PAY_PV'],
+                ]);
+                // 把该会员加入到能拿到业绩的会员缓存中
+                PrepareCalcCache::addHasPerfUsers($data['USER_ID'], $this->_periodNum);
+                //加入到报单会员中
+                $toInfo = PrepareCalcCache::getUserInfo($data['USER_ID'], $this->_periodNum);
+                PrepareCalcCache::addHasBDUsers($data['USER_ID'], $this->_periodNum, [
+                    'TO_USER_ID' => $data['USER_ID'],
+                    'USER_ID' => $toInfo['DEC_ID'],
+                    'DEC_ID' => $toInfo['DEC_ID'],
+                    //考虑可能会移网的情况
+                    'REC_USER_ID' => $toInfo['REC_UID'] ?? '',
+                    'CON_USER_ID' => $toInfo['CON_UID'] ?? '',
+                    'DEC_AMOUNT' => $data['ORDER_AMOUNT'],
+                    'DEC_PV' => $data['PAY_PV'],
+                ]);
+                // 给上追加业绩
+                $this->loopNetworkParentDo($data['USER_ID'], function ($parent) use (&$data) {
+                    // 给上级会员追加本期业绩到缓存中
+                    PrepareCalcCache::nowPeriodPerf($parent['PARENT_UID'], $this->_periodNum, [
+                        'PV_' . $parent['LOCATION'] . 'L' => $data['PAY_PV'],
+                        'PV_' . $parent['LOCATION'] . 'L_TOUCH' => $data['PAY_PV'],
+                        'PV_' . $parent['LOCATION'] . 'L_' . $data['ORDER_TYPE'] => $data['PAY_PV'],
+                    ]);
+                    // 把该会员加入到能拿到业绩的会员缓存中
+                    PrepareCalcCache::addHasPerfUsers($parent['PARENT_UID'], $this->_periodNum);
+                    unset($parent);
+                });
+                //给推荐关系累计增加业绩
+                $this->loopRelationParentDo($data['USER_ID'], function ($parent) use (&$data) {
+                    // 给上级会员追加本期业绩到缓存中
+                    PrepareCalcCache::nowPeriodPerf($parent['PARENT_UID'], $this->_periodNum, [
+                        'PV_PSS' => $data['PAY_PV'],
+                    ]);
+                    // 把该会员加入到能拿到业绩的会员缓存中
+                    PrepareCalcCache::addHasPerfUsers($parent['PARENT_UID'], $this->_periodNum);
+                    unset($parent);
+                });
+
+                // 写入业绩单表
+                $decInfo = PrepareCalcCache::getUserInfo($toInfo['DEC_ID'], $this->_periodNum);
+                $sn = PerfOrderPrepare::generateSN();
+                $insertPerfOrderData[] = [
+                    'ID' => SnowFake::instance()->generateId(),
+                    'SN' => $sn,
+                    'DEC_SN' => $data['SN'],
+                    'DEC_TYPE' => strtoupper($data['ORDER_TYPE']),
+                    'DEC_STATUS' => PerfOrder::STATUS_NORMAL,
+                    'USER_ID' => $data['USER_ID'],
+                    'LAST_REC_USER_NAME' => $toInfo['REC_USER_NAME'],
+                    'LAST_REC_REAL_NAME' => $toInfo['REC_REAL_NAME'],
+                    'LAST_DEC_LV' => $toInfo['DEC_LV'],
+                    'LAST_EMP_LV' => $toInfo['EMP_LV'],
+                    'LAST_STATUS' => $toInfo['STATUS'],
+                    'PV' => $data['PAY_PV'],
+                    'DEC_AMOUNT' => $data['ORDER_AMOUNT'],
+                    'LAST_SUB_COM_ID' => $toInfo['SUB_COM_ID'],
+                    'LAST_PROVINCE' => $toInfo['PROVINCE'],
+                    'LAST_CITY' => $toInfo['CITY'],
+                    'LAST_COUNTY' => $toInfo['COUNTY'],
+                    'DEC_USER_ID' => $toInfo['DEC_ID'],
+                    'LAST_DEC_DEC_LV' => $decInfo['DEC_LV'],
+                    'LAST_DEC_SUB_COM_ID' => $decInfo['SUB_COM_ID'],
+                    'LAST_DEC_PROVINCE' => $decInfo['DEC_PROVINCE'],
+                    'LAST_DEC_CITY' => $decInfo['DEC_CITY'],
+                    'LAST_DEC_COUNTY' => $decInfo['DEC_COUNTY'],
+                    'PERIOD_NUM' => $this->_periodNum,
+                    'CALC_MONTH' => $this->_calcYearMonth,
+                    'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
+                    'CREATED_AT' => Date::nowTime(),
+                    'CLOSED_AT' => 0,
+                    'ORDER_CREATED_AT' => $data['CREATED_AT']
+                ];
+                unset($data, $decInfo, $sn, $toInfo);
+            }
+            PerfOrderPrepare::batchInsert($insertPerfOrderData);
+            unset($insertPerfOrderData, $allData, $snArr);
+            return $this->loopCalcPeriodPerfByOrderDec($offset + $this->_limit);
+        }
+        unset($allData);
+        return true;
+    }
+
+
+    /**
+     * 从会员的复销订单会员计算复销业绩并加入业绩单
+     * @param int $offset
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function loopCalcPerfByFXOrder(int $offset = 0) {
+        // 循环获取全部报单
+        $allData = Order::findUseDbCalc()
+        ->select('ID,SN,DEC_SN,USER_ID,ORDER_TYPE,ORDER_AMOUNT,PAY_AMOUNT,PAY_PV,PAY_TYPE,PERIOD_NUM,STATUS,IS_DELETE,
+        P_CALC_MONTH,CREATED_AT')
+        ->where(
+            "PERIOD_NUM=:PERIOD_NUM AND IS_DELETE=0 AND ORDER_TYPE=:ORDER_TYPE AND CREATED_AT<=:CREATED_AT", 
+            [':PERIOD_NUM' => $this->_periodNum, ':ORDER_TYPE'=>DeclarationForm::TYPE_FX,':CREATED_AT' => $this->_lastTime]
+        )
+        ->orderBy('CREATED_AT DESC,ID DESC')
+        ->offset($offset)
+        ->limit($this->_limit)
+        ->asArray()
+        ->all();
+        if ($allData) {
+            $insertPerfOrderData = [];
+            foreach ($allData as $data) {
+                // 是否关停等状态不能拿业绩
+                if (!$this->isHasPerf($data['USER_ID'])) {
+                    continue;
+                }
+
+                //如果支付方式是现金,那么实际业绩是支付PV的50%
+                if( $data['PAY_TYPE'] === self::ORDER_PAY_TYPE_CASH ) {
+                    $orderCashAmount = $data['ORDER_AMOUNT'];
+                    //111期开始由50%改为60%-by 2020-04-30修改
+                    $payPv = $data['PAY_PV'] * $this->_sysConfig['cashReconsumeBonusPercent']['VALUE'] / 100;
+                    $cacheDataKey = 'PV_PCS_FX_CASH';
+                }else {
+                    $orderCashAmount = 0;
+                    $payPv = $data['PAY_PV'];
+                    $cacheDataKey = 'PV_PCS_FX_POINT';
+                }
+
+                if( $payPv <= 0 ) continue;
+
+                // 给自己增加PCS(个人消费)
+                PrepareCalcCache::nowPeriodPerf($data['USER_ID'], $this->_periodNum, [
+                    'FX_AMOUNT_CASH' => $orderCashAmount,
+                    'PV_PCS' => $payPv,
+                    'PV_PCS_FX' => $payPv,
+                    $cacheDataKey => $payPv,
+                ]);
+                // 把该会员加入到能拿到业绩的会员缓存中
+                PrepareCalcCache::addHasPerfUsers($data['USER_ID'], $this->_periodNum);
+                // 给上追加业绩
+                try {
+                    $this->loopNetworkParentDo($data['USER_ID'], function ($parent) use (&$data, $payPv) {
+                        // 给上级会员追加本期业绩到缓存中
+                        PrepareCalcCache::nowPeriodPerf($parent['PARENT_UID'], $this->_periodNum, [
+                            'PV_' . $parent['LOCATION'] . 'L' => $payPv,
+                            'PV_' . $parent['LOCATION'] . 'L_TOUCH' => $payPv,
+                            'PV_' . $parent['LOCATION'] . 'L_FX' => $payPv,
+                        ]);
+                        // 把该会员加入到能拿到业绩的会员缓存中
+                        PrepareCalcCache::addHasPerfUsers($parent['PARENT_UID'], $this->_periodNum);
+                    });
+                } catch(\Exception $e) {
+                    file_put_contents('loopNetworkParentDo_error.txt', var_export([
+                        'USER_ID' => $data['USER_ID'],
+                        '_periodNum' => $this->_periodNum,
+                        'error' => $e->getMessage()
+                    ],true));
+                }
+                //给推荐关系累计增加业绩
+                $this->loopRelationParentDo($data['USER_ID'], function ($parent) use ($data, $payPv) {
+                    // 给上级会员追加本期业绩到缓存中
+                    PrepareCalcCache::nowPeriodPerf($parent['PARENT_UID'], $this->_periodNum, [
+                        'PV_PSS' => $payPv,
+                    ]);
+                    // 把该会员加入到能拿到业绩的会员缓存中
+                    PrepareCalcCache::addHasPerfUsers($parent['PARENT_UID'], $this->_periodNum);
+                });
+
+//                }
+                // 写入业绩单表
+                $baseInfo = PrepareCalcCache::getUserInfo($data['USER_ID'], $this->_periodNum);
+                $sn = PerfOrderPrepare::generateSN();
+                $insertPerfOrderData[] = [
+                    'ID' => SnowFake::instance()->generateId(),
+                    'SN' => $sn,
+                    'DEC_SN' => null,
+                    'DEC_TYPE' => 'FX',
+                    'DEC_STATUS' => PerfOrder::STATUS_NORMAL,
+                    'USER_ID' => $data['USER_ID'],
+                    'LAST_REC_USER_NAME' => $baseInfo['REC_USER_NAME'],
+                    'LAST_REC_REAL_NAME' => $baseInfo['REC_REAL_NAME'],
+                    'LAST_DEC_LV' => $baseInfo['DEC_LV'],
+                    'LAST_EMP_LV' => $baseInfo['EMP_LV'],
+                    'LAST_STATUS' => $baseInfo['STATUS'],
+                    'PV' => $payPv,
+                    'DEC_AMOUNT' => $data['PAY_AMOUNT'],
+                    'LAST_SUB_COM_ID' => $baseInfo['SUB_COM_ID'],
+                    'LAST_PROVINCE' => $baseInfo['PROVINCE'],
+                    'LAST_CITY' => $baseInfo['CITY'],
+                    'LAST_COUNTY' => $baseInfo['COUNTY'],
+                    'DEC_USER_ID' => $data['USER_ID'],
+                    'LAST_DEC_DEC_LV' => $baseInfo['DEC_LV'],
+                    'LAST_DEC_SUB_COM_ID' => $baseInfo['SUB_COM_ID'],
+                    'LAST_DEC_PROVINCE' => $baseInfo['PROVINCE'],
+                    'LAST_DEC_CITY' => $baseInfo['CITY'],
+                    'LAST_DEC_COUNTY' => $baseInfo['COUNTY'],
+                    'PERIOD_NUM' => $this->_periodNum,
+                    'CALC_MONTH' => $this->_calcYearMonth,
+                    'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
+                    'CREATED_AT' => Date::nowTime(),
+                    'CLOSED_AT' => 0,
+                    'ORDER_CREATED_AT' => $data['CREATED_AT']
+                ];
+                unset($data, $baseInfo, $sn, $orderCashAmount, $payPv, $cacheDataKey);
+            }
+            PerfOrderPrepare::batchInsert($insertPerfOrderData);
+
+            unset($insertPerfOrderData, $allData, $snArr);
+            return $this->loopCalcPerfByFXOrder($offset + $this->_limit);
+        }
+
+        unset($allData);
+        return true;
+    }
+
+    /**
+     * 从会员的商城复销订单会员计算复销业绩并加入业绩单
+     * @param int $offset
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function loopCalcPerfByShopFXOrder(int $offset = 0) {
+        // 循环获取全部报单
+        $allData = OrderShop::findUseDbCalc()
+        ->select(
+            'ID,SN,DEC_SN,USER_ID,ORDER_TYPE,ORDER_AMOUNT,PAY_AMOUNT,PAY_PV,PAY_TYPE,PERIOD_NUM,STATUS,IS_DELETE,
+            P_CALC_MONTH,CREATED_AT')
+        ->where(
+            "PERIOD_NUM=:PERIOD_NUM AND IS_DELETE=0 AND ORDER_TYPE=:ORDER_TYPE AND CREATED_AT<=:CREATED_AT", 
+            [':PERIOD_NUM' => $this->_periodNum, ':ORDER_TYPE'=>DeclarationForm::TYPE_FX,':CREATED_AT' => $this->_lastTime]
+        )
+        ->orderBy('CREATED_AT DESC,ID DESC')
+        ->offset($offset)
+        ->limit($this->_limit)
+        ->asArray()
+        ->all();
+        if ($allData) {
+            $insertPerfOrderData = [];
+            foreach ($allData as $data) {
+                // 是否关停等状态不能拿业绩
+                if (!$this->isHasPerf($data['USER_ID'])) {
+                    continue;
+                }
+
+                //如果支付方式是现金,那么实际业绩是支付PV的50%
+                if( $data['PAY_TYPE'] === self::ORDER_PAY_TYPE_CASH ) {
+                    $orderCashAmount = $data['ORDER_AMOUNT'];
+                    //111期开始由50%改为60%-by 2020-04-30修改
+                    $payPv = $data['PAY_PV'] * $this->_sysConfig['cashReconsumeBonusPercent']['VALUE'] / 100;
+                    $cacheDataKey = 'PV_PCS_FX_CASH';
+                }else {
+                    $orderCashAmount = 0;
+                    $payPv = $data['PAY_PV'];
+                    $cacheDataKey = 'PV_PCS_FX_POINT';
+                }
+
+                if( $payPv <= 0 ) continue;
+
+                // 给自己增加PCS(个人消费)
+                PrepareCalcCache::nowPeriodPerf($data['USER_ID'], $this->_periodNum, [
+                    'FX_AMOUNT_CASH' => $orderCashAmount,
+                    'PV_PCS' => $payPv,
+                    'PV_PCS_FX' => $payPv,
+                    $cacheDataKey => $payPv,
+                ]);
+                // 把该会员加入到能拿到业绩的会员缓存中
+                PrepareCalcCache::addHasPerfUsers($data['USER_ID'], $this->_periodNum);
+                // 给上追加业绩
+                $this->loopNetworkParentDo($data['USER_ID'], function ($parent) use (&$data, $payPv) {
+                    // 给上级会员追加本期业绩到缓存中
+                    PrepareCalcCache::nowPeriodPerf($parent['PARENT_UID'], $this->_periodNum, [
+                        'PV_' . $parent['LOCATION'] . 'L' => $payPv,
+                        'PV_' . $parent['LOCATION'] . 'L_TOUCH' => $payPv,
+                        'PV_' . $parent['LOCATION'] . 'L_FX' => $payPv,
+                    ]);
+                    // 把该会员加入到能拿到业绩的会员缓存中
+                    PrepareCalcCache::addHasPerfUsers($parent['PARENT_UID'], $this->_periodNum);
+                });
+                //给推荐关系累计增加业绩
+                $this->loopRelationParentDo($data['USER_ID'], function ($parent) use ($data, $payPv) {
+                    // 给上级会员追加本期业绩到缓存中
+                    PrepareCalcCache::nowPeriodPerf($parent['PARENT_UID'], $this->_periodNum, [
+                        'PV_PSS' => $payPv,
+                    ]);
+                    // 把该会员加入到能拿到业绩的会员缓存中
+                    PrepareCalcCache::addHasPerfUsers($parent['PARENT_UID'], $this->_periodNum);
+                });
+
+//                }
+                // 写入业绩单表
+                $baseInfo = PrepareCalcCache::getUserInfo($data['USER_ID'], $this->_periodNum);
+                $sn = PerfOrderPrepare::generateSN();
+                $insertPerfOrderData[] = [
+                    'ID' => SnowFake::instance()->generateId(),
+                    'SN' => $sn,
+                    'DEC_SN' => null,
+                    'DEC_TYPE' => 'FX',
+                    'DEC_STATUS' => PerfOrder::STATUS_NORMAL,
+                    'USER_ID' => $data['USER_ID'],
+                    'LAST_REC_USER_NAME' => $baseInfo['REC_USER_NAME'],
+                    'LAST_REC_REAL_NAME' => $baseInfo['REC_REAL_NAME'],
+                    'LAST_DEC_LV' => $baseInfo['DEC_LV'],
+                    'LAST_EMP_LV' => $baseInfo['EMP_LV'],
+                    'LAST_STATUS' => $baseInfo['STATUS'],
+                    'PV' => $payPv,
+                    'DEC_AMOUNT' => $data['PAY_AMOUNT'],
+                    'LAST_SUB_COM_ID' => $baseInfo['SUB_COM_ID'],
+                    'LAST_PROVINCE' => $baseInfo['PROVINCE'],
+                    'LAST_CITY' => $baseInfo['CITY'],
+                    'LAST_COUNTY' => $baseInfo['COUNTY'],
+                    'DEC_USER_ID' => $data['USER_ID'],
+                    'LAST_DEC_DEC_LV' => $baseInfo['DEC_LV'],
+                    'LAST_DEC_SUB_COM_ID' => $baseInfo['SUB_COM_ID'],
+                    'LAST_DEC_PROVINCE' => $baseInfo['PROVINCE'],
+                    'LAST_DEC_CITY' => $baseInfo['CITY'],
+                    'LAST_DEC_COUNTY' => $baseInfo['COUNTY'],
+                    'PERIOD_NUM' => $this->_periodNum,
+                    'CALC_MONTH' => $this->_calcYearMonth,
+                    'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
+                    'CREATED_AT' => Date::nowTime(),
+                    'CLOSED_AT' => 0,
+                    'ORDER_CREATED_AT' => $data['CREATED_AT']
+                ];
+                unset($data, $baseInfo, $sn, $orderCashAmount, $payPv, $cacheDataKey);
+            }
+            PerfOrderPrepare::batchInsert($insertPerfOrderData);
+
+            unset($insertPerfOrderData, $allData, $snArr);
+            return $this->loopCalcPerfByShopFXOrder($offset + $this->_limit);
+        }
+
+        unset($allData);
+        return true;
+    }
+
+    /**
+     * 计算月业绩表相关的数据并写入数据库
+     * @param int $offset
+     * @return bool
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public function loopCalcMonthPerfTableData(int $offset = 0) {
+        if (!$this->_isCalcMonth) {
+            return true;
+        }
+        file_put_contents('ccctxt.txt',var_export([
+            'offset' => $offset,
+            'CALC_MONTH' => $this->_calcYearMonth,
+            'PERIOD_NUM' => $this->_periodNum
+        ],true), FILE_APPEND);
+        // AR_PERF_ORDER_PREPARE\AR_PERF_PERIOD_PREPARE\AR_PERIOD_PREPARE\AR_PERF_MONTH_PREPARE
+        // AR_PERIOD_PREPARE 表只需要是结算月的数据
+        // AR_PERF_PERIOD_PREPARE 表特殊,需要增加一个字段,是否存在于前三期中  已被第一次算月业绩使用过了
+        //  `IS_HAS_USER` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否有此用户,默认为0没有此用户1为有
+        // 如果依旧是0则再次循环此月业绩的时候,需要再次处理' 相当于前三期没有数据,需要单独再添加一次
+        //
+        // 月业绩由perfperiod表加上perfperiodprepare表之和,其中perfperiod表数据为此月非计算月的期业绩数据
+        // 先查询perfperiod表的数据,再查询perfperiodprepare这个表的数据.
+        // 如果查询到了perfperiodprepare的数据,则将此perfperiodprepare表的新增的是否已经在计算第一次统计到的字段标识为1.
+        // 最后再循环 perfperiodprepare 表中标识依旧为0的数据,再次循环.相当于这些数据是此结算月业绩期的新增用户
+        echo sprintf("时间:[%s]月业绩,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
+        // 从缓存列表里面从底层往上倒序获取会员       
+        $allData = PerfPeriod::findUseDbCalc()
+        ->select('USER_ID, SUM(FX_AMOUNT_CASH) AS FX_AMOUNT_CASH_SUM,SUM(PV_PCS) AS PV_PCS_SUM,
+        SUM(PV_PCS_FX) AS PV_PCS_FX_SUM,SUM(PV_PSS) AS PV_PSS_SUM,
+        SUM(PV_1L) AS PV_1L_SUM,SUM(PV_2L) AS PV_2L_SUM,
+        SUM(PV_3L) AS PV_3L_SUM,SUM(PV_4L) AS PV_4L_SUM,
+        SUM(PV_5L) AS PV_5L_SUM,SUM(PV_1L_ZC) AS PV_1L_ZC_SUM,
+        SUM(PV_2L_ZC) AS PV_2L_ZC_SUM,SUM(PV_3L_ZC) AS PV_3L_ZC_SUM,
+        SUM(PV_4L_ZC) AS PV_4L_ZC_SUM,SUM(PV_5L_ZC) AS PV_5L_ZC_SUM')
+        ->where('CALC_MONTH=:CALC_MONTH AND PERIOD_NUM!=:PERIOD_NUM', [':CALC_MONTH' => $this->_calcYearMonth,':PERIOD_NUM'=>$this->_periodNum])
+        ->groupBy('USER_ID')
+        ->orderBy('USER_ID DESC')
+        ->offset($offset)
+        ->limit($this->_limit)
+        ->asArray()
+        ->all();
+        if ($allData) {
+            // 月度业绩表
+            foreach ($allData as $everyData) {
+                $userId = $everyData['USER_ID'];
+                //往期业绩
+                $userLastPerf = PrepareCalcCache::userPerf($userId, $this->_periodNum);
+                //本期业绩
+                $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()
+                ->select('USER_ID, SUM(FX_AMOUNT_CASH) AS FX_AMOUNT_CASH_SUM,SUM(PV_PCS) AS PV_PCS_SUM,
+                SUM(PV_PCS_FX) AS PV_PCS_FX_SUM,SUM(PV_PSS) AS PV_PSS_SUM,
+                SUM(PV_1L) AS PV_1L_SUM,SUM(PV_2L) AS PV_2L_SUM,
+                SUM(PV_3L) AS PV_3L_SUM,SUM(PV_4L) AS PV_4L_SUM,
+                SUM(PV_5L) AS PV_5L_SUM,SUM(PV_1L_ZC) AS PV_1L_ZC_SUM,
+                SUM(PV_2L_ZC) AS PV_2L_ZC_SUM,SUM(PV_3L_ZC) AS PV_3L_ZC_SUM,
+                SUM(PV_4L_ZC) AS PV_4L_ZC_SUM,SUM(PV_5L_ZC) AS PV_5L_ZC_SUM')
+                ->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM ', [':USER_ID' => $userId, ':PERIOD_NUM' => $this->_periodNum])
+                ->asArray()
+                ->one();
+                if (!empty($monthPrepare)) {
+                    // 如果前三期中,在此提前计算业绩期中有数据,则需要加上此用户信息
+                    $everyData['FX_AMOUNT_CASH_SUM'] = $everyData['FX_AMOUNT_CASH_SUM'] + $monthPrepare['FX_AMOUNT_CASH_SUM'];
+                    $everyData['PV_PCS_SUM'] = $everyData['PV_PCS_SUM'] + $monthPrepare['PV_PCS_SUM'];
+                    $everyData['PV_PCS_FX_SUM'] =  $everyData['PV_PCS_FX_SUM'] + $monthPrepare['PV_PCS_FX_SUM'];
+                    $everyData['PV_PSS_SUM'] = $everyData['PV_PSS_SUM'] + $monthPrepare['PV_PSS_SUM'];
+                    $everyData['PV_1L_SUM'] = $everyData['PV_1L_SUM'] + $monthPrepare['PV_1L_SUM'];
+                    $everyData['PV_2L_SUM'] = $everyData['PV_2L_SUM'] + $monthPrepare['PV_2L_SUM'];
+                    $everyData['PV_3L_SUM'] = $everyData['PV_3L_SUM'] + $monthPrepare['PV_3L_SUM'];
+                    $everyData['PV_4L_SUM'] = $everyData['PV_4L_SUM'] + $monthPrepare['PV_4L_SUM'];
+                    $everyData['PV_5L_SUM'] = $everyData['PV_5L_SUM'] + $monthPrepare['PV_5L_SUM'];
+                    $everyData['PV_1L_ZC_SUM'] = $everyData['PV_1L_ZC_SUM'] + $monthPrepare['PV_1L_ZC_SUM'];
+                    $everyData['PV_2L_ZC_SUM'] = $everyData['PV_2L_ZC_SUM'] + $monthPrepare['PV_2L_ZC_SUM'];
+                    $everyData['PV_3L_ZC_SUM'] = $everyData['PV_3L_ZC_SUM'] + $monthPrepare['PV_3L_ZC_SUM'];
+                    $everyData['PV_4L_ZC_SUM'] = $everyData['PV_4L_ZC_SUM'] + $monthPrepare['PV_4L_ZC_SUM'];
+                    $everyData['PV_5L_ZC_SUM'] = $everyData['PV_5L_ZC_SUM'] + $monthPrepare['PV_5L_ZC_SUM'];
+                    // 将用户的状态改成1,为存在此用户.当之后再次循环PerfPeriodPrepare的时候,不再循环此用户了.
+                    PerfPeriodPrepare::updateAll(
+                        [
+                            'IS_HAS_USER' => 1
+                        ], 
+                        'PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID', 
+                        [':PERIOD_NUM' => $this->_periodNum, ':USER_ID' => $userId]
+                    );
+                }
+
+                $nowMonthPerf = [
+                    'USER_ID' => $userId,
+                    'FX_AMOUNT_CASH' => $everyData['FX_AMOUNT_CASH_SUM'],
+                    'PV_PCS' => $everyData['PV_PCS_SUM'],
+                    'PV_PCS_FX' => $everyData['PV_PCS_FX_SUM'],
+                    'PV_PSS' => $everyData['PV_PSS_SUM'],
+                    'PV_1L' => $everyData['PV_1L_SUM'],
+                    'PV_2L' => $everyData['PV_2L_SUM'],
+                    'PV_3L' => $everyData['PV_3L_SUM'],
+                    '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'],
+                    'PV_3L_TOTAL' => $periodPerf['PV_3L'] + $userLastPerf['PV_3L'],
+                    'PV_4L_TOTAL' => $periodPerf['PV_4L'] + $userLastPerf['PV_4L'],
+                    'PV_5L_TOTAL' => $periodPerf['PV_5L'] + $userLastPerf['PV_5L'],
+                    'PV_PSS_TOTAL' => $periodPerf['PV_PSS'] + $userLastPerf['PV_PSS_TOTAL'],
+                ];
+
+                // 把会员的月业绩写入缓存中,以便下面的奖金计算从缓冲中获取数据效率高
+                PrepareCalcCache::addHasMonthPerfUsers($userId, $this->_periodNum);
+                PrepareCalcCache::nowMonthPerf($userId, $this->_periodNum, $nowMonthPerf);
+
+                unset($userId, $everyData, $nowMonthPerf, $lastMonthData, $userBaseInfo, $isVip);
+            }
+            unset($allData);
+            return $this->loopCalcMonthPerfTableData($offset + $this->_limit);
+        }
+
+        unset($allData);
+        return true;
+    }
+
+    /**
+     * 预计计算月业绩,当前三期没有此最新业绩单的用户
+     * 再次添加进去
+     * @param int $offset
+     * @return bool
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public function loopCalcMonthPerfTableDataPrepare(int $offset = 0) {
+        if (!$this->_isCalcMonth) {
+            return true;
+        }
+        // 上面的计算月业绩,计算了前三期有的用户,此次只计算此结算周期未含有前三期业绩的用户
+       
+        echo sprintf("时间:[%s]预计月业绩,结算月新添加的用户,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
+        // 从缓存列表里面从底层往上倒序获取会员      IS_HAS_USER 0 代表是此结算周期新增的业绩 
+        $allData = PerfPeriodPrepare::findUseDbCalc()
+        ->select('USER_ID, SUM(FX_AMOUNT_CASH) AS FX_AMOUNT_CASH_SUM,SUM(PV_PCS) AS PV_PCS_SUM,
+        SUM(PV_PCS_FX) AS PV_PCS_FX_SUM,SUM(PV_PSS) AS PV_PSS_SUM,
+        SUM(PV_1L) AS PV_1L_SUM,SUM(PV_2L) AS PV_2L_SUM,
+        SUM(PV_3L) AS PV_3L_SUM,SUM(PV_4L) AS PV_4L_SUM,
+        SUM(PV_5L) AS PV_5L_SUM,SUM(PV_1L_ZC) AS PV_1L_ZC_SUM,
+        SUM(PV_2L_ZC) AS PV_2L_ZC_SUM,SUM(PV_3L_ZC) AS PV_3L_ZC_SUM,
+        SUM(PV_4L_ZC) AS PV_4L_ZC_SUM,SUM(PV_5L_ZC) AS PV_5L_ZC_SUM')
+        ->where('CALC_MONTH=:CALC_MONTH AND IS_HAS_USER=0', [':CALC_MONTH' => $this->_calcYearMonth])
+        ->groupBy('USER_ID')
+        ->orderBy('USER_ID DESC')
+        ->offset($offset)
+        ->limit($this->_limit)
+        ->asArray()
+        ->all();
+        if ($allData) {
+            // 月度业绩表
+            foreach ($allData as $everyData) {
+                $userId = $everyData['USER_ID'];
+                //往期业绩
+                $userLastPerf = PrepareCalcCache::userPerf($userId, $this->_periodNum);
+                //本期业绩
+                $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,
+                    'FX_AMOUNT_CASH' => $everyData['FX_AMOUNT_CASH_SUM'],
+                    'PV_PCS' => $everyData['PV_PCS_SUM'],
+                    'PV_PCS_FX' => $everyData['PV_PCS_FX_SUM'],
+                    'PV_PSS' => $everyData['PV_PSS_SUM'],
+                    'PV_1L' => $everyData['PV_1L_SUM'],
+                    'PV_2L' => $everyData['PV_2L_SUM'],
+                    'PV_3L' => $everyData['PV_3L_SUM'],
+                    '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'],
+                    'PV_3L_TOTAL' => $periodPerf['PV_3L'] + $userLastPerf['PV_3L'],
+                    'PV_4L_TOTAL' => $periodPerf['PV_4L'] + $userLastPerf['PV_4L'],
+                    'PV_5L_TOTAL' => $periodPerf['PV_5L'] + $userLastPerf['PV_5L'],
+                    'PV_PSS_TOTAL' => $periodPerf['PV_PSS'] + $userLastPerf['PV_PSS_TOTAL'],
+                ];
+
+                // 把会员的月业绩写入缓存中,以便下面的奖金计算从缓冲中获取数据效率高
+                PrepareCalcCache::addHasMonthPerfUsers($userId, $this->_periodNum);
+                PrepareCalcCache::nowMonthPerf($userId, $this->_periodNum, $nowMonthPerf);
+                // 将用户的状态改成1,为存在此用户.当之后再次循环PerfPeriodPrepare的时候,不再循环此用户了.
+                PerfPeriodPrepare::updateAll(
+                    [
+                        'IS_HAS_USER' => 1
+                    ], 
+                    'PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID', 
+                    [':PERIOD_NUM' => $this->_periodNum, ':USER_ID' => $userId]
+                );
+
+
+                unset($userId, $everyData, $nowMonthPerf, $lastMonthData, $userBaseInfo, $isVip);
+            }
+            unset($allData);
+            return $this->loopCalcMonthPerfTableDataPrepare($offset + $this->_limit);
+        }
+
+        unset($allData);
+        return true;
+    }
+
+    /**
+     * 循环有业绩会员,并入库
+     * @param int $offset
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function loopWriteNowPerf($offset = 0) {
+        echo sprintf("时间:[%s]缓存本期业绩数据入库,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
+        // 从缓存列表里面从底层往上倒序获取会员
+        $allData = PrepareCalcCache::getHasPerfUsers($this->_periodNum, $offset, $this->_limit);
+        if($allData){
+            $insertDataPeriodPerf = [];
+            foreach($allData as $userId){
+                $insertDataPeriodPerf[] = $this->nowPeriodPerfData($userId);
+                unset($userId);
+            }
+            PerfPeriodPrepare::batchInsert($insertDataPeriodPerf);
+
+            unset($insertDataPeriodPerf, $allData);
+            return $this->loopWriteNowPerf($offset + $this->_limit);
+        }
+        unset($allData);
+        return true;
+    }
+
+    /**
+     * 循环有月业绩会员,并入库
+     * @param int $offset
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function loopWriteMonthPerf($offset = 0) {
+        if(!$this->_isCalcMonth){
+            return true;
+        }
+        echo sprintf("时间:[%s]缓存本月业绩数据入库,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
+        // 从缓存列表里面从底层往上倒序获取会员
+        $allData = PrepareCalcCache::getHasMonthPerfUsers($this->_periodNum, $offset, $this->_limit);
+        if($allData){
+            $insertDataMonthPerf = [];
+            foreach($allData as $userId){
+                $insertDataMonthPerf[] = $this->nowMonthPerfData($userId);
+                unset($userId);
+            }
+            // 月预计计算业绩插入数据
+            PerfMonthPrepare::batchInsert($insertDataMonthPerf);
+            unset($insertDataMonthPerf, $allData);
+            return $this->loopWriteMonthPerf($offset + $this->_limit);
+        }
+        unset($allData);
+        return true;
+    }
+
+    /**
+     * 本期业绩数据
+     * @param $userId
+     * @return array
+     */
+    public function nowPeriodPerfData($userId){
+        $data = PrepareCalcCache::nowPeriodPerf($userId, $this->_periodNum);
+        $baseInfo = PrepareCalcCache::getUserInfo($userId, $this->_periodNum);
+        $result = [
+            'ID' => SnowFake::instance()->generateId(),
+            'USER_ID' => $userId,
+            'LAST_DEC_LV' => $baseInfo['DEC_LV'],
+            'LAST_EMP_LV' => $baseInfo['EMP_LV'],
+            'LAST_STATUS' => $baseInfo['STATUS'],
+            'FX_AMOUNT_CASH' => $data['FX_AMOUNT_CASH'],
+            'PV_PCS' => $data['PV_PCS'],
+            'PV_PSS' => $data['PV_PSS'],
+            'PV_PCS_ZC' => $data['PV_PCS_ZC'],
+            'PV_PCS_YH' => $data['PV_PCS_YH'],
+            'PV_PCS_ZG' => $data['PV_PCS_ZG'],
+            'PV_PCS_LS' => $data['PV_PCS_LS'],
+            'PV_PCS_FX' => $data['PV_PCS_FX'],
+            'PV_PCS_FX_CASH' => $data['PV_PCS_FX_CASH'],
+            'PV_PCS_FX_POINT' => $data['PV_PCS_FX_POINT'],
+            'PV_1L' => $data['PV_1L'],
+            'PV_1L_TOUCH' => $data['PV_1L_TOUCH'],
+            'PV_1L_ZC' => $data['PV_1L_ZC'],
+            'PV_1L_YH' => $data['PV_1L_YH'],
+            'PV_1L_ZG' => $data['PV_1L_ZG'],
+            'PV_1L_LS' => $data['PV_1L_LS'],
+            'PV_1L_FX' => $data['PV_1L_FX'],
+            'PV_2L' => $data['PV_2L'],
+            'PV_2L_TOUCH' => $data['PV_2L_TOUCH'],
+            'PV_2L_ZC' => $data['PV_2L_ZC'],
+            'PV_2L_YH' => $data['PV_2L_YH'],
+            'PV_2L_ZG' => $data['PV_2L_ZG'],
+            'PV_2L_LS' => $data['PV_2L_LS'],
+            'PV_2L_FX' => $data['PV_2L_FX'],
+            'PV_3L' => $data['PV_3L'],
+            'PV_3L_TOUCH' => $data['PV_3L_TOUCH'],
+            'PV_3L_ZC' => $data['PV_3L_ZC'],
+            'PV_3L_YH' => $data['PV_3L_YH'],
+            'PV_3L_ZG' => $data['PV_3L_ZG'],
+            'PV_3L_LS' => $data['PV_3L_LS'],
+            'PV_3L_FX' => $data['PV_3L_FX'],
+            'PV_4L' => $data['PV_4L'],
+            'PV_4L_TOUCH' => $data['PV_4L_TOUCH'],
+            'PV_4L_ZC' => $data['PV_4L_ZC'],
+            'PV_4L_YH' => $data['PV_4L_YH'],
+            'PV_4L_ZG' => $data['PV_4L_ZG'],
+            'PV_4L_LS' => $data['PV_4L_LS'],
+            'PV_4L_FX' => $data['PV_4L_FX'],
+            'PV_5L' => $data['PV_5L'],
+            'PV_5L_TOUCH' => $data['PV_5L_TOUCH'],
+            'PV_5L_ZC' => $data['PV_5L_ZC'],
+            'PV_5L_YH' => $data['PV_5L_YH'],
+            'PV_5L_ZG' => $data['PV_5L_ZG'],
+            'PV_5L_LS' => $data['PV_5L_LS'],
+            'PV_5L_FX' => $data['PV_5L_FX'],
+            'PV_LS_TOUCH' => $data['PV_LS_TOUCH'],
+            'SURPLUS_1L' => $data['SURPLUS_1L'],
+            'SURPLUS_2L' => $data['SURPLUS_2L'],
+            'SURPLUS_3L' => $data['SURPLUS_3L'],
+            'SURPLUS_4L' => $data['SURPLUS_4L'],
+            'SURPLUS_5L' => $data['SURPLUS_5L'],
+            'SURPLUS_LS' => $data['SURPLUS_LS'],
+            'PERIOD_NUM' => $this->_periodNum,
+            'CALC_MONTH' => $this->_calcYearMonth,
+            'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
+            'CREATED_AT' => Date::nowTime(),
+        ];
+        unset($data);
+        return $result;
+    }
+
+
+
+    /**
+     * 本月业绩
+     * @param $userId
+     * @return array
+     */
+    public function nowMonthPerfData($userId){
+        $data = PrepareCalcCache::nowMonthPerf($userId, $this->_periodNum);
+        $baseInfo = PrepareCalcCache::getUserInfo($userId, $this->_periodNum);
+        $result = [
+            'ID' => SnowFake::instance()->generateId(),
+            'USER_ID' => $userId,
+            'LAST_DEC_LV' => $baseInfo['DEC_LV'],
+            'LAST_EMP_LV' => $data['EMP_LEVEL'],
+            'LAST_STATUS' => $baseInfo['STATUS'],
+            'FX_AMOUNT_CASH' => $data['FX_AMOUNT_CASH'],
+            'PV_PCS' => $data['PV_PCS'],
+            'PV_PCS_FX' => $data['PV_PCS_FX'],
+            'PV_PSS' => $data['PV_PSS'],
+            'PV_1L' => $data['PV_1L'],
+            'PV_2L' => $data['PV_2L'],
+            'PV_3L' => $data['PV_3L'],
+            'PV_4L' => $data['PV_4L'],
+            'PV_5L' => $data['PV_5L'],
+            'VIP_PV_1L_ZC' => $data['VIP_PV_1L_ZC'],
+            'VIP_PV_2L_ZC' => $data['VIP_PV_2L_ZC'],
+            'VIP_PV_3L_ZC' => $data['VIP_PV_3L_ZC'],
+            'VIP_PV_4L_ZC' => $data['VIP_PV_4L_ZC'],
+            'VIP_PV_5L_ZC' => $data['VIP_PV_5L_ZC'],
+            'PV_1L_TOTAL' => $data['PV_1L_TOTAL'],
+            'PV_2L_TOTAL' => $data['PV_2L_TOTAL'],
+            'PV_3L_TOTAL' => $data['PV_3L_TOTAL'],
+            'PV_4L_TOTAL' => $data['PV_4L_TOTAL'],
+            'PV_5L_TOTAL' => $data['PV_5L_TOTAL'],
+            'PV_PSS_TOTAL' => $data['PV_PSS_TOTAL'],
+            'CF_PERCENT' => $data['CF_PERCENT'],
+            'LX_PERCENT' => $data['LX_PERCENT'],
+            'FX_STATUS' => $data['FX_STATUS'],
+            'CALC_MONTH' => $this->_calcYearMonth,
+            'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
+            'CREATED_AT' => Date::nowTime(),
+        ];
+        unset($data);
+        return $result;
+    }
+
+    /**
+     * 循环父级并执行回调函数
+     * @param $userId
+     * @param callable $callbackFunc
+     * @param int $offset
+     * @return bool
+     */
+    public function loopNetworkParentDo($userId, callable $callbackFunc, int $offset = 0) {
+        $allParents = Cache::getAllNetworkParents($userId, true);
+        $allData = array_slice($allParents, $offset, $this->_limit);
+        unset($allParents);
+        if ($allData) {
+            foreach ($allData as $data) {
+                $funcResult = $callbackFunc($data);
+                if ($funcResult === self::LOOP_FINISH) {
+                    return true;
+                } elseif ($funcResult === self::LOOP_CONTINUE) {
+                    continue;
+                }
+                unset($data, $funcResult);
+            }
+            unset($allData);
+            return $this->loopNetworkParentDo($userId, $callbackFunc, $offset + $this->_limit);
+        }
+        return true;
+    }
+
+    /**
+     * 循环推荐网络的父级
+     * @param $userId
+     * @param callable $callbackFunc
+     * @param int $offset
+     * @return bool
+     */
+    public function loopRelationParentDo($userId, callable $callbackFunc, int $offset = 0) {
+        $allParents = Cache::getAllRelationParents($userId,true);
+        $allData = array_slice($allParents, $offset, $this->_limit);
+        unset($allParents);
+        if ($allData) {
+            foreach ($allData as $data) {
+                $funcResult = $callbackFunc($data);
+                if ($funcResult === self::LOOP_FINISH) {
+                    return true;
+                } elseif ($funcResult === self::LOOP_CONTINUE) {
+                    continue;
+                }
+                unset($data, $funcResult);
+            }
+
+            unset($allData);
+            return $this->loopRelationParentDo($userId, $callbackFunc, $offset + $this->_limit);
+        }
+        return true;
+    }
+
+    /**
+     * 是否可拿业绩(即注销、关停、停发状态)
+     * @param $userId
+     * @return bool
+     */
+    public function isHasPerf($userId) {
+        //@todo 所有人都有业绩
+        return true;
+    }
+
+    /**
+     * 更新百分比并发送
+     * @param $percent
+     */
+    private function _updatePercent($percent) {
+        // 把数据写入数据库中
+        PeriodPrepare::updateAll(['PERF_PERCENT' => $percent], 'PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM' => $this->_periodNum]);
+    }
+}

+ 2 - 0
common/libs/dataList/DataList.php

@@ -114,7 +114,9 @@ class DataList extends Model
      * @throws Exception
      */
     public function getList($params = null){
+
         if($params !== null) {
+
             $this->prepare($params);
         }
         // 获取数据

+ 1 - 1
common/models/BalanceAudit.php

@@ -40,7 +40,7 @@ class BalanceAudit extends \common\components\ActiveRecord
         ],
         'exchange_points' => [
             'name' => 'exchange_points',
-            'label' => '兑换积分',
+            'label' => '兑换点数',
         ],
         'cash' => [
             'name' => 'cash',

+ 290 - 290
common/models/CalcBonus.php

@@ -1,290 +1,290 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_USER_NAME 结算时会员编号
- * @property string $LAST_REAL_NAME 结算时会员姓名
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $LAST_MOBILE 结算时手机号码
- * @property int $LAST_PERIOD_AT 结算时加入期数
- * @property int $LAST_CREATED_AT 结算时加入时间
- * @property string $LAST_SUB_COM_ID 结算时所属分公司
- * @property int $LAST_PROVINCE 结算时所属省份
- * @property int $LAST_CITY 结算时所属城市
- * @property int $LAST_COUNTY 结算时所属地区
- * @property string $LAST_SYSTEM_ID 结算时体系
- * @property int $LAST_IS_DIRECT_SELLER 结算时是否直销员
- * @property string $LAST_REC_USER_NAME 结算时开拓者编号
- * @property string $LAST_REC_REAL_NAME 结算时开拓者姓名
- * @property string $LAST_CON_USER_NAME 结算时上级编号
- * @property string $LAST_CON_REAL_NAME 结算时上级姓名
- * @property int $LAST_LOCATION 结算时市场
- * @property string $BONUS_QY 区域津贴
- * @property string $BONUS_YC 育成津贴
- * @property string $BONUS_VIP VIP奖
- * @property string $BONUS_FX 复销奖
- * @property string $BONUS_LS 零售奖
- * @property string $BONUS_FW 服务奖
- * @property string $BONUS_BT 店补
- * @property string $BONUS_BT_PROD 产品补贴
- * @property string $BONUS_BT_TOOL 工具流补贴
- * @property string $DEDUCT_ZR 责任业绩扣除
- * @property string $BONUS_FL 形象店货补
- * @property string $BONUS_CF 车房养老奖
- * @property string $BONUS_LX 领袖分红
- * @property string $SHOULD_QY 应发区域津贴
- * @property string $SHOULD_DEDUCT_ZR 应扣责任业绩
- * @property string $PV_1L 一市场新增业绩
- * @property string $QY_1L 一市场区域业绩
- * @property string $SURPLUS_1L 一市场结余业绩
- * @property string $PV_2L 二市场新增业绩
- * @property string $QY_2L 二市场区域业绩
- * @property string $SURPLUS_2L 二市场结余业绩
- * @property string $PV_3L 三市场新增业绩
- * @property string $QY_3L 三市场区域业绩
- * @property string $SURPLUS_3L 三市场结余业绩
- * @property string $PV_4L 四市场新增业绩
- * @property string $QY_4L 四市场区域业绩
- * @property string $SURPLUS_4L 四市场结余业绩
- * @property string $PV_5L 五市场新增业绩
- * @property string $QY_5L 五市场区域业绩
- * @property string $SURPLUS_5L 五市场结余业绩
- * @property string $PV_PCS 当期零售
- * @property string $PV_LS_TOUCH 虚拟零售区新增业绩
- * @property string $SURPLUS_LS 虚拟零售区结余
- * @property string $QY_LS 虚拟零售区区域业绩
- * @property string $PV_TOUCH 新增业绩累计
- * @property string $BONUS_REAL 实际奖金
- * @property string $BONUS_TOTAL 总奖金
- * @property string $BONUS_INCOME 总收入
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_YEAR 所在结算年
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $IS_SENT 是否挂网
- * @property int $SENT_AT 挂网时间
- * @property string $P_CALC_MONTH 表分区的日期索引
- * @property int $CREATED_AT 创建时间
- *
- * @property string $ORI_BONUS_QY 团队奖原奖金
- * @property string $ORI_BONUS_QY_BD 报单团队奖原奖金
- * @property string $ORI_BONUS_QY_FX 复消团队奖原奖金
- * @property string $ORI_BONUS_YC 荣衔奖奖原奖金
- * @property string $ORI_BONUS_VIP VIP奖奖原奖金
- * @property string $ORI_BONUS_STANDARD 达标奖原奖金
- * @property string $BONUS_BD 服务奖
- * @property string $ORI_BONUS_BD 服务奖原奖金
- * @property string $BONUS_TG 推广奖
- * @property string $ORI_BONUS_TG 推广奖原奖金
- * @property string $BONUS_XF 消费奖
- * @property string $ORI_BONUS_XF 消费奖原奖金
- * @property string $BONUS_YJ 业绩奖
- * @property string $ORI_BONUS_YJ 业绩奖原奖金
- * @property string $ORI_BONUS_YJ_BD 报单业绩奖原奖金
- * @property string $ORI_BONUS_YJ_FX 复消业绩奖原奖金
- * @property string $BONUS_GX 共享奖
- * @property string $ORI_BONUS_GX 共享奖原奖金
- * @property string $BONUS_BONUS_GX 实发共享奖奖金
- * @property string $BONUS_GL 管理奖
- * @property string $ORI_BONUS_GL 管理奖原奖金
- * @property string $BONUS_BONUS_GL 实发管理奖奖金
- * @property string $ORI_BONUS_GL_BD 报单管理奖原奖金
- * @property string $ORI_BONUS_GL_FX 复消管理奖原奖金
- * @property string $RECONSUME_POINTS 复消积分
- * @property string $MANAGE_TAX 管理费 
- * @property string $BONUS_BS 蓝星奖金(即新的管理奖)
- * @property string $ORI_BONUS_BS 蓝星原奖金(即新的管理奖,原奖金)
- */
-class CalcBonus extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'LAST_USER_NAME', 'LAST_REAL_NAME', 'LAST_MOBILE', 'LAST_SYSTEM_ID','LAST_LOCATION', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CALCULATED_AT', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['LAST_STATUS', 'LAST_PERIOD_AT', 'LAST_CREATED_AT', 'LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY', 'LAST_IS_DIRECT_SELLER', 'LAST_LOCATION', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CALCULATED_AT', 'IS_SENT', 'SENT_AT', 'CREATED_AT'], 'integer'],
-            [['ORI_BONUS_BS','EXCHANGE_POINTS','BONUS_BS','BONUS_QY', 'BONUS_YC', 'BONUS_VIP', 'BONUS_FX', 'BONUS_LS', 'BONUS_FW', 'BONUS_BT', 'BONUS_BT_PROD', 'BONUS_BT_TOOL', 'DEDUCT_ZR', 'BONUS_FL', 'BONUS_CF', 'BONUS_LX', 'SHOULD_QY', 'SHOULD_DEDUCT_ZR', 'PV_1L', 'QY_1L', 'SURPLUS_1L', 'PV_2L', 'QY_2L', 'SURPLUS_2L', 'PV_3L', 'QY_3L', 'SURPLUS_3L', 'PV_4L', 'QY_4L', 'SURPLUS_4L', 'PV_5L', 'QY_5L', 'SURPLUS_5L', 'PV_PCS', 'PV_LS_TOUCH', 'SURPLUS_LS', 'QY_LS', 'PV_TOUCH', 'BONUS_REAL', 'BONUS_TOTAL', 'BONUS_INCOME', 'ORI_BONUS_QY','ORI_BONUS_QY_BD','ORI_BONUS_QY_FX','ORI_BONUS_YC', 'ORI_BONUS_VIP','ORI_BONUS_STANDARD','BONUS_BD','ORI_BONUS_BD','BONUS_TG','ORI_BONUS_TG','BONUS_XF','ORI_BONUS_XF','BONUS_YJ','ORI_BONUS_YJ','ORI_BONUS_YJ_BD','ORI_BONUS_YJ_FX','BONUS_GX','ORI_BONUS_GX','REAL_BONUS_GX','BONUS_GL','ORI_BONUS_GL','REAL_BONUS_GL','ORI_BONUS_GL_BD','ORI_BONUS_GL_FX','RECONSUME_POINTS','MANAGE_TAX'], 'number'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_SUB_COM_ID', 'LAST_SYSTEM_ID'], 'string', 'max' => 32],
-            [['LAST_USER_NAME', 'LAST_REC_USER_NAME', 'LAST_CON_USER_NAME'], 'string', 'max' => 16],
-            [['LAST_REAL_NAME', 'LAST_REC_REAL_NAME', 'LAST_CON_REAL_NAME'], 'string', 'max' => 128],
-            [['LAST_MOBILE'], 'string', 'max' => 11],
-            [['P_CALC_MONTH'], 'safe'],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_USER_NAME' => '结算时会员编号',
-            'LAST_REAL_NAME' => '结算时会员姓名',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'LAST_MOBILE' => '结算时手机号码',
-            'LAST_PERIOD_AT' => '结算时加入期数',
-            'LAST_CREATED_AT' => '结算时加入时间',
-            'LAST_SUB_COM_ID' => '结算时所属分公司',
-            'LAST_PROVINCE' => '结算时所属省份',
-            'LAST_CITY' => '结算时所属城市',
-            'LAST_COUNTY' => '结算时所属地区',
-            'LAST_SYSTEM_ID' => '结算时体系',
-            'LAST_IS_DIRECT_SELLER' => '结算时是否直销员',
-            'LAST_REC_USER_NAME' => '结算时开拓者编号',
-            'LAST_REC_REAL_NAME' => '结算时开拓者姓名',
-            'LAST_CON_USER_NAME' => '结算时上级编号',
-            'LAST_CON_REAL_NAME' => '结算时上级姓名',
-            'LAST_LOCATION' => '结算时市场',
-            'BONUS_QY' => '区域津贴',
-            'BONUS_YC' => '荣衔奖',
-            'BONUS_VIP' => 'VIP奖',
-            'BONUS_FX' => '复销奖',
-            'BONUS_LS' => '零售奖',
-            'BONUS_FW' => '服务奖',
-            'BONUS_BT' => '店补',
-            'BONUS_BT_PROD' => '产品补贴',
-            'BONUS_BT_TOOL' => '工具流补贴',
-            'DEDUCT_ZR' => '责任业绩扣除',
-            'BONUS_FL' => '形象店货补',
-            'BONUS_CF' => '车房养老奖',
-            'BONUS_LX' => '领袖分红',
-            'SHOULD_QY' => '应发区域津贴',
-            'SHOULD_DEDUCT_ZR' => '应扣责任业绩',
-            'PV_1L' => '一市场新增业绩',
-            'QY_1L' => '一市场区域业绩',
-            'SURPLUS_1L' => '一市场结余业绩',
-            'PV_2L' => '二市场新增业绩',
-            'QY_2L' => '二市场区域业绩',
-            'SURPLUS_2L' => '二市场结余业绩',
-            'PV_3L' => '三市场新增业绩',
-            'QY_3L' => '三市场区域业绩',
-            'SURPLUS_3L' => '三市场结余业绩',
-            'PV_4L' => '四市场新增业绩',
-            'QY_4L' => '四市场区域业绩',
-            'SURPLUS_4L' => '四市场结余业绩',
-            'PV_5L' => '五市场新增业绩',
-            'QY_5L' => '五市场区域业绩',
-            'SURPLUS_5L' => '五市场结余业绩',
-            'PV_PCS' => '当期零售',
-            'PV_LS_TOUCH' => '虚拟零售区新增业绩',
-            'SURPLUS_LS' => '虚拟零售区结余',
-            'QY_LS' => '虚拟零售区区域业绩',
-            'PV_TOUCH' => '新增业绩累计',
-            'BONUS_REAL' => '实际奖金',
-            'BONUS_TOTAL' => '总奖金',
-            'BONUS_INCOME' => '总收入',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_YEAR' => '所在结算年',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'IS_SENT' => '是否挂网',
-            'SENT_AT' => '挂网时间',
-            'P_CALC_MONTH' => '表分区的日期索引',
-            'CREATED_AT' => '创建时间',
-            'ORI_BONUS_QY'=> '团队奖原奖金',
-            'ORI_BONUS_QY_BD'=> '报单团队奖原奖金',
-            'ORI_BONUS_QY_FX'=> '复消团队奖原奖金',
-            'ORI_BONUS_YC'=> '荣衔奖原奖金',
-            'ORI_BONUS_VIP'=> 'VIP奖原奖金',
-            'ORI_BONUS_STANDARD'=> '达标奖原奖金',
-            'BONUS_BD'=> '服务奖',
-            'ORI_BONUS_BD'=> '服务奖原奖金',
-            'BONUS_TG'=> '推广奖',
-            'ORI_BONUS_TG'=> '推广奖原奖金',
-            'BONUS_XF'=> '消费奖',
-            'ORI_BONUS_XF'=> '消费奖原奖金',
-            'BONUS_YJ'=> '业绩奖',
-            'ORI_BONUS_YJ'=> '业绩奖原奖金',
-            'ORI_BONUS_YJ_BD'=> '报单业绩奖原奖金',
-            'ORI_BONUS_YJ_FX'=> '复消业绩奖原奖金',
-            'BONUS_GX'=> '共享奖',
-            'ORI_BONUS_GX'=> '共享奖原奖金',
-            'REAL_BONUS_GX'=> '实发共享奖奖金',
-            'BONUS_GL'=> '管理奖',
-            'ORI_BONUS_GL'=> '管理奖原奖金',
-            'REAL_BONUS_GL'=> '实发管理奖奖金',
-            'ORI_BONUS_GL_BD'=> '报单管理奖原奖金',
-            'ORI_BONUS_GL_FX'=> '复消管理奖原奖金',
-            'RECONSUME_POINTS'=> '复消积分',
-            'MANAGE_TAX'=> '管理费',
-            'EXCHANGE_POINTS' => '兑换积分',
-            'BONUS_BS' => '蓝星奖',
-            'ORI_BONUS_BS' => '蓝星原奖金'
-        ];
-    }
-
-    /**
-     * 近几期的奖金
-     * @param $userId
-     * @param int $num
-     * @return array
-     * @throws \yii\db\Exception
-     */
-    public static function periodBonus($userId, $num = 7){
-        // 获取近几期的年月
-        $periodYearMonths = Period::getNearlyPeriodYearMonth($num);
-        $allBonus = [];
-        foreach($periodYearMonths as $data){
-            $allBonus[] = static::findUseSlaves()->yearMonth($data['yearMonth'])->select('USER_ID,BONUS_QY, BONUS_YC, BONUS_FX, BONUS_LS, BONUS_FW, BONUS_BT, BONUS_BT_PROD, BONUS_BT_TOOL, DEDUCT_ZR, BONUS_FL, BONUS_CF, BONUS_LX, SHOULD_QY')->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM AND IS_SENT=1', [':USER_ID'=>$userId, ':PERIOD_NUM'=>$data['periodNum']])->asArray()->one();
-        }
-        return $allBonus;
-    }
-
-    /**
-     * 获取期数对应的奖金情况
-     * @param $userId
-     * @param $periodNum
-     * @return array|null|\yii\db\ActiveRecord
-     * @throws \yii\db\Exception
-     */
-    public static function periodNumBonus($userId, $periodNum){
-        $period = Period::instance();
-        $yearMonth = $period->getYearMonth($periodNum);
-        return static::findUseSlaves()->yearMonth($yearMonth)->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', [':USER_ID'=>$userId, ':PERIOD_NUM'=>$periodNum])->select('USER_ID,BONUS_QY, BONUS_YC, BONUS_TG, BONUS_YJ, BONUS_GX, BONUS_GL, ORI_BONUS_QY, ORI_BONUS_YC, ORI_BONUS_TG, ORI_BONUS_YJ, ORI_BONUS_GX, ORI_BONUS_GL, RECONSUME_POINTS, MANAGE_TAX, BONUS_REAL, BONUS_TOTAL, BONUS_INCOME')->asArray()->one();
-    }
-
-    /**
-     * 根据期数获取月累计奖金
-     * @param $userId
-     * @param $periodNum
-     * @param string $type
-     * @return int|mixed
-     * @throws \yii\db\Exception
-     */
-    public static function monthBonus($userId, $periodNum=null, $type = 'BONUS_QY') {
-        if($periodNum) {
-            $period = Period::instance();
-            $yearMonth = $period->getYearMonth($periodNum);
-            if ($yearMonth) {
-                $bonus = CalcBonus::findUseSlaves()->yearMonth($yearMonth)->select('SUM(' . $type . ') AS ' . $type . '_SUM')->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH AND IS_SENT=1', [':USER_ID' => $userId, ':CALC_MONTH' => $yearMonth])->asArray()->one();
-            }
-        }else{
-            $bonus = CalcBonus::findUseSlaves()->select('SUM(' . $type . ') AS ' . $type . '_SUM')->where('USER_ID=:USER_ID AND IS_SENT=1', [':USER_ID' => $userId])->asArray()->one();
-        }
-        return $bonus[$type . '_SUM'] ?? 0;
-    }
-}
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%CALC_BONUS}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 会员ID
+ * @property string $LAST_USER_NAME 结算时会员编号
+ * @property string $LAST_REAL_NAME 结算时会员姓名
+ * @property string $LAST_DEC_LV 结算时会员级别
+ * @property string $LAST_EMP_LV 结算时会员聘级
+ * @property int $LAST_STATUS 结算时状态
+ * @property string $LAST_MOBILE 结算时手机号码
+ * @property int $LAST_PERIOD_AT 结算时加入期数
+ * @property int $LAST_CREATED_AT 结算时加入时间
+ * @property string $LAST_SUB_COM_ID 结算时所属分公司
+ * @property int $LAST_PROVINCE 结算时所属省份
+ * @property int $LAST_CITY 结算时所属城市
+ * @property int $LAST_COUNTY 结算时所属地区
+ * @property string $LAST_SYSTEM_ID 结算时体系
+ * @property int $LAST_IS_DIRECT_SELLER 结算时是否直销员
+ * @property string $LAST_REC_USER_NAME 结算时开拓者编号
+ * @property string $LAST_REC_REAL_NAME 结算时开拓者姓名
+ * @property string $LAST_CON_USER_NAME 结算时上级编号
+ * @property string $LAST_CON_REAL_NAME 结算时上级姓名
+ * @property int $LAST_LOCATION 结算时市场
+ * @property string $BONUS_QY 区域津贴
+ * @property string $BONUS_YC 育成津贴
+ * @property string $BONUS_VIP VIP奖
+ * @property string $BONUS_FX 复销奖
+ * @property string $BONUS_LS 零售奖
+ * @property string $BONUS_FW 服务奖
+ * @property string $BONUS_BT 店补
+ * @property string $BONUS_BT_PROD 产品补贴
+ * @property string $BONUS_BT_TOOL 工具流补贴
+ * @property string $DEDUCT_ZR 责任业绩扣除
+ * @property string $BONUS_FL 形象店货补
+ * @property string $BONUS_CF 车房养老奖
+ * @property string $BONUS_LX 领袖分红
+ * @property string $SHOULD_QY 应发区域津贴
+ * @property string $SHOULD_DEDUCT_ZR 应扣责任业绩
+ * @property string $PV_1L 一市场新增业绩
+ * @property string $QY_1L 一市场区域业绩
+ * @property string $SURPLUS_1L 一市场结余业绩
+ * @property string $PV_2L 二市场新增业绩
+ * @property string $QY_2L 二市场区域业绩
+ * @property string $SURPLUS_2L 二市场结余业绩
+ * @property string $PV_3L 三市场新增业绩
+ * @property string $QY_3L 三市场区域业绩
+ * @property string $SURPLUS_3L 三市场结余业绩
+ * @property string $PV_4L 四市场新增业绩
+ * @property string $QY_4L 四市场区域业绩
+ * @property string $SURPLUS_4L 四市场结余业绩
+ * @property string $PV_5L 五市场新增业绩
+ * @property string $QY_5L 五市场区域业绩
+ * @property string $SURPLUS_5L 五市场结余业绩
+ * @property string $PV_PCS 当期零售
+ * @property string $PV_LS_TOUCH 虚拟零售区新增业绩
+ * @property string $SURPLUS_LS 虚拟零售区结余
+ * @property string $QY_LS 虚拟零售区区域业绩
+ * @property string $PV_TOUCH 新增业绩累计
+ * @property string $BONUS_REAL 实际奖金
+ * @property string $BONUS_TOTAL 总奖金
+ * @property string $BONUS_INCOME 总收入
+ * @property int $PERIOD_NUM 结算期数
+ * @property int $CALC_YEAR 所在结算年
+ * @property int $CALC_MONTH 所在结算月
+ * @property int $CALCULATED_AT 结算时间
+ * @property int $IS_SENT 是否挂网
+ * @property int $SENT_AT 挂网时间
+ * @property string $P_CALC_MONTH 表分区的日期索引
+ * @property int $CREATED_AT 创建时间
+ *
+ * @property string $ORI_BONUS_QY 团队奖原奖金
+ * @property string $ORI_BONUS_QY_BD 报单团队奖原奖金
+ * @property string $ORI_BONUS_QY_FX 复消团队奖原奖金
+ * @property string $ORI_BONUS_YC 荣衔奖奖原奖金
+ * @property string $ORI_BONUS_VIP VIP奖奖原奖金
+ * @property string $ORI_BONUS_STANDARD 达标奖原奖金
+ * @property string $BONUS_BD 服务奖
+ * @property string $ORI_BONUS_BD 服务奖原奖金
+ * @property string $BONUS_TG 推广奖
+ * @property string $ORI_BONUS_TG 推广奖原奖金
+ * @property string $BONUS_XF 消费奖
+ * @property string $ORI_BONUS_XF 消费奖原奖金
+ * @property string $BONUS_YJ 业绩奖
+ * @property string $ORI_BONUS_YJ 业绩奖原奖金
+ * @property string $ORI_BONUS_YJ_BD 报单业绩奖原奖金
+ * @property string $ORI_BONUS_YJ_FX 复消业绩奖原奖金
+ * @property string $BONUS_GX 共享奖
+ * @property string $ORI_BONUS_GX 共享奖原奖金
+ * @property string $BONUS_BONUS_GX 实发共享奖奖金
+ * @property string $BONUS_GL 管理奖
+ * @property string $ORI_BONUS_GL 管理奖原奖金
+ * @property string $BONUS_BONUS_GL 实发管理奖奖金
+ * @property string $ORI_BONUS_GL_BD 报单管理奖原奖金
+ * @property string $ORI_BONUS_GL_FX 复消管理奖原奖金
+ * @property string $RECONSUME_POINTS 复消积分
+ * @property string $MANAGE_TAX 管理费 
+ * @property string $BONUS_BS 蓝星奖金(即新的管理奖)
+ * @property string $ORI_BONUS_BS 蓝星原奖金(即新的管理奖,原奖金)
+ */
+class CalcBonus extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%CALC_BONUS}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'LAST_USER_NAME', 'LAST_REAL_NAME', 'LAST_MOBILE', 'LAST_SYSTEM_ID','LAST_LOCATION', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CALCULATED_AT', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
+            [['LAST_STATUS', 'LAST_PERIOD_AT', 'LAST_CREATED_AT', 'LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY', 'LAST_IS_DIRECT_SELLER', 'LAST_LOCATION', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CALCULATED_AT', 'IS_SENT', 'SENT_AT', 'CREATED_AT'], 'integer'],
+            [['ORI_BONUS_BS','EXCHANGE_POINTS','BONUS_BS','BONUS_QY', 'BONUS_YC', 'BONUS_VIP', 'BONUS_FX', 'BONUS_LS', 'BONUS_FW', 'BONUS_BT', 'BONUS_BT_PROD', 'BONUS_BT_TOOL', 'DEDUCT_ZR', 'BONUS_FL', 'BONUS_CF', 'BONUS_LX', 'SHOULD_QY', 'SHOULD_DEDUCT_ZR', 'PV_1L', 'QY_1L', 'SURPLUS_1L', 'PV_2L', 'QY_2L', 'SURPLUS_2L', 'PV_3L', 'QY_3L', 'SURPLUS_3L', 'PV_4L', 'QY_4L', 'SURPLUS_4L', 'PV_5L', 'QY_5L', 'SURPLUS_5L', 'PV_PCS', 'PV_LS_TOUCH', 'SURPLUS_LS', 'QY_LS', 'PV_TOUCH', 'BONUS_REAL', 'BONUS_TOTAL', 'BONUS_INCOME', 'ORI_BONUS_QY','ORI_BONUS_QY_BD','ORI_BONUS_QY_FX','ORI_BONUS_YC', 'ORI_BONUS_VIP','ORI_BONUS_STANDARD','BONUS_BD','ORI_BONUS_BD','BONUS_TG','ORI_BONUS_TG','BONUS_XF','ORI_BONUS_XF','BONUS_YJ','ORI_BONUS_YJ','ORI_BONUS_YJ_BD','ORI_BONUS_YJ_FX','BONUS_GX','ORI_BONUS_GX','REAL_BONUS_GX','BONUS_GL','ORI_BONUS_GL','REAL_BONUS_GL','ORI_BONUS_GL_BD','ORI_BONUS_GL_FX','RECONSUME_POINTS','MANAGE_TAX'], 'number'],
+            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_SUB_COM_ID', 'LAST_SYSTEM_ID'], 'string', 'max' => 32],
+            [['LAST_USER_NAME', 'LAST_REC_USER_NAME', 'LAST_CON_USER_NAME'], 'string', 'max' => 16],
+            [['LAST_REAL_NAME', 'LAST_REC_REAL_NAME', 'LAST_CON_REAL_NAME'], 'string', 'max' => 128],
+            [['LAST_MOBILE'], 'string', 'max' => 11],
+            [['P_CALC_MONTH'], 'safe'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'USER_ID' => '会员ID',
+            'LAST_USER_NAME' => '结算时会员编号',
+            'LAST_REAL_NAME' => '结算时会员姓名',
+            'LAST_DEC_LV' => '结算时会员级别',
+            'LAST_EMP_LV' => '结算时会员聘级',
+            'LAST_STATUS' => '结算时状态',
+            'LAST_MOBILE' => '结算时手机号码',
+            'LAST_PERIOD_AT' => '结算时加入期数',
+            'LAST_CREATED_AT' => '结算时加入时间',
+            'LAST_SUB_COM_ID' => '结算时所属分公司',
+            'LAST_PROVINCE' => '结算时所属省份',
+            'LAST_CITY' => '结算时所属城市',
+            'LAST_COUNTY' => '结算时所属地区',
+            'LAST_SYSTEM_ID' => '结算时体系',
+            'LAST_IS_DIRECT_SELLER' => '结算时是否直销员',
+            'LAST_REC_USER_NAME' => '结算时开拓者编号',
+            'LAST_REC_REAL_NAME' => '结算时开拓者姓名',
+            'LAST_CON_USER_NAME' => '结算时上级编号',
+            'LAST_CON_REAL_NAME' => '结算时上级姓名',
+            'LAST_LOCATION' => '结算时市场',
+            'BONUS_QY' => '区域津贴',
+            'BONUS_YC' => '荣衔奖',
+            'BONUS_VIP' => 'VIP奖',
+            'BONUS_FX' => '复销奖',
+            'BONUS_LS' => '零售奖',
+            'BONUS_FW' => '服务奖',
+            'BONUS_BT' => '店补',
+            'BONUS_BT_PROD' => '产品补贴',
+            'BONUS_BT_TOOL' => '工具流补贴',
+            'DEDUCT_ZR' => '责任业绩扣除',
+            'BONUS_FL' => '形象店货补',
+            'BONUS_CF' => '车房养老奖',
+            'BONUS_LX' => '领袖分红',
+            'SHOULD_QY' => '应发区域津贴',
+            'SHOULD_DEDUCT_ZR' => '应扣责任业绩',
+            'PV_1L' => '一市场新增业绩',
+            'QY_1L' => '一市场区域业绩',
+            'SURPLUS_1L' => '一市场结余业绩',
+            'PV_2L' => '二市场新增业绩',
+            'QY_2L' => '二市场区域业绩',
+            'SURPLUS_2L' => '二市场结余业绩',
+            'PV_3L' => '三市场新增业绩',
+            'QY_3L' => '三市场区域业绩',
+            'SURPLUS_3L' => '三市场结余业绩',
+            'PV_4L' => '四市场新增业绩',
+            'QY_4L' => '四市场区域业绩',
+            'SURPLUS_4L' => '四市场结余业绩',
+            'PV_5L' => '五市场新增业绩',
+            'QY_5L' => '五市场区域业绩',
+            'SURPLUS_5L' => '五市场结余业绩',
+            'PV_PCS' => '当期零售',
+            'PV_LS_TOUCH' => '虚拟零售区新增业绩',
+            'SURPLUS_LS' => '虚拟零售区结余',
+            'QY_LS' => '虚拟零售区区域业绩',
+            'PV_TOUCH' => '新增业绩累计',
+            'BONUS_REAL' => '实际奖金',
+            'BONUS_TOTAL' => '总奖金',
+            'BONUS_INCOME' => '总收入',
+            'PERIOD_NUM' => '结算期数',
+            'CALC_YEAR' => '所在结算年',
+            'CALC_MONTH' => '所在结算月',
+            'CALCULATED_AT' => '结算时间',
+            'IS_SENT' => '是否挂网',
+            'SENT_AT' => '挂网时间',
+            'P_CALC_MONTH' => '表分区的日期索引',
+            'CREATED_AT' => '创建时间',
+            'ORI_BONUS_QY'=> '团队奖原奖金',
+            'ORI_BONUS_QY_BD'=> '报单团队奖原奖金',
+            'ORI_BONUS_QY_FX'=> '复消团队奖原奖金',
+            'ORI_BONUS_YC'=> '荣衔奖原奖金',
+            'ORI_BONUS_VIP'=> 'VIP奖原奖金',
+            'ORI_BONUS_STANDARD'=> '达标奖原奖金',
+            'BONUS_BD'=> '服务奖',
+            'ORI_BONUS_BD'=> '服务奖原奖金',
+            'BONUS_TG'=> '推广奖',
+            'ORI_BONUS_TG'=> '推广奖原奖金',
+            'BONUS_XF'=> '消费奖',
+            'ORI_BONUS_XF'=> '消费奖原奖金',
+            'BONUS_YJ'=> '业绩奖',
+            'ORI_BONUS_YJ'=> '业绩奖原奖金',
+            'ORI_BONUS_YJ_BD'=> '报单业绩奖原奖金',
+            'ORI_BONUS_YJ_FX'=> '复消业绩奖原奖金',
+            'BONUS_GX'=> '共享奖',
+            'ORI_BONUS_GX'=> '共享奖原奖金',
+            'REAL_BONUS_GX'=> '实发共享奖奖金',
+            'BONUS_GL'=> '管理奖',
+            'ORI_BONUS_GL'=> '管理奖原奖金',
+            'REAL_BONUS_GL'=> '实发管理奖奖金',
+            'ORI_BONUS_GL_BD'=> '报单管理奖原奖金',
+            'ORI_BONUS_GL_FX'=> '复消管理奖原奖金',
+            'RECONSUME_POINTS'=> '复消积分',
+            'MANAGE_TAX'=> '管理费',
+            'EXCHANGE_POINTS' => '兑换点数',
+            'BONUS_BS' => '蓝星奖',
+            'ORI_BONUS_BS' => '蓝星原奖金'
+        ];
+    }
+
+    /**
+     * 近几期的奖金
+     * @param $userId
+     * @param int $num
+     * @return array
+     * @throws \yii\db\Exception
+     */
+    public static function periodBonus($userId, $num = 7){
+        // 获取近几期的年月
+        $periodYearMonths = Period::getNearlyPeriodYearMonth($num);
+        $allBonus = [];
+        foreach($periodYearMonths as $data){
+            $allBonus[] = static::findUseSlaves()->yearMonth($data['yearMonth'])->select('USER_ID,BONUS_QY, BONUS_YC, BONUS_FX, BONUS_LS, BONUS_FW, BONUS_BT, BONUS_BT_PROD, BONUS_BT_TOOL, DEDUCT_ZR, BONUS_FL, BONUS_CF, BONUS_LX, SHOULD_QY')->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM AND IS_SENT=1', [':USER_ID'=>$userId, ':PERIOD_NUM'=>$data['periodNum']])->asArray()->one();
+        }
+        return $allBonus;
+    }
+
+    /**
+     * 获取期数对应的奖金情况
+     * @param $userId
+     * @param $periodNum
+     * @return array|null|\yii\db\ActiveRecord
+     * @throws \yii\db\Exception
+     */
+    public static function periodNumBonus($userId, $periodNum){
+        $period = Period::instance();
+        $yearMonth = $period->getYearMonth($periodNum);
+        return static::findUseSlaves()->yearMonth($yearMonth)->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', [':USER_ID'=>$userId, ':PERIOD_NUM'=>$periodNum])->select('USER_ID,BONUS_QY, BONUS_YC, BONUS_TG, BONUS_YJ, BONUS_GX, BONUS_GL, ORI_BONUS_QY, ORI_BONUS_YC, ORI_BONUS_TG, ORI_BONUS_YJ, ORI_BONUS_GX, ORI_BONUS_GL, RECONSUME_POINTS, MANAGE_TAX, BONUS_REAL, BONUS_TOTAL, BONUS_INCOME')->asArray()->one();
+    }
+
+    /**
+     * 根据期数获取月累计奖金
+     * @param $userId
+     * @param $periodNum
+     * @param string $type
+     * @return int|mixed
+     * @throws \yii\db\Exception
+     */
+    public static function monthBonus($userId, $periodNum=null, $type = 'BONUS_QY') {
+        if($periodNum) {
+            $period = Period::instance();
+            $yearMonth = $period->getYearMonth($periodNum);
+            if ($yearMonth) {
+                $bonus = CalcBonus::findUseSlaves()->yearMonth($yearMonth)->select('SUM(' . $type . ') AS ' . $type . '_SUM')->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH AND IS_SENT=1', [':USER_ID' => $userId, ':CALC_MONTH' => $yearMonth])->asArray()->one();
+            }
+        }else{
+            $bonus = CalcBonus::findUseSlaves()->select('SUM(' . $type . ') AS ' . $type . '_SUM')->where('USER_ID=:USER_ID AND IS_SENT=1', [':USER_ID' => $userId])->asArray()->one();
+        }
+        return $bonus[$type . '_SUM'] ?? 0;
+    }
+}

+ 69 - 69
common/models/OrderGoods.php

@@ -1,69 +1,69 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%ORDER_GOODS}}".
- *
- * @property string $ID
- * @property string $ORDER_SN 订单ID
- * @property string $GOODS_ID 商品ID
- * @property string $GOODS_TITLE 商品名称
- * @property string $PRICE 价格
- * @property string $REAL_PRICE 实际价格
- * @property string $PV 订货PV
- * @property string $REAL_PV 实际PV
- * @property string $POINT 兑换积分
- * @property string $SKU_CODE 商品编码
- * @property int $BUY_NUMS 购买数量
- * @property string $P_CALC_MONTH 分区日期
- */
-class OrderGoods extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%ORDER_GOODS}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['ORDER_SN', 'GOODS_ID', 'GOODS_TITLE', 'SKU_CODE'], 'required'],
-            [['PRICE', 'REAL_PRICE', 'PV', 'REAL_PV', 'POINT'], 'number'],
-            [['BUY_NUMS'], 'integer'],
-            [['ID', 'ORDER_SN', 'GOODS_ID'], 'string', 'max' => 32],
-            [['GOODS_TITLE'], 'string', 'max' => 255],
-            [['SKU_CODE'], 'string', 'max' => 16],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'ORDER_SN' => '订单ID',
-            'GOODS_ID' => '商品ID',
-            'GOODS_TITLE' => '商品名称',
-            'PRICE' => '价格',
-            'REAL_PRICE' => '实际价格',
-            'PV' => '订货PV',
-            'REAL_PV' => '实际PV',
-            'POINT' => '兑换积分',
-            'SKU_CODE' => '商品编码',
-            'BUY_NUMS' => '购买数量',
-            'P_CALC_MONTH' => '分区日期',
-        ];
-    }
-}
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%ORDER_GOODS}}".
+ *
+ * @property string $ID
+ * @property string $ORDER_SN 订单ID
+ * @property string $GOODS_ID 商品ID
+ * @property string $GOODS_TITLE 商品名称
+ * @property string $PRICE 价格
+ * @property string $REAL_PRICE 实际价格
+ * @property string $PV 订货PV
+ * @property string $REAL_PV 实际PV
+ * @property string $POINT 兑换点数
+ * @property string $SKU_CODE 商品编码
+ * @property int $BUY_NUMS 购买数量
+ * @property string $P_CALC_MONTH 分区日期
+ */
+class OrderGoods extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%ORDER_GOODS}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['ORDER_SN', 'GOODS_ID', 'GOODS_TITLE', 'SKU_CODE'], 'required'],
+            [['PRICE', 'REAL_PRICE', 'PV', 'REAL_PV', 'POINT'], 'number'],
+            [['BUY_NUMS'], 'integer'],
+            [['ID', 'ORDER_SN', 'GOODS_ID'], 'string', 'max' => 32],
+            [['GOODS_TITLE'], 'string', 'max' => 255],
+            [['SKU_CODE'], 'string', 'max' => 16],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'ORDER_SN' => '订单ID',
+            'GOODS_ID' => '商品ID',
+            'GOODS_TITLE' => '商品名称',
+            'PRICE' => '价格',
+            'REAL_PRICE' => '实际价格',
+            'PV' => '订货PV',
+            'REAL_PV' => '实际PV',
+            'POINT' => '兑换点数',
+            'SKU_CODE' => '商品编码',
+            'BUY_NUMS' => '购买数量',
+            'P_CALC_MONTH' => '分区日期',
+        ];
+    }
+}

+ 71 - 71
common/models/OrderGoodsDec.php

@@ -1,71 +1,71 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%ORDER_GOODS_DEC}}".
- *
- * @property string $ID
- * @property string $ORDER_SN 订单ID
- * @property string $GOODS_TITLE 商品名称
- * @property string $PRICE 价格
- * @property string $REAL_PRICE 实际价格
- * @property string $PV 订货PV
- * @property string $REAL_PV 实际PV
- * @property string $POINT 兑换积分
- * @property int $PERIOD_NUM 期数
- * @property int $ORDER_DAY 日期
- * @property string $SKU_CODE 商品编码
- * @property int $BUY_NUMS 购买数量
- * @property string $P_CALC_MONTH 分区日期
- */
-class OrderGoodsDec extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%ORDER_GOODS_DEC}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['ORDER_SN', 'GOODS_TITLE', 'SKU_CODE'], 'required'],
-            [['PRICE', 'REAL_PRICE', 'PV', 'REAL_PV', 'POINT'], 'number'],
-            [['BUY_NUMS', 'PERIOD_NUM'], 'integer'],
-            [['ID', 'ORDER_SN'], 'string', 'max' => 32],
-            [['GOODS_TITLE'], 'string', 'max' => 255],
-            [['SKU_CODE','ORDER_DAY'], 'string', 'max' => 16],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'ORDER_SN' => '订单ID',
-            'GOODS_TITLE' => '商品名称',
-            'PRICE' => '价格',
-            'REAL_PRICE' => '实际价格',
-            'PV' => '订货PV',
-            'REAL_PV' => '实际PV',
-            'POINT' => '兑换积分',
-            'PERIOD_NUM' => '期数',
-            'ORDER_DAY' => '日期',
-            'SKU_CODE' => '商品编码',
-            'BUY_NUMS' => '购买数量',
-            'P_CALC_MONTH' => '分区日期',
-        ];
-    }
-}
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%ORDER_GOODS_DEC}}".
+ *
+ * @property string $ID
+ * @property string $ORDER_SN 订单ID
+ * @property string $GOODS_TITLE 商品名称
+ * @property string $PRICE 价格
+ * @property string $REAL_PRICE 实际价格
+ * @property string $PV 订货PV
+ * @property string $REAL_PV 实际PV
+ * @property string $POINT 兑换积分
+ * @property int $PERIOD_NUM 期数
+ * @property int $ORDER_DAY 日期
+ * @property string $SKU_CODE 商品编码
+ * @property int $BUY_NUMS 购买数量
+ * @property string $P_CALC_MONTH 分区日期
+ */
+class OrderGoodsDec extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%ORDER_GOODS_DEC}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['ORDER_SN', 'GOODS_TITLE', 'SKU_CODE'], 'required'],
+            [['PRICE', 'REAL_PRICE', 'PV', 'REAL_PV', 'POINT'], 'number'],
+            [['BUY_NUMS', 'PERIOD_NUM'], 'integer'],
+            [['ID', 'ORDER_SN'], 'string', 'max' => 32],
+            [['GOODS_TITLE'], 'string', 'max' => 255],
+            [['SKU_CODE','ORDER_DAY'], 'string', 'max' => 16],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'ORDER_SN' => '订单ID',
+            'GOODS_TITLE' => '商品名称',
+            'PRICE' => '价格',
+            'REAL_PRICE' => '实际价格',
+            'PV' => '订货PV',
+            'REAL_PV' => '实际PV',
+            'POINT' => '兑换点数',
+            'PERIOD_NUM' => '期数',
+            'ORDER_DAY' => '日期',
+            'SKU_CODE' => '商品编码',
+            'BUY_NUMS' => '购买数量',
+            'P_CALC_MONTH' => '分区日期',
+        ];
+    }
+}

+ 69 - 69
common/models/OrderGoodsShop.php

@@ -1,69 +1,69 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%ORDER_GOODS}}".
- *
- * @property string $ID
- * @property string $ORDER_SN 订单ID
- * @property string $GOODS_TITLE 商品名称
- * @property string $PRICE 价格
- * @property string $REAL_PRICE 实际价格
- * @property string $PV 订货PV
- * @property string $REAL_PV 实际PV
- * @property string $POINT 兑换积分
- * @property int $PERIOD_NUM 期数
- * @property string $SKU_CODE 商品编码
- * @property int $BUY_NUMS 购买数量
- * @property string $P_CALC_MONTH 分区日期
- */
-class OrderGoodsShop extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%ORDER_GOODS_SHOP}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['ORDER_SN', 'GOODS_TITLE', 'SKU_CODE'], 'required'],
-            [['PRICE', 'REAL_PRICE', 'PV', 'REAL_PV', 'POINT'], 'number'],
-            [['BUY_NUMS', 'PERIOD_NUM'], 'integer'],
-            [['ID', 'ORDER_SN'], 'string', 'max' => 32],
-            [['GOODS_TITLE'], 'string', 'max' => 255],
-            [['SKU_CODE'], 'string', 'max' => 16],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'ORDER_SN' => '订单ID',
-            'GOODS_TITLE' => '商品名称',
-            'PRICE' => '价格',
-            'REAL_PRICE' => '实际价格',
-            'PV' => '订货PV',
-            'REAL_PV' => '实际PV',
-            'POINT' => '兑换积分',
-            'PERIOD_NUM' => '期数',
-            'SKU_CODE' => '商品编码',
-            'BUY_NUMS' => '购买数量',
-            'P_CALC_MONTH' => '分区日期',
-        ];
-    }
-}
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%ORDER_GOODS}}".
+ *
+ * @property string $ID
+ * @property string $ORDER_SN 订单ID
+ * @property string $GOODS_TITLE 商品名称
+ * @property string $PRICE 价格
+ * @property string $REAL_PRICE 实际价格
+ * @property string $PV 订货PV
+ * @property string $REAL_PV 实际PV
+ * @property string $POINT 兑换积分
+ * @property int $PERIOD_NUM 期数
+ * @property string $SKU_CODE 商品编码
+ * @property int $BUY_NUMS 购买数量
+ * @property string $P_CALC_MONTH 分区日期
+ */
+class OrderGoodsShop extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%ORDER_GOODS_SHOP}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['ORDER_SN', 'GOODS_TITLE', 'SKU_CODE'], 'required'],
+            [['PRICE', 'REAL_PRICE', 'PV', 'REAL_PV', 'POINT'], 'number'],
+            [['BUY_NUMS', 'PERIOD_NUM'], 'integer'],
+            [['ID', 'ORDER_SN'], 'string', 'max' => 32],
+            [['GOODS_TITLE'], 'string', 'max' => 255],
+            [['SKU_CODE'], 'string', 'max' => 16],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'ORDER_SN' => '订单ID',
+            'GOODS_TITLE' => '商品名称',
+            'PRICE' => '价格',
+            'REAL_PRICE' => '实际价格',
+            'PV' => '订货PV',
+            'REAL_PV' => '实际PV',
+            'POINT' => '兑换点数',
+            'PERIOD_NUM' => '期数',
+            'SKU_CODE' => '商品编码',
+            'BUY_NUMS' => '购买数量',
+            'P_CALC_MONTH' => '分区日期',
+        ];
+    }
+}

+ 192 - 0
common/models/PerfMonthPrepare.php

@@ -0,0 +1,192 @@
+<?php
+
+namespace common\models;
+
+use common\helpers\Tool;
+use Yii;
+use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
+
+/**
+ * This is the model class for table "{{%PERF_MONTH_PREPARE}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 会员ID
+ * @property string $LAST_DEC_LV 结算时会员级别
+ * @property string $LAST_EMP_LV 结算时会员聘级
+ * @property int $LAST_STATUS 结算时会有状态
+ * @property string $FX_AMOUNT_CASH 复消现金金额
+ * @property string $PV_PCS 个人消费
+ * @property string $PV_PCS_FX 个人复消业绩
+ * @property string $PV_1L 一市场业绩
+ * @property string $PV_2L 二市场业绩
+ * @property string $PV_3L 三市场业绩
+ * @property string $PV_4L 四市场业绩
+ * @property string $PV_5L 五市场业绩
+ * @property string $VIP_PV_1L_ZC VIP一市场报单业绩
+ * @property string $VIP_PV_2L_ZC VIP二市场报单业绩
+ * @property string $VIP_PV_3L_ZC VIP三市场报单业绩
+ * @property string $VIP_PV_4L_ZC VIP四市场报单业绩
+ * @property string $VIP_PV_5L_ZC VIP五市场报单业绩
+ * @property string $VIP_SURPLUS_1L_ZC VIP一市场剩余报单业绩
+ * @property string $VIP_SURPLUS_2L_ZC VIP二市场剩余报单业绩
+ * @property string $VIP_SURPLUS_3L_ZC VIP三市场剩余报单业绩
+ * @property string $VIP_SURPLUS_4L_ZC VIP四市场剩余报单业绩
+ * @property string $VIP_SURPLUS_5L_ZC VIP五市场剩余报单业绩
+ * @property string $PV_1L_TOTAL 一市场历史累计加该月业绩
+ * @property string $PV_2L_TOTAL 二市场历史累计加该月业绩
+ * @property string $PV_3L_TOTAL 三市场历史累计加该月业绩
+ * @property string $PV_4L_TOTAL 四市场历史累计加该月业绩
+ * @property string $PV_5L_TOTAL 五市场历史累计加该月业绩
+ * @property int $CF_PERCENT 车房养老奖分工系数
+ * @property int $LX_PERCENT 领袖分红分工系数
+ * @property int $FX_STATUS 本月复销状态作为下月发奖资格
+ * @property int $CALC_MONTH 结算月
+ * @property string $P_CALC_MONTH 表分区日期索引
+ * @property int $CREATED_AT 创建时间
+ */
+class PerfMonthPrepare extends \common\components\ActiveRecord
+{
+    const NEXT_MONTH_FX_TRUE = 1;
+    const NEXT_MONTH_FX_FALSE = 0;
+
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%PERF_MONTH_PREPARE}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
+            [['LAST_STATUS', 'CF_PERCENT', 'LX_PERCENT', 'FX_STATUS', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
+            [['FX_AMOUNT_CASH', 'PV_PCS', 'PV_PCS_FX', 'PV_1L', 'PV_2L', 'PV_3L', 'PV_4L', 'PV_5L', 'VIP_PV_1L_ZC', 'VIP_PV_2L_ZC',  'VIP_PV_3L_ZC', 'VIP_PV_4L_ZC', 'VIP_PV_5L_ZC', 'VIP_SURPLUS_1L_ZC', 'VIP_SURPLUS_2L_ZC', 'VIP_SURPLUS_3L_ZC', 'VIP_SURPLUS_4L_ZC', 'VIP_SURPLUS_5L_ZC', 'PV_1L_TOTAL', 'PV_2L_TOTAL', 'PV_3L_TOTAL', 'PV_4L_TOTAL', 'PV_5L_TOTAL'], 'number'],
+            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV'], 'string', 'max' => 32],
+            [['P_CALC_MONTH'], 'safe'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'USER_ID' => '会员ID',
+            'LAST_DEC_LV' => '结算时会员级别',
+            'LAST_EMP_LV' => '结算时会员聘级',
+            'LAST_STATUS' => '结算时会有状态',
+            'FX_AMOUNT_CASH' => '复消现金金额',
+            'PV_PCS' => '个人消费',
+            'PV_PCS_FX' => '个人复消业绩',
+            'PV_1L' => '一市场业绩',
+            'PV_2L' => '二市场业绩',
+            'PV_3L' => '三市场业绩',
+            'PV_4L' => '四市场业绩',
+            'PV_5L' => '五市场业绩',
+            'VIP_PV_1L_ZC' => 'VIP一市场报单业绩',
+            'VIP_PV_2L_ZC' => 'VIP二市场报单业绩',
+            'VIP_PV_3L_ZC' => 'VIP三市场报单业绩',
+            'VIP_PV_4L_ZC' => 'VIP四市场报单业绩',
+            'VIP_PV_5L_ZC' => 'VIP五市场报单业绩',
+            'VIP_SURPLUS_1L_ZC' => 'VIP一市场剩余报单业绩',
+            'VIP_SURPLUS_2L_ZC' => 'VIP二市场剩余报单业绩',
+            'VIP_SURPLUS_3L_ZC' => 'VIP三市场剩余报单业绩',
+            'VIP_SURPLUS_4L_ZC' => 'VIP四市场剩余报单业绩',
+            'VIP_SURPLUS_5L_ZC' => 'VIP五市场剩余报单业绩',
+            'PV_1L_TOTAL' => '一市场历史累计加该月业绩',
+            'PV_2L_TOTAL' => '二市场历史累计加该月业绩',
+            'PV_3L_TOTAL' => '三市场历史累计加该月业绩',
+            'PV_4L_TOTAL' => '四市场历史累计加该月业绩',
+            'PV_5L_TOTAL' => '五市场历史累计加该月业绩',
+            'CF_PERCENT' => '车房养老奖分工系数',
+            'LX_PERCENT' => '领袖分红分工系数',
+            'FX_STATUS' => '本月复销状态作为下月发奖资格',
+            'CALC_MONTH' => '结算月',
+            'P_CALC_MONTH' => '表分区日期索引',
+            'CREATED_AT' => '创建时间',
+        ];
+    }
+
+    /**
+     * 获取会员的月业绩总和
+     * @param $yearMonth
+     * @param $userId
+     * @return array|null|\yii\db\ActiveRecord
+     */
+    public static function getMonthPerf($yearMonth, $userId){
+        $result = static::find()->yearMonth($yearMonth)->where('USER_ID=:USER_ID', [':USER_ID'=>$userId])->asArray()->one();
+        if(!$result){
+            $result = [
+                'USER_ID' => $userId,
+                'FX_AMOUNT_CASH' => 0,
+                'PV_PCS' => 0,
+                'PV_PSS' => 0,
+                'PV_1L' => 0,
+                'PV_2L' => 0,
+                'PV_3L' => 0,
+                'PV_4L' => 0,
+                'PV_5L' => 0,
+                'PV_1L_TOTAL' => 0,
+                'PV_2L_TOTAL' => 0,
+                'PV_3L_TOTAL' => 0,
+                'PV_4L_TOTAL' => 0,
+                'PV_5L_TOTAL' => 0,
+                'PV_PSS_TOTAL' => 0,
+                'DEC_LEVEL' => null,
+                'EMP_LEVEL' => null,
+                'CF_PERCENT' => 0,
+                'LX_PERCENT' => 0,
+                'FX_STATUS' => self::NEXT_MONTH_FX_FALSE,
+            ];
+        }
+        $result['PV_TOTAL'] = Tool::formatPrice($result['PV_1L_TOTAL']+$result['PV_2L_TOTAL']+$result['PV_3L_TOTAL']+$result['PV_4L_TOTAL']+$result['PV_5L_TOTAL']);
+        return $result;
+    }
+
+    // 获取会员的月业绩信息
+    public static function getMonthPerfPrepare($userId,$calcMonth) {
+        $result = PerfMonthPrepare::findUseSlaves()
+        ->where(
+            'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID' => $userId,':CALC_MONTH'=>$calcMonth]
+        )
+        ->asArray()
+        ->one();
+
+        return $result;
+    }
+
+    // 校验业绩状态
+    public static function checkPrepareStatus($pv) {
+        if ($pv >= 10000) {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * 操作日志记录条件
+     * @return array
+     */
+    public function attrLabelsWithLogType(){
+        return [
+            'USER_ID' => '会员ID',
+            'FX_STATUS' => [
+                'label' => '复销资格',
+                'type' => function($data){
+                    $value = $data['value'];
+                    return $value==1?'是':'否';
+                },
+            ],
+            'CALC_MONTH' => '结算月',
+        ];
+    }
+}

+ 130 - 0
common/models/PerfOrderPrepare.php

@@ -0,0 +1,130 @@
+<?php
+
+namespace common\models;
+
+use common\helpers\snowflake\SnowFake;
+use common\helpers\Tool;
+use Yii;
+use yii\base\Exception;
+
+/**
+ * This is the model class for table "{{%PERF_ORDER_PREPARE}}".
+ *
+ * @property string $ID
+ * @property string $SN 业绩单编号
+ * @property string $DEC_SN 报单编号
+ * @property string $DEC_TYPE 报单类型
+ * @property int $DEC_STATUS 业绩单状态
+ * @property string $USER_ID 产生业绩会员ID
+ * @property string $LAST_DEC_LV 结算时会员级别
+ * @property string $LAST_EMP_LV 结算时会员聘级
+ * @property int $LAST_STATUS 结算时状态
+ * @property string $LAST_REC_USER_NAME 结算时开拓者编号
+ * @property string $LAST_REC_REAL_NAME 结算时开拓者姓名
+ * @property string $PV 业绩单PV
+ * @property string $DEC_AMOUNT 报单金额
+ * @property string $LAST_SUB_COM_ID 结算时所属分公司
+ * @property int $LAST_PROVINCE 结算时省份
+ * @property int $LAST_CITY 结算时城市
+ * @property int $LAST_COUNTY 结算时地区
+ * @property string $DEC_USER_ID 报单主体ID
+ * @property string $LAST_DEC_DEC_LV 结算时报单主体级别
+ * @property string $LAST_DEC_SUB_COM_ID 结算时报单主体所属分公司
+ * @property int $LAST_DEC_PROVINCE 结算时报单主体省份
+ * @property int $LAST_DEC_CITY 结算时报单主体城市
+ * @property int $LAST_DEC_COUNTY 结算时报单主体地区
+ * @property int $PERIOD_NUM 所在期数
+ * @property int $CALC_MONTH 结算月
+ * @property string $P_CALC_MONTH 分区结算月
+ * @property int $CREATED_AT 创建时间
+ * @property int $CLOSED_AT 置废时间
+ */
+class PerfOrderPrepare extends \common\components\ActiveRecord
+{
+    //业绩单状态
+    const STATUS_NORMAL = 1; //正常
+    const STATUS_CLOSED = 2; //置废
+    const STATUS_NAME = [
+      self::STATUS_NORMAL=>'已审核',
+      self::STATUS_CLOSED=>'置废',
+    ];
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%PERF_ORDER_PREPARE}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['SN', 'DEC_TYPE', 'USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT', 'CLOSED_AT'], 'required'],
+            [['LAST_STATUS', 'DEC_STATUS', 'LAST_PROVINCE', 'LAST_CITY', 'LAST_COUNTY', 'LAST_DEC_PROVINCE', 'LAST_DEC_CITY', 'LAST_DEC_COUNTY', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT', 'CLOSED_AT'], 'integer'],
+            [['PV', 'DEC_AMOUNT'], 'number'],
+            [['ID', 'USER_ID', 'LAST_DEC_LV','LAST_EMP_LV', 'LAST_SUB_COM_ID', 'DEC_USER_ID', 'LAST_DEC_DEC_LV', 'LAST_DEC_SUB_COM_ID'], 'string', 'max' => 32],
+            [['SN', 'DEC_SN', 'DEC_TYPE'], 'string', 'max' => 32],
+            [['LAST_REC_USER_NAME'], 'string', 'max' => 16],
+            [['LAST_REC_REAL_NAME'], 'string', 'max' => 128],
+            [['P_CALC_MONTH'], 'string', 'max' => 7],
+            [['SN'], 'unique'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'SN' => '业绩单编号',
+            'DEC_SN' => '报单编号',
+            'DEC_TYPE' => '报单类型',
+            'DEC_STATUS' => '业绩单状态',
+            'USER_ID' => '产生业绩会员ID',
+            'LAST_DEC_LV' => '结算时会员级别',
+            'LAST_EMP_LV' => '结算时会员聘级',
+            'LAST_STATUS' => '结算时状态',
+            'LAST_REC_USER_NAME' => '结算时开拓者编号',
+            'LAST_REC_REAL_NAME' => '结算时开拓者姓名',
+            'PV' => '业绩单PV',
+            'DEC_AMOUNT' => '报单金额',
+            'LAST_SUB_COM_ID' => '结算时所属分公司',
+            'LAST_PROVINCE' => '结算时省份',
+            'LAST_CITY' => '结算时城市',
+            'LAST_COUNTY' => '结算时地区',
+            'DEC_USER_ID' => '报单主体ID',
+            'LAST_DEC_DEC_LV' => '结算时报单主体级别',
+            'LAST_DEC_SUB_COM_ID' => '结算时报单主体所属分公司',
+            'LAST_DEC_PROVINCE' => '结算时报单主体省份',
+            'LAST_DEC_CITY' => '结算时报单主体城市',
+            'LAST_DEC_COUNTY' => '结算时报单主体地区',
+            'PERIOD_NUM' => '所在期数',
+            'CALC_MONTH' => '结算月',
+            'P_CALC_MONTH' => '分区结算月',
+            'CREATED_AT' => '创建时间',
+            'CLOSED_AT' => '置废时间',
+        ];
+    }
+
+    /**
+     * 获取当前最大的订单编号
+     * @return mixed
+     */
+    public static function getMaxSn(){
+        return static::find()->where('1=1')->max('SN');
+    }
+
+    /**
+     * 生成sn
+     * @return string
+     */
+    public static function generateSN() {
+        return  SnowFake::instance()->generateId();
+    }
+}

+ 228 - 0
common/models/PerfPeriodPrepare.php

@@ -0,0 +1,228 @@
+<?php
+
+namespace common\models;
+
+use common\helpers\user\Info;
+use Yii;
+
+/**
+ * This is the model class for table "{{%PERF_PERIOD_PREPARE}}".
+ * 预计算用户团队月业绩
+ *
+ * @property string $ID
+ * @property string $USER_ID 会员ID
+ * @property string $LAST_DEC_LV 结算时会员级别
+ * @property string $LAST_EMP_LV 结算时会员聘级
+ * @property int $LAST_STATUS 结算时会有状态
+ * @property string $FX_AMOUNT_CASH 复消现金金额
+ * @property string $PV_PCS 个人消费
+ * @property string $PV_PCS_ZC 个人消费注册单
+ * @property string $PV_PCS_YH 个人消费优惠单
+ * @property string $PV_PCS_ZG 个人消费增购单
+ * @property string $PV_PCS_LS 个人消费零售单
+ * @property string $PV_PCS_FX 个人消费复销单
+ * @property string $PV_PCS_FX_CASH 现金复消
+ * @property string $PV_PCS_FX_POINT 积分复消
+ * @property string $PV_1L 一市场业绩
+ * @property string $PV_1L_TOUCH 一市场对碰业绩
+ * @property string $PV_1L_ZC
+ * @property string $PV_1L_YH
+ * @property string $PV_1L_ZG
+ * @property string $PV_1L_LS
+ * @property string $PV_1L_FX
+ * @property string $PV_2L 二市场业绩
+ * @property string $PV_2L_TOUCH 二市场对碰业绩
+ * @property string $PV_2L_ZC
+ * @property string $PV_2L_YH
+ * @property string $PV_2L_ZG
+ * @property string $PV_2L_LS
+ * @property string $PV_2L_FX
+ * @property string $PV_3L 三市场业绩
+ * @property string $PV_3L_TOUCH 三市场对碰业绩
+ * @property string $PV_3L_ZC
+ * @property string $PV_3L_YH
+ * @property string $PV_3L_ZG
+ * @property string $PV_3L_LS
+ * @property string $PV_3L_FX
+ * @property string $PV_4L 四市场业绩
+ * @property string $PV_4L_TOUCH 四市场对碰业绩
+ * @property string $PV_4L_ZC
+ * @property string $PV_4L_YH
+ * @property string $PV_4L_ZG
+ * @property string $PV_4L_LS
+ * @property string $PV_4L_FX
+ * @property string $PV_5L 五市场业绩
+ * @property string $PV_5L_TOUCH 五市场对碰业绩
+ * @property string $PV_5L_ZC
+ * @property string $PV_5L_YH
+ * @property string $PV_5L_ZG
+ * @property string $PV_5L_LS
+ * @property string $PV_5L_FX
+ * @property string $PV_LS_TOUCH 隐藏零售区业绩30%后的
+ * @property string $SURPLUS_1L 一市场结余业绩
+ * @property string $SURPLUS_1L_ZC 一市场首购结余业绩
+ * @property string $SURPLUS_1L_FX 一市场复消结余业绩
+ * @property string $SURPLUS_2L 二市场结余业绩
+ * @property string $SURPLUS_2L_ZC 二市场首购结余业绩
+ * @property string $SURPLUS_2L_FX 二市场复消结余业绩
+ * @property string $SURPLUS_3L 三市场结余业绩
+ * @property string $SURPLUS_3L_ZC 三市场首购结余业绩
+ * @property string $SURPLUS_3L_FX 三市场复消结余业绩
+ * @property string $SURPLUS_4L 四市场结余业绩
+ * @property string $SURPLUS_4L_ZC 四市场首购结余业绩
+ * @property string $SURPLUS_4L_FX 四市场复消结余业绩
+ * @property string $SURPLUS_5L 五市场结余业绩
+ * @property string $SURPLUS_5L_ZC 五市场首购结余业绩
+ * @property string $SURPLUS_5L_FX 五市场复消结余业绩
+ * @property string $SURPLUS_LS 零售隐藏区结余业绩
+ * @property int $PERIOD_NUM 期数
+ * @property int $CALC_MONTH 结算月YYYYMM
+ * @property string $P_CALC_MONTH 表分区日期索引
+ * @property int $CREATED_AT 创建时间
+ */
+class PerfPeriodPrepare extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%PERF_PERIOD_PREPARE}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
+            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
+            [['FX_AMOUNT_CASH', 'PV_PCS', 'PV_PCS_ZC', 'PV_PCS_YH', 'PV_PCS_ZG', 'PV_PCS_LS', 'PV_PCS_FX', 'PV_PCS_FX_CASH', 'PV_PCS_FX_POINT', 'PV_1L', 'PV_1L_TOUCH', 'PV_1L_ZC', 'PV_1L_YH', 'PV_1L_ZG', 'PV_1L_LS', 'PV_1L_FX', 'PV_2L', 'PV_2L_TOUCH', 'PV_2L_ZC', 'PV_2L_YH', 'PV_2L_ZG', 'PV_2L_LS', 'PV_2L_FX', 'PV_3L', 'PV_3L_TOUCH', 'PV_3L_ZC', 'PV_3L_YH', 'PV_3L_ZG', 'PV_3L_LS', 'PV_3L_FX', 'PV_4L', 'PV_4L_TOUCH', 'PV_4L_ZC', 'PV_4L_YH', 'PV_4L_ZG', 'PV_4L_LS', 'PV_4L_FX', 'PV_5L', 'PV_5L_TOUCH', 'PV_5L_ZC', 'PV_5L_YH', 'PV_5L_ZG', 'PV_5L_LS', 'PV_5L_FX', 'PV_LS_TOUCH', 'SURPLUS_1L', 'SURPLUS_1L_ZC', 'SURPLUS_1L_FX', 'SURPLUS_2L', 'SURPLUS_2L_ZC', 'SURPLUS_2L_FX', 'SURPLUS_3L', 'SURPLUS_3L_ZC', 'SURPLUS_3L_FX', 'SURPLUS_4L', 'SURPLUS_4L_ZC', 'SURPLUS_4L_FX', 'SURPLUS_5L', 'SURPLUS_5L_ZC', 'SURPLUS_5L_FX', 'SURPLUS_LS'], 'number'],
+            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV'], 'string', 'max' => 32],
+            [['P_CALC_MONTH'], 'safe'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'USER_ID' => '会员ID',
+            'LAST_DEC_LV' => '结算时会员级别',
+            'LAST_EMP_LV' => '结算时会员聘级',
+            'LAST_STATUS' => '结算时会有状态',
+            'FX_AMOUNT_CASH' => '复消现金金额',
+            'PV_PCS' => '个人消费',
+            'PV_PCS_ZC' => '个人消费注册单',
+            'PV_PCS_YH' => '个人消费优惠单',
+            'PV_PCS_ZG' => '个人消费增购单',
+            'PV_PCS_LS' => '个人消费零售单',
+            'PV_PCS_FX' => '个人消费复销单',
+            'PV_PCS_FX_CASH' => '现金复消',
+            'PV_PCS_FX_POINT' => '积分复消',
+            'PV_1L' => '一市场业绩',
+            'PV_1L_TOUCH' => '一市场对碰业绩',
+            'PV_1L_ZC' => 'Pv 1 L  Zc',
+            'PV_1L_YH' => 'Pv 1 L  Yh',
+            'PV_1L_ZG' => 'Pv 1 L  Zg',
+            'PV_1L_LS' => 'Pv 1 L  Ls',
+            'PV_1L_FX' => 'Pv 1 L  Fx',
+            'PV_2L' => '二市场业绩',
+            'PV_2L_TOUCH' => '二市场对碰业绩',
+            'PV_2L_ZC' => 'Pv 2 L  Zc',
+            'PV_2L_YH' => 'Pv 2 L  Yh',
+            'PV_2L_ZG' => 'Pv 2 L  Zg',
+            'PV_2L_LS' => 'Pv 2 L  Ls',
+            'PV_2L_FX' => 'Pv 2 L  Fx',
+            'PV_3L' => '三市场业绩',
+            'PV_3L_TOUCH' => '三市场对碰业绩',
+            'PV_3L_ZC' => 'Pv 3 L  Zc',
+            'PV_3L_YH' => 'Pv 3 L  Yh',
+            'PV_3L_ZG' => 'Pv 3 L  Zg',
+            'PV_3L_LS' => 'Pv 3 L  Ls',
+            'PV_3L_FX' => 'Pv 3 L  Fx',
+            'PV_4L' => '四市场业绩',
+            'PV_4L_TOUCH' => '四市场对碰业绩',
+            'PV_4L_ZC' => 'Pv 4 L  Zc',
+            'PV_4L_YH' => 'Pv 4 L  Yh',
+            'PV_4L_ZG' => 'Pv 4 L  Zg',
+            'PV_4L_LS' => 'Pv 4 L  Ls',
+            'PV_4L_FX' => 'Pv 4 L  Fx',
+            'PV_5L' => '五市场业绩',
+            'PV_5L_TOUCH' => '五市场对碰业绩',
+            'PV_5L_ZC' => 'Pv 5 L  Zc',
+            'PV_5L_YH' => 'Pv 5 L  Yh',
+            'PV_5L_ZG' => 'Pv 5 L  Zg',
+            'PV_5L_LS' => 'Pv 5 L  Ls',
+            'PV_5L_FX' => 'Pv 5 L  Fx',
+            'PV_LS_TOUCH' => '隐藏零售区业绩30%后的',
+            'SURPLUS_1L' => '一市场结余业绩',
+            'SURPLUS_1L_ZC' => '一市场首购结余业绩',
+            'SURPLUS_1L_FX' => '一市场复消结余业绩',
+            'SURPLUS_2L' => '二市场结余业绩',
+            'SURPLUS_2L_ZC' => '二市场首购结余业绩',
+            'SURPLUS_2L_FX' => '二市场复消结余业绩',
+            'SURPLUS_3L' => '三市场结余业绩',
+            'SURPLUS_3L_ZC' => '三市场首购结余业绩',
+            'SURPLUS_3L_FX' => '三市场复消结余业绩',
+            'SURPLUS_4L' => '四市场结余业绩',
+            'SURPLUS_4L_ZC' => '四市场首购结余业绩',
+            'SURPLUS_4L_FX' => '四市场复消结余业绩',
+            'SURPLUS_5L' => '五市场结余业绩',
+            'SURPLUS_5L_ZC' => '五市场首购结余业绩',
+            'SURPLUS_5L_FX' => '五市场复消结余业绩',
+            'SURPLUS_LS' => '零售隐藏区结余业绩',
+            'PERIOD_NUM' => '期数',
+            'CALC_MONTH' => '结算月YYYYMM',
+            'P_CALC_MONTH' => '表分区日期索引',
+            'CREATED_AT' => '创建时间',
+        ];
+    }
+
+    /**
+     * 操作日志记录条件
+     * @return array
+     */
+    public function attrLabelsWithLogType(){
+        return [
+            'USER_ID' => '会员ID',
+            'SURPLUS_1L' => '一市场结余业绩',
+            'SURPLUS_2L' => '二市场结余业绩',
+            'SURPLUS_3L' => '三市场结余业绩',
+            'SURPLUS_4L' => '四市场结余业绩',
+            'SURPLUS_5L' => '五市场结余业绩',
+            'SURPLUS_LS' => '虚拟零售区结余业绩',
+        ];
+    }
+
+    /**
+     * 获取期结余业绩
+     * @param $periodNum
+     * @param $userId
+     * @return array|\yii\db\ActiveRecord|null
+     * @throws \yii\db\Exception
+     */
+    public static function getPeriodSurplusPerf($periodNum, $userId){
+        $period = Period::instance();
+        $yearMonth = $period->getYearMonth($periodNum);
+        $result = static::findUseDbCalc()->yearMonth($yearMonth)->select('SURPLUS_1L,SURPLUS_2L,SURPLUS_3L,SURPLUS_4L,SURPLUS_5L,SURPLUS_LS')->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', [':USER_ID'=>$userId, ':PERIOD_NUM'=>$periodNum])->asArray()->one();
+        if(!$result){
+            $result = [
+                'USER_ID' => $userId,
+                'SURPLUS_1L' => 0,
+                'SURPLUS_2L' => 0,
+                'SURPLUS_3L' => 0,
+                'SURPLUS_4L' => 0,
+                'SURPLUS_5L' => 0,
+                'SURPLUS_LS' => 0,
+            ];
+        }
+
+        return $result;
+    }
+}

+ 155 - 0
common/models/PeriodPrepare.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace common\models;
+
+use common\helpers\Date;
+use common\helpers\Tool;
+use Yii;
+use yii\db\Exception;
+
+/**
+ * This is the model class for table "{{%PERIOD_PREPARE}}".
+ *
+ * @property string $ID
+ * @property int $PERIOD_NUM 期数
+ * @property int $CALC_MONTH 所在结算月
+ * @property int $CALC_YEAR 所在结算年
+ * @property int $START_TIME 期数开始时间戳
+ * @property int $END_TIME 期数结束时间戳
+ * @property int $IS_MONTH 是否结算月节点
+ * @property int $IS_YEAR 是否结算年节点
+ * @property int $IS_CLOSED 是否已封期
+ * @property int $IS_PERFED 是否已生成业绩单
+ * @property int $IS_CALCULATED 是否已结算
+ * @property int $IS_SENT 是否已发放
+ * @property int $IS_PERFING 是否正在生成业绩单
+ * @property int $IS_CALCING 是否正在计算状态
+ * @property int $IS_SENDING 是否正在挂网状态
+ * @property int $CALC_PERCENT 结算进度
+ * @property int $SENT_PERCENT 发放进度
+ * @property string $PERF_ADMIN_ID 生成业绩单管理员
+ * @property string $CLOSE_ADMIN_ID 手动封期管理员ID
+ * @property string $CALC_ADMIN_ID 结算管理员ID
+ * @property string $SENT_ADMIN_ID 发放管理员ID
+ * @property int $CLOSED_AT 发放管理员ID
+ * @property int $PERF_STARTED_AT 生成业绩单开始时间
+ * @property int $PERFED_AT 生成业绩单结束时间
+ * @property int $CALCULATE_STARTED_AT 结算开始时间
+ * @property int $CALCULATED_AT 结算完成时间
+ * @property int $SEND_STARTED_AT 发放开始时间
+ * @property int $SENT_AT 发放完成时间
+ * @property int $CREATED_AT 创建时间
+ */
+class PeriodPrepare extends \common\components\ActiveRecord
+{
+    const CALCULATE_NONE = 0;
+    const CALCULATE_FINISH = 1;
+    const CALCULATE_FAIL = 2;
+
+    const SEND_NONE = 0;
+    const SEND_FINISH = 1;
+    const SEND_FAIL = 2;
+
+    const PERF_NONE = 0;
+    const PERF_FINISH = 1;
+    const PERF_FAIL = 2;
+
+    const SYSTEM_START_PERIOD_NUM = 100;
+
+    public $nowPeriodArr = null;
+    public $periodNum = null;
+    public $periodArr = null;
+
+    public function init()
+    {
+        parent::init();
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%PERIOD_PREPARE}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['PERIOD_NUM', 'CALC_MONTH', 'CALC_YEAR', 'START_TIME', 'END_TIME', 'CREATED_AT'], 'required'],
+            [['PERIOD_NUM', 'CALC_MONTH', 'CALC_YEAR', 'START_TIME', 'END_TIME', 'IS_MONTH', 'IS_YEAR', 'IS_CLOSED', 'IS_PERFED', 'IS_CALCULATED', 'IS_SENT', 'IS_PERFING', 'IS_CALCING', 'IS_SENDING', 'CALC_PERCENT', 'SENT_PERCENT', 'CLOSED_AT', 'PERF_STARTED_AT', 'PERFED_AT', 'CALCULATE_STARTED_AT', 'CALCULATED_AT', 'SEND_STARTED_AT', 'SENT_AT', 'CREATED_AT'], 'integer'],
+            [['ID', 'PERF_ADMIN_ID', 'CLOSE_ADMIN_ID', 'CALC_ADMIN_ID', 'SENT_ADMIN_ID'], 'string', 'max' => 32],
+            [['PERIOD_NUM'], 'unique'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'PERIOD_NUM' => '期数',
+            'CALC_MONTH' => '所在结算月',
+            'CALC_YEAR' => '所在结算年',
+            'START_TIME' => '期数开始时间戳',
+            'END_TIME' => '期数结束时间戳',
+            'IS_MONTH' => '是否结算月节点',
+            'IS_YEAR' => '是否结算年节点',
+            'IS_CLOSED' => '是否已封期',
+            'IS_PERFED' => '是否已生成业绩单',
+            'IS_CALCULATED' => '是否已结算',
+            'IS_SENT' => '是否已发放',
+            'IS_PERFING' => '是否正在生成业绩单',
+            'IS_CALCING' => '是否正在计算状态',
+            'IS_SENDING' => '是否正在挂网状态',
+            'CALC_PERCENT' => '结算进度',
+            'SENT_PERCENT' => '发放进度',
+            'PERF_ADMIN_ID' => '生成业绩单管理员',
+            'CLOSE_ADMIN_ID' => '手动封期管理员ID',
+            'CALC_ADMIN_ID' => '结算管理员ID',
+            'SENT_ADMIN_ID' => '发放管理员ID',
+            'CLOSED_AT' => '发放管理员ID',
+            'PERF_STARTED_AT' => '生成业绩单开始时间',
+            'PERFED_AT' => '生成业绩单结束时间',
+            'CALCULATE_STARTED_AT' => '结算开始时间',
+            'CALCULATED_AT' => '结算完成时间',
+            'SEND_STARTED_AT' => '发放开始时间',
+            'SENT_AT' => '发放完成时间',
+            'CREATED_AT' => '创建时间',
+        ];
+    }
+
+    // 获取此业绩是否已计算完成,只有计算完成,计算完成才给用户展示
+    public static function isPerfed($periodNum) {
+        $result = PeriodPrepare::findUseSlaves()
+        ->where(
+            'PERIOD_NUM=:PERIOD_NUM ', [':PERIOD_NUM' => $periodNum]
+        )
+        ->asArray()
+        ->one();
+
+        if (isset($result['IS_PERFED']) && $result['IS_PERFED'] == 1) {
+            return true;
+        }
+
+        return false;
+    }
+
+    // 根据业绩期获取数据信息
+    public static function getInfo($periodNum) {
+        $result = PeriodPrepare::findUseSlaves()
+        ->where(
+            'PERIOD_NUM=:PERIOD_NUM ', [':PERIOD_NUM' => $periodNum]
+        )
+        ->asArray()
+        ->one();
+
+        return $result;
+    }
+}

+ 175 - 175
common/models/ShopGoods.php

@@ -1,175 +1,175 @@
-<?php
-
-namespace common\models;
-
-/**
- * This is the model class for table "{{%SHOP_GOODS}}".
- *
- * @property string $ID
- * @property string $GOODS_NAME 商品名称
- * @property string $CATE_ID 所属分类ID
- * @property string $TYPE 商品来源
- * @property string $GIFT_TYPE 商品类型
- * @property string $SELL_TYPE 允许购买方式
- * @property int $GOODS_NO 商品编号
- * @property string $UNIT 单位
- * @property string $COVER 商品封面
- * @property int $IMAGES 商品图片
- * @property string $CONTENT 商品内容
- * @property string $SELL_PRICE 销售价格
- * @property string $MARKET_PRICE 市场价格
- * @property int $PRICE_PV 价格PV
- * @property int $POINT 兑换积分
- * @property int $STORE_NUMS 库存
- * @property int $IS_DEL 是否删除
- * @property int $CREATED_AT 创建时间
- * @property int $UPDATED_AT 更新时间
- * @property int $DELETED_AT 删除时间
- * @property int $STATUS 状态
- * @property string $SORT 排序
- */
-class ShopGoods extends \common\components\ActiveRecord
-{
-    const SALE_TYPE = [
-        1 => [
-            'name' => '余额购买',
-        ],
-        2 => [
-            'name' => '复消兑换',
-        ],
-        3 => [
-            'name' => '积分兑换'
-        ]
-    ];
-    const GOODS_TYPE = [
-        1 =>[
-            'name'=>'国内商品',
-            'discount'=>'50',
-        ],
-        2 =>[
-            'name'=>'进口商品',
-            'discount'=>'60',
-        ],
-    ];
-    const GIFT_TYPE = [
-        1 =>[
-            'name'=>'报单区',
-        ],
-        2 =>[
-            'name'=>'复消区',
-        ],
-        3 =>[
-            'name'=>'工作室报单',
-        ],
-        4 =>[
-            'name'=>'工作室复消',
-        ],
-    ];
-    const STATUS_NAME = [
-        1 => '已上架',
-        0 => '已下架',
-    ];
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%SHOP_GOODS}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['SELL_DISCOUNT','GOODS_NAME', 'CATE_ID','GIFT_TYPE', 'GOODS_NO', 'SELL_PRICE','MARKET_PRICE','PRICE_PV','STORE_NUMS'], 'required'],
-            [['STORE_NUMS'], 'integer'],
-            [['SELL_PRICE','MARKET_PRICE','PRICE_PV','POINT'], 'number'],
-            [['ID','CATE_ID', 'GOODS_NO','SELL_TYPE','GIFT_TYPE'], 'string', 'max' => 32],
-            [['UNIT'], 'string', 'max' => 16],
-            [['COVER', 'GOODS_NAME'], 'string', 'max' => 255],
-            [['IMAGES','CONTENT'], 'string', 'max' => 4000],
-            [['GOODS_NAME'], 'unique'],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'GOODS_NAME' => '商品名称',
-            'CATE_ID' => '所属分类ID',
-            // 'TYPE' => '商品来源',
-            'SELL_DISCOUNT' => '会员折扣',
-            'GIFT_TYPE' => '商品类型',
-            'SELL_TYPE' => '出售方式',
-            'GOODS_NO' => '商品编号',
-            'UNIT' => '商品单位',
-            'COVER' => '商品封面',
-            'IMAGES' => '商品图片',
-            'CONTENT' => '商品内容',
-            'SELL_PRICE' => '销售价格',
-            'MARKET_PRICE' => '市场价格',
-            'PRICE_PV' => '价格PV',
-            'POINT' => '兑换积分',
-            'STORE_NUMS' => '库存',
-            'STATUS' => '是否上架',
-            'IS_DEL' => '是否删除',
-            'CREATED_AT' => '创建时间',
-            'UPDATED_AT' => '更新时间',
-            'DELETED_AT' => '更新时间',
-            'SORT' => '排序',
-        ];
-    }
-
-    /**
-     * 判断提现状态
-     * @param $nowStatus
-     * @param $toStatus
-     * @return string
-     */
-    public static function chkAuditStatus($nowStatus, $toStatus) {
-        $statusName = self::STATUS_NAME;
-        $msg = '当前商品状态为【' . $statusName[$nowStatus] . '】,无法设置为【' . $statusName[$toStatus] . '】';
-        switch ($toStatus) {
-            // 下架
-            case 0:
-                if ($nowStatus == 1) {
-                    $msg = '';
-                }
-                break;
-            //上架
-            case 1:
-                if ($nowStatus == 0) {
-                    $msg = '';
-                }
-                break;
-            default:
-        }
-        return $msg;
-    }
-
-    /**
-     * 支付方式
-     * @return array
-     */
-    public static function payTypes(){
-        return [
-            'cash'=>[
-                'name'=>'余额支付'
-            ],
-            'point'=>[
-                'name'=>'积分支付'
-            ],
-            'exchange' => [
-                'name' => '无业绩兑换券'
-            ]
-        ];
-    }
-
-}
+<?php
+
+namespace common\models;
+
+/**
+ * This is the model class for table "{{%SHOP_GOODS}}".
+ *
+ * @property string $ID
+ * @property string $GOODS_NAME 商品名称
+ * @property string $CATE_ID 所属分类ID
+ * @property string $TYPE 商品来源
+ * @property string $GIFT_TYPE 商品类型
+ * @property string $SELL_TYPE 允许购买方式
+ * @property int $GOODS_NO 商品编号
+ * @property string $UNIT 单位
+ * @property string $COVER 商品封面
+ * @property int $IMAGES 商品图片
+ * @property string $CONTENT 商品内容
+ * @property string $SELL_PRICE 销售价格
+ * @property string $MARKET_PRICE 市场价格
+ * @property int $PRICE_PV 价格PV
+ * @property int $POINT 兑换积分
+ * @property int $STORE_NUMS 库存
+ * @property int $IS_DEL 是否删除
+ * @property int $CREATED_AT 创建时间
+ * @property int $UPDATED_AT 更新时间
+ * @property int $DELETED_AT 删除时间
+ * @property int $STATUS 状态
+ * @property string $SORT 排序
+ */
+class ShopGoods extends \common\components\ActiveRecord
+{
+    const SALE_TYPE = [
+        1 => [
+            'name' => '余额购买',
+        ],
+        2 => [
+            'name' => '复消兑换',
+        ],
+        3 => [
+            'name' => '积分兑换'
+        ]
+    ];
+    const GOODS_TYPE = [
+        1 =>[
+            'name'=>'国内商品',
+            'discount'=>'50',
+        ],
+        2 =>[
+            'name'=>'进口商品',
+            'discount'=>'60',
+        ],
+    ];
+    const GIFT_TYPE = [
+        1 =>[
+            'name'=>'报单区',
+        ],
+        2 =>[
+            'name'=>'复消区',
+        ],
+        3 =>[
+            'name'=>'工作室报单',
+        ],
+        4 =>[
+            'name'=>'工作室复消',
+        ],
+    ];
+    const STATUS_NAME = [
+        1 => '已上架',
+        0 => '已下架',
+    ];
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%SHOP_GOODS}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['SELL_DISCOUNT','GOODS_NAME', 'CATE_ID','GIFT_TYPE', 'GOODS_NO', 'SELL_PRICE','MARKET_PRICE','PRICE_PV','STORE_NUMS'], 'required'],
+            [['STORE_NUMS'], 'integer'],
+            [['SELL_PRICE','MARKET_PRICE','PRICE_PV','POINT'], 'number'],
+            [['ID','CATE_ID', 'GOODS_NO','SELL_TYPE','GIFT_TYPE'], 'string', 'max' => 32],
+            [['UNIT'], 'string', 'max' => 16],
+            [['COVER', 'GOODS_NAME'], 'string', 'max' => 255],
+            [['IMAGES','CONTENT'], 'string', 'max' => 4000],
+            [['GOODS_NAME'], 'unique'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'GOODS_NAME' => '商品名称',
+            'CATE_ID' => '所属分类ID',
+            // 'TYPE' => '商品来源',
+            'SELL_DISCOUNT' => '会员折扣',
+            'GIFT_TYPE' => '商品类型',
+            'SELL_TYPE' => '出售方式',
+            'GOODS_NO' => '商品编号',
+            'UNIT' => '商品单位',
+            'COVER' => '商品封面',
+            'IMAGES' => '商品图片',
+            'CONTENT' => '商品内容',
+            'SELL_PRICE' => '销售价格',
+            'MARKET_PRICE' => '市场价格',
+            'PRICE_PV' => '价格PV',
+            'POINT' => '兑换点数',
+            'STORE_NUMS' => '库存',
+            'STATUS' => '是否上架',
+            'IS_DEL' => '是否删除',
+            'CREATED_AT' => '创建时间',
+            'UPDATED_AT' => '更新时间',
+            'DELETED_AT' => '更新时间',
+            'SORT' => '排序',
+        ];
+    }
+
+    /**
+     * 判断提现状态
+     * @param $nowStatus
+     * @param $toStatus
+     * @return string
+     */
+    public static function chkAuditStatus($nowStatus, $toStatus) {
+        $statusName = self::STATUS_NAME;
+        $msg = '当前商品状态为【' . $statusName[$nowStatus] . '】,无法设置为【' . $statusName[$toStatus] . '】';
+        switch ($toStatus) {
+            // 下架
+            case 0:
+                if ($nowStatus == 1) {
+                    $msg = '';
+                }
+                break;
+            //上架
+            case 1:
+                if ($nowStatus == 0) {
+                    $msg = '';
+                }
+                break;
+            default:
+        }
+        return $msg;
+    }
+
+    /**
+     * 支付方式
+     * @return array
+     */
+    public static function payTypes(){
+        return [
+            'cash'=>[
+                'name'=>'余额支付'
+            ],
+            'point'=>[
+                'name'=>'积分支付'
+            ],
+            'exchange' => [
+                'name' => '无业绩兑换点数'
+            ]
+        ];
+    }
+
+}

+ 1 - 0
common/models/Transfer.php

@@ -37,6 +37,7 @@ class Transfer extends \common\components\ActiveRecord
     const WALLET_NAME = [
         'bonus'=>'奖金',
         'cash'=>'余额',
+        'point'=>'复消积分'
     ];
 
     /**

+ 3 - 2
common/models/UserNetwork.php

@@ -454,10 +454,11 @@ class UserNetwork extends \common\components\ActiveRecord
     /**
      * 从缓存中获取会员的全部父级(主要用于结算时的处理,能够提高效率不去查库)
      * @param $userId
+     * @param $isPrepare 是否是预计计算 true为是 则使用预计计算的缓存key
      * @return array|mixed
      */
-    public static function getAllParentsFromRedis($userId){
-        $key = Cache::USER_NETWORK_PARENTS;
+    public static function getAllParentsFromRedis($userId,$isPrepare=false){
+        $key = $isPrepare === true ? Cache::PREPARE_USER_NETWORK_PARENTS : Cache::USER_NETWORK_PARENTS;
         $data = Yii::$app->redis->hget($key, $userId);
         if(!$data){
             $data = [];

+ 59 - 59
common/models/UserPeriodExchangePoints.php

@@ -1,59 +1,59 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%USER_PERIOD_POINTS}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property int $PERIOD_NUM 报单期数
- * @property string $EXCHANGE_POINTS 兑换积分
- * @property string $REMAINDER_POINTS 剩余积分
- * @property int EXPIRED 是否过期
- * @property int EXPIRED_PERIOD 过期期数
- * @property int EXPIRED_AT 过期时间
- * @property int $CREATED_AT 创建时间
- */
-class UserPeriodExchangePoints extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%USER_PERIOD_EXCHANGE_POINTS}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CREATED_AT'], 'required'],
-            [['PERIOD_NUM', 'CREATED_AT', 'EXPIRED', 'EXPIRED_PERIOD', 'EXPIRED_AT'], 'integer'],
-            [['EXCHANGE_POINTS', 'REMAINDER_POINTS'], 'number'],
-            [['ID', 'USER_ID'], 'string', 'max' => 32],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'EXCHANGE_POINTS' => '兑换积分',
-            'REMAINDER_POINTS' => '剩余积分',
-            'EXPIRED' => '是否过期',
-            'EXPIRED_PERIOD' => '过期期数',
-            'EXPIRED_AT' => '过期时间',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%USER_PERIOD_POINTS}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 会员ID
+ * @property int $PERIOD_NUM 报单期数
+ * @property string $EXCHANGE_POINTS 兑换点数
+ * @property string $REMAINDER_POINTS 剩余点数
+ * @property int EXPIRED 是否过期
+ * @property int EXPIRED_PERIOD 过期期数
+ * @property int EXPIRED_AT 过期时间
+ * @property int $CREATED_AT 创建时间
+ */
+class UserPeriodExchangePoints extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%USER_PERIOD_EXCHANGE_POINTS}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'PERIOD_NUM', 'CREATED_AT'], 'required'],
+            [['PERIOD_NUM', 'CREATED_AT', 'EXPIRED', 'EXPIRED_PERIOD', 'EXPIRED_AT'], 'integer'],
+            [['EXCHANGE_POINTS', 'REMAINDER_POINTS'], 'number'],
+            [['ID', 'USER_ID'], 'string', 'max' => 32],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'USER_ID' => '会员ID',
+            'EXCHANGE_POINTS' => '兑换点数',
+            'REMAINDER_POINTS' => '剩余点数',
+            'EXPIRED' => '是否过期',
+            'EXPIRED_PERIOD' => '过期期数',
+            'EXPIRED_AT' => '过期时间',
+            'CREATED_AT' => '创建时间',
+        ];
+    }
+}

+ 3 - 2
common/models/UserRelation.php

@@ -346,10 +346,11 @@ class UserRelation extends \common\components\ActiveRecord
     /**
      * 从缓存中获取会员的全部父级(主要用于结算时的处理,能够提高效率不去查库)
      * @param $userId
+     * @param $isPrepare 是否是预计计算 true为是 则使用预计计算的缓存key
      * @return array|mixed
      */
-    public static function getAllParentsFromRedis($userId){
-        $key = Cache::USER_RELATION_PARENTS;
+    public static function getAllParentsFromRedis($userId, $isPrepare = false){
+        $key = $isPrepare === true ? Cache::PREPARE_USER_RELATION_PARENTS : Cache::USER_RELATION_PARENTS;
         $data = Yii::$app->redis->hget($key, $userId);
         if(!$data){
             $data = [];

+ 610 - 610
common/models/forms/OrderForm.php

@@ -1,610 +1,610 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\user\Balance;
-use common\helpers\user\Cash;
-use common\helpers\user\Info;
-use common\libs\logging\operate\AdminOperate;
-use common\models\DealType;
-use common\models\Order;
-use common\models\OrderGoods;
-use common\models\Period;
-use common\models\ReceiveAddress;
-use common\models\Region;
-use common\models\ShopGoods;
-use common\models\User;
-use common\models\UserNetwork;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class OrderForm extends Model
-{
-    public $sn;
-    public $expressCompany;
-    public $orderTrackNo;
-    public $status;
-    public $remark;
-
-    public $type;
-    public $addressId;
-    public $payType;
-    public $goodsId;
-    public $goodsNum;
-    public $payPassword;
-
-    public $userName;
-    public $consignee;
-    public $acceptMobile;
-    public $province;
-    public $city;
-    public $county;
-    public $detailaddress;
-
-    private $_address;
-    private $_decAmount;
-    private $_decPv;
-    private $_freight;
-    private $_payAmount;
-    private $_orderGoods;
-
-    /**
-     * @var Order
-     */
-    private $_model;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => Order::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province','city','county','detailaddress'], 'trim'],
-            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province','city','county','detailaddress'], 'required'],
-            [['status'], 'isStatus'],
-            [['addressId'], 'isAddress'],
-            [['payType'], 'isPayType'],
-            [['payPassword'], 'validatePassword'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'sn' => '订单号',
-            'expressCompany' => '快递公司',
-            'orderTrackNo' => '快递单号',
-            'status' => '状态',
-            'remark' => '备注',
-            'type' => '订单类型',
-            'addressId' => '收货地址',
-            'payType' => '支付方式',
-            'goodsId' => '商品ID',
-            'goodsNum' => '商品数量',
-            'userName' => '复消会员编号',
-            'consignee' => '收货人',
-            'acceptMobile' => '收货电话',
-            'province' => '省',
-            'city' => '市',
-            'county' => '区',
-            'detailaddress' => '收货详细地址',
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            // 管理员发货
-            'adminDelivery' => ['sn', 'expressCompany', 'orderTrackNo'],
-            // 会员确认收货
-            'userConfirm' => ['sn', 'expressCompany', 'orderTrackNo'],
-            // 管理员修改订单状态
-            'adminStatus' => ['sn', 'status'],
-            // 管理员修改备注
-            'adminRemark' => ['sn', 'remark'],
-            // 会员下单
-            'userOrder' => ['type','addressId', 'payType','goodsId','goodsNum', 'remark', 'payPassword'],
-            // 帮会员复消下单
-            'reconsumeOrder' => ['type','userName', 'payType','goodsId','goodsNum', 'remark', 'payPassword','consignee','acceptMobile','province','city','county','detailaddress'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 校验之前
-     * @return bool
-     */
-    public function beforeValidate()
-    {
-        $parentValidate = parent::beforeValidate();
-        if ($this->sn) {
-            $this->_model = Order::findOne(['SN'=>$this->sn]);
-            if (!$this->_model){
-                $this->addError('sn', '订单不存在');
-                return false;
-            }
-        }
-        if ($this->scenario == 'adminDelivery'){
-            if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['cancel']) {
-                $this->addError('sn', '订单已取消不能发货');
-                return false;
-            }
-            if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['del']) {
-                $this->addError('sn', '订单已删除不能发货');
-                return false;
-            }
-        }
-
-        return $parentValidate;
-    }
-
-    /**
-     * 校验支付密码
-     * @param $attribute
-     * @param $params
-     */
-    public function validatePassword($attribute, $params) {
-        if (!User::validatePayPassword(\Yii::$app->user->id, $this->payPassword)) {
-            $this->addError($attribute, '支付密码不正确');
-        }
-    }
-
-    /**
-     * 判断收货地址是否存在
-     * @param $attribute
-     */
-    public function isAddress($attribute){
-        if (!$receiveAddress = ReceiveAddress::find()->where(' ID=:ID', [':ID' => $this->addressId])->asArray()->one()) {
-            $this->addError($attribute, '收货地址不存在');
-        } else {
-            $this->_address = $receiveAddress;
-        }
-    }
-
-    /**
-     * 判断支付方式
-     * @param $attribute
-     */
-    public function isPayType($attribute){
-        if(!array_key_exists($this->payType, ShopGoods::payTypes())){
-            $this->addError($attribute, '支付方式错误');
-            return;
-        }
-    }
-
-    /**
-     * 校验类型
-     * @param $attribute
-     */
-    public function isStatus($attribute){
-        if(!in_array($this->type, \Yii::$app->params['orderStatus'])){
-            $this->addError($attribute, '类型错误');
-            return ;
-        }
-        if ($this->scenario == 'adminStatus'){
-            if ($this->status == $this->_model['STATUS']) {
-                $this->addError($attribute, '订单状态没有改变');
-                return ;
-            }
-            if($this->status == \Yii::$app->params['orderStatus']['notPaid'] && $this->_model['STATUS'] >= \Yii::$app->params['orderStatus']['delivery']) {
-                $this->addError($attribute, '订单已经进入物流状态不能改为未支付');
-                return ;
-            }
-            elseif($this->status == \Yii::$app->params['orderStatus']['paid'] && $this->_model['STATUS'] >= \Yii::$app->params['orderStatus']['cancel']) {
-                $this->addError($attribute, '订单已失效不能处理');
-                return ;
-            }
-            elseif($this->status == \Yii::$app->params['orderStatus']['delivery']) {
-                $this->addError($attribute, '订单不能单独处理为物流状态');
-                return ;
-            }
-            elseif($this->status == \Yii::$app->params['orderStatus']['complete'] && $this->_model['STATUS'] > \Yii::$app->params['orderStatus']['cancel']) {
-                $this->addError($attribute, '订单已失效不能处理');
-                return ;
-            }
-            elseif($this->status == \Yii::$app->params['orderStatus']['cancel']) {
-                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['complete']) {
-                    $this->addError($attribute, '订单已完成不能取消');
-                    return ;
-                }
-                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['del']) {
-                    $this->addError($attribute, '订单已删除不能取消');
-                    return ;
-                }
-            }
-            elseif($this->status == \Yii::$app->params['orderStatus']['del']) {
-                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['complete']) {
-                    $this->addError($attribute, '订单已完成不能删除');
-                    return ;
-                }
-            }
-        }
-
-    }
-
-    /**
-     * 管理员发货
-     * @return Order|null
-     * @throws \yii\db\Exception
-     */
-    public function adminDelivery(){
-        if(!$this->validate()){
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $period = Period::instance();
-            $this->_model->DELIVERY_STATUS = \Yii::$app->params['deliveryStatus']['delivered']['value'];
-            $this->_model->DELIVERY_PERIOD = $period->getNowPeriodNum();
-            $this->_model->DELIVERY_AT = Date::nowTime();
-            $this->_model->EXPRESS_COMPANY = $this->expressCompany;
-            $this->_model->ORDER_TRACK_NO = $this->orderTrackNo;
-            $this->_model->STATUS = \Yii::$app->params['orderStatus']['delivery']['value'];
-            if(!$this->_model->save()){
-                throw new Exception(Form::formatErrorsForApi($this->_model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        return $this->_model;
-    }
-
-    /**
-     * 复销
-     * @return bool|null
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    public function add(){
-        if(!$this->validate()){
-            return null;
-        }
-        $ids = $this->goodsId;
-        $totalAmount = 0;
-        $totalPv = 0;
-        $goodsType = ShopGoods::GOODS_TYPE;
-        foreach ($this->goodsNum as $k => $v) {
-            if ($v) {
-                $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
-                if($goods['STORE_NUMS']>0){
-                    if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
-                        $discount = $goodsType[$goods['TYPE']]['discount'];
-                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
-                        $realPv = $goods['PRICE_PV'] * $discount/100;
-                    } else {
-                        $discount = $goods['SELL_DISCOUNT'];
-                        $realPrice = $goods['SELL_PRICE'] * $discount;
-                        $realPv = $goods['PRICE_PV'] * $discount;
-                    }
-                    $totalAmount += $realPrice * intval($v);
-                    $totalPv += $realPv * intval($v);
-//                    if($this->payType=='cash') {
-//                        $discount = $goodsType[$goods['TYPE']]['discount'];
-//                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
-//                        $realPv = $goods['PRICE_PV'] * $discount/100;
-//                        $totalAmount += $realPrice * intval($v);
-//                        $totalPv += $realPv * intval($v);
-//                    }else{
-//                        $realPrice = $goods['SELL_PRICE'];
-//                        $realPv = $goods['PRICE_PV'];
-//                        $totalAmount += $realPrice * intval($v);
-//                        $totalPv += $realPv * intval($v);
-//                    }
-                    $this->_orderGoods[] = [
-                        'GOODS_ID' => $goods['ID'],
-                        'PRICE' => $goods['SELL_PRICE'],
-                        'PV' => $goods['PRICE_PV'],
-                        'REAL_PRICE' => $realPrice,
-                        'REAL_PV' => $realPv,
-                        'POINT' => $goods['POINT'],
-                        'BUY_NUMS' => intval($v),
-                        'SKU_CODE' => $goods['GOODS_NO'],
-                        'GOODS_TITLE' => $goods['GOODS_NAME']
-                    ];
-                }
-            }
-        }
-        $this->_decAmount = $totalAmount;
-        $this->_decPv = $totalPv;
-        $this->_freight = ($totalAmount>=300) ? 0 : 15;
-        $this->_payAmount = $this->_decAmount + $this->_freight;
-
-
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            //判断用户余额是否充足
-            $loginUserId = \Yii::$app->user->id;
-            if($this->payType=='cash') {
-                if (Cash::getAvailableBalance($loginUserId) < $this->_payAmount) {
-                    throw new Exception('余额不足,无法购买商品');
-                }
-            } else if ($this->payType =='exchange') {
-                if ($this->_payAmount > Balance::getBalanceExchangePoints($loginUserId)) {
-                    throw new Exception('兑换积分不足,无法购买商品');
-                }
-            } else{
-                if ($this->_payAmount > Balance::getBalanceReconsumePoints($loginUserId)) {
-                    throw new Exception('复消积分不足,无法购买商品');
-                }
-            }
-            //写入订单
-            if (!$orderResult = $this->addOrder()) {
-                throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
-            }
-            $transaction->commit();
-        }catch (\Exception $e){
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-        return true;
-    }
-
-    /**
-     * 复销订单
-     */
-    public function addOrder(){
-        $periodObj = Period::instance();
-        $nowPeriodNum = $periodObj->getNowPeriodNum();
-        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
-
-        $userId = \Yii::$app->user->id;
-        $userName = Info::getUserNameByUserId($userId);
-
-        // 加入订单信息
-        $warehouse = Region::getWarehouseByCode($this->_address['PROVINCE']);//仓库
-        if(!$warehouse){
-            throw new Exception('地区暂时不支持配送,具体联系客服');
-        }
-        $ordNo = $this->_generateSn();
-        $orderModel = new Order();
-        $orderModel->SN = 'OS'.$ordNo;
-        $orderModel->DEC_SN = 'DS'.$ordNo;
-        $orderModel->ORDER_TYPE = $this->type;
-        $orderModel->USER_ID = $userId;
-        $orderModel->USER_NAME = $userName;
-        $orderModel->ORDER_AMOUNT = $this->_decAmount;
-        $orderModel->PV = $this->payType =='exchange' ? 0 : $this->_decPv;
-        $orderModel->PAY_AMOUNT = $this->_payAmount;
-        $orderModel->PAY_PV = $this->payType =='exchange' ? 0 : $this->_decPv; // 兑换积分不能算业绩
-        $orderModel->PAY_AT = Date::nowTime();
-        $orderModel->PAY_TYPE = $this->payType;
-        $orderModel->PERIOD_NUM = $nowPeriodNum;
-        $orderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
-        $orderModel->FREIGHT = $this->_freight;
-        $orderModel->PAY_FREIGHT = $this->_freight;
-        $orderModel->CONSIGNEE = $this->_address['CONSIGNEE'];
-        $orderModel->MOBILE = $this->_address['MOBILE'];
-        $orderModel->PROVINCE = $this->_address['PROVINCE'];
-        $orderModel->CITY = $this->_address['CITY'];
-        $orderModel->COUNTY = $this->_address['COUNTY'];
-        $orderModel->ADDRESS = $this->_address['ADDRESS'];
-        $orderModel->FRONT_REMARK = $this->remark;
-        $orderModel->WAREHOUSE = $warehouse;
-        $orderModel->STATUS = 1;
-        $orderModel->CREATED_AT = Date::nowTime();
-        $orderModel->CREATE_USER = $userName;
-        if(!$orderModel->save()){
-            $this->addErrors($orderModel->getErrors());
-            return false;
-        }
-        // 加入商品到订单商品表
-        foreach($this->_orderGoods as $key=>$value){
-            // 增加判断,如果订单是兑换券购买,则AR_ORDER_GOODS中的REAL_PV真实PV应该是0
-            if ($orderModel->PAY_TYPE == 'exchange') {
-                $this->_orderGoods[$key]['REAL_PV'] = 0;
-            }
-            $this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
-            $this->_orderGoods[$key]['P_CALC_MONTH'] = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
-        }
-        OrderGoods::batchInsert($this->_orderGoods);
-
-        //扣除会员余额/积分
-        if($this->payType=='cash') {
-            Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_payAmount), ['REMARK' => '会员复销余额支付']);
-        } else if ($this->payType=='exchange') {
-            Balance::changeUserBonus(\Yii::$app->user->id,'exchange_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::EXCHANGE_POINTS_EXCHANGE,'REMARK' => '会员兑换积分兑换']);
-        } else{
-            Balance::changeUserBonus(\Yii::$app->user->id,'reconsume_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::RECONSUME_POINTS_EXCHANGE,'REMARK' => '会员复销积分兑换']);
-        }
-        return $orderModel;
-    }
-
-    /**
-     * 帮会员复销
-     * @return bool|null
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    public function reconsumeAdd(){
-        if(!$this->validate()){
-            return null;
-        }
-        $ids = $this->goodsId;
-        $totalAmount = 0;
-        $totalPv = 0;
-        $goodsType = ShopGoods::GOODS_TYPE;
-        foreach ($this->goodsNum as $k => $v) {
-            if ($v) {
-                $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
-                if($goods['STORE_NUMS']>0){
-                    if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
-                        $discount = $goodsType[$goods['TYPE']]['discount'];
-                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
-                        $realPv = $goods['PRICE_PV'] * $discount/100;
-                    } else {
-                        $discount = $goods['SELL_DISCOUNT'];
-                        $realPrice = $goods['SELL_PRICE'] * $discount;
-                        $realPv = $goods['PRICE_PV'] * $discount;
-                    }
-                    $totalAmount += $realPrice * intval($v);
-                    $totalPv += $realPv * intval($v);
-                    $this->_orderGoods[] = [
-                        'GOODS_ID' => $goods['ID'],
-                        'PRICE' => $goods['SELL_PRICE'],
-                        'PV' => $goods['PRICE_PV'],
-                        'REAL_PRICE' => $realPrice,
-                        'REAL_PV' => $realPv,
-                        'POINT' => $goods['POINT'],
-                        'BUY_NUMS' => intval($v),
-                        'SKU_CODE' => $goods['GOODS_NO'],
-                        'GOODS_TITLE' => $goods['GOODS_NAME']
-                    ];
-                }
-            }
-        }
-        $this->_decAmount = $totalAmount;
-        $this->_decPv = $totalPv;
-        $this->_freight = ($totalAmount>=300) ? 0 : 15;
-        $this->_payAmount = $this->_decAmount + $this->_freight;
-
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $loginUserId = \Yii::$app->user->id;
-
-            //是否开启伞下会员限制
-            $isResaleUmbrella = Cache::getSystemConfig()['isResaleUmbrella']['VALUE'];
-            if($isResaleUmbrella){
-                $userId = Info::getUserIdByUserName($this->userName);
-                $userNetwork = UserNetwork::find()->where("USER_ID=:USER_ID AND INSTR(PARENT_UIDS,'{$loginUserId}')>0", ['USER_ID'=>$userId])->count();
-                if(!$userNetwork){
-                    throw new Exception($this->userName.'不是您的伞下会员,不能为其复消!');
-                }
-            }
-            //判断用户余额是否充足
-            if($this->payType=='cash') {
-                if (Cash::getAvailableBalance($loginUserId) < $this->_payAmount) {
-                    throw new Exception('余额不足,无法购买商品');
-                }
-            }else{
-                if ($this->_payAmount > Balance::getBalanceReconsumePoints($loginUserId)) {
-                    throw new Exception('复消积分不足,无法购买商品');
-                }
-            }
-            //写入订单
-            if (!$orderResult = $this->addUserOrder()) {
-                throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
-            }
-            $transaction->commit();
-        }catch (\Exception $e){
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-        return true;
-    }
-
-    /**
-     * 帮会员复消的订单
-     */
-    public function addUserOrder(){
-        $periodObj = Period::instance();
-        $nowPeriodNum = $periodObj->getNowPeriodNum();
-        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
-        //帮复消会员Id(登陆会员)
-        $loginUserId = \Yii::$app->user->id;
-        $loginUserName = Info::getUserNameByUserId($loginUserId);
-        //订单会员Id
-        $userId = Info::getUserIdByUserName($this->userName);
-
-        // 加入订单信息
-        $warehouse = Region::getWarehouseByCode($this->province);//仓库
-        if(!$warehouse){
-            throw new Exception('地区暂时不支持配送,具体联系客服');
-        }
-        $ordNo = $this->_generateSn();
-        $orderModel = new Order();
-        $orderModel->SN = 'OS'.$ordNo;
-        $orderModel->DEC_SN = 'DS'.$ordNo;
-        $orderModel->ORDER_TYPE = $this->type;
-        $orderModel->USER_ID = $userId;
-        $orderModel->USER_NAME = $this->userName;
-        $orderModel->ORDER_AMOUNT = $this->_decAmount;
-        $orderModel->PV = $this->_decPv;
-        $orderModel->PAY_AMOUNT = $this->_payAmount;
-        $orderModel->PAY_PV = $this->_decPv;
-        $orderModel->PAY_AT = Date::nowTime();
-        $orderModel->PAY_TYPE = $this->payType;
-        $orderModel->PERIOD_NUM = $nowPeriodNum;
-        $orderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
-        $orderModel->FREIGHT = $this->_freight;
-        $orderModel->PAY_FREIGHT = $this->_freight;
-        $orderModel->CONSIGNEE = $this->consignee;
-        $orderModel->MOBILE = $this->acceptMobile;
-        $orderModel->PROVINCE = $this->province;
-        $orderModel->CITY = $this->city;
-        $orderModel->COUNTY = $this->county;
-        $orderModel->ADDRESS = $this->detailaddress;
-        $orderModel->FRONT_REMARK = $this->remark;
-        $orderModel->WAREHOUSE = $warehouse;
-        $orderModel->STATUS = 1;
-        $orderModel->CREATED_AT = Date::nowTime();
-        $orderModel->CREATE_USER = $loginUserName;
-        if(!$orderModel->save()){
-            $this->addErrors($orderModel->getErrors());
-            return false;
-        }
-        // 加入商品到订单商品表
-        foreach($this->_orderGoods as $key=>$value){
-            $this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
-            $this->_orderGoods[$key]['P_CALC_MONTH'] = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
-        }
-        OrderGoods::batchInsert($this->_orderGoods);
-
-        //扣除会员余额/积分
-        if($this->payType=='cash') {
-            Cash::changeUserCash($loginUserId, 'CASH', -abs($this->_payAmount), ['REMARK' => '会员复销余额支付']);
-        }else{
-            Balance::changeUserBonus($loginUserId,'reconsume_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::RECONSUME_POINTS_EXCHANGE, 'REMARK' => '会员复销积分兑换']);
-        }
-        return $orderModel;
-    }
-
-    /**
-     * 生成流水号
-     * @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;
-    }
-}
+<?php
+namespace common\models\forms;
+
+use common\helpers\Cache;
+use common\helpers\Date;
+use common\components\Model;
+use common\helpers\Form;
+use common\helpers\user\Balance;
+use common\helpers\user\Cash;
+use common\helpers\user\Info;
+use common\libs\logging\operate\AdminOperate;
+use common\models\DealType;
+use common\models\Order;
+use common\models\OrderGoods;
+use common\models\Period;
+use common\models\ReceiveAddress;
+use common\models\Region;
+use common\models\ShopGoods;
+use common\models\User;
+use common\models\UserNetwork;
+use yii\base\Exception;
+
+/**
+ * Login form
+ */
+class OrderForm extends Model
+{
+    public $sn;
+    public $expressCompany;
+    public $orderTrackNo;
+    public $status;
+    public $remark;
+
+    public $type;
+    public $addressId;
+    public $payType;
+    public $goodsId;
+    public $goodsNum;
+    public $payPassword;
+
+    public $userName;
+    public $consignee;
+    public $acceptMobile;
+    public $province;
+    public $city;
+    public $county;
+    public $detailaddress;
+
+    private $_address;
+    private $_decAmount;
+    private $_decPv;
+    private $_freight;
+    private $_payAmount;
+    private $_orderGoods;
+
+    /**
+     * @var Order
+     */
+    private $_model;
+
+    public function init() {
+        parent::init();
+        $this->adminOperateLogger = new AdminOperate([
+            'fetchClass' => Order::class,
+        ]);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province','city','county','detailaddress'], 'trim'],
+            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province','city','county','detailaddress'], 'required'],
+            [['status'], 'isStatus'],
+            [['addressId'], 'isAddress'],
+            [['payType'], 'isPayType'],
+            [['payPassword'], 'validatePassword'],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'sn' => '订单号',
+            'expressCompany' => '快递公司',
+            'orderTrackNo' => '快递单号',
+            'status' => '状态',
+            'remark' => '备注',
+            'type' => '订单类型',
+            'addressId' => '收货地址',
+            'payType' => '支付方式',
+            'goodsId' => '商品ID',
+            'goodsNum' => '商品数量',
+            'userName' => '复消会员编号',
+            'consignee' => '收货人',
+            'acceptMobile' => '收货电话',
+            'province' => '省',
+            'city' => '市',
+            'county' => '区',
+            'detailaddress' => '收货详细地址',
+        ];
+    }
+
+    /**
+     * 指定校验场景
+     * @return array
+     */
+    public function scenarios()
+    {
+        $parentScenarios =  parent::scenarios();
+        $customScenarios = [
+            // 管理员发货
+            'adminDelivery' => ['sn', 'expressCompany', 'orderTrackNo'],
+            // 会员确认收货
+            'userConfirm' => ['sn', 'expressCompany', 'orderTrackNo'],
+            // 管理员修改订单状态
+            'adminStatus' => ['sn', 'status'],
+            // 管理员修改备注
+            'adminRemark' => ['sn', 'remark'],
+            // 会员下单
+            'userOrder' => ['type','addressId', 'payType','goodsId','goodsNum', 'remark', 'payPassword'],
+            // 帮会员复消下单
+            'reconsumeOrder' => ['type','userName', 'payType','goodsId','goodsNum', 'remark', 'payPassword','consignee','acceptMobile','province','city','county','detailaddress'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    /**
+     * 校验之前
+     * @return bool
+     */
+    public function beforeValidate()
+    {
+        $parentValidate = parent::beforeValidate();
+        if ($this->sn) {
+            $this->_model = Order::findOne(['SN'=>$this->sn]);
+            if (!$this->_model){
+                $this->addError('sn', '订单不存在');
+                return false;
+            }
+        }
+        if ($this->scenario == 'adminDelivery'){
+            if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['cancel']) {
+                $this->addError('sn', '订单已取消不能发货');
+                return false;
+            }
+            if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['del']) {
+                $this->addError('sn', '订单已删除不能发货');
+                return false;
+            }
+        }
+
+        return $parentValidate;
+    }
+
+    /**
+     * 校验支付密码
+     * @param $attribute
+     * @param $params
+     */
+    public function validatePassword($attribute, $params) {
+        if (!User::validatePayPassword(\Yii::$app->user->id, $this->payPassword)) {
+            $this->addError($attribute, '支付密码不正确');
+        }
+    }
+
+    /**
+     * 判断收货地址是否存在
+     * @param $attribute
+     */
+    public function isAddress($attribute){
+        if (!$receiveAddress = ReceiveAddress::find()->where(' ID=:ID', [':ID' => $this->addressId])->asArray()->one()) {
+            $this->addError($attribute, '收货地址不存在');
+        } else {
+            $this->_address = $receiveAddress;
+        }
+    }
+
+    /**
+     * 判断支付方式
+     * @param $attribute
+     */
+    public function isPayType($attribute){
+        if(!array_key_exists($this->payType, ShopGoods::payTypes())){
+            $this->addError($attribute, '支付方式错误');
+            return;
+        }
+    }
+
+    /**
+     * 校验类型
+     * @param $attribute
+     */
+    public function isStatus($attribute){
+        if(!in_array($this->type, \Yii::$app->params['orderStatus'])){
+            $this->addError($attribute, '类型错误');
+            return ;
+        }
+        if ($this->scenario == 'adminStatus'){
+            if ($this->status == $this->_model['STATUS']) {
+                $this->addError($attribute, '订单状态没有改变');
+                return ;
+            }
+            if($this->status == \Yii::$app->params['orderStatus']['notPaid'] && $this->_model['STATUS'] >= \Yii::$app->params['orderStatus']['delivery']) {
+                $this->addError($attribute, '订单已经进入物流状态不能改为未支付');
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['paid'] && $this->_model['STATUS'] >= \Yii::$app->params['orderStatus']['cancel']) {
+                $this->addError($attribute, '订单已失效不能处理');
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['delivery']) {
+                $this->addError($attribute, '订单不能单独处理为物流状态');
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['complete'] && $this->_model['STATUS'] > \Yii::$app->params['orderStatus']['cancel']) {
+                $this->addError($attribute, '订单已失效不能处理');
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['cancel']) {
+                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['complete']) {
+                    $this->addError($attribute, '订单已完成不能取消');
+                    return ;
+                }
+                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['del']) {
+                    $this->addError($attribute, '订单已删除不能取消');
+                    return ;
+                }
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['del']) {
+                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['complete']) {
+                    $this->addError($attribute, '订单已完成不能删除');
+                    return ;
+                }
+            }
+        }
+
+    }
+
+    /**
+     * 管理员发货
+     * @return Order|null
+     * @throws \yii\db\Exception
+     */
+    public function adminDelivery(){
+        if(!$this->validate()){
+            return null;
+        }
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            $period = Period::instance();
+            $this->_model->DELIVERY_STATUS = \Yii::$app->params['deliveryStatus']['delivered']['value'];
+            $this->_model->DELIVERY_PERIOD = $period->getNowPeriodNum();
+            $this->_model->DELIVERY_AT = Date::nowTime();
+            $this->_model->EXPRESS_COMPANY = $this->expressCompany;
+            $this->_model->ORDER_TRACK_NO = $this->orderTrackNo;
+            $this->_model->STATUS = \Yii::$app->params['orderStatus']['delivery']['value'];
+            if(!$this->_model->save()){
+                throw new Exception(Form::formatErrorsForApi($this->_model->getErrors()));
+            }
+            $transaction->commit();
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            $this->addError('edit', $e->getMessage());
+            return null;
+        }
+        return $this->_model;
+    }
+
+    /**
+     * 复销
+     * @return bool|null
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public function add(){
+        if(!$this->validate()){
+            return null;
+        }
+        $ids = $this->goodsId;
+        $totalAmount = 0;
+        $totalPv = 0;
+        $goodsType = ShopGoods::GOODS_TYPE;
+        foreach ($this->goodsNum as $k => $v) {
+            if ($v) {
+                $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                if($goods['STORE_NUMS']>0){
+                    if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
+                        $discount = $goodsType[$goods['TYPE']]['discount'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
+                        $realPv = $goods['PRICE_PV'] * $discount/100;
+                    } else {
+                        $discount = $goods['SELL_DISCOUNT'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount;
+                        $realPv = $goods['PRICE_PV'] * $discount;
+                    }
+                    $totalAmount += $realPrice * intval($v);
+                    $totalPv += $realPv * intval($v);
+//                    if($this->payType=='cash') {
+//                        $discount = $goodsType[$goods['TYPE']]['discount'];
+//                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
+//                        $realPv = $goods['PRICE_PV'] * $discount/100;
+//                        $totalAmount += $realPrice * intval($v);
+//                        $totalPv += $realPv * intval($v);
+//                    }else{
+//                        $realPrice = $goods['SELL_PRICE'];
+//                        $realPv = $goods['PRICE_PV'];
+//                        $totalAmount += $realPrice * intval($v);
+//                        $totalPv += $realPv * intval($v);
+//                    }
+                    $this->_orderGoods[] = [
+                        'GOODS_ID' => $goods['ID'],
+                        'PRICE' => $goods['SELL_PRICE'],
+                        'PV' => $goods['PRICE_PV'],
+                        'REAL_PRICE' => $realPrice,
+                        'REAL_PV' => $realPv,
+                        'POINT' => $goods['POINT'],
+                        'BUY_NUMS' => intval($v),
+                        'SKU_CODE' => $goods['GOODS_NO'],
+                        'GOODS_TITLE' => $goods['GOODS_NAME']
+                    ];
+                }
+            }
+        }
+        $this->_decAmount = $totalAmount;
+        $this->_decPv = $totalPv;
+        $this->_freight = ($totalAmount>=300) ? 0 : 15;
+        $this->_payAmount = $this->_decAmount + $this->_freight;
+
+
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            //判断用户余额是否充足
+            $loginUserId = \Yii::$app->user->id;
+            if($this->payType=='cash') {
+                if (Cash::getAvailableBalance($loginUserId) < $this->_payAmount) {
+                    throw new Exception('余额不足,无法购买商品');
+                }
+            } else if ($this->payType =='exchange') {
+                if ($this->_payAmount > Balance::getBalanceExchangePoints($loginUserId)) {
+                    throw new Exception('兑换点数不足,无法购买商品');
+                }
+            } else{
+                if ($this->_payAmount > Balance::getBalanceReconsumePoints($loginUserId)) {
+                    throw new Exception('复消积分不足,无法购买商品');
+                }
+            }
+            //写入订单
+            if (!$orderResult = $this->addOrder()) {
+                throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
+            }
+            $transaction->commit();
+        }catch (\Exception $e){
+            $transaction->rollBack();
+            $this->addError('add', $e->getMessage());
+            return null;
+        }
+        return true;
+    }
+
+    /**
+     * 复销订单
+     */
+    public function addOrder(){
+        $periodObj = Period::instance();
+        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
+
+        $userId = \Yii::$app->user->id;
+        $userName = Info::getUserNameByUserId($userId);
+
+        // 加入订单信息
+        $warehouse = Region::getWarehouseByCode($this->_address['PROVINCE']);//仓库
+        if(!$warehouse){
+            throw new Exception('地区暂时不支持配送,具体联系客服');
+        }
+        $ordNo = $this->_generateSn();
+        $orderModel = new Order();
+        $orderModel->SN = 'OS'.$ordNo;
+        $orderModel->DEC_SN = 'DS'.$ordNo;
+        $orderModel->ORDER_TYPE = $this->type;
+        $orderModel->USER_ID = $userId;
+        $orderModel->USER_NAME = $userName;
+        $orderModel->ORDER_AMOUNT = $this->_decAmount;
+        $orderModel->PV = $this->payType =='exchange' ? 0 : $this->_decPv;
+        $orderModel->PAY_AMOUNT = $this->_payAmount;
+        $orderModel->PAY_PV = $this->payType =='exchange' ? 0 : $this->_decPv; // 兑换积分不能算业绩
+        $orderModel->PAY_AT = Date::nowTime();
+        $orderModel->PAY_TYPE = $this->payType;
+        $orderModel->PERIOD_NUM = $nowPeriodNum;
+        $orderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        $orderModel->FREIGHT = $this->_freight;
+        $orderModel->PAY_FREIGHT = $this->_freight;
+        $orderModel->CONSIGNEE = $this->_address['CONSIGNEE'];
+        $orderModel->MOBILE = $this->_address['MOBILE'];
+        $orderModel->PROVINCE = $this->_address['PROVINCE'];
+        $orderModel->CITY = $this->_address['CITY'];
+        $orderModel->COUNTY = $this->_address['COUNTY'];
+        $orderModel->ADDRESS = $this->_address['ADDRESS'];
+        $orderModel->FRONT_REMARK = $this->remark;
+        $orderModel->WAREHOUSE = $warehouse;
+        $orderModel->STATUS = 1;
+        $orderModel->CREATED_AT = Date::nowTime();
+        $orderModel->CREATE_USER = $userName;
+        if(!$orderModel->save()){
+            $this->addErrors($orderModel->getErrors());
+            return false;
+        }
+        // 加入商品到订单商品表
+        foreach($this->_orderGoods as $key=>$value){
+            // 增加判断,如果订单是兑换券购买,则AR_ORDER_GOODS中的REAL_PV真实PV应该是0
+            if ($orderModel->PAY_TYPE == 'exchange') {
+                $this->_orderGoods[$key]['REAL_PV'] = 0;
+            }
+            $this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
+            $this->_orderGoods[$key]['P_CALC_MONTH'] = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        }
+        OrderGoods::batchInsert($this->_orderGoods);
+
+        //扣除会员余额/积分
+        if($this->payType=='cash') {
+            Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_payAmount), ['REMARK' => '会员复销余额支付']);
+        } else if ($this->payType=='exchange') {
+            Balance::changeUserBonus(\Yii::$app->user->id,'exchange_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::EXCHANGE_POINTS_EXCHANGE,'REMARK' => '会员兑换积分兑换']);
+        } else{
+            Balance::changeUserBonus(\Yii::$app->user->id,'reconsume_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::RECONSUME_POINTS_EXCHANGE,'REMARK' => '会员复销积分兑换']);
+        }
+        return $orderModel;
+    }
+
+    /**
+     * 帮会员复销
+     * @return bool|null
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public function reconsumeAdd(){
+        if(!$this->validate()){
+            return null;
+        }
+        $ids = $this->goodsId;
+        $totalAmount = 0;
+        $totalPv = 0;
+        $goodsType = ShopGoods::GOODS_TYPE;
+        foreach ($this->goodsNum as $k => $v) {
+            if ($v) {
+                $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                if($goods['STORE_NUMS']>0){
+                    if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
+                        $discount = $goodsType[$goods['TYPE']]['discount'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
+                        $realPv = $goods['PRICE_PV'] * $discount/100;
+                    } else {
+                        $discount = $goods['SELL_DISCOUNT'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount;
+                        $realPv = $goods['PRICE_PV'] * $discount;
+                    }
+                    $totalAmount += $realPrice * intval($v);
+                    $totalPv += $realPv * intval($v);
+                    $this->_orderGoods[] = [
+                        'GOODS_ID' => $goods['ID'],
+                        'PRICE' => $goods['SELL_PRICE'],
+                        'PV' => $goods['PRICE_PV'],
+                        'REAL_PRICE' => $realPrice,
+                        'REAL_PV' => $realPv,
+                        'POINT' => $goods['POINT'],
+                        'BUY_NUMS' => intval($v),
+                        'SKU_CODE' => $goods['GOODS_NO'],
+                        'GOODS_TITLE' => $goods['GOODS_NAME']
+                    ];
+                }
+            }
+        }
+        $this->_decAmount = $totalAmount;
+        $this->_decPv = $totalPv;
+        $this->_freight = ($totalAmount>=300) ? 0 : 15;
+        $this->_payAmount = $this->_decAmount + $this->_freight;
+
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            $loginUserId = \Yii::$app->user->id;
+
+            //是否开启伞下会员限制
+            $isResaleUmbrella = Cache::getSystemConfig()['isResaleUmbrella']['VALUE'];
+            if($isResaleUmbrella){
+                $userId = Info::getUserIdByUserName($this->userName);
+                $userNetwork = UserNetwork::find()->where("USER_ID=:USER_ID AND INSTR(PARENT_UIDS,'{$loginUserId}')>0", ['USER_ID'=>$userId])->count();
+                if(!$userNetwork){
+                    throw new Exception($this->userName.'不是您的伞下会员,不能为其复消!');
+                }
+            }
+            //判断用户余额是否充足
+            if($this->payType=='cash') {
+                if (Cash::getAvailableBalance($loginUserId) < $this->_payAmount) {
+                    throw new Exception('余额不足,无法购买商品');
+                }
+            }else{
+                if ($this->_payAmount > Balance::getBalanceReconsumePoints($loginUserId)) {
+                    throw new Exception('复消积分不足,无法购买商品');
+                }
+            }
+            //写入订单
+            if (!$orderResult = $this->addUserOrder()) {
+                throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
+            }
+            $transaction->commit();
+        }catch (\Exception $e){
+            $transaction->rollBack();
+            $this->addError('add', $e->getMessage());
+            return null;
+        }
+        return true;
+    }
+
+    /**
+     * 帮会员复消的订单
+     */
+    public function addUserOrder(){
+        $periodObj = Period::instance();
+        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
+        //帮复消会员Id(登陆会员)
+        $loginUserId = \Yii::$app->user->id;
+        $loginUserName = Info::getUserNameByUserId($loginUserId);
+        //订单会员Id
+        $userId = Info::getUserIdByUserName($this->userName);
+
+        // 加入订单信息
+        $warehouse = Region::getWarehouseByCode($this->province);//仓库
+        if(!$warehouse){
+            throw new Exception('地区暂时不支持配送,具体联系客服');
+        }
+        $ordNo = $this->_generateSn();
+        $orderModel = new Order();
+        $orderModel->SN = 'OS'.$ordNo;
+        $orderModel->DEC_SN = 'DS'.$ordNo;
+        $orderModel->ORDER_TYPE = $this->type;
+        $orderModel->USER_ID = $userId;
+        $orderModel->USER_NAME = $this->userName;
+        $orderModel->ORDER_AMOUNT = $this->_decAmount;
+        $orderModel->PV = $this->_decPv;
+        $orderModel->PAY_AMOUNT = $this->_payAmount;
+        $orderModel->PAY_PV = $this->_decPv;
+        $orderModel->PAY_AT = Date::nowTime();
+        $orderModel->PAY_TYPE = $this->payType;
+        $orderModel->PERIOD_NUM = $nowPeriodNum;
+        $orderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        $orderModel->FREIGHT = $this->_freight;
+        $orderModel->PAY_FREIGHT = $this->_freight;
+        $orderModel->CONSIGNEE = $this->consignee;
+        $orderModel->MOBILE = $this->acceptMobile;
+        $orderModel->PROVINCE = $this->province;
+        $orderModel->CITY = $this->city;
+        $orderModel->COUNTY = $this->county;
+        $orderModel->ADDRESS = $this->detailaddress;
+        $orderModel->FRONT_REMARK = $this->remark;
+        $orderModel->WAREHOUSE = $warehouse;
+        $orderModel->STATUS = 1;
+        $orderModel->CREATED_AT = Date::nowTime();
+        $orderModel->CREATE_USER = $loginUserName;
+        if(!$orderModel->save()){
+            $this->addErrors($orderModel->getErrors());
+            return false;
+        }
+        // 加入商品到订单商品表
+        foreach($this->_orderGoods as $key=>$value){
+            $this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
+            $this->_orderGoods[$key]['P_CALC_MONTH'] = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        }
+        OrderGoods::batchInsert($this->_orderGoods);
+
+        //扣除会员余额/积分
+        if($this->payType=='cash') {
+            Cash::changeUserCash($loginUserId, 'CASH', -abs($this->_payAmount), ['REMARK' => '会员复销余额支付']);
+        }else{
+            Balance::changeUserBonus($loginUserId,'reconsume_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::RECONSUME_POINTS_EXCHANGE, 'REMARK' => '会员复销积分兑换']);
+        }
+        return $orderModel;
+    }
+
+    /**
+     * 生成流水号
+     * @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;
+    }
+}

+ 121 - 0
common/models/forms/PreparePeriodForm.php

@@ -0,0 +1,121 @@
+<?php
+namespace common\models\forms;
+
+use common\helpers\bonus\BonusCalc;
+use common\helpers\bonus\BonusSend;
+use common\helpers\bonus\PerfCalc;
+use common\helpers\Cache;
+use common\helpers\Date;
+use common\components\Model;
+use common\helpers\bonus\PreparePerfCalc;
+use common\helpers\Form;
+use common\models\Period;
+use common\models\PeriodPrepare;
+use common\models\UserWallet;
+use common\models\User;
+use common\models\UserStatusAudit;
+use common\models\Withdraw;
+use yii\base\Exception;
+
+/**
+ * Login form
+ */
+class PreparePeriodForm extends Model
+{
+    public $periodNum;
+
+    private $_periodModel;
+    private $_limit = 1000;
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['periodNum'], 'trim'],
+            [['periodNum'], 'required'],
+            [['periodNum'], 'integer'],
+            [['periodNum'], 'isPeriod'],
+        ];
+    }
+
+    public function scenarios()
+    {
+        $parentScenarios =  parent::scenarios();
+        $customScenarios = [
+            'close' => ['periodNum'],
+            'perf' => ['periodNum'],
+            'calc' => ['periodNum'],
+            'send' => ['periodNum'],
+            'autoClose' => ['periodNum'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'periodNum' => '期数',
+        ];
+    }
+
+    public function isPeriod($attributes){
+        $periodModel = PeriodPrepare::findOne(['PERIOD_NUM' => $this->periodNum]);
+        if(!$periodModel){
+            $this->addError($attributes, '所传期数不存在');
+        }
+
+        $this->_periodModel = $periodModel;
+    }
+
+    /**
+     * 页面请求异步处理生成业绩单
+     * @return string | null
+     */
+    public function perfWebToAsync(){
+        if(!$this->validate()){
+            return null;
+        }
+        $model = $this->_periodModel;
+        $model->IS_PERFING = 1;
+        $model->PERF_ADMIN_ID = \Yii::$app->user->id;
+        if(!$model->save()){
+            $this->addError('perf', Form::formatErrorsForApi($model->getErrors()));
+            return null;
+        }
+        // 异步处理添加任务
+        $settings = \Yii::$app->params['swooleAsyncTimer'];
+        $bonusSettings = \Yii::$app->params['swooleBonusConfig'];
+        $settings = array_merge($settings, $bonusSettings);
+        $taskKey = \Yii::$app->swooleAsyncTimer->asyncHandle('bonus/prepare-perf', \Yii::$app->request->get(), $settings);
+        if($taskKey === false){
+            $this->addError('perf', '请求失败');
+            return null;
+        }
+        return $model;
+    }
+
+    /**
+     * 异步处理逻辑
+     * @param $handleUserId
+     * @return bool|null
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public function perfAsync($handleUserId,$periodNum){
+        if(!$this->validate()){
+            return null;
+        }
+        $bonusCalc = PreparePerfCalc::instance();
+        $periodNum = $periodNum ? $periodNum : $this->periodNum;
+        $asyncResult = $bonusCalc->calcStep($periodNum, $handleUserId);
+        if($asyncResult){
+            $bonusCalc->endCalcTask();
+        } else {
+            $bonusCalc->errorCalcTask();
+            $this->addErrors($bonusCalc->getErrors());
+        }
+        return $asyncResult;
+    }
+}

+ 29 - 3
common/models/forms/TransferForm.php

@@ -33,10 +33,11 @@ use yii\helpers\Json;
  * Login form
  */
 class TransferForm extends Model {
-    const allowTransferType = [1, 2, 3];
+    const allowTransferType = [1, 2, 3, 4];
     const BONUS_TO_BALANCE = 1;
     const BONUS_TO_BONUS = 2;
     const BALANCE_TO_BALANCE = 3;
+    const POINT_TO_BALANCE = 4;
 
     public $toUserName;
     public $toRealName;
@@ -206,7 +207,9 @@ class TransferForm extends Model {
         // 获取当前用户的可用金额
         if( $this->type == self::BALANCE_TO_BALANCE ) {
             $haveBalance = Cash::getAvailableBalance($this->_fromUserInfo['ID']);
-        }else {
+        }else if ($this->type == self::POINT_TO_BALANCE) {
+            $haveBalance = Balance::getBalanceReconsumePoints($this->_fromUserInfo['ID']);
+        } else {
             $haveBalance = Balance::getAvailableBalance($this->_fromUserInfo['ID']);
         }
         if ($this->amount > $haveBalance) {
@@ -347,7 +350,30 @@ class TransferForm extends Model {
                 // 会员金额减少
                 Cash::changeUserCash($this->_fromUserInfo['ID'], 'CASH', -abs($this->amount), ['TRANSFER_SN' => $model->TRANSFER_SN,'DEAL_TYPE_ID' => DealType::TRANSFER_OUT, 'REMARK' => 'To:' . $this->_toUserInfo['USER_NAME'] . ',' . $this->remark]);
                 Cash::changeUserCash($this->_toUserInfo['ID'], 'CASH', abs($amount), ['TRANSFER_SN' => $model->TRANSFER_SN,'DEAL_TYPE_ID' => DealType::TRANSFER_IN, 'REMARK' => 'From:' . $this->_fromUserInfo['USER_NAME'] . ',' . $this->remark]);
-            }else {
+            } else if ($this->type == self::POINT_TO_BALANCE) {
+                // 复消积分转余额
+                // 减少复消积分
+                Balance::changeUserBonus(
+                    $this->_fromUserInfo['ID'], 
+                    'reconsume_points', 
+                    -abs($this->amount), 
+                    [
+                        'TRANSFER_SN' => $model->TRANSFER_SN, 
+                        'DEAL_TYPE_ID' => DealType::TRANSFER_OUT, 
+                        'REMARK' => 'To:' . $this->_toUserInfo['USER_NAME'] . ',' . $this->remark
+                    ]
+                );
+                // 增加余额
+                Cash::changeUserCash(
+                    $this->_toUserInfo['ID'], 
+                    'CASH', abs($amount), 
+                    [
+                        'TRANSFER_SN' => $model->TRANSFER_SN,
+                        'DEAL_TYPE_ID' => DealType::TRANSFER_IN, 
+                        'REMARK' => 'From:' . $this->_fromUserInfo['USER_NAME'] . ',' . $this->remark
+                    ]
+                );
+            } else {
                 throw new \Exception('错误的交易类型');
             }
 

+ 2 - 1
common/models/forms/WithdrawForm.php

@@ -381,7 +381,8 @@ class WithdrawForm extends Model {
             $this->addError('add', '完善身份信息后才可以提现');
             return -1;
         }
-
+        return 0; 
+        // 暂时不进行身份证号接口校验了,先直接返回正常
         $response = LingYunGongApi::hasIdCardInfo($user['ID_CARD']);
         if( !$response ) {
             $this->addError('add', '接口网络错误');

+ 25 - 2
console/controllers/BonusController.php

@@ -53,6 +53,7 @@ use common\helpers\http\RemoteUploadApi;
 use common\helpers\Log;
 use common\libs\export\module\BonusExport;
 use common\models\forms\PeriodForm;
+use common\models\forms\PreparePeriodForm;
 use common\models\LogAsync;
 use common\models\Withdraw;
 use yii\db\Exception;
@@ -60,6 +61,28 @@ use yii\db\Exception;
 class BonusController extends BaseController
 {
 
+    /**
+     * 预计计算生成月业绩,如果是月节点的话
+     * @param $taskKey
+     * @throws Exception
+     * @throws \yii\base\Exception
+     */
+    public function actionPreparePerf($taskKey){
+        $params = Cache::getAsyncParams($taskKey);
+        $formModel = new PreparePeriodForm();
+        $handleResult = false;
+        $periodNum = isset($params['periodNum']) && !empty($params['periodNum']) ? $params['periodNum'] : null;
+        if($formModel->load($params, '') && $formModel->perfAsync($params['handleUserId'],$periodNum)){
+            $handleResult = true;
+            \Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($params['handleUserId'], "预计算月业绩第{$params['periodNum']}期生成业绩单更新成功");
+        } else {
+            \Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($params['handleUserId'], "预计算月业绩第{$params['periodNum']}期生成业绩单更新失败,原因:".Form::formatErrorsForApi($formModel->getErrors()), false);
+        }
+        if(!$handleResult){
+            echo "预计算月业绩,第{$params['periodNum']}期生成业绩单更新失败,原因:".Form::formatErrorsForApi($formModel->getErrors());
+        }
+    }
+
     /**
      * 生成业绩单并计算业绩
      * @param $taskKey
@@ -231,12 +254,12 @@ class BonusController extends BaseController
     }
 
     /**
-     * 兑换积分流水导出
+     * 兑换点数流水导出
      * @param $taskId
      * @return bool
      */
     public function actionFlowExchangeExport($taskId){
-        return $this->_export($taskId, FlowExchangePointsList::class, '兑换积分流水列表');
+        return $this->_export($taskId, FlowExchangePointsList::class, '兑换点数流水列表');
     }
 
     /**

+ 1 - 0
frontendApi/config/menu.php

@@ -73,6 +73,7 @@ return [
         'show'=>1,
         'child'=>[
             ['name'=>'我的账户', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'index', 'routePath'=>'bonus/index', 'show'=>1,],
+            ['name'=>'团队查询', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'teams', 'routePath'=>'bonus/teams', 'show'=>1,],
             ['name'=>'最新奖金', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'new', 'routePath'=>'bonus/new', 'show'=>1,'allow'=>'newBonusSwitch'],
             ['name'=>'往期奖金', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'other', 'routePath'=>'bonus/other', 'show'=>1,'allow'=>'pastBonusSwitch'],
             //['name'=>'实时业绩', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'real-time-perf', 'routePath'=>'bonus/real-time-perf', 'show'=>1,],

+ 1 - 0
frontendApi/config/urlManagerRules.php

@@ -113,6 +113,7 @@ return [
             'GET index' => 'index',
             'GET wallet-flow' => 'wallet-flow',
             'GET new' => 'new',
+            'GET teams' => 'teams',
             'GET other' => 'other',
             'GET real-time-perf' => 'real-time-perf',
             'GET flow-bt' => 'flow-bt',

+ 107 - 4
frontendApi/modules/v1/controllers/BonusController.php

@@ -29,10 +29,14 @@ use common\models\Period;
 use common\models\DecRole;
 use common\models\EmployLevel;
 use common\models\FlowExchangePoints;
+use common\models\PerfMonthPrepare;
+use common\models\PeriodPrepare;
 use common\models\ScoreMonth;
 use common\models\UserBonus;
+use common\models\UserRelation;
 use common\models\UserWallet;
 use frontendApi\modules\v1\models\User;
+use Yii;
 
 class BonusController extends BaseController {
     public $modelClass = CalcBonus::class;
@@ -69,7 +73,7 @@ class BonusController extends BaseController {
         $wallet[] = ['walletType' => 'bonus', 'walletName' => '会员奖金', 'amount' => Tool::formatPrice($data['BONUS'])];
         $wallet[] = ['walletType' => 'cash', 'walletName' => '会员余额', 'amount' => Tool::formatPrice($data['CASH'])];
         $wallet[] = ['walletType' => 'point', 'walletName' => '会员积分', 'amount' => Tool::formatPrice($data['RECONSUME_POINTS'])];
-        $wallet[] = ['walletType' => 'exchange', 'walletName' => '兑换积分', 'amount' => Tool::formatPrice($data['EXCHANGE_POINTS'])];
+        $wallet[] = ['walletType' => 'exchange', 'walletName' => '兑换点数', 'amount' => Tool::formatPrice($data['EXCHANGE_POINTS'])];
 //        if ($showCFLX) {
 //            $wallet[] = ['walletType' => 'cf', 'walletName' => '福利积分一', 'amount' => Tool::formatPrice($data['CF'])];
 //            $wallet[] = ['walletType' => 'lx', 'walletName' => '福利积分二', 'amount' => Tool::formatPrice($data['LX'])];
@@ -94,6 +98,105 @@ class BonusController extends BaseController {
         return static::notice(['wallet' => $wallet,'dealSwitch'=>$dealSwitch]);
     }
 
+    /**
+     * 团队查询
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionTeams() {
+        $userId = \Yii::$app->user->id;
+        $period = Period::instance();
+        $periodNum = $period->getNowPeriodNum();
+        $month = $period->getNowYearMonth();
+        // 判断是否是周日,并且是否是月结节点
+        // 特殊要求,测试环境要去掉是否是周日的判断,周一至周日都能看.正式环境只有周日能看
+        // 读取加入到忽略文件的common/config/config.php文件内容
+        $preparePerfLimit = isset(Yii::$app->params['preparePerfLimit']) ? Yii::$app->params['preparePerfLimit'] : false;
+        $isCalcMonth = $period->isCalcMonth($periodNum);
+        $w = date('w', time());
+        //特殊要求,测试环境要去掉是否是周日的判断,周一至周日都能看
+        if($preparePerfLimit === true && $isCalcMonth != 1) {
+            return static::notice(['user' => [],'team'=>[]]);
+        } else if ($preparePerfLimit !== true && ($w != '0' || $isCalcMonth != 1)) {
+            return static::notice(['user' => [],'team'=>[]]);
+        }
+        // 判断此业绩期是否已经完成生成了预计算业绩单,生成完毕才能看到
+        $isPerfed = PeriodPrepare::isPerfed($periodNum);
+        if (!$isPerfed) {
+            return static::notice(['user' => [],'team'=>[]]);
+        }
+        
+        // 获取最新的计算时间
+        $calcAt = PeriodPrepare::getInfo($periodNum);
+        $calcAt = date('Y-m-d H:i:s', $calcAt['PERF_STARTED_AT']);
+
+        // 达标规则,小组底下有一个大于等于一万.或者个人情况里的合计大于等于一万
+        $data = PerfMonthPrepare::getMonthPerfPrepare($userId, $month);
+        // PV_PCS 个人业绩  PV_PSS 月新增团队业绩  PV_PSS_TOTAL月累计团队业绩
+        // 其中页面使用的是月新增团队业绩
+        // 获取用信息
+        $userInfo = User::getEnCodeInfo($userId);
+        $user[0] = [
+            'number' => $userInfo['USER_NAME'],
+            'name' => $userInfo['REAL_NAME'],
+            'perf_status' => '0', // 0  未达标  1为已达标
+            'perf_status_name' => '不达标',
+            'user_perf' => 0, // 个人业绩
+            'team_perf' => 0, // 团队新增累计业绩
+            'total_perf' => 0 // 合计业绩
+        ];
+        if (!empty($data)) {
+            // 调整个人合格了,依旧不显示业绩
+            $userCheck = PerfMonthPrepare::checkPrepareStatus($data['PV_PCS']+$data['PV_PSS']);
+            $user[0]['user_perf'] = $userCheck ? '' : Tool::formatPreparePerf($data['PV_PCS']);
+            $user[0]['team_perf'] = $userCheck ? '' : Tool::formatPreparePerf($data['PV_PSS']);
+            $user[0]['total_perf'] = $userCheck ? '' : Tool::formatPreparePerf($data['PV_PCS']+$data['PV_PSS']);
+            $user[0]['perf_status'] = $userCheck ? '1' : $user[0]['perf_status'];
+            $user[0]['perf_status_name'] = $userCheck ? '达标' : $user[0]['perf_status_name'];
+        }
+        $teamInfo = [];
+        // 查询此用户的推荐(开拓)团队一级信息
+        $relation = UserRelation::getChildrenWithDeepAndLayer($userId, 1, 1, $periodNum);
+        $userStatusFlag = false;
+        if ($relation) {
+            // 循环一级开拓用户
+            foreach($relation as $k=>$v) {
+                // 获取此用户预计算月业绩
+                $relationPerf = PerfMonthPrepare::getMonthPerfPrepare($v['USER_ID'], $month);
+                if (empty($relationPerf)) {
+                    $relationPerf['PV_PCS'] = 0;
+                    $relationPerf['PV_PSS'] = 0;
+                }
+                $relationCheck = PerfMonthPrepare::checkPrepareStatus($relationPerf['PV_PCS']+$relationPerf['PV_PSS']);
+                $teamInfo[]['perf_status'] = $relationCheck ? 1 : 0;
+                if ($relationCheck) {
+                    $userStatusFlag = true; // 只要有一个达标,则个人就达标
+                    $teamInfo[$k]['number'] = '';
+                    $teamInfo[$k]['name'] = '';
+                    $teamInfo[$k]['user_perf'] = '';
+                    $teamInfo[$k]['team_perf'] = '';
+                    $teamInfo[$k]['total_perf'] = '';
+                    $teamInfo[$k]['perf_status'] = '1';
+                    $teamInfo[$k]['perf_status_name'] = '达标';
+                } else {
+                    $teamInfo[$k]['number'] = $v['USER_NAME'];
+                    $teamInfo[$k]['name'] = $v['REAL_NAME'];
+                    $teamInfo[$k]['user_perf'] = Tool::formatPreparePerf($relationPerf['PV_PCS']);
+                    $teamInfo[$k]['team_perf'] = Tool::formatPreparePerf($relationPerf['PV_PSS']);
+                    $teamInfo[$k]['total_perf'] = Tool::formatPreparePerf($relationPerf['PV_PCS']+$relationPerf['PV_PSS']);
+                    $teamInfo[$k]['perf_status'] = '0';
+                    $teamInfo[$k]['perf_status_name'] = '不达标';
+                } 
+            }
+        }
+        if ($userStatusFlag === true) {
+            $user[0]['perf_status'] = 1;
+            $user[0]['perf_status_name'] = '达标';
+        }
+        
+        return static::notice(['user' => $user,'team'=>$teamInfo,'calcAt' => $calcAt]);
+    }
+
     /**
      * 交易记录
      * @return mixed
@@ -235,7 +338,7 @@ class BonusController extends BaseController {
         if($detailSwitch) {
             $data[] = ['name' => '期数', 'value' => $periodNum];
             $data[] = ['name' => '级别', 'value' => Cache::getDecLevelConfig()[$calcBonus['LAST_DEC_LV']]['LEVEL_NAME']];
-            $data[] = ['name' => '荣誉', 'value' => Cache::getEmpLevelConfig()[$calcBonus['LAST_EMP_LV']]['LEVEL_NAME']];
+            $data[] = ['name' => '最新聘级', 'value' => Cache::getEmpLevelConfig()[$calcBonus['LAST_EMP_LV']]['LEVEL_NAME']];
             if ($sysConfig['openTG']['VALUE']) {
                 // 销售奖金 就是 原来的推广奖
                 $data[] = ['name' => '销售奖金', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_TG'])];
@@ -257,7 +360,7 @@ class BonusController extends BaseController {
             $data[] = ['name' => '管理费', 'value' => Tool::formatPrice($calcBonus['MANAGE_TAX'])];
             $data[] = ['name' => '实发奖金', 'value' => Tool::formatPrice($calcBonus['BONUS_REAL'])];
             $data[] = ['name' => '复消积分', 'value' => Tool::formatPrice($calcBonus['RECONSUME_POINTS'])];
-            $data[] = ['name' => '兑换积分', 'value' => Tool::formatPrice($calcBonus['EXCHANGE_POINTS'])];
+            $data[] = ['name' => '兑换点数', 'value' => Tool::formatPrice($calcBonus['EXCHANGE_POINTS'])];
             $data[] = ['name' => '一市场新增业绩', 'value' => Tool::formatFrontPerf($calcBonus['PV_1L'])];
             $data[] = ['name' => '二市场新增业绩', 'value' => Tool::formatFrontPerf($calcBonus['PV_2L'])];
             $data[] = ['name' => '三市场新增业绩', 'value' => Tool::formatFrontPerf($calcBonus['PV_3L'])];
@@ -365,7 +468,7 @@ class BonusController extends BaseController {
                 // 总奖金
                 $calcBonus[$key]['BONUS_TOTAL'] = ['name' => '总奖金', 'value' => Tool::formatPrice($calcBonus[$key]['BONUS_TOTAL'])];
                 $calcBonus[$key]['RECONSUME_POINTS'] = ['name' => '复销积分', 'value' => Tool::formatPrice($calcBonus[$key]['RECONSUME_POINTS'])];
-                $calcBonus[$key]['EXCHANGE_POINTS'] = ['name' => '兑换积分', 'value' => Tool::formatPrice($calcBonus[$key]['EXCHANGE_POINTS'])];
+                $calcBonus[$key]['EXCHANGE_POINTS'] = ['name' => '兑换点数', 'value' => Tool::formatPrice($calcBonus[$key]['EXCHANGE_POINTS'])];
                 $calcBonus[$key]['MANAGE_TAX'] = ['name' => '管理费', 'value' => Tool::formatPrice($calcBonus[$key]['MANAGE_TAX'])];
                 $calcBonus[$key]['BONUS_REAL'] = ['name' => '实发奖金', 'value' => Tool::formatPrice($calcBonus[$key]['BONUS_REAL'])];
                 // if ($sysConfig['openYC']['VALUE']) {

+ 1 - 0
frontendApi/modules/v1/controllers/FinanceController.php

@@ -302,6 +302,7 @@ class FinanceController extends BaseController {
     public function actionAvailableBalance() {
         $data['bonus'] = Balance::getAvailableBalance(\Yii::$app->user->id);
         $data['cash'] = Cash::getAvailableBalance(\Yii::$app->user->id);
+        $data['point'] = Balance::getBalanceReconsumePoints(\Yii::$app->user->id);
         return static::notice($data);
     }
 

+ 12 - 0
frontendEle/src/router/index.js

@@ -305,6 +305,18 @@ export const constantRouterMap = [
           ],
         },
       },
+      {
+        path: '/bonus/teams',
+        component: _import('bonus/teams'),
+        name: 'bonus_teams',
+        meta: {
+          title: '团队查询',
+          breadcrumb: [
+            {title: '首页', path: '/dashboard/index'},
+            {title: '奖金管理', path: '/bonus/index'},
+          ],
+        },
+      },
 
     ]
   },

+ 2 - 1
frontendEle/src/views/bonus/index.vue

@@ -121,6 +121,7 @@
         let vueObj = this
         vueObj.loading = true
         network.getData('bonus/index').then(response => {
+          console.log(response.wallet);
           vueObj.walletData = response.wallet
           vueObj.dealSwitch = response.dealSwitch
           vueObj.loading = false
@@ -207,4 +208,4 @@
 <style>
   .dialog-footer:after{content: '';
     clear: both;display: table;}
-</style>
+</style>

+ 48 - 47
frontendEle/src/views/bonus/new.vue

@@ -1,48 +1,49 @@
-<template>
-  <div v-loading="loading">
-    <div class="bonus-list">
-      <div class="bonus-item" v-for="(item,key) in newData" :key="key">
-        <el-tooltip effect="dark" :content="item.name" placement="top-end">
-          <div>{{item.value}}</div>
-        </el-tooltip>
-      </div>
-    </div>
-  </div>
-</template>
-
-<script>
-  import network from '@/utils/network'
-  import tool from '@/utils/tool'
-
-  export default {
-    name: 'bonus_new',
-    components: {},
-    mounted() {
-      this.getData()
-    },
-    data() {
-      return {
-        loading:false,
-        newData:null
-      }
-    },
-    methods: {
-      getData() {
-        let vueObj = this
-        vueObj.loading = true
+<template>
+  <div v-loading="loading">
+    <div class="bonus-list">
+      <div class="bonus-item" v-for="(item,key) in newData" :key="key">
+        <el-tooltip effect="dark" :content="item.name" placement="top-end">
+          <div>{{item.value}}</div>
+        </el-tooltip>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+  import network from '@/utils/network'
+  import tool from '@/utils/tool'
+
+  export default {
+    name: 'bonus_new',
+    components: {},
+    mounted() {
+      this.getData()
+    },
+    data() {
+      return {
+        loading:false,
+        newData:null
+      }
+    },
+    methods: {
+      getData() {
+        let vueObj = this
+        vueObj.loading = true
         network.getData('bonus/new').then(response => {
-          vueObj.newData = response
-          vueObj.loading = false
-        }).catch(response => {
-          vueObj.loading = false
-        })
-      },
-    }
-  }
-
-</script>
-<style>
-  .bonus-list:after{content: '';clear: both;display: table;}
-  .bonus-list .bonus-item{float: left;width: 33.333%;text-align: center;background: #fff;height:36px;line-height:36px;border: 1px solid #ddd;margin: -1px 0 0 -1px;box-sizing: border-box;}
-  .bonus-list .bonus-item:hover{background: #f5f5f5;cursor: pointer;}
-</style>
+          //console.log(response);
+          vueObj.newData = response
+          vueObj.loading = false
+        }).catch(response => {
+          vueObj.loading = false
+        })
+      },
+    }
+  }
+
+</script>
+<style>
+  .bonus-list:after{content: '';clear: both;display: table;}
+  .bonus-list .bonus-item{float: left;width: 33.333%;text-align: center;background: #fff;height:36px;line-height:36px;border: 1px solid #ddd;margin: -1px 0 0 -1px;box-sizing: border-box;}
+  .bonus-list .bonus-item:hover{background: #f5f5f5;cursor: pointer;}
+</style>

+ 101 - 99
frontendEle/src/views/bonus/other.vue

@@ -1,101 +1,103 @@
-<template>
-  <div v-loading="loading">
-    <div class="white-box">
-      <el-table class="table-box other-table-box" :data="tableData" style="width: 100%;">
-        <el-table-column v-for="(item,key) in tableKey" :key="key">
-          <template slot-scope="scope">
-            <el-tooltip effect="dark" :content="scope.row[item].name" placement="top">
-            <div class="bonus-item">{{scope.row[item].value}}</div>
-            </el-tooltip>
-          </template>
-        </el-table-column>
-
-        <el-table-column >
-          <template slot-scope="scope">
-            <el-button type="primary" size="small" @click.native="showFlow(scope.row.PERIOD_NUM.value)">查看全部</el-button>
-          </template>
-        </el-table-column>
-
-      </el-table>
-    </div>
-    <el-dialog :title="`${periodNum}期奖金`" :visible.sync="dialogFlowVisible" width="80%">
-      <div class="bonus-list" v-loading="dialogLoading">
-        <div class="bonus-item" v-for="(item,key) in newData" :key="key">
-          <el-tooltip effect="dark" :content="item.name" placement="top-end">
-            <div>{{item.value}}</div>
-          </el-tooltip>
-        </div>
-      </div>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-  import network from '@/utils/network'
-  import tool from '@/utils/tool'
-
-  export default {
-    name: 'bonus_other',
-    components: {},
-    mounted() {
-      this.getData()
-    },
-    data() {
-      return {
-        allData: null,
-        tableKey: null,
-        newData: null,
-        loading: true,
-        tableData: null,
-        dialogFlowVisible:false,
-        periodNum: '',
-        dialogLoading: false,
-        tool: tool,
-      }
-    },
-    methods: {
-      getData() {
-        let vueObj = this
-        vueObj.loading = true
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <el-table class="table-box other-table-box" :data="tableData" style="width: 100%;">
+        <el-table-column v-for="(item,key) in tableKey" :key="key">
+          <template slot-scope="scope">
+            <el-tooltip effect="dark" :content="scope.row[item].name" placement="top">
+            <div class="bonus-item">{{scope.row[item].value}}</div>
+            </el-tooltip>
+          </template>
+        </el-table-column>
+
+        <el-table-column >
+          <template slot-scope="scope">
+            <el-button type="primary" size="small" @click.native="showFlow(scope.row.PERIOD_NUM.value)">查看全部</el-button>
+          </template>
+        </el-table-column>
+
+      </el-table>
+    </div>
+    <el-dialog :title="`${periodNum}期奖金`" :visible.sync="dialogFlowVisible" width="80%">
+      <div class="bonus-list" v-loading="dialogLoading">
+        <div class="bonus-item" v-for="(item,key) in newData" :key="key">
+          <el-tooltip effect="dark" :content="item.name" placement="top-end">
+            <div>{{item.value}}</div>
+          </el-tooltip>
+        </div>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import network from '@/utils/network'
+  import tool from '@/utils/tool'
+
+  export default {
+    name: 'bonus_other',
+    components: {},
+    mounted() {
+      this.getData()
+    },
+    data() {
+      return {
+        allData: null,
+        tableKey: null,
+        newData: null,
+        loading: true,
+        tableData: null,
+        dialogFlowVisible:false,
+        periodNum: '',
+        dialogLoading: false,
+        tool: tool,
+      }
+    },
+    methods: {
+      getData() {
+        let vueObj = this
+        vueObj.loading = true
         network.getData('bonus/other').then(response => {
-          vueObj.tableData = response.tableData
-          vueObj.tableKey = response.tableKey
-          vueObj.loading = false
-        }).catch(response => {
-          vueObj.loading = false
-        })
-      },
-      showFlow(periodNum){
-        let vueObj = this
-        this.$message({
-          message: '正在获取数据',
-          type: 'info'
-        })
-        this.periodNum = periodNum
-        vueObj.dialogFlowVisible = true
-        vueObj.dialogLoading = true
-        this.getFlowData()
-      },
-      getFlowData() {
-        let vueObj = this
+          //console.log(response);
+          vueObj.tableData = response.tableData
+          vueObj.tableKey = response.tableKey
+          vueObj.loading = false
+        }).catch(response => {
+          vueObj.loading = false
+        })
+      },
+      showFlow(periodNum){
+        let vueObj = this
+        this.$message({
+          message: '正在获取数据',
+          type: 'info'
+        })
+        this.periodNum = periodNum
+        vueObj.dialogFlowVisible = true
+        vueObj.dialogLoading = true
+        this.getFlowData()
+      },
+      getFlowData() {
+        let vueObj = this
         network.getData('bonus/new',{periodNum: vueObj.periodNum}).then(response => {
-          vueObj.newData = response
-          vueObj.dialogLoading = false
-        }).catch(response => {
-          vueObj.dialogLoading = false
-        })
-      },
-
-    }
-  }
-
-</script>
-<style>
-  .other-table-box .el-table__header-wrapper{display: none;}
-  .other-table-box .el-table__body tr:hover>td{background-color: #fff!important;}
-  .other-table-box .el-table__body tr td:not(:last-child):hover{background-color: #f5f5f5!important;}
-  .bonus-list:after{content: '';clear: both;display: table;}
-  .bonus-list .bonus-item{float: left;width: 33.333%;background: #fff;height:36px;line-height:36px;border: 1px solid #ddd;margin: -1px 0 0 -1px;box-sizing: border-box;}
-  .bonus-item{text-align: center;}
-  .bonus-item:hover{background: #f5f5f5;cursor: pointer;}
-</style>
+          console.log(response);
+          vueObj.newData = response
+          vueObj.dialogLoading = false
+        }).catch(response => {
+          vueObj.dialogLoading = false
+        })
+      },
+
+    }
+  }
+
+</script>
+<style>
+  .other-table-box .el-table__header-wrapper{display: none;}
+  .other-table-box .el-table__body tr:hover>td{background-color: #fff!important;}
+  .other-table-box .el-table__body tr td:not(:last-child):hover{background-color: #f5f5f5!important;}
+  .bonus-list:after{content: '';clear: both;display: table;}
+  .bonus-list .bonus-item{float: left;width: 33.333%;background: #fff;height:36px;line-height:36px;border: 1px solid #ddd;margin: -1px 0 0 -1px;box-sizing: border-box;}
+  .bonus-item{text-align: center;}
+  .bonus-item:hover{background: #f5f5f5;cursor: pointer;}
+</style>

+ 245 - 0
frontendEle/src/views/bonus/teams.vue

@@ -0,0 +1,245 @@
+<template>
+  <div v-loading="loading">
+    <el-table
+    border
+    :data="userData"
+    style="width: 100%"
+    :cell-style="tableCellStyle"
+    >
+    <el-table-column label="个人情况">
+      <el-table-column
+      type="index"
+      :index="indexMethod"
+          width="60px"
+          label=""
+          >
+        </el-table-column>
+        <el-table-column
+          prop="number"
+          label="会员编号"
+          >
+        </el-table-column>
+        <el-table-column
+          prop="name"
+          label="会员姓名"
+          >
+        </el-table-column>
+        <el-table-column
+          prop="perf_status_name"
+          label="状态"
+          >
+        </el-table-column>
+        <el-table-column
+          prop="user_perf"
+          label="业绩"
+          >
+        </el-table-column>
+         <el-table-column
+          prop="team_perf"
+          label="累计业绩"
+          >
+        </el-table-column>
+         <el-table-column
+          prop="total_perf"
+          label="合计"
+          >
+        </el-table-column>
+      </el-table-column>
+
+  </el-table>
+
+  <el-table
+    border
+    :data="tableData"
+    style="width: 100%;margin-top:20px;"
+    :cell-style="tableCellStyle"
+   >
+    <el-table-column label="团队情况">
+      <el-table-column
+      type="index"
+      :index="indexMethod"
+          width="60px"
+          label=""
+          >
+        </el-table-column>
+         <el-table-column
+          prop="number"
+          label="会员编号"
+          >
+        </el-table-column>
+        <el-table-column
+          prop="name"
+          label="会员姓名"
+          >
+        </el-table-column>
+        <el-table-column
+          class="dsdd"
+          prop="perf_status_name"
+          label="状态"
+          >
+        </el-table-column>
+        <el-table-column
+          prop="user_perf"
+          label="业绩"
+          >
+        </el-table-column>
+         <el-table-column
+          prop="team_perf"
+          label="累计业绩"
+          >
+        </el-table-column>
+         <el-table-column
+          prop="total_perf"
+          label="合计"
+          >
+        </el-table-column>
+      </el-table-column>
+
+  </el-table>
+  <el-descriptions  :column="2"  >
+  <el-descriptions-item label="最新计算时间" >{{calcTime}}</el-descriptions-item>
+</el-descriptions>
+  </div>
+</template>
+
+<script>
+  import network from '@/utils/network'
+  import tool from '@/utils/tool'
+  import Pagination from '@/components/Pagination'
+
+  export default {
+    name: 'bonus_teams',
+    components: {Pagination},
+    mounted() {
+      this.getData()
+    },
+    data() {
+      return {
+        calcTime:'',
+        userData:[],
+        tableData: [],
+        allData: null,
+        walletData: null,
+        dealSwitch: null,
+        loading: true,
+        dialogFlowVisible:false,
+        currentPage: 1,
+        totalPages: 1,
+        totalCount: 1,
+        pageSize: 20,
+        walletType: 'bonus',
+        walletName: '',
+        dialogLoading: false,
+        tool: tool,
+        createAt: '',
+        dealType: null,
+        remark: '',
+        dealTypes: [],
+      }
+    },
+    methods: {
+      tableCellStyle({row,column,rowIndex,columnIndex}) {
+        // console.log(row,column,rowIndex,columnIndex)
+        if (row.perf_status == '0' && columnIndex == '3') {
+            return "background-color:rgb(225, 25, 98);font-weight:bold";
+        } else if (row.perf_status == '1' && columnIndex == '3') {
+            return "background-color:rgb(31, 156, 18);font-weight:bold";
+        }
+        
+      },
+      indexMethod(index) {
+        return index + 1;
+      },
+      getData() {
+        let vueObj = this
+        vueObj.loading = true
+        network.getData('bonus/teams').then(response => {
+          this.userData = response.user
+          this.tableData = response.team
+          this.calcTime = response.calcAt
+          vueObj.loading = false
+        }).catch(response => {
+          vueObj.loading = false
+        })
+      },
+      showFlow(walletType,walletName){
+        let vueObj = this
+        this.$message({
+          message: '正在获取数据',
+          type: 'info'
+        })
+        this.walletType = walletType
+        this.walletName = walletName
+        vueObj.dialogFlowVisible = true
+        vueObj.dialogLoading = true
+        this.handleFilterClear()
+      },
+    }
+  }
+
+</script>
+<style scoped>
+  .leo-filter {
+    padding: 0 0 15px 0;
+  }
+
+  .leo-filter .filter-hidden {
+    display: none;
+  }
+
+  .filter-item {
+    margin-right: 10px;
+  }
+
+  @media (min-width: 768px) {
+    .leo-filter {
+    }
+
+    .leo-filter .filter-item {
+      display: inline-block;
+      max-width: 200px;
+    }
+
+    .leo-filter .filter-item.filter-date-month-picker {
+      display: inline-block;
+      max-width: 220px;
+    }
+
+    .leo-filter .filter-item.filter-date-range-picker {
+      display: inline-block;
+      max-width: 380px;
+    }
+
+    .leo-filter .filter-item.filter-filter-btn {
+      height: 38px;
+      width: 80px;
+    }
+
+    .leo-filter .filter-hidden {
+      display: none;
+    }
+  }
+</style>
+<style scoped>
+  .dialog-footer:after{content: '';
+    clear: both;display: table;}
+
+ 
+  .el-table .warning-row {
+    background: oldlace;
+  }
+
+  .el-table .success-row {
+    background: #f0f9eb;
+      /* color:rgb(225, 25, 98)   */
+  }
+.el-descriptions {
+  margin-top:20px;
+}
+/deep/ .el-descriptions-item__container {
+  margin-top:10px;
+}
+/deep/ .el-descriptions-item__label.has-colon {
+  margin-left:10px;
+}  
+</style>

+ 253 - 252
frontendEle/src/views/dashboard/index.vue

@@ -1,253 +1,254 @@
-<template>
-  <div v-loading="loading">
-    <div>
-      <div class="welcome" :style="getEmpBg(myEmpLv['ICON_TYPE'])">
-        <h1>欢迎您,{{userName}}
-
-        <b v-if="verified==='0'" class="text-danger"> 您未实名认证,请登录商城系统完善会员资料并上传身份证</b>
-        </h1>
-        <el-row :gutter="0" class="wel-info">
-          <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">当前系统时间:{{nowDateTime}}</el-col>
-              <el-col :xs="24" :sm="24" :md="24" :lg="4" :xl="12">聘级:{{myEmpLv['LEVEL_NAME']!='无聘级'?myEmpLv['LEVEL_NAME']:''}}<span v-if="myEmpLv['ICON_TYPE']==0">无</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">
-              </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-row>
-          </el-col>
-        </el-row>
-      </div>
-      <div style="display: none;">
-<!--        <el-button type="primary" @click="go('/config/base')">个人设置</el-button>-->
-        <el-button type="success" @click="go('/user/index')">个人资料</el-button>
-<!--        <el-button type="danger" @click="go('/user/rec-user')">开拓会员</el-button>-->
-        <el-button type="primary" @click="go('/finance/flow-bonus')">奖金流水</el-button>
-        <el-button type="warning" @click="go('/finance/withdraw')">提现明细</el-button>
-        <el-button type="success" @click="go('/finance/perf')">往期业绩</el-button>
-      </div>
-    </div>
-    <el-carousel trigger="click" :height="bannerHeight+'px'">
-      <el-carousel-item v-for="(item,key) in slides" :key="key">
-        <template v-if="item.TYPE==='1'">
-          <a :href="item.CONTENT" target="_blank" class="islide">
-            <img ref="bannerHeight" :src="item.IMAGE" alt="" @load="imgLoad">
-          </a>
-        </template>
-        <template v-else>
-          <router-link :to="`/article/detail/${item.CONTENT}`" target="_blank" class="islide"><img ref="bannerHeight" :src="item.IMAGE" alt="" @load="imgLoad"></router-link>
-        </template>
-      </el-carousel-item>
-    </el-carousel>
-
-    <el-row :gutter="10" class="news-c">
-      <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8" v-for="(item,key) in news" :key="key">
-        <el-card class="box-card">
-          <div slot="header" class="clearfix">
-            <span>{{item.CATE_NAME}}</span>
-            <el-button type="text" class="box-card-more">
-              <router-link :to="`/article/list/${item.ID}`">more+</router-link>
-            </el-button>
-          </div>
-          <div v-for="(o,k) in item.LISTS" :key="k" class="text item" v-if="item.LISTS.length>0">
-            <router-link :to="`/article/detail/${o.ID}`" :title="o.TITLE">{{sub_str(o.TITLE)}}</router-link>
-            <span>{{tool.formatDate(o.CREATED_AT,false)}}</span>
-          </div>
-          <div v-if="item.LISTS.length==0">暂无内容</div>
-        </el-card>
-      </el-col>
-    </el-row>
-  </div>
-</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'
-
-  export default {
-    name: 'dashboard_index',
-    components: {
-      countUp
-    },
-    mounted() {
+<template>
+  <div v-loading="loading">
+    <div>
+      <div class="welcome" :style="getEmpBg(myEmpLv['ICON_TYPE'])">
+        <h1>欢迎您,{{userName}}
+
+        <b v-if="verified==='0'" class="text-danger"> 您未实名认证,请登录商城系统完善会员资料并上传身份证</b>
+        </h1>
+        <el-row :gutter="0" class="wel-info">
+          <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">当前系统时间:{{nowDateTime}}</el-col>
+              <el-col :xs="24" :sm="24" :md="24" :lg="4" :xl="12">最高聘级:{{myEmpLv['LEVEL_NAME']!='无聘级'?myEmpLv['LEVEL_NAME']:''}}<span v-if="myEmpLv['ICON_TYPE']==0">无</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">
+              </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-row>
+          </el-col>
+        </el-row>
+      </div>
+      <div style="display: none;">
+<!--        <el-button type="primary" @click="go('/config/base')">个人设置</el-button>-->
+        <el-button type="success" @click="go('/user/index')">个人资料</el-button>
+<!--        <el-button type="danger" @click="go('/user/rec-user')">开拓会员</el-button>-->
+        <el-button type="primary" @click="go('/finance/flow-bonus')">奖金流水</el-button>
+        <el-button type="warning" @click="go('/finance/withdraw')">提现明细</el-button>
+        <el-button type="success" @click="go('/finance/perf')">往期业绩</el-button>
+      </div>
+    </div>
+    <el-carousel trigger="click" :height="bannerHeight+'px'">
+      <el-carousel-item v-for="(item,key) in slides" :key="key">
+        <template v-if="item.TYPE==='1'">
+          <a :href="item.CONTENT" target="_blank" class="islide">
+            <img ref="bannerHeight" :src="item.IMAGE" alt="" @load="imgLoad">
+          </a>
+        </template>
+        <template v-else>
+          <router-link :to="`/article/detail/${item.CONTENT}`" target="_blank" class="islide"><img ref="bannerHeight" :src="item.IMAGE" alt="" @load="imgLoad"></router-link>
+        </template>
+      </el-carousel-item>
+    </el-carousel>
+
+    <el-row :gutter="10" class="news-c">
+      <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8" v-for="(item,key) in news" :key="key">
+        <el-card class="box-card">
+          <div slot="header" class="clearfix">
+            <span>{{item.CATE_NAME}}</span>
+            <el-button type="text" class="box-card-more">
+              <router-link :to="`/article/list/${item.ID}`">more+</router-link>
+            </el-button>
+          </div>
+          <div v-for="(o,k) in item.LISTS" :key="k" class="text item" v-if="item.LISTS.length>0">
+            <router-link :to="`/article/detail/${o.ID}`" :title="o.TITLE">{{sub_str(o.TITLE)}}</router-link>
+            <span>{{tool.formatDate(o.CREATED_AT,false)}}</span>
+          </div>
+          <div v-if="item.LISTS.length==0">暂无内容</div>
+        </el-card>
+      </el-col>
+    </el-row>
+  </div>
+</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'
+
+  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.loading = false
-        this.imgLoad()
-        return network.getData(`dashboard/bonus-num`)
-      })
-      if(this.verified==='0'){
-        this.$confirm('您未实名认证,请登录商城系统完善会员资料并上传身份证', '请注意', {
-          confirmButtonText: '确定',
-          type: 'warning'
-        }).then(() => {
-        }).catch(() => {
-
-        })
-      }
-      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: '',
-        bannerHeight: '',
-      }
-    },
-    computed: {
-      nowDateTime: function () {
-        return tool.formatDate(this.nowTime)
-      }
-    },
-    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
-        _this.$nextTick(function () {
-          _this.bannerHeight = _this.$refs.bannerHeight[0].height
-        })
-      }
-    }
-  }
-</script>
-
-<style scoped>
-  h1 {
-    margin-top: 0
-  }
-
-  .welcome {
-    padding-bottom: 10px;
-    background-repeat: no-repeat;
-    background-position: right top;
-  }
-
-  .wel-info {
-    line-height: 36px;
-  }
-
-  .wel-info img {
-    vertical-align: middle;
-  }
-
-  .news-c .el-col .box-card {
-    margin-top: 10px;
-  }
-
-  .news-c .el-col:nth-child(3n+1) .box-card {
-    border-bottom: 4px solid #f34d14;
-  }
-
-  .news-c .el-col:nth-child(3n+2) .box-card {
-    border-bottom: 4px solid #27a2d3;
-  }
-
-  .news-c .el-col:nth-child(3n+3) .box-card {
-    border-bottom: 4px solid #1bbc61;
-  }
-
-  .box-card-more {
-    float: right;
-    padding: 3px 10px;
-    border: 1px solid #ddd;
-    border-radius: 10px;
-  }
-
-  .box-card-more a {
-    color: #666;
-  }
-
-  .box-card-more:hover {
-    border-color: #409EFF;
-  }
-
-  .box-card .item {
-    position: relative;
-    line-height: 30px;
-    padding-left: 10px;
-  }
-
-  .box-card .item:before {
-    content: '';
-    display: block;
-    width: 4px;
-    height: 4px;
-    background: #f60;
-    position: absolute;
-    left: 0px;
-    top: 14px;
-  }
-
-  .box-card .item:after {
-    content: '';
-    display: table;
-    clear: both;
-  }
-
-  .box-card .item a {
-    color: #333;
-    float: left;
-  }
-
-  .box-card .item a:hover {
-    color: #f60;
-  }
-
-  .box-card .item span {
-    float: right;
-    color: #999;
-    font-size: 12px;
-  }
-
-  .islide {
-    display: block;
-    text-align: center;
-  }
-
-  .islide img {
-    max-width: 100%;
-    max-height: 330px;
-  }
-</style>
+        console.log(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.loading = false
+        this.imgLoad()
+        return network.getData(`dashboard/bonus-num`)
+      })
+      if(this.verified==='0'){
+        this.$confirm('您未实名认证,请登录商城系统完善会员资料并上传身份证', '请注意', {
+          confirmButtonText: '确定',
+          type: 'warning'
+        }).then(() => {
+        }).catch(() => {
+
+        })
+      }
+      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: '',
+        bannerHeight: '',
+      }
+    },
+    computed: {
+      nowDateTime: function () {
+        return tool.formatDate(this.nowTime)
+      }
+    },
+    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
+        _this.$nextTick(function () {
+          _this.bannerHeight = _this.$refs.bannerHeight[0].height
+        })
+      }
+    }
+  }
+</script>
+
+<style scoped>
+  h1 {
+    margin-top: 0
+  }
+
+  .welcome {
+    padding-bottom: 10px;
+    background-repeat: no-repeat;
+    background-position: right top;
+  }
+
+  .wel-info {
+    line-height: 36px;
+  }
+
+  .wel-info img {
+    vertical-align: middle;
+  }
+
+  .news-c .el-col .box-card {
+    margin-top: 10px;
+  }
+
+  .news-c .el-col:nth-child(3n+1) .box-card {
+    border-bottom: 4px solid #f34d14;
+  }
+
+  .news-c .el-col:nth-child(3n+2) .box-card {
+    border-bottom: 4px solid #27a2d3;
+  }
+
+  .news-c .el-col:nth-child(3n+3) .box-card {
+    border-bottom: 4px solid #1bbc61;
+  }
+
+  .box-card-more {
+    float: right;
+    padding: 3px 10px;
+    border: 1px solid #ddd;
+    border-radius: 10px;
+  }
+
+  .box-card-more a {
+    color: #666;
+  }
+
+  .box-card-more:hover {
+    border-color: #409EFF;
+  }
+
+  .box-card .item {
+    position: relative;
+    line-height: 30px;
+    padding-left: 10px;
+  }
+
+  .box-card .item:before {
+    content: '';
+    display: block;
+    width: 4px;
+    height: 4px;
+    background: #f60;
+    position: absolute;
+    left: 0px;
+    top: 14px;
+  }
+
+  .box-card .item:after {
+    content: '';
+    display: table;
+    clear: both;
+  }
+
+  .box-card .item a {
+    color: #333;
+    float: left;
+  }
+
+  .box-card .item a:hover {
+    color: #f60;
+  }
+
+  .box-card .item span {
+    float: right;
+    color: #999;
+    font-size: 12px;
+  }
+
+  .islide {
+    display: block;
+    text-align: center;
+  }
+
+  .islide img {
+    max-width: 100%;
+    max-height: 330px;
+  }
+</style>

+ 11 - 4
frontendEle/src/views/finance/transfer-add.vue

@@ -13,6 +13,9 @@
         <el-form-item label="当前可用余额">
           <el-tag type="success">{{cash}}元</el-tag>
         </el-form-item>
+        <el-form-item label="当前可用复消积分">
+          <el-tag type="success">{{point}}元</el-tag>
+        </el-form-item>
         <el-form-item label="当前转账比例" v-if="false">
           <el-tag type="info">{{transferProp}}%</el-tag>
         </el-form-item>
@@ -28,9 +31,10 @@
         <!--<el-form-item label="转入会员姓名">-->
           <!--<el-input v-model="form.toRealName"></el-input>-->
         <!--</el-form-item>-->
-        <el-form-item label="转账金额" style="margin-bottom: 0;">
+        <el-form-item label="转账金额">
           <el-input v-model="form.amount" type="number" :max="maxAmount" @change="chkReal"></el-input>
-          <span style="font-size: 8pt;color: #909399;">每次转账不得少于100</span>
+          <!--<span style="font-size: 8pt;color: #909399;">每次转账不得少于100</span>-->
+          <span></span>
         </el-form-item>
         <el-form-item label="手续费" v-show="fee!=='0'">
           <el-tag type="info">{{fee}}%</el-tag>
@@ -62,7 +66,7 @@ export default {
   },
   data () {
     return {
-      allWallet:{'bonus':'会员账户','cash':'现金钱包'},
+      allWallet:{'bonus':'会员账户','cash':'现金钱包','point':'复消积分'},
       form: {
         type:1,
         toUserName: '',
@@ -77,6 +81,7 @@ export default {
       },
       balance: 0,
       cash: 0,
+      point:0,
       maxAmount: 0,
       fee: '0',
       realAmount: 0,
@@ -111,6 +116,7 @@ export default {
     },
     chkTransferUserinfo(){
       network.getData(`finance/chk-transfer-user`).then(response => {
+        console.log(response);
         this.loading = false
         this.userInfo = response.userInfo
         this.transferConfig = response.transferConfig
@@ -129,6 +135,7 @@ export default {
         this.$message.closeAll()
         this.balance = response.bonus
         this.cash = response.cash
+        this.point = response.point
         this.getMaxAmount()
         this.loading = false
       })
@@ -187,4 +194,4 @@ export default {
 
 <style scoped>
 
-</style>
+</style>

+ 1 - 1
frontendEle/src/views/shop/order.vue

@@ -75,7 +75,7 @@
                         <div>¥{{balance.cash}}元</div>
                     </div>
                     <div class="sum_box">
-                        <div>无业绩兑换</div>
+                        <div>无业绩兑换点数</div>
                         <div>{{balance.exchange}}</div>
                     </div>
                 </div>

+ 125 - 125
mysql_db_yyj.sql

@@ -1,125 +1,125 @@
--- AR_SHOP_GOODS表结构修改
-ALTER TABLE `AR_SHOP_GOODS` ADD `IS_DEL` TINYINT(2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除';
-ALTER TABLE `AR_SHOP_GOODS` ADD `DELETED_AT` INT(10) NOT NULL DEFAULT '0' COMMENT '删除时间';
-ALTER TABLE `AR_SHOP_GOODS` ADD `POINT` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '兑换积分';
-ALTER TABLE `AR_SHOP_GOODS` ADD `SELL_TYPE` VARCHAR(32) NOT NULL DEFAULT '1,2' COMMENT '出售方式';
-
--- AR_ORDER_GOODS表结构修改
-ALTER TABLE `AR_ORDER_GOODS` ADD `POINT` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT '兑换积分';
-
--- AR_ORDER表结构修改
-ALTER TABLE `AR_ORDER` ADD `PAY_TYPE` VARCHAR(32) NOT NULL DEFAULT 'cash' COMMENT '支付方式';
-
--- 03-15更新表结构
-ALTER TABLE `AR_FLOW_WALLET`
-ADD COLUMN `TRANSFER_SN` varchar(32) DEFAULT NULL AFTER `SORT`;
-
-ALTER TABLE `AR_DECLARATION_PACKAGE`
-ADD COLUMN `PACKAGE_NO` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT 'PG546763' AFTER `PACKAGE_NAME`;
-
-ALTER TABLE `AR_ORDER`
-ADD COLUMN `WAREHOUSE` varchar(16) COLLATE utf8mb4_bin NOT NULL DEFAULT '01' AFTER `PAY_TYPE`;
-
-UPDATE AR_CONFIG SET VALUE='[{"out":"bonus","in":"cash","outMin":"100","outMax":"0","fee":"3","feeMin":"0","feeMax":"0","weekMax":"0","monthMax":"0","isSystem":true,"isBind":true,"isOpen":true},{"out":"bonus","in":"bonus","outMin":"100","outMax":"0","fee":"0","feeMin":"0","feeMax":"0","weekMax":"0","monthMax":"0","isSystem":true,"isBind":true,"isOpen":true},{"out":"cash","in":"cash","outMin":"100","outMax":"0","fee":"0","feeMin":"0","feeMax":"0","weekMax":"0","monthMax":"0","isSystem":true,"isBind":true,"isOpen":true}]' WHERE CONFIG_NAME='allowWallet';
-
--- ALTER TABLE `AR_USER_WALLET`
--- MODIFY COLUMN `CASH` decimal(16, 2) UNSIGNED NOT NULL DEFAULT 0.00 AFTER `USER_ID`;
--- ALTER TABLE `AR_USER_BONUS`
--- MODIFY COLUMN `BONUS` decimal(16, 2) UNSIGNED NOT NULL DEFAULT 0.00 AFTER `USER_ID`;
-
-
-DROP TABLE IF EXISTS `AR_TMP_OLD_NETWORK`;
-CREATE TABLE `AR_TMP_OLD_NETWORK` (
-  `ID` varchar(32) NOT NULL,
-  `USER_NAME` varchar(16) NOT NULL,
-  `REAL_NAME` varchar(128) NOT NULL,
-  `PARENT_USER_NAME` varchar(16) NOT NULL,
-  `PARENT_REAL_NAME` varchar(128) NOT NULL,
-  `NET_USER_NAME` varchar(16) NOT NULL,
-  `NET_REAL_NAME` varchar(128) NOT NULL,
-  `SORT` int(10) UNSIGNED NOT NULL DEFAULT '0',
-  `NET_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
-  `REC_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
-  PRIMARY KEY (`ID`),
-  KEY `USER_NAME` (`USER_NAME`) USING BTREE,
-  KEY `PARENT_USER_NAME` (`PARENT_USER_NAME`) USING BTREE,
-  KEY `NET_USER_NAME` (`NET_USER_NAME`) USING BTREE,
-  KEY `SORT` (`SORT`) USING BTREE,
-  KEY `NET_DEEP` (`NET_DEEP`) USING BTREE,
-  KEY `REC_DEEP` (`REC_DEEP`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='excel新增会员关系临时表';
-
-
-CREATE TABLE `AR_TMP_OLD_NETWORK_ALL` (
-  `ID` varchar(32) NOT NULL,
-  `USER_NAME` varchar(16) NOT NULL,
-  `REAL_NAME` varchar(128) NOT NULL,
-  `PARENT_USER_NAME` varchar(16) NOT NULL,
-  `PARENT_REAL_NAME` varchar(128) NOT NULL,
-  `NET_USER_NAME` varchar(16) NOT NULL,
-  `NET_REAL_NAME` varchar(128) NOT NULL,
-  `REC_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
-  `NET_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
-  `SORT` int(10) UNSIGNED NOT NULL DEFAULT '0',
-  `NET_SAME` tinyint(2) NOT NULL DEFAULT '0' COMMENT '相同0 不同1',
-  `REC_SAME` tinyint(2) NOT NULL DEFAULT '0',
-  `OLD_IS_EXSIT` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0 不存在 1 存在',
-  PRIMARY KEY (`ID`),
-  KEY `USER_NAME` (`USER_NAME`) USING BTREE,
-  KEY `PARENT_USER_NAME` (`PARENT_USER_NAME`) USING BTREE,
-  KEY `NET_USER_NAME` (`NET_USER_NAME`) USING BTREE,
-  KEY `SORT` (`SORT`) USING BTREE,
-  KEY `NET_DEEP` (`NET_DEEP`) USING BTREE,
-  KEY `REC_DEEP` (`REC_DEEP`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='老系统总会员关系临时表';
-
-
-
-CREATE TABLE `AR_TMP_DELETE_USER` (
-  `ID` varchar(32) NOT NULL,
-  `USER_NAME` varchar(16) NOT NULL,
-  `REAL_NAME` varchar(128) NOT NULL,
-  `USER_ID` varchar(32) NOT NULL COMMENT '用户ID',
-  PRIMARY KEY (`ID`),
-  KEY `USER_ID` (`USER_ID`) USING BTREE,
-  KEY `USER_NAME` (`USER_NAME`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='线上会员多于34w的会员';
-
-
-
-CREATE TABLE `AR_TMP_OLD_NETWORK_ERROR` (
-  `ID` varchar(32) NOT NULL,
-  `USER_NAME` varchar(16) NOT NULL,
-  `REAL_NAME` varchar(128) NOT NULL,
-  `PARENT_USER_NAME` varchar(16) NOT NULL,
-  `PARENT_REAL_NAME` varchar(128) NOT NULL,
-  `NET_USER_NAME` varchar(16) NOT NULL,
-  `NET_REAL_NAME` varchar(128) NOT NULL,
-  `REC_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
-  `NET_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
-  `SORT` int(10) UNSIGNED NOT NULL DEFAULT '0',
-  PRIMARY KEY (`ID`),
-  KEY `USER_NAME` (`USER_NAME`) USING BTREE,
-  KEY `PARENT_USER_NAME` (`PARENT_USER_NAME`) USING BTREE,
-  KEY `NET_USER_NAME` (`NET_USER_NAME`) USING BTREE,
-  KEY `SORT` (`SORT`) USING BTREE,
-  KEY `NET_DEEP` (`NET_DEEP`) USING BTREE,
-  KEY `REC_DEEP` (`REC_DEEP`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='改错表';
-
-
-
-CREATE TABLE `AR_USER_REG` (
-  `ID` varchar(32) NOT NULL,
-  `USER_NAME` varchar(16) NOT NULL,
-  `REAL_NAME` varchar(128) NOT NULL,
-  `CON_UID` varchar(32) NOT NULL,
-  `REC_UID` varchar(32) NOT NULL,
-  `PARENT_USER_NAME` varchar(16) NOT NULL,
-  `PARENT_REAL_NAME` varchar(128) NOT NULL,
-  `NET_USER_NAME` varchar(16) NOT NULL,
-  `NET_REAL_NAME` varchar(128) NOT NULL,
-  PRIMARY KEY (`ID`),
-  KEY `USER_NAME` (`USER_NAME`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='正式站报单用户44';
-
+-- AR_SHOP_GOODS表结构修改
+ALTER TABLE `AR_SHOP_GOODS` ADD `IS_DEL` TINYINT(2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '是否删除';
+ALTER TABLE `AR_SHOP_GOODS` ADD `DELETED_AT` INT(10) NOT NULL DEFAULT '0' COMMENT '删除时间';
+ALTER TABLE `AR_SHOP_GOODS` ADD `POINT` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '兑换点数';
+ALTER TABLE `AR_SHOP_GOODS` ADD `SELL_TYPE` VARCHAR(32) NOT NULL DEFAULT '1,2' COMMENT '出售方式';
+
+-- AR_ORDER_GOODS表结构修改
+ALTER TABLE `AR_ORDER_GOODS` ADD `POINT` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0' COMMENT '兑换点数';
+
+-- AR_ORDER表结构修改
+ALTER TABLE `AR_ORDER` ADD `PAY_TYPE` VARCHAR(32) NOT NULL DEFAULT 'cash' COMMENT '支付方式';
+
+-- 03-15更新表结构
+ALTER TABLE `AR_FLOW_WALLET`
+ADD COLUMN `TRANSFER_SN` varchar(32) DEFAULT NULL AFTER `SORT`;
+
+ALTER TABLE `AR_DECLARATION_PACKAGE`
+ADD COLUMN `PACKAGE_NO` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT 'PG546763' AFTER `PACKAGE_NAME`;
+
+ALTER TABLE `AR_ORDER`
+ADD COLUMN `WAREHOUSE` varchar(16) COLLATE utf8mb4_bin NOT NULL DEFAULT '01' AFTER `PAY_TYPE`;
+
+UPDATE AR_CONFIG SET VALUE='[{"out":"bonus","in":"cash","outMin":"100","outMax":"0","fee":"3","feeMin":"0","feeMax":"0","weekMax":"0","monthMax":"0","isSystem":true,"isBind":true,"isOpen":true},{"out":"bonus","in":"bonus","outMin":"100","outMax":"0","fee":"0","feeMin":"0","feeMax":"0","weekMax":"0","monthMax":"0","isSystem":true,"isBind":true,"isOpen":true},{"out":"cash","in":"cash","outMin":"100","outMax":"0","fee":"0","feeMin":"0","feeMax":"0","weekMax":"0","monthMax":"0","isSystem":true,"isBind":true,"isOpen":true}]' WHERE CONFIG_NAME='allowWallet';
+
+-- ALTER TABLE `AR_USER_WALLET`
+-- MODIFY COLUMN `CASH` decimal(16, 2) UNSIGNED NOT NULL DEFAULT 0.00 AFTER `USER_ID`;
+-- ALTER TABLE `AR_USER_BONUS`
+-- MODIFY COLUMN `BONUS` decimal(16, 2) UNSIGNED NOT NULL DEFAULT 0.00 AFTER `USER_ID`;
+
+
+DROP TABLE IF EXISTS `AR_TMP_OLD_NETWORK`;
+CREATE TABLE `AR_TMP_OLD_NETWORK` (
+  `ID` varchar(32) NOT NULL,
+  `USER_NAME` varchar(16) NOT NULL,
+  `REAL_NAME` varchar(128) NOT NULL,
+  `PARENT_USER_NAME` varchar(16) NOT NULL,
+  `PARENT_REAL_NAME` varchar(128) NOT NULL,
+  `NET_USER_NAME` varchar(16) NOT NULL,
+  `NET_REAL_NAME` varchar(128) NOT NULL,
+  `SORT` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `NET_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `REC_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  PRIMARY KEY (`ID`),
+  KEY `USER_NAME` (`USER_NAME`) USING BTREE,
+  KEY `PARENT_USER_NAME` (`PARENT_USER_NAME`) USING BTREE,
+  KEY `NET_USER_NAME` (`NET_USER_NAME`) USING BTREE,
+  KEY `SORT` (`SORT`) USING BTREE,
+  KEY `NET_DEEP` (`NET_DEEP`) USING BTREE,
+  KEY `REC_DEEP` (`REC_DEEP`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='excel新增会员关系临时表';
+
+
+CREATE TABLE `AR_TMP_OLD_NETWORK_ALL` (
+  `ID` varchar(32) NOT NULL,
+  `USER_NAME` varchar(16) NOT NULL,
+  `REAL_NAME` varchar(128) NOT NULL,
+  `PARENT_USER_NAME` varchar(16) NOT NULL,
+  `PARENT_REAL_NAME` varchar(128) NOT NULL,
+  `NET_USER_NAME` varchar(16) NOT NULL,
+  `NET_REAL_NAME` varchar(128) NOT NULL,
+  `REC_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `NET_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `SORT` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `NET_SAME` tinyint(2) NOT NULL DEFAULT '0' COMMENT '相同0 不同1',
+  `REC_SAME` tinyint(2) NOT NULL DEFAULT '0',
+  `OLD_IS_EXSIT` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0 不存在 1 存在',
+  PRIMARY KEY (`ID`),
+  KEY `USER_NAME` (`USER_NAME`) USING BTREE,
+  KEY `PARENT_USER_NAME` (`PARENT_USER_NAME`) USING BTREE,
+  KEY `NET_USER_NAME` (`NET_USER_NAME`) USING BTREE,
+  KEY `SORT` (`SORT`) USING BTREE,
+  KEY `NET_DEEP` (`NET_DEEP`) USING BTREE,
+  KEY `REC_DEEP` (`REC_DEEP`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='老系统总会员关系临时表';
+
+
+
+CREATE TABLE `AR_TMP_DELETE_USER` (
+  `ID` varchar(32) NOT NULL,
+  `USER_NAME` varchar(16) NOT NULL,
+  `REAL_NAME` varchar(128) NOT NULL,
+  `USER_ID` varchar(32) NOT NULL COMMENT '用户ID',
+  PRIMARY KEY (`ID`),
+  KEY `USER_ID` (`USER_ID`) USING BTREE,
+  KEY `USER_NAME` (`USER_NAME`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='线上会员多于34w的会员';
+
+
+
+CREATE TABLE `AR_TMP_OLD_NETWORK_ERROR` (
+  `ID` varchar(32) NOT NULL,
+  `USER_NAME` varchar(16) NOT NULL,
+  `REAL_NAME` varchar(128) NOT NULL,
+  `PARENT_USER_NAME` varchar(16) NOT NULL,
+  `PARENT_REAL_NAME` varchar(128) NOT NULL,
+  `NET_USER_NAME` varchar(16) NOT NULL,
+  `NET_REAL_NAME` varchar(128) NOT NULL,
+  `REC_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `NET_DEEP` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  `SORT` int(10) UNSIGNED NOT NULL DEFAULT '0',
+  PRIMARY KEY (`ID`),
+  KEY `USER_NAME` (`USER_NAME`) USING BTREE,
+  KEY `PARENT_USER_NAME` (`PARENT_USER_NAME`) USING BTREE,
+  KEY `NET_USER_NAME` (`NET_USER_NAME`) USING BTREE,
+  KEY `SORT` (`SORT`) USING BTREE,
+  KEY `NET_DEEP` (`NET_DEEP`) USING BTREE,
+  KEY `REC_DEEP` (`REC_DEEP`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='改错表';
+
+
+
+CREATE TABLE `AR_USER_REG` (
+  `ID` varchar(32) NOT NULL,
+  `USER_NAME` varchar(16) NOT NULL,
+  `REAL_NAME` varchar(128) NOT NULL,
+  `CON_UID` varchar(32) NOT NULL,
+  `REC_UID` varchar(32) NOT NULL,
+  `PARENT_USER_NAME` varchar(16) NOT NULL,
+  `PARENT_REAL_NAME` varchar(128) NOT NULL,
+  `NET_USER_NAME` varchar(16) NOT NULL,
+  `NET_REAL_NAME` varchar(128) NOT NULL,
+  PRIMARY KEY (`ID`),
+  KEY `USER_NAME` (`USER_NAME`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='正式站报单用户44';
+