Просмотр исходного кода

Merge branch 'master' of http://18.167.157.193:1026/guanli/ngds

# Conflicts:
#	backendApi/config/menu.php
#	backendApi/modules/v1/models/lists/shop/GoodsList.php
#	common/helpers/bonus/BonusCalc.php
#	common/models/ShopGoods.php
#	common/models/forms/OrderForm.php
#	common/models/forms/ShopGoodsForm.php
#	frontendApi/config/menu.php
#	frontendApi/modules/v1/controllers/BonusController.php
#	frontendApi/modules/v1/controllers/ShopController.php
#	frontendEle/src/router/index.js
#	frontendEle/src/views/bonus/other.vue
#	frontendEle/src/views/shop/order.vue
theo 3 лет назад
Родитель
Сommit
8586bdf6e4
40 измененных файлов с 1285 добавлено и 505 удалено
  1. 4 4
      backendApi/config/menu.php
  2. 1 0
      backendApi/config/urlManagerRules.php
  3. 23 0
      backendApi/modules/v1/controllers/ConfigController.php
  4. 2 3
      backendApi/modules/v1/controllers/UserController.php
  5. 7 22
      backendApi/modules/v1/models/lists/bonus/BalanceList.php
  6. 6 6
      backendApi/modules/v1/models/lists/shop/GoodsList.php
  7. 91 8
      backendEle/src/views/config/bonus-opt.vue
  8. 5 9
      common/config/params.php
  9. 10 0
      common/helpers/Cache.php
  10. 2 1
      common/helpers/PayStack.php
  11. 13 0
      common/helpers/Tool.php
  12. 239 161
      common/helpers/bonus/BonusCalc.php
  13. 61 21
      common/helpers/bonus/BonusSend.php
  14. 60 6
      common/helpers/bonus/CalcCache.php
  15. 2 1
      common/helpers/bonus/PerfCalc.php
  16. 52 47
      common/helpers/user/Balance.php
  17. 1 0
      common/libs/logging/operate/valueType/Config.php
  18. 5 9
      common/models/BalanceAudit.php
  19. 9 9
      common/models/CalcBonus.php
  20. 4 6
      common/models/CalcBonusGarage.php
  21. 2 1
      common/models/CalcBonusQY.php
  22. 69 0
      common/models/CalcBonusTourism.php
  23. 6 9
      common/models/DealType.php
  24. 4 1
      common/models/EmployLevel.php
  25. 3 3
      common/models/FlowGaragePoints.php
  26. 81 0
      common/models/FlowTourismPoints.php
  27. 18 33
      common/models/ShopGoods.php
  28. 245 0
      common/models/StarCrownLevel.php
  29. 72 0
      common/models/StarCrownLevelForm.php
  30. 10 3
      common/models/User.php
  31. 13 7
      common/models/UserBonus.php
  32. 12 3
      common/models/forms/ApproachOrderForm.php
  33. 67 12
      common/models/forms/OrderForm.php
  34. 0 7
      common/models/forms/ShopGoodsForm.php
  35. 2 2
      frontendApi/config/menu.php
  36. 25 43
      frontendApi/modules/v1/controllers/BonusController.php
  37. 9 15
      frontendApi/modules/v1/controllers/ShopController.php
  38. 24 24
      frontendEle/src/router/index.js
  39. 4 6
      frontendEle/src/views/bonus/other.vue
  40. 22 23
      frontendEle/src/views/shop/order.vue

+ 4 - 4
backendApi/config/menu.php

@@ -42,14 +42,14 @@ return [
             // 新添加的商品操作 ---stop
             ['name'=>'商品列表导出', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'goods-list-export', 'routePath'=>'shop/goods-list-export', 'show'=>0,],
             ['name'=>' Kitting products manage', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'package', 'routePath'=>'shop/package', 'show'=>1,],//套餐管理
-            ['name'=>'报单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,],
-            ['name'=>'报单列表导出', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list-export', 'routePath'=>'shop/dec-order-list-export', 'show'=>0,],
+//            ['name'=>'报单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,],
+//            ['name'=>'报单列表导出', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list-export', 'routePath'=>'shop/dec-order-list-export', 'show'=>0,],
             ['name'=>'订单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],
             ['name'=>'订单列表导出', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list-export', 'routePath'=>'shop/order-list-export', 'show'=>0,],
             ['name'=>'订单发货', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-delivery', 'routePath'=>'shop/order-delivery', 'show'=>0,],
             ['name'=>'外部商城订单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-shop-list', 'routePath'=>'shop/order-shop-list', 'show'=>1,],
-            ['name'=>'外部商城报单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-dec-list', 'routePath'=>'shop/order-dec-list', 'show'=>1,],
-            ['name'=>'外部商城达标订单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-standard-list', 'routePath'=>'shop/order-standard-list', 'show'=>1,],
+//            ['name'=>'外部商城报单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-dec-list', 'routePath'=>'shop/order-dec-list', 'show'=>1,],
+//            ['name'=>'外部商城达标订单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-standard-list', 'routePath'=>'shop/order-standard-list', 'show'=>1,],
         ]
     ],
     'user'=>[

+ 1 - 0
backendApi/config/urlManagerRules.php

@@ -277,6 +277,7 @@ return [
             'POST emp-level-delete' => 'emp-level-delete',
             'POST bonus-dec-level' => 'bonus-dec-level',
             'POST bonus-emp-level' => 'bonus-emp-level',
+            'POST bonus-star-level' => 'bonus-star-level',
             'GET clear-data' => 'clear-data',
             'GET clear-cache' => 'clear-cache',
             'GET clear-table-cache' => 'clear-table-cache',

+ 23 - 0
backendApi/modules/v1/controllers/ConfigController.php

@@ -29,6 +29,7 @@ use common\models\FlowBonus;
 use common\models\forms\OcrApiForm;
 use common\models\forms\SmsApiForm;
 use common\models\forms\SmsTemplateForm;
+use common\models\StarCrownLevelForm;
 use common\models\forms\WithdrawLevelForm;
 use common\models\OcrApi;
 use common\models\PerfCompany;
@@ -40,6 +41,7 @@ use common\models\DeclarationLevel;
 use common\models\EmployLevel;
 use common\models\SmsApi;
 use common\models\SmsTemplate;
+use common\models\StarCrownLevel;
 use common\models\UserBonus;
 use common\models\UserClose;
 use common\models\UserInfo;
@@ -116,10 +118,13 @@ class ConfigController extends BaseController {
         $decLevel = DeclarationLevel::find()->orderBy('SORT ASC')->asArray()->all();
         // 获取会员聘级相关参数
         $empLevel = EmployLevel::getAllDataWithNumIndex();
+        // 获取会员星级相关参数
+        $starLevel = StarCrownLevel::getAllDataWithNumIndex();
         $result = [
             'config' => $configs,
             'decLevel' => $decLevel,
             'empLevel' => $empLevel,
+            'starLevel' => $starLevel,
         ];
         return static::notice($result);
     }
@@ -178,6 +183,24 @@ class ConfigController extends BaseController {
         }
     }
 
+    /**
+     * 修改会员星级相关的奖金配置
+     * @return mixed
+     * @throws \yii\db\Exception
+     * @throws \yii\web\HttpException
+     */
+    public function actionBonusStarLevel() {
+        $form = new StarCrownLevelForm();
+        if (Yii::$app->request->post() && $form->load(Yii::$app->request->post(), '')) {
+            if ($form->updateBonus()) {
+                StarCrownLevel::updateToCache();
+                return static::notice('更新星级奖金配置成功');
+            } else {
+                return static::notice(Form::formatErrorsForApi($form->getErrors()), 422);
+            }
+        }
+    }
+
     /**
      * 更新封期参数
      * @return mixed

+ 2 - 3
backendApi/modules/v1/controllers/UserController.php

@@ -885,9 +885,8 @@ class UserController extends BaseController
             $userInfo['CASH'] = Cash::getAvailableBalance($userInfo['ID']);
             $userInfo['RECONSUME_POINTS'] = Balance::getBalanceReconsumePoints($userInfo['ID']);
             $userInfo['EXCHANGE_POINTS'] = Balance::getBalanceExchangePoints($userInfo['ID']);
-            $userInfo['TRAVEL_POINTS'] = Balance::getAccountBalance($userInfo['ID'], 'travel_points');
-            $userInfo['CAR_POINTS'] = Balance::getAccountBalance($userInfo['ID'], 'car_points');
-            $userInfo['HOUSE_POINTS'] = Balance::getAccountBalance($userInfo['ID'], 'house_points');
+            $userInfo['TOURISM_POINTS'] = Balance::getAccountBalance($userInfo['ID'], 'tourism_points');
+            $userInfo['GARAGE_POINTS'] = Balance::getAccountBalance($userInfo['ID'], 'garage_points');
             return static::notice($userInfo);
         }else{
             return static::notice('会员编号不存在', 400);

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

@@ -317,46 +317,31 @@ class BalanceList extends \common\libs\dataList\DataList implements DataListInte
 //                    'header' => '历史最高聘级',
 //                    'headerOther' => ['width' => '130'],
 //                ],
-                'TRAVEL_POINTS' => [
+                'TOURISM_POINTS' => [
                     'header' => '旅游积分',
                     'value' => function($row) {
                         return (new Price([
-                            'value' => $row['TRAVEL_POINTS'],
+                            'value' => $row['TOURISM_POINTS'],
                         ]))->result();
                     },
                     'headerOther' => [
                         'width' => '150',
-                        'prop'=>'TRAVEL_POINTS',
+                        'prop'=>'TOURISM_POINTS',
                     ],
                     'valueOther' => [
                         'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
                     ],
                 ],
-                'CAR_POINTS' => [
-                    'header' => '车积分',
+                'GARAGE_POINTS' => [
+                    'header' => '车积分',
                     'value' => function($row) {
                         return (new Price([
-                            'value' => $row['CAR_POINTS'],
+                            'value' => $row['GARAGE_POINTS'],
                         ]))->result();
                     },
                     'headerOther' => [
                         'width' => '150',
-                        'prop'=>'CAR_POINTS',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
-                    ],
-                ],
-                'HOUSE_POINTS' => [
-                    'header' => '豪宅积分',
-                    'value' => function($row) {
-                        return (new Price([
-                            'value' => $row['HOUSE_POINTS'],
-                        ]))->result();
-                    },
-                    'headerOther' => [
-                        'width' => '150',
-                        'prop'=>'HOUSE_POINTS',
+                        'prop'=>'GARAGE_POINTS',
                     ],
                     'valueOther' => [
                         'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],

+ 6 - 6
backendApi/modules/v1/models/lists/shop/GoodsList.php

@@ -103,13 +103,13 @@ class GoodsList extends \common\libs\dataList\DataList implements DataListInterf
                     },
                     'headerOther' => ['width' => '150'],
                 ],
-                'SELL_PRICE' => [
-                    'header' => 'Products Prices ',//商品价格
+                'SELL_PRICE_STANDARD' => [
+                    'header' => '标准价格($)',
                     'headerOther' => [
                         'width' => '150',
                     ],
                     'value' => function ($row) {
-                        return Tool::formatPrice($row['SELL_PRICE']);
+                        return Tool::formatPrice($row['SELL_PRICE_STANDARD']);
                     },
                     'valueOther' => function ($row) {
                         return [
@@ -117,13 +117,13 @@ class GoodsList extends \common\libs\dataList\DataList implements DataListInterf
                         ];
                     },
                 ],
-                'SELL_PRICE_STANDARD' => [
-                    'header' => '标准价格($)',
+                'SELL_PRICE' => [
+                    'header' => 'Products Prices ',//商品价格
                     'headerOther' => [
                         'width' => '150',
                     ],
                     'value' => function ($row) {
-                        return Tool::formatPrice($row['SELL_PRICE_STANDARD']);
+                        return Tool::formatPrice($row['SELL_PRICE']);
                     },
                     'valueOther' => function ($row) {
                         return [

+ 91 - 8
backendEle/src/views/config/bonus-opt.vue

@@ -151,19 +151,19 @@
     </div>
     <div class="panel" v-if="permission.hasPermission(`config/bonus-emp-level`)">
       <div class="panel-heading">
-        荣衔奖和积分配置
+        荣衔配置
       </div>
       <div class="panel-wrapper">
         <div class="panel-body">
           <el-table :data="empLevelTableData" stripe style="width: 100%;">
             <el-table-column prop="LEVEL_NAME" label="级别名称"></el-table-column>
-            <el-table-column label="荣衔奖比例">
-              <template slot-scope="scope">
-                <el-input v-model="scope.row.RX_PERCENT" min="0" max="100">
-                  <template slot="append">%</template>
-                </el-input>
-              </template>
-            </el-table-column>
+<!--            <el-table-column label="荣衔奖比例">-->
+<!--              <template slot-scope="scope">-->
+<!--                <el-input v-model="scope.row.RX_PERCENT" min="0" max="100">-->
+<!--                  <template slot="append">%</template>-->
+<!--                </el-input>-->
+<!--              </template>-->
+<!--            </el-table-column>-->
             <el-table-column label="级别分数">
               <template slot-scope="scope">
                 <el-input v-model="scope.row.LEVEL_SCORE" min="0">
@@ -178,6 +178,27 @@
                 </el-input>
               </template>
             </el-table-column>
+            <el-table-column label="蓝星奖比例">
+              <template slot-scope="scope">
+                  <el-input v-model="scope.row.BS_PERCENT" min="0" max="100">
+                      <template slot="append">%</template>
+                  </el-input>
+              </template>
+            </el-table-column>
+            <el-table-column label="旅游奖比例">
+              <template slot-scope="scope">
+                <el-input v-model="scope.row.TOURISM_PERCENT" min="0" max="100">
+                  <template slot="append">%</template>
+                </el-input>
+              </template>
+            </el-table-column>
+            <el-table-column label="车房奖比例">
+              <template slot-scope="scope">
+                <el-input v-model="scope.row.GARAGE_PERCENT" min="0" max="100">
+                  <template slot="append">%</template>
+                </el-input>
+              </template>
+            </el-table-column>
           </el-table>
         </div>
         <div class="panel-footer">
@@ -186,6 +207,51 @@
         </div>
       </div>
     </div>
+
+      <div class="panel" v-if="permission.hasPermission(`config/bonus-star-level`)">
+          <div class="panel-heading">
+              星级配置
+          </div>
+          <div class="panel-wrapper">
+              <div class="panel-body">
+                  <el-table :data="starLevelTableData" stripe style="width: 100%;">
+                      <el-table-column prop="LEVEL_NAME" label="级别名称"></el-table-column>
+                      <el-table-column label="级别分数(BV)">
+                          <template slot-scope="scope">
+                              <el-input v-model="scope.row.LEVEL_SCORE" min="0">
+                                  <template slot="append">分</template>
+                              </el-input>
+                          </template>
+                      </el-table-column>
+                      <el-table-column label="升级分数(BV)">
+                          <template slot-scope="scope">
+                              <el-input v-model="scope.row.UPGRADE_SCORE" min="0">
+                                  <template slot="append">分</template>
+                              </el-input>
+                          </template>
+                      </el-table-column>
+                      <el-table-column label="旅游奖比例">
+                          <template slot-scope="scope">
+                              <el-input v-model="scope.row.TOURISM_PERCENT" min="0" max="100">
+                                  <template slot="append">%</template>
+                              </el-input>
+                          </template>
+                      </el-table-column>
+                      <el-table-column label="车房奖比例">
+                          <template slot-scope="scope">
+                              <el-input v-model="scope.row.GARAGE_PERCENT" min="0" max="100">
+                                  <template slot="append">%</template>
+                              </el-input>
+                          </template>
+                      </el-table-column>
+                  </el-table>
+              </div>
+              <div class="panel-footer">
+                  <el-button type="primary" @click="onStarSubmit" :loading="starSubmitButtonStat" style="float: right;">保存
+                  </el-button>
+              </div>
+          </div>
+      </div>
   </div>
 </template>
 
@@ -200,6 +266,7 @@ export default {
       this.configData = response.config
       this.decLevelTableData = response.decLevel
       this.empLevelTableData = response.empLevel
+      this.starLevelTableData = response.starLevel
       this.loading = false
     })
   },
@@ -207,11 +274,13 @@ export default {
     return {
       decLevelTableData: null,
       empLevelTableData: null,
+      starLevelTableData: null,
       loading: true,
       submitButtonStat: false,
       qySubmitButtonStat: false,
       glSubmitButtonStat: false,
       ycSubmitButtonStat: false,
+      starSubmitButtonStat: false,
       configData: null,
       permission: permission,
     }
@@ -280,6 +349,20 @@ export default {
         this.ycSubmitButtonStat = false
       })
     },
+    onStarSubmit() {
+      this.starSubmitButtonStat = true
+      network.postData('config/bonus-star-level', {
+          data: this.starLevelTableData
+      }).then(response => {
+          this.$message({
+              message: response,
+              type: 'success'
+          })
+          this.starSubmitButtonStat = false
+      }).catch(_ => {
+          this.starSubmitButtonStat = false
+      })
+    },
   }
 }
 </script>

+ 5 - 9
common/config/params.php

@@ -209,17 +209,13 @@ return [
 //            'name' => 'lx',
 //            'label' => '领袖分红奖余额',
 //        ],
-        'travel_points' => [
-            'name' => 'travel_points',
+        'tourism_points' => [
+            'name' => 'tourism_points',
             'label' => '旅游积分余额',
         ],
-        'car_points' => [
-            'name' => 'car_points',
-            'label' => '名车积分余额',
-        ],
-        'house_points' => [
-            'name' => 'house_points',
-            'label' => '豪宅积分余额',
+        'garage_points' => [
+            'name' => 'garage_points',
+            'label' => '车房积分余额',
         ],
     ],
     'auditStatus' => [

+ 10 - 0
common/helpers/Cache.php

@@ -16,6 +16,7 @@ use common\models\EmployLevel;
 use common\models\Region;
 use common\models\SmsApi;
 use common\models\SmsTemplate;
+use common\models\StarCrownLevel;
 use common\models\User;
 use common\models\UserNetwork;
 use common\models\UserRelation;
@@ -30,6 +31,7 @@ class Cache
     const DEC_LEVEL_CONFIG_KEY = 'sys:decLevel';
     const DEC_ROLE_CONFIG_KEY = 'sys:decRole';
     const EMP_LEVEL_CONFIG_KEY = 'sys:empLevel';
+    const STAR_LEVEL_CONFIG_KEY = 'sys:starLevel';
     const ADMIN_ROLE_KEY = 'sys:adminRole';
     const SMS_TEMPLATE_DEC_KEY = 'sys:smsTemplateDec';
     const SMS_TEMPLATE_EMP_KEY = 'sys:smsTemplateEmp';
@@ -145,6 +147,14 @@ class Cache
         return EmployLevel::getFromCache();
     }
 
+    /**
+     * 获取星级
+     * @return array|mixed|\yii\db\ActiveRecord[]
+     */
+    public static function getStarCrownLevelConfig(){
+        return StarCrownLevel::getFromCache();
+    }
+
     /**
      *  更新管理员角色
      * @return array|\yii\db\ActiveRecord[]

+ 2 - 1
common/helpers/PayStack.php

@@ -57,8 +57,9 @@ class PayStack
 
     /**
      * 交易退款.
-     * @param string $transaction
+     * @param string $reference
      * @param int $amount
+     * @return array
      */
     public static function transactionRefund(string $reference, int $amount)
     {

+ 13 - 0
common/helpers/Tool.php

@@ -9,6 +9,7 @@
 namespace common\helpers;
 
 
+use Faker\Provider\Uuid;
 use yii\base\Exception;
 use yii\helpers\Url;
 use yii\httpclient\Client;
@@ -453,4 +454,16 @@ class Tool {
         }
         return $prefix.$random_string;
     }
+
+    /**
+     * 生成UUID
+     * @param $upper boolean 是否大写
+     * @param $symbol string 替换符号
+     * @return string|string[]
+     */
+    public static function generateId(bool $upper = true, string $symbol = '')
+    {
+        $uuid = !$upper ? Uuid::uuid() : strtoupper(Uuid::uuid());
+        return str_replace('-', $symbol, $uuid);
+    }
 }

+ 239 - 161
common/helpers/bonus/BonusCalc.php

@@ -10,6 +10,7 @@ namespace common\helpers\bonus;
 
 use common\helpers\Cache;
 use common\helpers\Date;
+use common\helpers\LoggerTool;
 use common\helpers\snowflake\SnowFake;
 use common\helpers\Tool;
 use common\models\CalcBonus;
@@ -20,6 +21,7 @@ use common\models\CalcBonusCF;
 use common\models\CalcBonusFL;
 use common\models\CalcBonusFW;
 use common\models\CalcBonusFX;
+use common\models\CalcBonusGarage;
 use common\models\CalcBonusGL;
 use common\models\CalcBonusGX;
 use common\models\CalcBonusHB;
@@ -28,11 +30,11 @@ use common\models\CalcBonusLX;
 use common\models\CalcBonusQY;
 use common\models\CalcBonusStandard;
 use common\models\CalcBonusTG;
+use common\models\CalcBonusTourism;
 use common\models\CalcBonusVIP;
 use common\models\CalcBonusXF;
 use common\models\CalcBonusYC;
 use common\models\CalcBonusYJ;
-use common\models\CalcBonusZone;
 use common\models\CalcMonthBonusUser;
 use common\models\Config;
 use common\models\FlowDeductZR;
@@ -47,6 +49,7 @@ use common\models\EmployLevel;
 use common\models\FlowBonus;
 use common\models\PerfActiveUser;
 use common\models\ScoreMonth;
+use common\models\StarCrownLevel;
 use common\models\User;
 use common\models\UserInfo;
 use common\models\UserPerf;
@@ -68,6 +71,7 @@ class BonusCalc extends BaseObject {
     private $_sysConfig = [];
     private $_decLevelConfig = [];
     private $_empLevelConfig = [];
+    private $_starCrownLevelConfig = [];
     private $_decRoleConfig = [];
     private $_errors = [];
     private $_periodNum = 0;
@@ -182,15 +186,17 @@ class BonusCalc extends BaseObject {
             $this->_updatePercent(5);
             $t3 = microtime(true);
             $this->_updatePercent(10);
-            // 奖金部分
-            if($this->_sysConfig['openFW']['VALUE']) {
-                $this->calcBonusBDStepOne();
-                $this->calcBonusBDStepTwo();
-            }
+
+//            // 奖金部分
+//            if($this->_sysConfig['openFW']['VALUE']) {
+//                $this->calcBonusBDStepOne();
+//                $this->calcBonusBDStepTwo();
+//            }
             $t4 = microtime(true);
-            echo('计算服务奖'.($this->_sysConfig['openFW']['VALUE']?'完成':'关闭').',耗时:' . round($t4 - $t3, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(15);
+//            echo('计算服务奖'.($this->_sysConfig['openFW']['VALUE']?'完成':'关闭').',耗时:' . round($t4 - $t3, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+//            $this->_updatePercent(15);
 
+            // 销售奖/推广奖
             if($this->_sysConfig['openTG']['VALUE']) {
                 $this->calcBonusTG();
             }
@@ -198,117 +204,114 @@ class BonusCalc extends BaseObject {
             echo('计算推广奖'.($this->_sysConfig['openTG']['VALUE']?'完成':'关闭').',耗时:' . round($t5 - $t4, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(20);
 
-            if($this->_sysConfig['openXF']['VALUE']) {
-                if( $this->_sysConfig['consumeRecPercent']['VALUE'] > 0 ) {
-                    $this->calcBonusXFToRec();
-                }
-                if( $this->_sysConfig['consumeSelfPercent']['VALUE'] > 0 ) {
-                    $this->calcBonusXFToSelf();
-                }
-            }
-            $t6 = microtime(true);
-            echo('计算消费奖'.($this->_sysConfig['openXF']['VALUE']?'完成':'关闭').',耗时:' . round($t6 - $t5, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(25);
-
-            if($this->_sysConfig['openYJ']['VALUE']) {
-                $this->calcBonusBdYJ();
-            }
-            $t7 = microtime(true);
-            echo('计算报单业绩奖'.($this->_sysConfig['openYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(30);
-
-            if($this->_sysConfig['fxOpenYJ']['VALUE']) {
-                $this->calcBonusFxYJ();
-            }
+//            if($this->_sysConfig['openXF']['VALUE']) {
+//                if( $this->_sysConfig['consumeRecPercent']['VALUE'] > 0 ) {
+//                    $this->calcBonusXFToRec();
+//                }
+//                if( $this->_sysConfig['consumeSelfPercent']['VALUE'] > 0 ) {
+//                    $this->calcBonusXFToSelf();
+//                }
+//            }
+//            $t6 = microtime(true);
+//            echo('计算消费奖'.($this->_sysConfig['openXF']['VALUE']?'完成':'关闭').',耗时:' . round($t6 - $t5, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+//            $this->_updatePercent(25);
+//
+//            if($this->_sysConfig['openYJ']['VALUE']) {
+//                $this->calcBonusBdYJ();
+//            }
+//            $t7 = microtime(true);
+//            echo('计算报单业绩奖'.($this->_sysConfig['openYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t7 - $t6, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+//            $this->_updatePercent(30);
+//
+//            if($this->_sysConfig['fxOpenYJ']['VALUE']) {
+//                $this->calcBonusFxYJ();
+//            }
             $t8 = microtime(true);
-            echo('计算复消业绩奖'.($this->_sysConfig['fxOpenYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t8 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(35);
-
+//            echo('计算复消业绩奖'.($this->_sysConfig['fxOpenYJ']['VALUE']?'完成':'关闭').',耗时:' . round($t8 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+//            $this->_updatePercent(35);
 
+            // 绩效奖/团队奖
             if($this->_sysConfig['openQY']['VALUE']) {
                 $this->calcBonusQY();
-                $this->calcBonusBdQY();
-                $this->calcBonusFxQY();
+//                $this->calcBonusBdQY();
+//                $this->calcBonusFxQY();
             }
             $t9 = microtime(true);
             echo('计算团队奖'.($this->_sysConfig['openQY']['VALUE']?'完成':'关闭').',耗时:' . round($t9 - $t8, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(65);
 
-            if($this->_sysConfig['openGX']['VALUE']) {
-                $this->calcBonusGXBefore();
-                $this->calcBonusGX();
-            }
-            $t11 = microtime(true);
-            echo('计算共享奖'.($this->_sysConfig['openGX']['VALUE']?'完成':'关闭').',耗时:' . round($t11 - $t9, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(68);
-
-            if($this->_sysConfig['openGL']['VALUE']) {
-                $this->calcBonusBdGL();
-            }
-            $t13 = microtime(true);
-            echo('计算报单管理奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t13 - $t11, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(50);
-
+//            if($this->_sysConfig['openGX']['VALUE']) {
+//                $this->calcBonusGXBefore();
+//                $this->calcBonusGX();
+//            }
+//            $t11 = microtime(true);
+//            echo('计算共享奖'.($this->_sysConfig['openGX']['VALUE']?'完成':'关闭').',耗时:' . round($t11 - $t9, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+//            $this->_updatePercent(68);
+//
+//            if($this->_sysConfig['openGL']['VALUE']) {
+//                $this->calcBonusBdGL();
+//            }
+//            $t13 = microtime(true);
+//            echo('计算报单管理奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t13 - $t11, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+//            $this->_updatePercent(50);
+//
 //            if($this->_sysConfig['fxOpenGL']['VALUE']) {
 //                $this->calcBonusFxGL();
 //            }
 //            $t14 = microtime(true);
 //            echo('计算复消管理奖'.($this->_sysConfig['fxOpenGL']['VALUE']?'完成':'关闭').',耗时:' . round($t14 - $t13, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
 //            $this->_updatePercent(70);
+//
+//            if($this->_sysConfig['openYC']['VALUE']) {
+//                $this->calcBonusYCStepOne();
+//                $this->calcBonusYCStepTwo();
+//            }
+//            $t16 = microtime(true);
+//            echo('计算荣衔奖'.($this->_sysConfig['openYC']['VALUE']?'完成':'关闭').',耗时:' . round($t16 - $t13, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+//            $this->_updatePercent(55);
+//
+//            if($this->_sysConfig['openVIP']['VALUE']) {
+//                $this->calcBonusVIP();
+//            }
+//            $t17 = microtime(true);
+//            echo('计算VIP奖'.($this->_sysConfig['openVIP']['VALUE']?'完成':'关闭').',耗时:' . round($t17 - $t16, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+//            $this->_updatePercent(60);
+//
+//            if($this->_sysConfig['openJXS']['VALUE']) {
+//                $this->calcBonusStandard();
+//            }
+//            $t18 = microtime(true);
+//            echo('计算达标奖'.($this->_sysConfig['openJXS']['VALUE']?'完成':'关闭').',耗时:' . round($t18 - $t17, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+//            $this->_updatePercent(65);
 
-            if($this->_sysConfig['openYC']['VALUE']) {
-                $this->calcBonusYCStepOne();
-                $this->calcBonusYCStepTwo();
-            }
-            $t16 = microtime(true);
-            echo('计算荣衔奖'.($this->_sysConfig['openYC']['VALUE']?'完成':'关闭').',耗时:' . round($t16 - $t13, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(55);
-
-            if($this->_sysConfig['openVIP']['VALUE']) {
-                $this->calcBonusVIP();
-            }
-            $t17 = microtime(true);
-            echo('计算VIP奖'.($this->_sysConfig['openVIP']['VALUE']?'完成':'关闭').',耗时:' . round($t17 - $t16, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(60);
-
-            if($this->_sysConfig['openJXS']['VALUE']) {
-                $this->calcBonusStandard();
-            }
-            $t18 = microtime(true);
-            echo('计算达标奖'.($this->_sysConfig['openJXS']['VALUE']?'完成':'关闭').',耗时:' . round($t18 - $t17, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(65);
-
+            $t19 = microtime(true);
             // 蓝星奖入库,实际上是插入有奖金会员数据缓存中.
+            echo('计算蓝星奖开始,' . date('Y-m-d H:i:s', $t19) . PHP_EOL);
             // 调用存储过程,计算蓝星管理奖金
             $this->calcBsProcedure();
             // 将有【蓝星业绩奖金】的用户加入到有奖金缓存用户中
             $this->calcBonusBsYJ();
             // 将有【蓝星管理奖金】的用户加入到有奖金缓存用户中
             $this->calcBonusBsGL();
-            $t18temp = microtime(true);
-            echo('计算蓝星奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t18temp - $t18, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            $this->_updatePercent(65);
-
-            $this->calcBonusZoneBS($this->_sysConfig['openTravel']);
-            $t18travel = microtime(true);
-            echo('计算旅游奖' . ($this->_sysConfig['openTravel']['VALUE'] ? '完成' : '关闭') . ',耗时:' . round($t18travel - $t18temp, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $t20 = microtime(true);
+            echo('计算蓝星奖'.($this->_sysConfig['openGL']['VALUE']?'完成':'关闭').',耗时:' . round($t20 - $t19, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(67);
 
-            $this->calcBonusZoneBS($this->_sysConfig['openCar']);
-            $t18car = microtime(true);
-            echo('计算名车奖' . ($this->_sysConfig['openCar']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t18car - $t18travel, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->calcBonusTourism($this->_sysConfig['openTourism']);
+            $t21 = microtime(true);
+            echo('计算旅游奖' . ($this->_sysConfig['openTourism']['VALUE'] ? '完成' : '关闭') . ',耗时:' . round($t21 - $t20, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(68);
 
-            $this->calcBonusZoneBS($this->_sysConfig['openHouse']);
-            $t18house = microtime(true);
-            echo('计算豪宅奖' . ($this->_sysConfig['openHouse']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t18house - $t18car, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->calcBonusGarage($this->_sysConfig['openGarage']);
+            $t22 = microtime(true);
+            echo('计算车房奖' . ($this->_sysConfig['openGarage']['VALUE'] ? '完成' : '关闭').',耗时:' . round($t22 - $t21, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL . PHP_EOL);
             $this->_updatePercent(69);
 
 
             //把奖金会员写入缓存
             $this->loopMonthBonusUserFromDbToCache();
-            $t19 = microtime(true);
-            echo('奖金会员写入缓存完成,耗时:' . round($t19 - $t18, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $t30 = microtime(true);
+            echo('奖金会员写入缓存完成,耗时:' . round($t30 - $t22, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(70);
 
             //奖金写库
@@ -318,31 +321,29 @@ class BonusCalc extends BaseObject {
             $this->loopCalcBlueEmpLv();
             $this->_updatePercent(75);
             unset($calcWrite);
-            $t20 = microtime(true);
-            echo('奖金写库操作完成,耗时:' . round($t20 - $t19, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $t31 = microtime(true);
+            echo('奖金写库操作完成,耗时:' . round($t31 - $t30, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
 
             //把本期奖金会员入库 - 把缓存中的月奖用户信息存到数据库.存储过程的入库不在这里进行,这里代码取的缓存,存储过程没有缓存,在上面进行入库
             $this->loopMonthBonusUserToDb();
-            $t21 = microtime(true);
-            echo('奖金会员入库完成,耗时:' . round($t21 - $t20, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $t32 = microtime(true);
+            echo('奖金会员入库完成,耗时:' . round($t32 - $t31, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(80);
 
             // 计算基础积分,不可以奖金入库之前计算这样可能会丢掉只有本期的奖金的会员
-//            $this->calcBaseScore();
-//            $this->_updatePercent(90);
-//            $t22 = microtime(true);
-//            echo('计算基础积分,耗时:' . round($t22 - $t21, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $this->calcBaseScore();
+            $this->_updatePercent(90);
+            $t33 = microtime(true);
+            echo('计算基础积分,耗时:' . round($t33 - $t32, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
 
             //积分入库
-//            $this->loopWriteScore();
-//            $this->_updatePercent(100);
-//            $t23 = microtime(true);
-//            echo('积分写库操作完成,耗时:' . round($t23 - $t22, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-
-            //@todo 计算房产奖
+            $this->loopWriteScore();
+            $this->_updatePercent(100);
+            $t34 = microtime(true);
+            echo('积分写库操作完成,耗时:' . round($t34 - $t33, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
 
-            $t30 = microtime(true);
-            echo('结算全部完成,共耗时:' . round($t30 - $t1, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            $t35 = microtime(true);
+            echo('结算全部完成,共耗时:' . round($t35 - $t34, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL . PHP_EOL);
         } catch (\Exception $e) {
             $this->errorCalcTask();
             $this->addError('calc', $e->getMessage());
@@ -377,6 +378,7 @@ class BonusCalc extends BaseObject {
         $this->_sysConfig = Cache::getSystemConfig();
         $this->_decLevelConfig = Cache::getDecLevelConfig();
         $this->_empLevelConfig = Cache::getEmpLevelConfig();
+        $this->_starCrownLevelConfig = Cache::getStarCrownLevelConfig();
         $this->_decRoleConfig = CalcCache::getDecRoleConfig($this->_periodNum);
         $periodNum = $this->_periodNum;
         // 获取本年月和上年月
@@ -444,7 +446,8 @@ class BonusCalc extends BaseObject {
             CalcBonusVIP::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
             CalcBonusStandard::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
             ScoreMonth::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
-            CalcBonusZone::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
+            CalcBonusTourism::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
+            CalcBonusGarage::pageDeleteAll('PERIOD_NUM='.$this->_periodNum);
         }
     }
 
@@ -1206,6 +1209,7 @@ class BonusCalc extends BaseObject {
                     'perfArr' => $perfArr,
                     'touchBonus' => 0,
                 ];
+
                 // 获取会员的报单级别
                 $userBaseInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
                 $decLevelConfig = $this->_decLevelConfig;
@@ -1226,7 +1230,7 @@ class BonusCalc extends BaseObject {
                 if ($touchBonusArr['touchBonus'] <= 0) continue;
 
                 $teamBonus = $touchBonusArr['touchBonus'];
-                //判断级别上限
+                //判断级别上限,个人奖金封顶限制
                 $teamBonus = $this->declarationLevelCap($teamBonus, $userId, $userBaseInfo['DEC_LV']);
                 if( $teamBonus <= 0 ) continue;
 
@@ -1239,12 +1243,20 @@ class BonusCalc extends BaseObject {
                 // 把对碰后的奖金存入缓存中
                 CalcCache::bonus($userId, $periodNum, 'BONUS_QY', $teamBonus, $deductData);
 
+                // TODO:取小腿值
+                $payLeg = max([$perfArr['SURPLUS_1L'], $perfArr['SURPLUS_2L']]);
+                // 计算荣衔星级
+                $starCrown = StarCrownLevel::getStarCrown($payLeg);
+                // 星级放入缓存
+                CalcCache::addUserStartCrown($userId, $periodNum, $starCrown['ID']);
+
                 //团队奖流水
                 $insertBonusData[] = [
                     'ID' => SnowFake::instance()->generateId(),
                     'USER_ID' => $userId,
                     'LAST_DEC_LV' => $userBaseInfo['DEC_LV'],
                     'LAST_EMP_LV' => $userBaseInfo['EMP_LV'],
+                    'LAST_STAR_LV' => $starCrown['ID'],
                     'LAST_STATUS' => $userBaseInfo['STATUS'],
                     'AMOUNT' => $deductData['surplus'],
                     'ORI_BONUS' => $teamBonus,
@@ -1261,7 +1273,6 @@ class BonusCalc extends BaseObject {
                         'touchPerfArr' => $touchPerfArr,
                         'nowDecLevelConfig' => $nowDecLevelConfig,
                         'decLevel' => $userBaseInfo['DEC_LV'],
-
                     ]),
                 ];
 
@@ -1632,8 +1643,8 @@ class BonusCalc extends BaseObject {
         return $result;
     }
 
-    // 执行旅游奖、名车奖、豪宅奖的计算
-    public function calcBonusZoneBS(array $bonusConfig) {
+    // 执行旅游奖的计算
+    public function calcBonusTourism(array $bonusConfig) {
         // 月结,如果不是月结点,则直接退出
         if (!$this->_isCalcMonth) {
             return true;
@@ -1662,38 +1673,105 @@ class BonusCalc extends BaseObject {
         $userBonusData = CalcBonusBS::find()
             ->yearMonth($this->_calcYearMonth)
             ->where('CALC_MONTH=:CALC_MONTH', [':CALC_MONTH' => $this->_calcYearMonth])
-            ->select('USER_ID,LEVEL_ID,LAST_DEC_LV,LAST_EMP_LV,LAST_STATUS,RECONSUME_POINTS')
+            ->select('USER_ID,LEVEL_ID,LAST_DEC_LV,LAST_EMP_LV,LAST_STATUS')
             ->groupBy('USER_ID')
             ->asArray()
             ->all();
 
-        // 获奖会员数
-        $userBonusNumber = count($userBonusData);
-        if (!$userBonusNumber) {
-            return true;
+        $insertBonusData = [];
+        foreach($userBonusData as $userBonus) {
+            // TODO:基于绩效奖,获取会员starCrown级别,计算奖金
+            $startCrownPoint = (mt_rand(10, 75) / 10) / 100;
+            $amount = Tool::formatPrice(($monthTotalPV * $mate) * $startCrownPoint);
+            if ($amount <= 0) {
+                continue;
+            }
+
+            // 会员级别+聘级都达到要求才会发放奖金
+            if (in_array($userBonus['LAST_DEC_LV'], $minDecLevel) && in_array($userBonus['LEVEL_ID'], $minEmpLevel)) {
+                // 放入缓存
+                CalcCache::tourismBonus($userBonus['USER_ID'], $this->_periodNum, $amount);
+                // 加入月奖的会员
+                CalcCache::addHasMonthBonusUsers($userBonus['USER_ID'], $this->_periodNum);
+            }
+
+            $insertBonusData[] = [
+                'ID' => SnowFake::instance()->generateId(),
+                'USER_ID' => $userBonus['USER_ID'],
+                'LEVEL_ID' => $userBonus['LEVEL_ID'],
+                'LAST_DEC_LV' => $userBonus['LAST_DEC_LV'],
+                'LAST_EMP_LV' => $userBonus['LAST_EMP_LV'],
+                'LAST_STATUS' => $userBonus['LAST_STATUS'],
+                'AMOUNT' => $amount,
+                'PERIOD_NUM' => $this->_periodNum,
+                'CALC_YEAR' => $this->_calcYear,
+                'CALC_MONTH' => $this->_calcYearMonth,
+                'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
+                'CREATED_AT' => Date::nowTime(),
+            ];
+        }
+
+        // 数据写入总表
+        if ($insertBonusData) {
+            CalcBonusTourism::batchInsert($insertBonusData);
         }
 
-        // 计算奖金:(公司月总PV * 奖金比) / 得奖人数
-        $amount = Tool::formatPrice(($monthTotalPV  * $mate) / $userBonusNumber);
-        if ($amount <= 0) {
+        return true;
+    }
+
+    // 执行车房奖的计算
+    public function calcBonusGarage($bonusConfig) {
+        // 月结,如果不是月结点,则直接退出
+        if (!$this->_isCalcMonth) {
             return true;
         }
 
-        // 奖金标识
-        if ($bonusConfig['CONFIG_NAME'] == 'openTravel') {
-            $bonusCacheKey = 'calc:travel:bonus_';
-        } else if ($bonusConfig['CONFIG_NAME'] == 'openCar') {
-            $bonusCacheKey = 'calc:car:bonus_';
-        } else {
-            $bonusCacheKey = 'calc:house:bonus_';
+        // 达标条件:聘级、级别、奖项比例
+        $config = json_decode($bonusConfig['OPTIONS'], true);
+        // 奖金总比例
+        $mate = $bonusConfig['VALUE'] / 100;
+        // 会员级别
+        $minDecLevel = $config['OPTIONS']['declarationLevel'] ?? [];
+        // 会员聘级
+        $minEmpLevel = $config['OPTIONS']['employLevel'] ?? [];
+        // 个人奖金封顶
+        $capBonus = intval($this->_sysConfig['openGarageCap']['VALUE'] ?? 0);
+
+        // 月度公司总PV
+        $monthTotalPV = PerfMonth::find()
+            ->yearMonth($this->_calcYearMonth)
+            ->where('CALC_MONTH=:CALC_MONTH', [':CALC_MONTH' => $this->_calcYearMonth])
+            ->sum('PV_PCS');
+
+        if ($monthTotalPV <= 0) {
+            return true;
         }
 
+        // 基于蓝星奖结果计算符合获奖条件的会员
+        $userBonusData = CalcBonusBS::find()
+            ->yearMonth($this->_calcYearMonth)
+            ->where('CALC_MONTH=:CALC_MONTH', [':CALC_MONTH' => $this->_calcYearMonth])
+            ->select('USER_ID,LEVEL_ID,LAST_DEC_LV,LAST_EMP_LV,LAST_STATUS,RECONSUME_POINTS')
+            ->groupBy('USER_ID')
+            ->asArray()
+            ->all();
+
         $insertBonusData = [];
         foreach($userBonusData as $userBonus) {
+            // TODO:基于绩效奖,获取会员starCrown级别,计算奖金
+            $startCrownPoint = mt_rand(1, 10) / 100;
+            $amount = Tool::formatPrice(($monthTotalPV * $mate) * $startCrownPoint);
+            if ($amount <= 0) {
+                continue;
+            }
+
+            // 奖金数不能大于封顶值
+            $amount = ($amount > $capBonus) ? $capBonus : $amount;
+
             // 会员级别+聘级都达到要求才会发放奖金
             if (in_array($userBonus['LAST_DEC_LV'], $minDecLevel) && in_array($userBonus['LEVEL_ID'], $minEmpLevel)) {
                 // 放入缓存
-                CalcCache::zoneBonus($userBonus['USER_ID'], $this->_periodNum, $bonusCacheKey, $amount);
+                CalcCache::garageBonus($userBonus['USER_ID'], $this->_periodNum, $amount);
                 // 加入月奖的会员
                 CalcCache::addHasMonthBonusUsers($userBonus['USER_ID'], $this->_periodNum);
             }
@@ -1711,13 +1789,12 @@ class BonusCalc extends BaseObject {
                 'CALC_MONTH' => $this->_calcYearMonth,
                 'P_CALC_MONTH' => Date::ociToDate($this->_calcYearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH),
                 'CREATED_AT' => Date::nowTime(),
-                'BONUS_TYPE' => $bonusConfig['CONFIG_NAME'],
             ];
         }
 
         // 数据写入总表
         if ($insertBonusData) {
-            CalcBonusZone::batchInsert($insertBonusData);
+            CalcBonusGarage::batchInsert($insertBonusData);
         }
 
         return true;
@@ -3312,15 +3389,15 @@ class BonusCalc extends BaseObject {
                         ':PERIOD_NUM' => $this->_periodNum
                     ]
                 );
-                // 共享奖流水
-                CalcBonusGX::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', 
-                    [
-                        ':USER_ID' => $data['USER_ID'],
-                        ':PERIOD_NUM' => $this->_periodNum
-                    ]
-                );
+//                // 共享奖流水
+//                CalcBonusGX::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',
+//                    [
+//                        ':USER_ID' => $data['USER_ID'],
+//                        ':PERIOD_NUM' => $this->_periodNum
+//                    ]
+//                );
                 // 推广奖流水
-                CalcBonusTG::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', 
+                CalcBonusTG::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',
                     [
                         ':USER_ID' => $data['USER_ID'],
                         ':PERIOD_NUM' => $this->_periodNum
@@ -3333,32 +3410,32 @@ class BonusCalc extends BaseObject {
                         ':PERIOD_NUM' => $this->_periodNum
                     ]
                 );
-                // 服务奖流水
-                CalcBonusBD::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', 
-                    [
-                        ':USER_ID' => $data['USER_ID'],
-                        ':PERIOD_NUM' => $this->_periodNum
-                    ]
-                );
-                // 更新form的聘级
-                CalcBonusGX::updateAll(['LAST_FROM_EMP_LV' => $nowBsEmpLv], 'FROM_USER_ID=:FROM_USER_ID AND PERIOD_NUM=:PERIOD_NUM', 
-                    [
-                        ':FROM_USER_ID' => $data['USER_ID'],
-                        ':PERIOD_NUM' => $this->_periodNum
-                    ]
-                );
-                CalcBonusTG::updateAll(['LAST_FROM_EMP_LV' => $nowBsEmpLv], 'FROM_USER_ID=:FROM_USER_ID AND PERIOD_NUM=:PERIOD_NUM', 
-                    [
-                        ':FROM_USER_ID' => $data['USER_ID'],
-                        ':PERIOD_NUM' => $this->_periodNum
-                    ]
-                );
-                CalcBonusBD::updateAll(['LAST_FROM_EMP_LV' => $nowBsEmpLv], 'FROM_USER_ID=:FROM_USER_ID AND PERIOD_NUM=:PERIOD_NUM', 
+//                // 服务奖流水
+//                CalcBonusBD::updateAll(['LAST_EMP_LV' => $nowBsEmpLv], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',
+//                    [
+//                        ':USER_ID' => $data['USER_ID'],
+//                        ':PERIOD_NUM' => $this->_periodNum
+//                    ]
+//                );
+//                // 更新form的聘级
+//                CalcBonusGX::updateAll(['LAST_FROM_EMP_LV' => $nowBsEmpLv], 'FROM_USER_ID=:FROM_USER_ID AND PERIOD_NUM=:PERIOD_NUM',
+//                    [
+//                        ':FROM_USER_ID' => $data['USER_ID'],
+//                        ':PERIOD_NUM' => $this->_periodNum
+//                    ]
+//                );
+                CalcBonusTG::updateAll(['LAST_FROM_EMP_LV' => $nowBsEmpLv], 'FROM_USER_ID=:FROM_USER_ID AND PERIOD_NUM=:PERIOD_NUM',
                     [
                         ':FROM_USER_ID' => $data['USER_ID'],
                         ':PERIOD_NUM' => $this->_periodNum
                     ]
                 );
+//                CalcBonusBD::updateAll(['LAST_FROM_EMP_LV' => $nowBsEmpLv], 'FROM_USER_ID=:FROM_USER_ID AND PERIOD_NUM=:PERIOD_NUM',
+//                    [
+//                        ':FROM_USER_ID' => $data['USER_ID'],
+//                        ':PERIOD_NUM' => $this->_periodNum
+//                    ]
+//                );
             }
             unset($allData);
             return $this->loopCalcBlueEmpLv($offset + $this->_limit);
@@ -3379,14 +3456,15 @@ class BonusCalc extends BaseObject {
         $standardBonus = CalcCache::standardBonus($userId, $this->_periodNum);
         $baseInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
         $perfData = CalcCache::nowPeriodPerf($userId, $this->_periodNum);
-        $travelBonus = CalcCache::zoneBonus($userId, $this->_periodNum, CalcCache::REDIS_KEY_PREFIX_TRAVEL_BONUS);
-        $carBonus = CalcCache::zoneBonus($userId, $this->_periodNum, CalcCache::REDIS_KEY_PREFIX_CAR_BONUS);
-        $houseBonus = CalcCache::zoneBonus($userId, $this->_periodNum, CalcCache::REDIS_KEY_PREFIX_HOUSE_BONUS);
+        $tourismBonus = CalcCache::tourismBonus($userId, $this->_periodNum);
+        $garageBonus = CalcCache::garageBonus($userId, $this->_periodNum);
         $empLv = $baseInfo['EMP_LV'];
 //        if($this->_isCalcMonth){
 //            $empLv = $this->nowMonthPerfData($userId)['LAST_EMP_LV'];
 //        }
         $pervSurplusPerf = CalcCache::surplusPerf($userId, $this->_periodNum);
+        // 星级
+        $starCrownLv = CalcCache::getUserStartCrown($userId, $this->_periodNum);
 
         // //没有共享和管理奖 以前的管理奖和共享奖逻辑
         // $bonusReal = $bonus['BONUS_BD'] + $bonus['BONUS_TG'] + $bonus['BONUS_XF'] + $bonus['BONUS_YJ'] + $bonus['BONUS_QY'] + $bonus['BONUS_YC'] + $bonus['BONUS_YC_EXTRA'] + $bonus['BONUS_VIP'] + $standardBonus;
@@ -3487,6 +3565,7 @@ class BonusCalc extends BaseObject {
             'LAST_REAL_NAME' => $baseInfo['REAL_NAME'],
             'LAST_DEC_LV' => $baseInfo['DEC_LV'],
             'LAST_EMP_LV' => $empLv,
+            'LAST_STAR_LV' => $starCrownLv ?? StarCrownLevel::getDefaultLevelId(),
             'LAST_STATUS' => $baseInfo['STATUS'],
             'LAST_MOBILE' => $baseInfo['MOBILE'],
             'LAST_PERIOD_AT' => $baseInfo['PERIOD_NUM'],
@@ -3553,9 +3632,8 @@ class BonusCalc extends BaseObject {
             'ORI_BONUS_VIP' => $bonus['ORI_BONUS_VIP'],
             'ORI_BONUS_STANDARD' => $standardBonus,
 
-            'BONUS_TRAVEL' => $travelBonus, // 旅游奖
-            'BONUS_CAR' => $carBonus, // 名车奖
-            'BONUS_HOUSE' => $houseBonus, // 豪宅奖
+            'BONUS_TOURISM' => $tourismBonus, // 旅游奖
+            'BONUS_GARAGE' => $garageBonus, // 车房奖
 
             //以下没有用
             'BONUS_FW' => 0,

+ 61 - 21
common/helpers/bonus/BonusSend.php

@@ -22,6 +22,7 @@ use common\models\DealType;
 use common\models\PerfPeriod;
 use common\models\DecOrder;
 use common\models\EmployLevel;
+use common\models\StarCrownLevel;
 use common\models\UserBonus;
 use common\models\UserPerfMonthUpdate;
 use common\models\UserPeriodPoints;
@@ -142,6 +143,13 @@ class BonusSend extends BaseObject {
             $this->_updatePercent(40);
             $t4 = microtime(true);
             echo('更新聘级完成,耗时:' . round($t4 - $t3, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+
+            // 更新星级
+            $this->updateStarLevel();
+            $this->_updatePercent(50);
+            $t41 = microtime(true);
+            echo('更新星级完成,耗时:' . round($t41 - $t4, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+
             // 发放奖金
             $this->sendBonusLoop();
             $this->_updatePercent(60);
@@ -348,37 +356,25 @@ class BonusSend extends BaseObject {
                     }
 
                     // 旅游奖
-                    if ($data['BONUS_TRAVEL'] > 0) {
-                        Balance::changeUserBonus($data['USER_ID'], 'travel_points', $data['BONUS_TRAVEL'], [
+                    if ($data['BONUS_TOURISM'] > 0) {
+                        Balance::changeUserBonus($data['USER_ID'], 'tourism_points', $data['BONUS_TOURISM'], [
                             'CALC_ID' => $data['ID'],
                             'REMARK' => 'From ' . $periodNum . '期',
                             'PERIOD_NUM' => $periodNum,
-                            'TRAVEL' => $data['BONUS_TRAVEL'],
-                            'DEAL_TYPE_ID' => DealType::TRAVEL_SEND,
+                            'TRAVEL' => $data['BONUS_TOURISM'],
+                            'DEAL_TYPE_ID' => DealType::TOURISM_SEND,
                             'SORT' => $key * 10,
                             'BONUS_ISSUE' => true,
                         ]);
                     }
-                    // 车奖
-                    if ($data['BONUS_CAR'] > 0) {
-                        Balance::changeUserBonus($data['USER_ID'], 'car_points', $data['BONUS_CAR'], [
+                    // 车
+                    if ($data['BONUS_GARAGE'] > 0) {
+                        Balance::changeUserBonus($data['USER_ID'], 'garage_points', $data['BONUS_GARAGE'], [
                             'CALC_ID' => $data['ID'],
                             'REMARK' => 'From ' . $periodNum . '期',
                             'PERIOD_NUM' => $periodNum,
-                            'HOUSE' => $data['BONUS_CAR'],
-                            'DEAL_TYPE_ID' => DealType::CAR_SEND,
-                            'SORT' => $key * 10,
-                            'BONUS_ISSUE' => true,
-                        ]);
-                    }
-                    // 豪宅奖
-                    if ($data['BONUS_HOUSE'] > 0) {
-                        Balance::changeUserBonus($data['USER_ID'], 'house_points', $data['BONUS_HOUSE'], [
-                            'CALC_ID' => $data['ID'],
-                            'REMARK' => 'From ' . $periodNum . '期',
-                            'PERIOD_NUM' => $periodNum,
-                            'HOUSE' => $data['BONUS_HOUSE'],
-                            'DEAL_TYPE_ID' => DealType::HOUSE_SEND,
+                            'HOUSE' => $data['BONUS_GARAGE'],
+                            'DEAL_TYPE_ID' => DealType::GARAGE_SEND,
                             'SORT' => $key * 10,
                             'BONUS_ISSUE' => true,
                         ]);
@@ -486,6 +482,50 @@ class BonusSend extends BaseObject {
         return true;
     }
 
+    /**
+     * 更新用户星级
+     * @param int $offset
+     * @return bool
+     */
+    public function updateStarLevel(int $offset = 0)
+    {
+        $allData = CalcBonusQY::findUseDbCalc()
+            ->yearMonth($this->_calcYearMonth)
+            ->where(
+                'CALC_MONTH=:CALC_MONTH AND PERIOD_NUM=:PERIOD_NUM',
+                [
+                    ':CALC_MONTH' => $this->_calcYearMonth,
+                    ':PERIOD_NUM' =>$this->_periodNum
+                ]
+            )
+            ->orderBy('CREATED_AT DESC')
+            ->groupBy('USER_ID')
+            ->offset($offset)
+            ->limit($this->_limit)
+            ->all();
+
+        if ($allData) {
+            $transaction = Yii::$app->db->beginTransaction();
+            try {
+                foreach ($allData as $data) {
+                    User::updateAll(['STAR_LV' => $data['LAST_STAR_LV']], 'ID = :USER_ID', [':USER_ID' => $data['USER_ID']]);
+                    User::deleteBaseInfoFromRedis($data['USER_ID']);
+                    unset($data);
+                }
+                $transaction->commit();
+            } catch (Exception $e) {
+                $transaction->rollBack();
+                $this->addError('updateStarCrownLevel', '更新星级失败,原因:' . $e->getMessage());
+                return false;
+            }
+            unset($transaction, $allData);
+            return $this->updateStarLevel($offset + $this->_limit);
+        }
+        unset($allData);
+
+        return true;
+    }
+
     // /**
     //  * 更新会员聘级
     //  * @param int $offset

+ 60 - 6
common/helpers/bonus/CalcCache.php

@@ -19,6 +19,7 @@ use common\models\Period;
 use common\models\DeclarationLevel;
 use common\models\DecRole;
 use common\models\EmployLevel;
+use common\models\StarCrownLevel;
 use common\models\User;
 use common\models\UserBonus;
 use common\models\UserNetwork;
@@ -49,9 +50,8 @@ class CalcCache {
     const REDIS_KEY_PREFIX_STANDARD_BONUS = 'calc:standard:bonus_';
     const REDIS_KEY_PREFIX_YC_BONUS = 'calc:yc:bonus_';
     const REDIS_KEY_PREFIX_FW_BONUS = 'calc:fw:bonus_';
-    const REDIS_KEY_PREFIX_TRAVEL_BONUS = 'calc:travel:bonus_';
-    const REDIS_KEY_PREFIX_CAR_BONUS = 'calc:car:bonus_';
-    const REDIS_KEY_PREFIX_HOUSE_BONUS = 'calc:house:bonus_';
+    const REDIS_KEY_PREFIX_TOURISM_BONUS = 'calc:tourism:bonus_';
+    const REDIS_KEY_PREFIX_GARAGE_BONUS = 'calc:garage:bonus_';
     const REDIS_KEY_PREFIX_HAS_PERF_USER = 'calc:hasPerfUser_';
     const REDIS_KEY_PREFIX_HAS_MONTH_PERF_USER = 'calc:hasMonthPerfUser_';
     const REDIS_KEY_PREFIX_HAS_STANDARD_MONTH_PERF_USER = 'calc:hasStandardMonthPerfUser_';
@@ -86,6 +86,7 @@ class CalcCache {
     const REDIS_KEY_PREFIX_GX_BONUS_DEEP_TWO_LIST_DATA = 'calc:gxBonusDeepTwoListData_';
     const REDIS_KEY_PREFIX_YC_BONUS_LIST_DATA = 'calc:ycBonusListData_';
     const REDIS_KEY_PREFIX_FW_BONUS_LIST_DATA = 'calc:fwBonusListData_';
+    const REDIS_KEY_PREFIX_BONUS_STAR_CROWN_LIST_DATA = 'calc:bonusStarCrownListData_';
 
     //@todo
     const REDIS_KEY_PREFIX_REPAIR_SURPLUS_PERF = 'calc:repairSurplusPerf_';
@@ -142,6 +143,7 @@ class CalcCache {
         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);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_BONUS_STAR_CROWN_LIST_DATA . $periodNum);
     }
 
     /**
@@ -208,6 +210,7 @@ class CalcCache {
         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);
+        Yii::$app->redis->del(self::REDIS_KEY_PREFIX_BONUS_STAR_CROWN_LIST_DATA . $periodNum);
     }
 
     /**
@@ -601,6 +604,32 @@ class CalcCache {
         return $userYcBonusData ? Json::decode($userYcBonusData, true) : [];
     }
 
+    /**
+     * 会员星级加入缓存
+     * @param $userId
+     * @param $periodNum
+     * @param $starCrown
+     */
+    public static function addUserStartCrown($userId, $periodNum, $starCrown) {
+        // 先从已存在的会员池里面获取
+        $data = Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_BONUS_STAR_CROWN_LIST_DATA . $periodNum, $userId);
+        if (!$data) {
+            Yii::$app->redis->hset(self::REDIS_KEY_PREFIX_BONUS_STAR_CROWN_LIST_DATA . $periodNum, $userId, $starCrown);
+        }
+
+        unset($userId, $periodNum, $saveData, $isset);
+    }
+
+    /**
+     * 获取会员星级信息
+     * @param $userId
+     * @param $periodNum
+     * @return array
+     */
+    public static function getUserStartCrown($userId, $periodNum) {
+        return Yii::$app->redis->hget(self::REDIS_KEY_PREFIX_BONUS_STAR_CROWN_LIST_DATA . $periodNum, $userId);
+    }
+
     /**
      * 加入有复销业绩的会员列表
      * @param $userId
@@ -765,7 +794,7 @@ class CalcCache {
                 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();
+            $userShopInfo = User::find()->select('REAL_NAME,LAST_DEC_LV,DEC_LV,EMP_LV,STAR_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);
             }
@@ -774,6 +803,7 @@ class CalcCache {
             //先用last_dec_lv
             $userInfo['DEC_LV'] = $userShopInfo['LAST_DEC_LV'];
             $userInfo['EMP_LV'] = $userShopInfo['EMP_LV'];
+            $userInfo['STAR_LV'] = $userShopInfo['STAR_LV'];
             $userInfo['IS_DEC'] = $userShopInfo['IS_DEC'];
             $userInfo['DEC_ID'] = $userShopInfo['DEC_ID'];
             $userInfo['DEC_ROLE_ID'] = $userShopInfo['DEC_ROLE_ID'];
@@ -812,6 +842,9 @@ class CalcCache {
             if (!$userInfo['EMP_LV']) {
                 $userInfo['EMP_LV'] = EmployLevel::getDefaultLevelId();
             }
+            if (!$userInfo['STAR_LV']) {
+                $userInfo['STAR_LV'] = StarCrownLevel::getDefaultLevelId();
+            }
             $data = Json::encode($userInfo);
             Yii::$app->redis->hset($key, $userId, $data);
             unset($userInfo, $key, $userId, $periodNum);
@@ -1543,8 +1576,29 @@ class CalcCache {
         return $value;
     }
 
-    public static function zoneBonus($userId, $periodNum, $bonusCacheKey, $bonus = 0.00) {
-        $cacheKey = $bonusCacheKey . $periodNum;
+    public static function tourismBonus($userId, $periodNum, $bonus = 0.00) {
+        $cacheKey = self::REDIS_KEY_PREFIX_TOURISM_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;
+    }
+
+    public static function garageBonus($userId, $periodNum, $bonus = 0.00) {
+        $cacheKey = self::REDIS_KEY_PREFIX_GARAGE_BONUS . $periodNum;
 
         $value = 0.00;
         if( $bonus > 0 ) {

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

@@ -131,6 +131,7 @@ class PerfCalc {
             echo('初始化、清空缓存及相关数据表完成,耗时:' . round($t2 - $t1, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(10);
             // 计算月奖,才需要向缓存中加入按推荐深度的所有用户
+            echo('向缓存中加入用户开始 ' . date('Y-m-d  H:i:s', time()) . PHP_EOL);
             //修改每一期都缓存所有用户
             CalcCache::addUsers($this->_periodNum);
             $t3 = microtime(true);
@@ -188,7 +189,7 @@ class PerfCalc {
             $this->_updatePercent(100);
             $t10 = microtime(true);
 
-            echo('业绩结算全部完成,共耗时:' . round($t10 - $t9, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
+            echo('业绩结算全部完成,共耗时:' . round($t10 - $t9, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL . PHP_EOL);
         } catch (\Exception $e) {
             $this->errorCalcTask();
             $this->addError('calc', $e->getMessage());

+ 52 - 47
common/helpers/user/Balance.php

@@ -15,9 +15,10 @@ use common\helpers\Form;
 use common\libs\lock\RedisLock;
 use common\models\FlowBonus;
 use common\models\FlowCF;
+use common\models\FlowGaragePoints;
 use common\models\FlowLX;
 use common\models\FlowReconsumePoints;
-use common\models\FlowZonePoints;
+use common\models\FlowTourismPoints;
 use common\models\InvoiceFlow;
 use common\models\Period;
 use common\models\DeclarationLevel;
@@ -43,9 +44,8 @@ class Balance {
     const CF_BALANCE_LOCK_KEY = 'CF';
     const LX_BALANCE_LOCK_KEY = 'LX';
     const INVOICE_BALANCE_LOCK_KEY = 'Invoice';
-    const TRAVEL_POINTS_BALANCE_LOCK_KEY = 'travelPoints';
-    const CAR_POINTS_BALANCE_LOCK_KEY = 'carPoints';
-    const HOUSE_POINTS_BALANCE_LOCK_KEY = 'housePoints';
+    const TOURISM_POINTS_BALANCE_LOCK_KEY = 'tourismPoints';
+    const GARAGE_POINTS_BALANCE_LOCK_KEY = 'garagePoints';
 
     const BALANCE_TYPE = [
         'exchange' => [
@@ -54,22 +54,16 @@ class Balance {
             'attr'  => 'EXCHANGE_POINTS',
             'pv'    => false,
         ],
-        'travel_points' => [
-            'id'    => 'travel_points',
+        'tourism_points' => [
+            'id'    => 'tourism_points',
             'title' => '旅游积分',
-            'attr'  => 'TRAVEL_POINTS',
+            'attr'  => 'TOURISM_POINTS',
             'pv'    => false,
         ],
-        'car_points' => [
-            'id'    => 'car_points',
-            'title' => '名车积分',
-            'attr'  => 'CAR_POINTS',
-            'pv'    => false,
-        ],
-        'house_points' => [
-            'id'    => 'house_points',
-            'title' => '豪宅积分',
-            'attr'  => 'HOUSE_POINTS',
+        'garage_points' => [
+            'id'    => 'garage_points',
+            'title' => '车房积分',
+            'attr'  => 'GARAGE_POINTS',
             'pv'    => false,
         ],
     ];
@@ -213,6 +207,26 @@ class Balance {
         }
     }
 
+    /**
+     * 获取当前旅游积分余额
+     * @param $userId
+     * @return int|mixed
+     */
+    public static function getBalanceTourism($userId) {
+        $oneData = UserBonus::find()->where('USER_ID=:USER_ID', [':USER_ID' => $userId])->asArray()->one();
+        return $oneData['TOURISM_POINTS'] ?? 0;
+    }
+
+    /**
+     * 获取当前车房余额
+     * @param $userId
+     * @return int|mixed
+     */
+    public static function getBalanceGarage($userId) {
+        $oneData = UserBonus::find()->where('USER_ID=:USER_ID', [':USER_ID' => $userId])->asArray()->one();
+        return $oneData['GARAGE_POINTS'] ?? 0;
+    }
+
     /**
      * 查询会员账户余额.
      * @param $userId
@@ -266,14 +280,11 @@ class Balance {
             case 'LX':
                 $lockKey = self::LX_BALANCE_LOCK_KEY . $userId;
                 break;
-            case 'TRAVEL_POINTS':
-                $lockKey = self::TRAVEL_POINTS_BALANCE_LOCK_KEY . $userId;
+            case 'TOURISM_POINTS':
+                $lockKey = self::TOURISM_POINTS_BALANCE_LOCK_KEY . $userId;
                 break;
-            case 'CAR_POINTS':
-                $lockKey = self::CAR_POINTS_BALANCE_LOCK_KEY . $userId;
-                break;
-            case 'HOUSE_POINTS':
-                $lockKey = self::HOUSE_POINTS_BALANCE_LOCK_KEY . $userId;
+            case 'GARAGE_POINTS':
+                $lockKey = self::GARAGE_POINTS_BALANCE_LOCK_KEY . $userId;
                 break;
             default:
                 throw new Exception('流水类型错误');
@@ -336,14 +347,11 @@ class Balance {
                 if (isset($params['BS_ABBR'])) {
                     $paramData['BS_ABBR_TOTAL'] = new Expression('BS_ABBR_TOTAL + ' . ($issueBonus ? $params['BS_ABBR'] * $exchangeRate : $params['BS_ABBR']));
                 }
-                if (isset($params['TRAVEL_POINTS'])) {
-                    $paramData['TRAVEL_POINTS_TOTAL'] = new Expression('TRAVEL_POINTS_TOTAL + ' . ($issueBonus ? $params['TRAVEL_POINTS'] * $exchangeRate : $params['TRAVEL_POINTS']));
-                }
-                if (isset($params['CAR_POINTS'])) {
-                    $paramData['CAR_POINTS_TOTAL'] = new Expression('CAR_POINTS_TOTAL + ' . ($issueBonus ? $params['CAR_POINTS'] * $exchangeRate : $params['CAR_POINTS']));
+                if (isset($params['TOURISM_POINTS'])) {
+                    $paramData['TOURISM_POINTS_TOTAL'] = new Expression('TOURISM_POINTS_TOTAL + ' . $params['TOURISM_POINTS']);
                 }
-                if (isset($params['HOUSE_POINTS'])) {
-                    $paramData['HOUSE_POINTS_TOTAL'] = new Expression('HOUSE_POINTS_TOTAL + ' . ($issueBonus ? $params['HOUSE_POINTS'] * $exchangeRate : $params['HOUSE_POINTS']));
+                if (isset($params['GARAGE_POINTS'])) {
+                    $paramData['GARAGE_POINTS_TOTAL'] = new Expression('GARAGE_POINTS_TOTAL + '.$params['GARAGE_POINTS']);
                 }
                 if (isset($params['RECONSUME_POINTS_TOTAL'])) {
                     $paramData['RECONSUME_POINTS_TOTAL'] = new Expression('RECONSUME_POINTS_TOTAL + ' . ($issueBonus ? $params['RECONSUME_POINTS_TOTAL'] * $exchangeRate : $params['RECONSUME_POINTS_TOTAL']));
@@ -464,16 +472,12 @@ class Balance {
                 if (isset($params['BS_ABBR'])) {
                     $paramData['BS_ABBR_TOTAL'] = ($issueBonus ? $params['BS_ABBR'] * $exchangeRate : $params['BS_ABBR']);
                 }
-                if (isset($params['TRAVEL_POINTS'])) {
-                    $paramData['TRAVEL_POINTS_TOTAL'] = ($issueBonus ? $params['TRAVEL_POINTS'] * $exchangeRate : $params['TRAVEL_POINTS']);
-                }
-                if (isset($params['CAR_POINTS'])) {
-                    $paramData['CAR_POINTS_TOTAL'] = ($issueBonus ? $params['CAR_POINTS'] * $exchangeRate : $params['CAR_POINTS']);
+                if (isset($params['TOURISM_POINTS'])) {
+                    $paramData['TOURISM_POINTS_TOTAL'] = $params['TOURISM_POINTS'];
                 }
-                if (isset($params['HOUSE_POINTS'])) {
-                    $paramData['HOUSE_POINTS_TOTAL'] = ($issueBonus ? $params['HOUSE_POINTS'] * $exchangeRate : $params['HOUSE_POINTS']);
+                if (isset($params['GARAGE_POINTS'])) {
+                    $paramData['GARAGE_POINTS_TOTAL'] = $params['GARAGE_POINTS'];
                 }
-
                 if (isset($params['RECONSUME_POINTS_TOTAL'])) {
 //                    $paramData['RECONSUME_POINTS_TOTAL'] = new Expression('RECONSUME_POINTS_TOTAL + '.$params['RECONSUME_POINTS_TOTAL']);
                     $paramData['RECONSUME_POINTS_TOTAL'] = ($issueBonus ? $params['RECONSUME_POINTS_TOTAL'] * $exchangeRate : $params['RECONSUME_POINTS_TOTAL']);
@@ -594,15 +598,16 @@ class Balance {
                     self::deductPeriodExchangePoints($userId, abs($amount));
                 }
                 FlowExchangePoints::insertOne($flowInsertData);
-//            } elseif (strtolower($type) == 'cf') {
-//                FlowCF::insertOne($flowInsertData);
-//            } elseif (strtolower($type) == 'lx') {
-//                FlowLX::insertOne($flowInsertData);
-            } elseif (in_array(strtolower($type), ['travel_points', 'car_points', 'house_points'])) {
-                // 这3个奖流水在一个表,需要加二级标识码
-                $flowInsertData['WALLET_TYPE'] = strtolower($type);
-                FlowZonePoints::insertOne($flowInsertData);
+            } elseif (strtolower($type) == 'cf') {
+                FlowCF::insertOne($flowInsertData);
+            } elseif (strtolower($type) == 'lx') {
+                FlowLX::insertOne($flowInsertData);
+            } elseif (strtolower($type) == 'tourism_points') {
+                FlowTourismPoints::insertOne($flowInsertData);
+            } elseif (strtolower($type) == 'garage_points') {
+                FlowGaragePoints::insertOne($flowInsertData);
             }
+
             unset($flowInsertData);
             RedisLock::instance()->unlock($lockKey);
         } else {

+ 1 - 0
common/libs/logging/operate/valueType/Config.php

@@ -16,6 +16,7 @@ class Config{
     const AREA_TYPE = 'area';
     const EMP_LV_TYPE = 'emp_lv';
     const DEC_LV_TYPE = 'dec_lv';
+    const STAR_LV_TYPE = 'star_lv';
     const DEC_ROLE_ID_TYPE = 'dec_role_id';
     const USER_SYSTEM_TYPE = 'user_system';
     const STATUS_TYPE = 'status';

+ 5 - 9
common/models/BalanceAudit.php

@@ -54,17 +54,13 @@ class BalanceAudit extends \common\components\ActiveRecord
 //            'name' => 'lx',
 //            'label' => '领袖分红奖余额',
 //        ],
-        'travel_points' => [
-            'name' => 'travel_points',
+        'tourism_points' => [
+            'name' => 'tourism_points',
             'label' => '旅游积分',
         ],
-        'car_points' => [
-            'name' => 'car_points',
-            'label' => '名车积分',
-        ],
-        'house_points' => [
-            'name' => 'house_points',
-            'label' => '豪宅积分',
+        'garage_points' => [
+            'name' => 'garage_points',
+            'label' => '车房积分',
         ],
     ];
 

+ 9 - 9
common/models/CalcBonus.php

@@ -13,6 +13,7 @@ use Yii;
  * @property string $LAST_REAL_NAME 结算时会员姓名
  * @property string $LAST_DEC_LV 结算时会员级别
  * @property string $LAST_EMP_LV 结算时会员聘级
+ * @property string $LAST_STAR_LV 结算时会员星级
  * @property int $LAST_STATUS 结算时状态
  * @property string $LAST_MOBILE 结算时手机号码
  * @property int $LAST_PERIOD_AT 结算时加入期数
@@ -103,9 +104,8 @@ use Yii;
  * @property string $MANAGE_TAX 管理费 
  * @property string $BONUS_BS 蓝星奖金(即新的管理奖)
  * @property string $ORI_BONUS_BS 蓝星原奖金(即新的管理奖,原奖金)
- * @property string $BONUS_TRAVEL 旅游奖奖金
- * @property string $BONUS_CAR 名车奖奖金
- * @property string $BONUS_HOUSE 豪宅奖奖金
+ * @property string $BONUS_TOURISM 旅游奖奖金
+ * @property string $BONUS_GARAGE 车房奖奖金
  */
 class CalcBonus extends \common\components\ActiveRecord
 {
@@ -125,8 +125,8 @@ class CalcBonus extends \common\components\ActiveRecord
         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', 'BONUS_TRAVEL', 'BONUS_CAR', 'BONUS_HOUSE'], 'number'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_SUB_COM_ID', 'LAST_SYSTEM_ID'], 'string', 'max' => 32],
+            [['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', 'BONUS_TOURISM', 'BONUS_GARAGE'], 'number'],
+            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_SUB_COM_ID', 'LAST_SYSTEM_ID', 'LAST_STAR_LV'], '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],
@@ -147,6 +147,7 @@ class CalcBonus extends \common\components\ActiveRecord
             'LAST_REAL_NAME' => '结算时会员姓名',
             'LAST_DEC_LV' => '结算时会员级别',
             'LAST_EMP_LV' => '结算时会员聘级',
+            'LAST_STAR_LV' => '结算时会员星级',
             'LAST_STATUS' => '结算时状态',
             'LAST_MOBILE' => '结算时手机号码',
             'LAST_PERIOD_AT' => '结算时加入期数',
@@ -241,9 +242,8 @@ class CalcBonus extends \common\components\ActiveRecord
             'ORI_BONUS_BS_MNT' => '蓝星管理奖原奖金',
             'BONUS_BS_ABBR' => '蓝星业绩奖',
             'ORI_BONUS_BS_ABBR' => '蓝星业绩奖原奖金',
-            'BONUS_TRAVEL' => '旅游奖奖金',
-            'BONUS_CAR' => '名车奖奖金',
-            'BONUS_HOUSE' => '豪宅奖奖金',
+            'BONUS_TOURISM' => '旅游奖奖金',
+            'BONUS_GARAGE' => '车房奖奖金',
         ];
     }
 
@@ -259,7 +259,7 @@ class CalcBonus extends \common\components\ActiveRecord
         $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();
+            $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,BONUS_TOURISM,BONUS_GARAGE')->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;
     }

+ 4 - 6
common/models/CalcBonusZone.php → common/models/CalcBonusGarage.php

@@ -5,7 +5,7 @@ namespace common\models;
 use Yii;
 
 /**
- * This is the model class for table "{{%CALC_BONUS_ZONE}}".
+ * This is the model class for table "{{%CALC_BONUS_GARAGE}}".
  *
  * @property string $ID
  * @property string $USER_ID 会员ID
@@ -19,16 +19,15 @@ use Yii;
  * @property string $P_CALC_MONTH 表分区的日期索引
  * @property string $LOGS 日志
  * @property int $CREATED_AT 创建时间
- * @property string $BONUS_TYPE 奖金类型
  */
-class CalcBonusZone extends \common\components\ActiveRecord
+class CalcBonusGarage extends \common\components\ActiveRecord
 {
     /**
      * @inheritdoc
      */
     public static function tableName()
     {
-        return '{{%CALC_BONUS_ZONE}}';
+        return '{{%CALC_BONUS_GARAGE}}';
     }
 
     /**
@@ -37,7 +36,7 @@ class CalcBonusZone extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT', 'BONUS_TYPE'], 'required'],
+            [['USER_ID', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
             [['AMOUNT'], 'number'],
             [['LAST_STATUS', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
             [['ID', 'USER_ID', 'LAST_DEC_LV', 'BONUS_TYPE'], 'string', 'max' => 32],
@@ -65,7 +64,6 @@ class CalcBonusZone extends \common\components\ActiveRecord
             'P_CALC_MONTH' => '表分区的日期索引',
             'CREATED_AT' => '创建时间',
             'LOGS' => '日志',
-            'BONUS_TYPE' => '奖金类型',
         ];
     }
 }

+ 2 - 1
common/models/CalcBonusQY.php

@@ -41,7 +41,7 @@ class CalcBonusQY extends \common\components\ActiveRecord
             [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
             [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
             [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV'], 'string', 'max' => 32],
+            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_STAR_LV'], 'string', 'max' => 32],
             [['LOGS'], 'string', 'max' => 2000],
             [['ID'], 'unique'],
         ];
@@ -57,6 +57,7 @@ class CalcBonusQY extends \common\components\ActiveRecord
             'USER_ID' => '会员ID',
             'LAST_DEC_LV' => '结算时会员级别',
             'LAST_EMP_LV' => '结算时会员聘级',
+            'LAST_STAR_LV' => '结算时会员星级',
             'LAST_STATUS' => '结算时状态',
             'AMOUNT' => '金额',
             'PERIOD_NUM' => '结算期数',

+ 69 - 0
common/models/CalcBonusTourism.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%CALC_BONUS_TOURISM}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 会员ID
+ * @property string $LAST_DEC_LV 结算时会员级别
+ * @property string $LAST_EMP_LV 结算时会员聘级
+ * @property int $LAST_STATUS 结算时状态
+ * @property string $AMOUNT 奖金金额
+ * @property int $PERIOD_NUM 结算期数
+ * @property int $CALC_YEAR 所在结算年
+ * @property int $CALC_MONTH 所在结算月
+ * @property string $P_CALC_MONTH 表分区的日期索引
+ * @property string $LOGS 日志
+ * @property int $CREATED_AT 创建时间
+ */
+class CalcBonusTourism extends \common\components\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%CALC_BONUS_TOURISM}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
+            [['AMOUNT'], 'number'],
+            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
+            [['ID', 'USER_ID', 'LAST_DEC_LV', 'BONUS_TYPE'], 'string', 'max' => 32],
+            [['P_CALC_MONTH'], 'safe'],
+            [['LOGS'], 'string', 'max' => 2000],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'USER_ID' => '会员ID',
+            'LAST_DEC_LV' => '结算时会员级别',
+            'LAST_EMP_LV' => '结算时会员聘级',
+            'LAST_STATUS' => '结算时状态',
+            'AMOUNT' => '奖金金额',
+            'PERIOD_NUM' => '结算期数',
+            'CALC_YEAR' => '所在结算年',
+            'CALC_MONTH' => '所在结算月',
+            'P_CALC_MONTH' => '表分区的日期索引',
+            'CREATED_AT' => '创建时间',
+            'LOGS' => '日志',
+        ];
+    }
+}

+ 6 - 9
common/models/DealType.php

@@ -47,15 +47,12 @@ class DealType extends \common\components\ActiveRecord
     CONST DEDUCT_LOGOUT = 'A1F1E76F34EE4981AB3BF4F8D20BB53E';//注销扣除
     CONST RECONSUME_POINTS_EXCHANGE = 'YA627DTHN81OBO7NIQ1OP8N3PGZX5C66';//复消积分兑换
     CONST EXCHANGE_POINTS_EXCHANGE = '316872011148300288';//兑换积分兑换
-    CONST TRAVEL_SEND = '364305038266470400';// 旅游奖奖金发放
-    CONST CAR_SEND = '364305160249413632';// 名车奖奖金发放
-    CONST HOUSE_SEND = '364305230252347392';// 豪宅奖奖金发放
-    CONST TRAVEL_POINTS_EXCHANGE = '365343018452127744'; // 旅游积分兑换
-    CONST CAR_POINTS_EXCHANGE = '365343060634243072'; // 名车积分兑换
-    CONST HOUSE_POINTS_EXCHANGE = '365343108638052352'; // 豪宅积分兑换
-    CONST TRAVEL_POINTS_ADJUST = '365753533326299136'; // 旅游积分余额调整
-    CONST CAR_POINTS_ADJUST = '365753643942678528'; // 名车积分余额调整
-    CONST HOUSE_POINTS_ADJUST = '365753716726435840'; // 豪宅积分余额调整
+    CONST TOURISM_SEND = '364305038266470400';// 旅游奖奖金发放
+    CONST GARAGE_SEND = '364305160249413632';// 车房奖奖金发放
+    CONST TOURISM_POINTS_EXCHANGE = '365343018452127744'; // 旅游积分兑换
+    CONST GARAGE_POINTS_EXCHANGE = '365343060634243072'; // 车房积分兑换
+    CONST TOURISM_POINTS_ADJUST = '365753533326299136'; // 旅游积分余额调整
+    CONST GARAGE_POINTS_ADJUST = '365753643942678528'; // 车房积分余额调整
 
     /**
      * {@inheritdoc}

+ 4 - 1
common/models/EmployLevel.php

@@ -32,10 +32,11 @@ use yii\helpers\Json;
  * @property int $MIN_EMPLOY_NUM 最小聘级的数量
  * @property string $LEVEL_SCORE 级别分数
  * @property string $UPGRADE_SCORE 升级分数
+ * @property string $TOURISM_PERCENT 旅游奖比例
+ * @property string $GARAGE_PERCENT 车房奖比例
  */
 class EmployLevel extends \common\components\ActiveRecord
 {
-
     const NO_LEVEL_ID = '67BE1C6C21F81B32E055736AECE8644D';
     const JX_ZR_LEVEL_ID = 'E121497617216708615';
     const SHX_ZJ_LEVEL_ID = '99BE5FE7857C216AE000223AECE8644D';
@@ -133,6 +134,8 @@ class EmployLevel extends \common\components\ActiveRecord
             'OTHER_DEPART_PERF' => '去除最大部门,其它部门累计推荐业绩',
             'LEVEL_SCORE' => '级别分数',
             'UPGRADE_SCORE' => '升级分数',
+            'TOURISM_PERCENT' => '旅游奖比例',
+            'GARAGE_PERCENT' => '车房奖比例',
         ];
     }
 

+ 3 - 3
common/models/FlowZonePoints.php → common/models/FlowGaragePoints.php

@@ -5,7 +5,7 @@ namespace common\models;
 use Yii;
 
 /**
- * This is the model class for table "{{%FLOW_ZONE_POINTS}}".
+ * This is the model class for table "{{%FLOW_GARAGE_POINTS}}".
  *
  * @property string $ID
  * @property string $USER_ID 会员ID
@@ -24,7 +24,7 @@ use Yii;
  * @property int $SORT 排序
  * @property string $TRANSFER_SN 转账流水号
  */
-class FlowZonePoints extends \common\components\ActiveRecord
+class FlowGaragePoints extends \common\components\ActiveRecord
 {
     const INCR_REDUCE = 0;      // 减少
     const INCR_ADD = 1;         // 增加
@@ -36,7 +36,7 @@ class FlowZonePoints extends \common\components\ActiveRecord
      */
     public static function tableName()
     {
-        return '{{%FLOW_ZONE_POINTS}}';
+        return '{{%FLOW_GARAGE_POINTS}}';
     }
 
     /**

+ 81 - 0
common/models/FlowTourismPoints.php

@@ -0,0 +1,81 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%FLOW_TOURISM_POINTS}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 会员ID
+ * @property string $CALC_ID 奖金结算表ID
+ * @property string $AMOUNT 金额
+ * @property string $TOTAL 当前总金额
+ * @property int $IS_INCR 是否增加
+ * @property string $REMARK 备注
+ * @property string $ADMIN_NAME 操作人名称
+ * @property int $PERIOD_NUM 所在期数
+ * @property int $CALC_MONTH 所在结算月
+ * @property string $P_MONTH 表分区的日期索引
+ * @property int $CREATED_AT 创建时间
+ * @property int $DELETED 是否删除
+ * @property int $DELETED_AT 删除时间
+ * @property int $SORT 排序
+ * @property string $TRANSFER_SN 转账流水号
+ */
+class FlowTourismPoints extends \common\components\ActiveRecord
+{
+    const INCR_REDUCE = 0;      // 减少
+    const INCR_ADD = 1;         // 增加
+    const INCR_FREEZE = 2;      // 冻结
+    const INCR_UNFREEZE = 3;    // 解冻
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%FLOW_TOURISM_POINTS}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'REMARK', 'PERIOD_NUM', 'CALC_MONTH', 'P_MONTH', 'CREATED_AT'], 'required'],
+            [['AMOUNT', 'TOTAL'], 'number'],
+            [['IS_INCR', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT', 'DELETED', 'DELETED_AT', 'SORT'], 'integer'],
+            [['ID', 'USER_ID', 'CALC_ID', 'ADMIN_NAME', 'TRANSFER_SN'], 'string', 'max' => 32],
+            [['REMARK'], 'string', 'max' => 255],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'USER_ID' => '会员ID',
+            'CALC_ID' => '结算表ID',
+            'AMOUNT' => '交易金额',
+            'TOTAL' => '当前总金额',
+            'IS_INCR' => '是否增加',
+            'REMARK' => '备注',
+            'ADMIN_NAME' => '操作人名称',
+            'PERIOD_NUM' => '所在期数',
+            'CALC_MONTH' => '所在结算月',
+            'P_MONTH' => '表分区的日期索引',
+            'CREATED_AT' => '创建时间',
+            'DELETED' => '是否删除',
+            'DELETED_AT' => '删除时间',
+            'SORT' => '排序',
+            'TRANSFER_SN' => '转账流水号',
+        ];
+    }
+}

+ 18 - 33
common/models/ShopGoods.php

@@ -42,25 +42,20 @@ class ShopGoods extends \common\components\ActiveRecord
 //            'id' => 2,
 //            'name' => '复消兑换',
 //        ],
-        3 => [
-            'id' => 3,
-            'name' => 'Bonus points', //兑换点数
-            'label' => 'exchange',
-        ],
+//        3 => [
+//            'id' => 3,
+//            'name' => '兑换点数',
+//            'label' => 'exchange',
+//        ],
         4 => [
             'id' => 4,
-            'name' => 'Travel bonus', //旅游积分
-            'label' => 'travel_points',
+            'name' => '旅游积分',
+            'label' => 'tourism_points',
         ],
         5 => [
             'id' => 5,
-            'name' => 'Car bonus',//名车积分
-            'label' => 'car_points',
-        ],
-        6 => [
-            'id' => 6,
-            'name' => 'House bonus',//豪宅积分
-            'label' => 'house_points',
+            'name' => '车房积分',
+            'label' => 'garage_points',
         ],
         7 => [
             'id' => 7,
@@ -102,7 +97,7 @@ class ShopGoods extends \common\components\ActiveRecord
             'name' => 'Common products',//普通商品
             'sell_type' => [
                 self::SALE_TYPE[1],
-                self::SALE_TYPE[3],
+//                self::SALE_TYPE[3],
                 self::SALE_TYPE[7],
             ]
         ],
@@ -115,18 +110,11 @@ class ShopGoods extends \common\components\ActiveRecord
         ],
         [
             'id' => 5,
-            'name' => 'Car bonus products',//名车积分商品
+            'name' => '车积分商品',
             'sell_type' => [
                 self::SALE_TYPE[5]
             ]
         ],
-        [
-            'id' => 6,
-            'name' => 'House bonus products',//豪宅积分商品
-            'sell_type' => [
-                self::SALE_TYPE[6]
-            ]
-        ],
     ];
     /**
      * @inheritdoc
@@ -227,17 +215,14 @@ class ShopGoods extends \common\components\ActiveRecord
             'point'=>[
                 'name'=>'积分支付' //积分支付
             ],
-            'exchange' => [
-                'name' => '积分点数' //积分点数
-            ],
-            'travel_points'=>[
-                'name'=>'旅游积分' //旅游积分
-            ],
-            'car_points'=>[
-                'name'=>'名车积分' //名车积分
+//            'exchange' => [
+//                'name' => '积分点数'
+//            ],
+            'tourism_points'=>[
+                'name'=>'旅游积分'
             ],
-            'house_points' => [
-                'name' => '豪宅积分'
+            'garage_points' => [
+                'name' => '车房积分'
             ],
             'pay_stack' => [
                 'name' => 'PayStack'

+ 245 - 0
common/models/StarCrownLevel.php

@@ -0,0 +1,245 @@
+<?php
+
+namespace common\models;
+
+use common\helpers\Cache;
+use common\helpers\LoggerTool;
+use Yii;
+
+/**
+ * This is the model class for table "{{%STAR_LEVEL}}".
+ *
+ * @property string $ID
+ * @property string $LEVEL_NAME 级别名称
+ * @property int $ICON_TYPE 图标类型
+ * @property int $ICON_NUM 图标个数
+ * @property int $RX_PERCENT 图标个数
+ * @property string $MIN_LEVEL_ID 上级ID
+ * @property string $LEVEL_SCORE 级别分数
+ * @property string $UPGRADE_SCORE 升级分数
+ * @property string $TOURISM_PERCENT 旅游奖比例
+ * @property string $GARAGE_PERCENT 车房奖比例
+ * @property int $SORT 排序
+ * @property int $CREATED_AT 创建时间
+ * @property int $UPDATED_AT 更新时间
+ * @property string $CREATE_ADMIN 创建人
+ * @property string $UPDATE_ADMIN 更新人
+ */
+class StarCrownLevel extends \common\components\ActiveRecord
+{
+    const NO_LEVEL_ID = 'DCBEDD8E0EAD3DF59D81CCC0C2ACAEFF';
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%STAR_LEVEL}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['LEVEL_NAME', 'CREATED_AT', 'CREATE_ADMIN'], 'required'],
+            [['SORT', 'CREATED_AT', 'UPDATED_AT', 'ICON_TYPE', 'ICON_NUM'], 'integer'],
+            [['LEVEL_SCORE', 'UPGRADE_SCORE', 'TOURISM_PERCENT', 'GARAGE_PERCENT'], 'number'],
+            [['ID', 'MIN_LEVEL_ID', 'CREATE_ADMIN', 'UPDATE_ADMIN'], 'string', 'max' => 32],
+            [['LEVEL_NAME'], 'string', 'max' => 20],
+            [['LEVEL_NAME'], 'unique'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'LEVEL_NAME' => '级别名称',
+            'SORT' => '排序',
+            'CREATED_AT' => '创建时间',
+            'UPDATED_AT' => '更新时间',
+            'CREATE_ADMIN' => '创建人',
+            'UPDATE_ADMIN' => '更新人',
+            'ICON_TYPE' => '图标类型',
+            'ICON_NUM' => '图标个数',
+            'MIN_LEVEL_ID' => '上级ID',
+            'LEVEL_SCORE' => '级别分数',
+            'UPGRADE_SCORE' => '升级分数',
+            'TOURISM_PERCENT' => '旅游奖比例',
+            'GARAGE_PERCENT' => '车房奖比例',
+        ];
+    }
+
+    /**
+     * 获取全部级别以数字索引的方式展现
+     * @return array|\yii\db\ActiveRecord[]
+     */
+    public static function getAllDataWithNumIndex()
+    {
+        return static::find()->where('1=1')->orderBy('SORT ASC, CREATED_AT ASC')->indexBy('SORT')->asArray()->all();
+    }
+
+    /**
+     * 获取全部配置
+     * @return array|\yii\db\ActiveRecord[]
+     */
+    public static function getAllData()
+    {
+        return static::find()->where('1=1')->orderBy('SORT ASC, CREATED_AT ASC')->indexBy('ID')->asArray()->all();
+    }
+
+    // 获取级别配置一维度数组,id为键,级别等级为值
+    public static function getIdConvertLevelSort()
+    {
+        $ret = [];
+        $allData = static::find()->where('1=1')->orderBy('SORT ASC, CREATED_AT ASC')->indexBy('ID')->asArray()->all();
+        foreach($allData as $data) {
+            $ret[$data['ID']] = $data['LEVEL_SORT'];
+        }
+        return $ret;
+    }
+
+    /**
+     * 从缓存获取信息
+     * @return array|mixed|\yii\db\ActiveRecord[]
+     */
+    public static function getIdConvertLevelSortCache()
+    {
+        $key = Cache::STAR_LEVEL_CONFIG_KEY . ':idsort';
+        $data = Yii::$app->cache->get($key);
+        if(!$data){
+            // 获取信息
+            $data = self::getIdConvertLevelSort();
+            Yii::$app->cache->set($key, $data);
+        }
+
+        return $data;
+    }
+
+    /**
+     * 从缓存获取信息
+     * @return array|mixed|\yii\db\ActiveRecord[]
+     */
+    public static function getFromCache()
+    {
+        $data = Yii::$app->cache->get(Cache::STAR_LEVEL_CONFIG_KEY);
+        if(!$data){
+            // 获取信息
+            $data = self::getAllData();
+            Yii::$app->cache->set(Cache::STAR_LEVEL_CONFIG_KEY, $data);
+        }
+        return $data;
+    }
+
+    /**
+     *  更新缓存
+     * @return array|\yii\db\ActiveRecord[]
+     */
+    public static function updateToCache()
+    {
+        // 获取配置
+        $data = self::getAllData();
+        Yii::$app->cache->set(Cache::STAR_LEVEL_CONFIG_KEY, $data);
+        return $data;
+    }
+
+    /**
+     * 通过排序获取级别
+     * @param int $sort
+     * @return mixed
+     */
+    public static function getLevelFromSort(int $sort)
+    {
+        static $starLevels;
+        if(!$starLevels){
+            $starLevels = self::getFromCache();
+            $starLevels = array_column($starLevels, null, 'sort');
+        }
+        return $starLevels[$sort];
+    }
+
+    /**
+     * 通过排序获取ID
+     * @param int $sort
+     * @return mixed
+     */
+    public static function getIdFromSort(int $sort)
+    {
+        $level = self::getLevelFromSort($sort);
+        return $level['ID'];
+    }
+
+    /**
+     * 获取默认级别
+     * @return mixed
+     */
+    public static function getDefaultLevelId()
+    {
+        return self::NO_LEVEL_ID;
+    }
+
+    /**
+     * 获取星级的排序
+     * @param $id
+     * @return mixed
+     */
+    public static function getSortById($id)
+    {
+        $starLevels = self::getFromCache();
+        return $starLevels[$id]['SORT'] ?? 0;
+    }
+
+    /**
+     * 通过ID获取星级名称
+     * @param $levelId
+     * @return mixed'
+     */
+    public static function getNameById($levelId)
+    {
+        return self::findOneAsArray('ID = :ID', [':ID' => $levelId])['LEVEL_NAME'] ?? '';
+    }
+
+    /**
+     * 奖金参数
+     */
+    public static function getBonusConfig(){
+        $allData = self::getAllData();
+        $data = [];
+        foreach ($allData as $value) {
+            $data[$value['ID']]['label'] = $value['LEVEL_NAME'];
+            $data[$value['ID']]['value'] = '【旅游奖】拿奖比例' . $value['TOURISM_PERCENT'] . '%,' . '【车房奖】拿奖比例' . $value['GARAGE_PERCENT'] . '%';
+        }
+        return $data;
+    }
+
+    /**
+     * 根据业绩计算星级
+     * @param $payLeg
+     * @return array|mixed|\yii\db\ActiveRecord
+     */
+    public static function getStarCrown($payLeg)
+    {
+        $starCrown = [];
+        $allData = self::getAllData();
+        // 最大边界值
+        $maxData = end($allData);
+        if ($payLeg >= $maxData) {
+            return $maxData;
+        }
+
+        foreach ($allData as $item) {
+            if (($payLeg >= $item['LEVEL_SCORE']) && ($payLeg < $item['UPGRADE_SCORE'])) {
+                $starCrown = $item;
+                break;
+            }
+        }
+
+        return $starCrown ?: $allData[self::NO_LEVEL_ID];
+    }
+}

+ 72 - 0
common/models/StarCrownLevelForm.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace common\models;
+
+use common\components\Model;
+use common\helpers\Form;
+use common\libs\logging\operate\AdminOperate;
+use common\models\DeclarationLevel;
+use common\models\StarCrownLevel;
+
+/**
+ * Login form
+ */
+class StarCrownLevelForm extends Model
+{
+
+    public function init()
+    {
+        parent::init();
+        $this->adminOperateLogger = new AdminOperate([
+            'fetchClass' => StarCrownLevel::class,
+        ]);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [];
+    }
+
+    /**
+     * 更新星级奖金
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function updateBonus()
+    {
+        $beforeData = StarCrownLevel::getBonusConfig();
+        $this->adminOperateLogger->saveBeforeContent=$beforeData;
+
+        $postData = \Yii::$app->request->post('data');
+        $transaction = \Yii::$app->db->beginTransaction();
+        try {
+            foreach ($postData as $value) {
+                $starLevelModel = StarCrownLevel::findOne(['ID' => $value['ID']]);
+                if ($starLevelModel) {
+                    $starLevelModel->TOURISM_PERCENT = $value['TOURISM_PERCENT'];
+                    $starLevelModel->GARAGE_PERCENT = $value['GARAGE_PERCENT'];
+                    if (!$starLevelModel->save()) {
+                        throw new \Exception(Form::formatErrorsForApi($starLevelModel->getErrors()));
+                    }
+                }
+            }
+            $transaction->commit();
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            $this->addError('updateBonus', $e->getMessage());
+            return null;
+        }
+
+        $afterData = StarCrownLevel::getBonusConfig();
+        $this->adminOperateLogger->saveAfterContent = $afterData;
+        unset($beforeData,$afterData);
+
+        $this->adminOperateLogger->clean()->save([
+            'optType' => '更新星级奖金配置',
+        ]);
+        return true;
+    }
+}

+ 10 - 3
common/models/User.php

@@ -38,6 +38,7 @@ use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
  * @property int $DEC_CLOSED_AT 关闭时间
  * @property string $DEC_LV 报单级别
  * @property string $EMP_LV 聘级
+ * @property string $STAR_LV 星级
  * @property int $PROVINCE 省份
  * @property int $CITY 城市
  * @property int $COUNTY 县区
@@ -113,7 +114,7 @@ class User extends \common\components\ActiveRecord
             [['USER_NAME', 'PASSWORD_HASH', 'PAY_PASSWORD', 'REAL_NAME', 'ID_CARD', 'AVATAR'], 'required'],
             [['NATION', 'ID_TYPE', 'BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY', 'CREATED_AT', 'UPDATED_AT', 'STATUS', 'DEC_CLOSED', 'DEC_CLOSED_AT', 'PROVINCE', 'CITY', 'COUNTY', 'DELETED', 'DELETED_AT', 'IS_DEC', 'IS_ATLAS', 'IS_RECHARGE','IS_STUDIO',  'PERIOD_AT', 'DEC_PROVINCE', 'DEC_CITY', 'DEC_COUNTY', 'IS_UNION', 'STATUS_AT', 'VERIFIED', 'VERIFIED_AT', 'ALLOW_LOGIN', 'NOT_OPERATING', 'REG_FROM', 'BANK_UPDATED_AT', 'IS_DIRECT_SELLER', 'DEC_LV_UPDATED_AT', 'DEC_LV_UPDATED_PERIOD', 'PART_FUNC_CLOSED', 'LAST_DEC_LV_UPDATED_PERIOD', 'LAST_DEC_LV_UPDATED_AT', 'DEC_CREATED_AT', 'DEC_CREATED_PERIOD', 'PASSWORD_CHANGED', 'SUB_COM_LEADER', 'READ_AGREEMENT', 'IS_FIRST_OPEN', 'IS_MODIFY_PASSWORD'], 'integer'],
             [['ZG_UPGRADE_PV'], 'number'],
-            [['ID', 'OPEN_BANK', 'BANK_NO', 'DEC_LV', 'EMP_LV', 'SUB_COM_ID', 'DEC_ID', 'DEC_ROLE_ID', 'ID_CARD_PREFIX', 'SEX', 'DEC_PHONE', 'GUARANTOR', 'USER_CREATOR', 'USER_UPDATER', 'LAST_DEC_LV', 'EMAIL'], 'string', 'max' => 32],
+            [['ID', 'OPEN_BANK', 'BANK_NO', 'DEC_LV', 'EMP_LV', 'STAR_LV', 'SUB_COM_ID', 'DEC_ID', 'DEC_ROLE_ID', 'ID_CARD_PREFIX', 'SEX', 'DEC_PHONE', 'GUARANTOR', 'USER_CREATOR', 'USER_UPDATER', 'LAST_DEC_LV', 'EMAIL'], 'string', 'max' => 32],
             [['USER_NAME', 'SPOUSE_NAME', 'TEL'], 'string', 'max' => 16],
             [['PASSWORD_HASH', 'PAY_PASSWORD', 'ID_IMAGE', 'BANK_ADDRESS', 'AVATAR'], 'string', 'max' => 255],
             [['REAL_NAME', 'APP_CLIENT_ID', 'BONUS_APP_CLIENT_ID'], 'string', 'max' => 128],
@@ -159,6 +160,7 @@ class User extends \common\components\ActiveRecord
             'DEC_CLOSED_AT' => '关闭时间',
             'DEC_LV' => '报单级别',
             'EMP_LV' => '聘级',
+            'STAR_LV' => '星级',
             'PROVINCE' => '省份',
             'CITY' => '城市',
             'COUNTY' => '县区',
@@ -239,7 +241,7 @@ class User extends \common\components\ActiveRecord
     public static function getBaseInfoFromRedis($userId){
         $userInfo = Yii::$app->redis->hget(Cache::USER_INFO_KEY, $userId);
         if(!$userInfo){
-            $userInfo = static::find()->select('ID,USER_NAME,NATION,REAL_NAME,ID_CARD,ID_TYPE,MOBILE,ADDRESS,STATUS,DEC_LV,LAST_DEC_LV,EMP_LV,DEC_CLOSED,AVATAR,OPEN_BANK,BANK_ADDRESS,BANK_NO,VERIFIED,IS_UNION,IS_DEC,IS_ATLAS,IS_RECHARGE,IS_STUDIO,DEC_ROLE_ID,PROVINCE,CITY,COUNTY,EMAIL')->where('ID=:ID', [':ID'=>$userId])->asArray()->one();
+            $userInfo = static::find()->select('ID,USER_NAME,NATION,REAL_NAME,ID_CARD,ID_TYPE,MOBILE,ADDRESS,STATUS,DEC_LV,LAST_DEC_LV,EMP_LV,STAR_LV,DEC_CLOSED,AVATAR,OPEN_BANK,BANK_ADDRESS,BANK_NO,VERIFIED,IS_UNION,IS_DEC,IS_ATLAS,IS_RECHARGE,IS_STUDIO,DEC_ROLE_ID,PROVINCE,CITY,COUNTY,EMAIL')->where('ID=:ID', [':ID'=>$userId])->asArray()->one();
             Yii::$app->redis->hset(Cache::USER_INFO_KEY, $userId, Json::encode($userInfo));
         } else {
             $userInfo = Json::decode($userInfo);
@@ -253,7 +255,7 @@ class User extends \common\components\ActiveRecord
      * @return mixed
      */
     public static function updateBaseInfoToRedis($userId){
-        $userInfo = static::find()->select('ID,USER_NAME,NATION,REAL_NAME,ID_CARD,ID_TYPE,MOBILE,ADDRESS,STATUS,DEC_LV,LAST_DEC_LV,EMP_LV,DEC_CLOSED,AVATAR,OPEN_BANK,BANK_ADDRESS,BANK_NO,VERIFIED,IS_UNION,IS_DEC,IS_ATLAS,IS_RECHARGE,IS_STUDIO,DEC_ROLE_ID,PROVINCE,CITY,COUNTY,EMAIL')->where('ID=:ID', [':ID'=>$userId])->asArray()->one();
+        $userInfo = static::find()->select('ID,USER_NAME,NATION,REAL_NAME,ID_CARD,ID_TYPE,MOBILE,ADDRESS,STATUS,DEC_LV,LAST_DEC_LV,EMP_LV,STAR_LV,DEC_CLOSED,AVATAR,OPEN_BANK,BANK_ADDRESS,BANK_NO,VERIFIED,IS_UNION,IS_DEC,IS_ATLAS,IS_RECHARGE,IS_STUDIO,DEC_ROLE_ID,PROVINCE,CITY,COUNTY,EMAIL')->where('ID=:ID', [':ID'=>$userId])->asArray()->one();
         return Yii::$app->redis->hset(Cache::USER_INFO_KEY, $userId, Json::encode($userInfo));
     }
 
@@ -352,6 +354,7 @@ class User extends \common\components\ActiveRecord
             'BANK_ADDRESS' => $userInfo['BANK_ADDRESS'],
             'DEC_LV' => $userInfo['DEC_LV'],
             'EMP_LV' => $userInfo['EMP_LV'],
+            'STAR_LV' => $userInfo['STAR_LV'],
             'PROVINCE' => $userInfo['PROVINCE'],
             'CITY' => $userInfo['CITY'],
             'COUNTY' => $userInfo['COUNTY'],
@@ -461,6 +464,10 @@ class User extends \common\components\ActiveRecord
                 'label' => '聘级',
                 'type' => ValueTypeConfig::EMP_LV_TYPE,
             ],
+            'STAR_LV' => [
+                'label' => '星级',
+                'type' => ValueTypeConfig::STAR_LV_TYPE,
+            ],
             'LAST_DEC_LV' => [
                 'label' => '上次的报单级别',
                 'type' => ValueTypeConfig::DEC_LV_TYPE,

+ 13 - 7
common/models/UserBonus.php

@@ -15,6 +15,8 @@ use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
  * @property string $BONUS_FREEZE 奖金冻结部分
  * @property string $CF 车房养老奖
  * @property string $LX 领袖分红奖
+ * @property string $TOURISM_POINTS 旅游积分
+ * @property string $GARAGE_POINTS 车房积分
  * @property string $QY_TOTAL 区域津贴累计
  * @property string $YC_TOTAL 育成津贴累计
  * @property string $VIP_TOTAL VIP奖金累计
@@ -28,6 +30,8 @@ use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
  * @property string $LX_TOTAL 领袖分红累计
  * @property string $DEDUCT_ZR_TOTAL 责任业绩扣除累计
  * @property string $FL_TOTAL 形象店货补累计
+ * @property string $TOURISM_POINTS_TOTAL 旅游积分累积
+ * @property string $GARAGE_POINTS_TOTAL 车房积分累积
  * @property int $VER 乐观锁标识
  * @property int $CREATED_AT 创建时间
  * @property int $BD_TOTAL 服务奖累计
@@ -68,7 +72,7 @@ class UserBonus extends \common\components\ActiveRecord
     {
         return [
             [['USER_ID', 'CREATED_AT'], 'required'],
-            [['BS_TOTAL','ORI_BS_TOTAL','BS','BONUS', 'BONUS_FREEZE', 'CF', 'LX', 'QY_TOTAL', 'YC_TOTAL', 'VIP_TOTAL', 'FX_TOTAL', 'LS_TOTAL', 'FW_TOTAL', 'BT_TOTAL', 'BT_PROD_TOTAL', 'BT_TOOL_TOTAL', 'CF_TOTAL', 'LX_TOTAL', 'DEDUCT_ZR_TOTAL', 'FL_TOTAL', 'BD_TOTAL','TG_TOTAL','YJ_TOTAL','GX_TOTAL','GL_TOTAL', 'ORI_QY_TOTAL','ORI_YC_TOTAL','ORI_YC_TOTAL','ORI_BD_TOTAL','ORI_TG_TOTAL','ORI_YJ_TOTAL','ORI_GX_TOTAL','ORI_GL_TOTAL','RECONSUME_POINTS','MANAGE_TAX', 'RECONSUME_POINTS_EXPIRED', 'RECONSUME_POINTS_TOTAL', 'BONUS_TOTAL', 'TRAVEL_POINTS', 'CAR_POINTS', 'HOUSE_POINTS'], 'number'],
+            [['BS_TOTAL','ORI_BS_TOTAL','BS','BONUS', 'BONUS_FREEZE', 'CF', 'LX', 'QY_TOTAL', 'YC_TOTAL', 'VIP_TOTAL', 'FX_TOTAL', 'LS_TOTAL', 'FW_TOTAL', 'BT_TOTAL', 'BT_PROD_TOTAL', 'BT_TOOL_TOTAL', 'CF_TOTAL', 'LX_TOTAL', 'DEDUCT_ZR_TOTAL', 'FL_TOTAL', 'BD_TOTAL','TG_TOTAL','YJ_TOTAL','GX_TOTAL','GL_TOTAL', 'ORI_QY_TOTAL','ORI_YC_TOTAL','ORI_YC_TOTAL','ORI_BD_TOTAL','ORI_TG_TOTAL','ORI_YJ_TOTAL','ORI_GX_TOTAL','ORI_GL_TOTAL','RECONSUME_POINTS','MANAGE_TAX', 'RECONSUME_POINTS_EXPIRED', 'RECONSUME_POINTS_TOTAL', 'BONUS_TOTAL', 'TOURISM_POINTS', 'GARAGE_POINTS'], 'number'],
             [['VER', 'CREATED_AT'], 'integer'],
             [['ID','USER_ID'], 'string', 'max' => 32],
             [['USER_ID'], 'unique'],
@@ -123,12 +127,10 @@ class UserBonus extends \common\components\ActiveRecord
             'BS' => '蓝星奖(即新的管理奖)',
             'BS_TOTAL' => '蓝星(管理)累计',
             'ORI_BS_TOTAL' => '蓝星原奖金累计',
-            'TRAVEL' => '旅游积分',
-            'TRAVEL_TOTAL' => '旅游积分累计',
-            'CAR' => '名车积分',
-            'CAR_TOTAL' => '名车积分累计',
-            'HOUSE' => '豪宅积分',
-            'HOUSE_TOTAL' => '豪宅积分累计',
+            'TOURISM' => '旅游积分',
+            'TOURISM_TOTAL' => '旅游积分累计',
+            'GARAGE' => '车房积分',
+            'GARAGE_TOTAL' => '车房积分累计',
         ];
     }
 
@@ -142,6 +144,8 @@ class UserBonus extends \common\components\ActiveRecord
             'BONUS' => '会员账户',
             'CF' => '车房养老奖',
             'LX' => '领袖分红奖',
+            'TOURISM' => '旅游积分',
+            'GARAGE' => '车房积分',
         ];
     }
 
@@ -167,6 +171,8 @@ class UserBonus extends \common\components\ActiveRecord
                 'BONUS' => 0,
                 'CF' => 0,
                 'LX' => 0,
+                'TOURISM' => 0,
+                'GARAGE' => 0,
             ];
         }
         return $data;

+ 12 - 3
common/models/forms/ApproachOrderForm.php

@@ -123,7 +123,7 @@ class ApproachOrderForm extends Model
             // 管理员修改订单状态
             'adminStatus' => ['sn', 'status'],
             // 管理员修改订单状态
-            'verifyPayStack' => ['sn', 'remark'],
+            'verifyPayStack' => ['sn', 'remark', 'email'],
             // 会员下单
             'userOrder' => ['type','addressId', 'payType','goodsId','goodsNum', 'remark', 'payPassword'/*, 'email'*/],
         ];
@@ -273,7 +273,7 @@ class ApproachOrderForm extends Model
      * 校验PayStack支付,更新订单状态.同步到正式订单.
      * @throws Exception
      */
-    public function verifyPayStack()
+    public function verifyPayStack(): ?ApproachOrder
     {
         if (!$this->validate()) {
             return null;
@@ -295,13 +295,22 @@ class ApproachOrderForm extends Model
             $this->_model->STATUS = \Yii::$app->params['orderStatus']['paid']['value'];
             $this->_model->REMARK = json_encode($this->remark);
             $this->_model->PAY_AT = Date::nowTime();
+            $this->_model->EMAIL = $this->email;
             if (!$this->_model->save()) {
                 throw new Exception(Form::formatErrorsForApi($this->_model->getErrors()));
             }
+            // 更新订单商品的支付Email
+            ApproachOrderGoods::updateAll(['EMAIL' => $this->email], 'ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+
 
             // 同步准订单到正式订单
             Order::insertOne($this->_model->toArray());
-            OrderGoods::batchInsert(ApproachOrderGoods::findAllAsArray('ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]));
+            // 同步准订单商品到正式订单商品
+            $approachOrderGoods = ApproachOrderGoods::findAllAsArray('ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+            foreach ($approachOrderGoods as &$approachOrderGood) {
+                $approachOrderGood['EMAIL'] = $this->email;
+            }
+            OrderGoods::batchInsert($approachOrderGoods);
 
             $transaction->commit();
         } catch (Exception $e) {

+ 67 - 12
common/models/forms/OrderForm.php

@@ -329,6 +329,45 @@ class OrderForm extends Model
         return $this->_model;
     }
 
+    /**
+     * 校验支付
+     * @return Order|null
+     * @throws Exception
+     */
+    public function verifyPayStack(): ?Order
+    {
+        if(!$this->validate()){
+            return null;
+        }
+
+        // 调用PayStack支付校验
+        $payload = PayStack::transactionVerify($this->remark['reference']);
+        if ($payload['status'] !== true) {
+            throw new Exception(Form::formatErrorsForApi($payload['message']));
+        }
+        if ($payload['data']['amount'] != $this->_model->PAY_AMOUNT * 100) {
+            throw new Exception(Form::formatErrorsForApi('支付金额与订单金额不符'));
+        }
+
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            $this->_model->STATUS = \Yii::$app->params['orderStatus']['paid']['value'];
+            $this->_model->REMARK = json_encode($this->remark);
+            $this->_model->PAY_AT = Date::nowTime();
+            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 Order|null
@@ -408,6 +447,20 @@ class OrderForm extends Model
                     }
                     $totalAmount += $realPrice * intval($v);
                     $totalPv += $realPv * intval($v);
+
+                    $totalAmountStandard += $realPriceStandard * 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'],
@@ -513,9 +566,13 @@ class OrderForm extends Model
             if ($payAmount > Balance::getBalanceExchangePoints($loginUserId)) {
                 return ['code' => 500, 'message' => '兑换积分不足,无法购买商品'];
             }
-        } else if (in_array($payType, ['travel_points', 'car_points', 'house_points'])) {
-            if ($payAmount > Balance::getAccountBalance($loginUserId, $payType)) {
-                return ['code' => 500, 'message' => (Balance::BALANCE_TYPE[$payType]['title'] ?? '积分') . '不足,无法购买商品'];
+        } else if ($payType == 'tourism_points') {
+            if ($payAmount > Balance::getBalanceTourism($loginUserId)) {
+                return ['code' => 500, 'message' => '旅游积分不足,无法购买商品'];
+            }
+        } else if ($payType == 'garage_points') {
+            if ($payAmount > Balance::getBalanceGarage($loginUserId)) {
+                return ['code' => 500, 'message' => '车房积分不足,无法购买商品'];
             }
         } else{
 //            if ($payAmount > Balance::getBalanceReconsumePoints($loginUserId)) {
@@ -551,7 +608,7 @@ class OrderForm extends Model
         }else{
             $warehouse = '01';
         }
-        $_hasPV = in_array($this->payType, ['exchange', 'travel_points', 'car_points', 'house_points']) ? 0 : $this->_decPv;
+        $_hasPV = in_array($this->payType, ['exchange', 'tourism_points', 'garage_points']) ? 0 : $this->_decPv;
 
         $ordNo = $this->_generateSn();
         $orderModel = new Order();
@@ -583,7 +640,7 @@ class OrderForm extends Model
         $orderModel->STATUS = \Yii::$app->params['orderStatus']['paid']['value'];
         $orderModel->CREATED_AT = Date::nowTime();
         $orderModel->CREATE_USER = $userName;
-        $orderModel->EMAIL = $userEmail?$userEmail:$userName.'@elken.com';
+        $orderModel->EMAIL = $userEmail ?? '';
         $orderModel->ORDER_AMOUNT_STANDARD = $this->_decAmountStandard;
         $orderModel->PAY_AMOUNT_STANDARD = $this->_standardAmount;
         $orderModel->EXCHANGE_RATE = $exchangeRate;
@@ -605,7 +662,7 @@ class OrderForm extends Model
         // 加入商品到订单商品表
         foreach($this->_orderGoods as $key=>$value){
             // 增加判断,如果订单是兑换券购买,则AR_ORDER_GOODS中的REAL_PV真实PV应该是0
-            if (in_array($orderModel->PAY_TYPE, ['exchange', 'travel_points', 'car_points', 'house_points'])) {
+            if (in_array($orderModel->PAY_TYPE, ['exchange', 'tourism_points', 'garage_points'])) {
                 $this->_orderGoods[$key]['REAL_PV'] = 0;
             }
             $this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
@@ -618,12 +675,10 @@ class OrderForm extends Model
             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 if ($this->payType == 'travel_points') {
-            Balance::changeUserBonus(\Yii::$app->user->id, 'travel_points', -abs($this->_payAmount), ['DEAL_TYPE_ID' => DealType::TRAVEL_POINTS_EXCHANGE,'REMARK' => '会员旅游换积分兑换']);
-        } else if ($this->payType == 'car_points') {
-            Balance::changeUserBonus(\Yii::$app->user->id, 'car_points', -abs($this->_payAmount), ['DEAL_TYPE_ID' => DealType::CAR_POINTS_EXCHANGE,'REMARK' => '会员名车积分兑换']);
-        } else if ($this->payType == 'house_points') {
-            Balance::changeUserBonus(\Yii::$app->user->id, 'house_points', -abs($this->_payAmount), ['DEAL_TYPE_ID' => DealType::HOUSE_POINTS_EXCHANGE,'REMARK' => '会员豪宅积分兑换']);
+        } else if ($this->payType == 'tourism_points') {
+            Balance::changeUserBonus(\Yii::$app->user->id, 'tourism_points', -abs($this->_payAmount), ['DEAL_TYPE_ID' => DealType::TOURISM_POINTS_EXCHANGE,'REMARK' => '会员旅游换积分兑换']);
+        } else if ($this->payType == 'garage_points') {
+            Balance::changeUserBonus(\Yii::$app->user->id, 'garage_points', -abs($this->_payAmount), ['DEAL_TYPE_ID' => DealType::GARAGE_POINTS_EXCHANGE,'REMARK' => '会员名车积分兑换']);
         } else if ($this->payType == 'reconsume_points') {
             Balance::changeUserBonus(\Yii::$app->user->id,'reconsume_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::RECONSUME_POINTS_EXCHANGE,'REMARK' => '会员复销积分兑换']);
         }

+ 0 - 7
common/models/forms/ShopGoodsForm.php

@@ -135,7 +135,6 @@ class ShopGoodsForm extends Model
                         break;
                     }
                 }
-
                 // 购买方式格式化为','分割的方式
                 $this->sellType = implode(',', array_column($sellType, 'id'));
                 // 如果是普通商品,有PV,旅游、名车、豪宅商品没有PV
@@ -187,9 +186,6 @@ class ShopGoodsForm extends Model
             return null;
         }
 
-        // 汇率
-        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
-
         $transaction = \Yii::$app->db->beginTransaction();
         try {
             // 添加商品
@@ -237,9 +233,6 @@ class ShopGoodsForm extends Model
             return null;
         }
 
-        // 汇率
-        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
-
         $transaction = \Yii::$app->db->beginTransaction();
         try {
             $model = $this->_model;

+ 2 - 2
frontendApi/config/menu.php

@@ -28,8 +28,8 @@ return [
         'show'=>1,
         'child'=>[
             ['name'=>'Products list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'index', 'routePath'=>'shop/index', 'show'=>1,],//商品列表
-            ['name'=>'Repeat sales products', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1,'allow'=>'studio'],//复消商品
-            ['name'=>'Entry list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,],//报单列表
+//            ['name'=>'Repeat sales products', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1,'allow'=>'studio'],//复消商品
+//            ['name'=>'Entry list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,],//报单列表
             ['name'=>'Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],//订单列表
         ]
     ],

+ 25 - 43
frontendApi/modules/v1/controllers/BonusController.php

@@ -21,9 +21,10 @@ use common\models\CalcBonusFL;
 use common\models\DealType;
 use common\models\FlowBonus;
 use common\models\FlowCF;
+use common\models\FlowGaragePoints;
 use common\models\FlowLX;
 use common\models\FlowReconsumePoints;
-use common\models\FlowZonePoints;
+use common\models\FlowTourismPoints;
 use common\models\FlowWallet;
 use common\models\PerfMonth;
 use common\models\Period;
@@ -45,15 +46,14 @@ class BonusController extends BaseController {
      */
     public function actionIndex() {
         $userId = \Yii::$app->user->id;
-        $data = UserBonus::findUseSlaves()->select('BONUS,RECONSUME_POINTS,EXCHANGE_POINTS,TRAVEL_POINTS,CAR_POINTS,HOUSE_POINTS')->where('USER_ID=:USER_ID', [':USER_ID' => $userId])->asArray()->one();
+        $data = UserBonus::findUseSlaves()->select('BONUS,RECONSUME_POINTS,EXCHANGE_POINTS,TOURISM_POINTS,GARAGE_POINTS')->where('USER_ID=:USER_ID', [':USER_ID' => $userId])->asArray()->one();
         if (!$data) {
             $data = [
                 'BONUS' => 0,
 //                'RECONSUME_POINTS' => 0,
                 'EXCHANGE_POINTS' => 0,
-                'TRAVEL_POINTS' => 0,
-                'CAR_POINTS' => 0,
-                'HOUSE_POINTS'  => 0,
+                'TOURISM_POINTS' => 0,
+                'GARAGE_POINTS' => 0,
             ];
         }
         $data['CASH'] = 0;
@@ -74,9 +74,8 @@ class BonusController extends BaseController {
         $wallet[] = ['walletType' => 'cash', 'walletName' => 'Member balance', 'amount' => Tool::formatPrice($data['CASH'])];//会员余额
 //        $wallet[] = ['walletType' => 'point', 'walletName' => '会员积分', 'amount' => Tool::formatPrice($data['RECONSUME_POINTS'])];
         $wallet[] = ['walletType' => 'exchange', 'walletName' => 'Exchange points', 'amount' => Tool::formatPrice($data['EXCHANGE_POINTS'])];//兑换点数
-        $wallet[] = ['walletType' => 'travel_points', 'walletName' => 'Travel bonus', 'amount' => Tool::formatPrice($data['TRAVEL_POINTS'])];//旅游积分
-        $wallet[] = ['walletType' => 'car_points', 'walletName' => 'Car bonus', 'amount' => Tool::formatPrice($data['CAR_POINTS'])];//名车积分
-        $wallet[] = ['walletType' => 'house_points', 'walletName' => 'House bonus', 'amount' => Tool::formatPrice($data['HOUSE_POINTS'])];//豪宅积分
+        $wallet[] = ['walletType' => 'travel_points', 'walletName' => 'Travel bonus', 'amount' => Tool::formatPrice($data['TOURISM_POINTS'])];//旅游积分
+        $wallet[] = ['walletType' => 'car_points', 'walletName' => 'Car House bonus', 'amount' => Tool::formatPrice($data['GARAGE_POINTS'])];//名车积分
 //        if ($showCFLX) {
 //            $wallet[] = ['walletType' => 'cf', 'walletName' => '福利积分一', 'amount' => Tool::formatPrice($data['CF'])];
 //            $wallet[] = ['walletType' => 'lx', 'walletName' => '福利积分二', 'amount' => Tool::formatPrice($data['LX'])];
@@ -108,7 +107,7 @@ class BonusController extends BaseController {
      */
     public function actionWalletFlow(){
         $walletType = \Yii::$app->request->get('walletType');
-        if(!in_array($walletType,['bonus', 'cash', 'exchange', 'travel_points', 'car_points', 'house_points'])) return static::notice('错误的账户类型',400);
+        if(!in_array($walletType,['bonus', 'cash', 'exchange', 'tourism_points', 'garage_points'])) return static::notice('错误的账户类型',400);
         $dealType = \Yii::$app->request->get('dealType');
         $createAt = \Yii::$app->request->get('createAt');
         $remark = \Yii::$app->request->get('remark');
@@ -160,41 +159,26 @@ class BonusController extends BaseController {
                 'orderBy' => 'CREATED_AT DESC',
             ]);
         }else if ($walletType == 'exchange') {
-            $dealLists = FlowExchangePoints::find()->groupBy('DEAL_TYPE_ID')->select('DEAL_TYPE_ID')->where('USER_ID=:USER_ID',[':USER_ID'=>\Yii::$app->user->id])->asArray()->all();
+            $dealLists = FlowExchangePoints::find()->groupBy('DEAL_TYPE_ID')->select('DEAL_TYPE_ID')->where('USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id])->asArray()->all();
             $data = FlowExchangePoints::lists($condition, $params, [
                 'useSlaves' => true,
                 'select' => 'AMOUNT,TOTAL,IS_INCR,REMARK,REMARK_IS_SHOW,PERIOD_NUM,CALC_MONTH,CREATED_AT,DEAL_TYPE_ID,DEAL_TYPE_IS_PRESET',
                 'orderBy' => 'CREATED_AT DESC',
             ]);
-        } elseif (in_array($walletType, ['travel_points', 'car_points', 'house_points'])) {
-            $dealLists = FlowZonePoints::find()->groupBy('DEAL_TYPE_ID')->select('DEAL_TYPE_ID')->where('USER_ID=:USER_ID AND WALLET_TYPE=:WALLET_TYPE',[':USER_ID'=>\Yii::$app->user->id, ':WALLET_TYPE'=>$walletType])->asArray()->all();
-
-            $condition .= " AND WALLET_TYPE = :WALLET_TYPE";
-            $params[':WALLET_TYPE'] = $walletType;
-            $data = FlowZonePoints::lists($condition, $params, [
+        } else if ($walletType == 'tourism_points') {
+                $dealLists = FlowTourismPoints::find()->groupBy('DEAL_TYPE_ID')->select('DEAL_TYPE_ID')->where('USER_ID=:USER_ID',[':USER_ID'=>\Yii::$app->user->id])->asArray()->all();
+                $data = FlowTourismPoints::lists($condition, $params, [
+                    'useSlaves' => true,
+                    'select' => 'AMOUNT,TOTAL,IS_INCR,REMARK,REMARK_IS_SHOW,PERIOD_NUM,CALC_MONTH,CREATED_AT,DEAL_TYPE_ID,DEAL_TYPE_IS_PRESET',
+                    'orderBy' => 'CREATED_AT DESC',
+                ]);
+        } else if ($walletType == 'garage_points') {
+            $dealLists = FlowGaragePoints::find()->groupBy('DEAL_TYPE_ID')->select('DEAL_TYPE_ID')->where('USER_ID=:USER_ID',[':USER_ID'=>\Yii::$app->user->id])->asArray()->all();
+            $data = FlowGaragePoints::lists($condition, $params, [
                 'useSlaves' => true,
                 'select' => 'AMOUNT,TOTAL,IS_INCR,REMARK,REMARK_IS_SHOW,PERIOD_NUM,CALC_MONTH,CREATED_AT,DEAL_TYPE_ID,DEAL_TYPE_IS_PRESET',
                 'orderBy' => 'CREATED_AT DESC',
             ]);
-
-//            $dealTypeId = '';
-//            switch ($walletType) {
-//                case 'travel_points':
-//                    $dealTypeId = DealType::TRAVEL_SEND;
-//                    break;
-//                case 'car_points':
-//                    $dealTypeId = DealType::CAR_SEND;
-//                    break;
-//                case 'house_points':
-//                    $dealTypeId = DealType::HOUSE_SEND;
-//                    break;
-//            }
-//            $condition .= ' AND DEAL_TYPE_ID=:DEAL_TYPE_ID';
-//            $params[':DEAL_TYPE_ID'] = $dealTypeId;
-//            $data = FlowZonePoints::lists($condition, $params, [
-//                'select' => 'AMOUNT,TOTAL,IS_INCR,REMARK,REMARK_IS_SHOW,PERIOD_NUM,CALC_MONTH,CREATED_AT,DEAL_TYPE_ID,DEAL_TYPE_IS_PRESET',
-//                'orderBy' => 'CREATED_AT DESC',
-//            ]);
         }
 
         if($data) {
@@ -294,10 +278,9 @@ class BonusController extends BaseController {
             $data['ORI_BONUS_BS_MNT'] = ['name' => '管理奖金', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_BS_MNT'])];
             $data['ORI_BONUS_BS_ABBR'] = ['name' => '绩效奖金', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_BS_ABBR'])];
 
-            $data['ORI_BONUS_QUARTER'] = ['name' => '季度奖金', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_QUARTER'])];
-            $data['BONUS_TRAVEL'] = ['name' => '旅游奖', 'value' => Tool::formatPrice($calcBonus['BONUS_TRAVEL'])];
-            $data['BONUS_CAR'] = ['name' => '名车奖', 'value' => Tool::formatPrice($calcBonus['BONUS_CAR'])];
-            $data['BONUS_HOUSE'] = ['name' => '豪宅奖', 'value' => Tool::formatPrice($calcBonus['BONUS_HOUSE'])];
+            $data['ORI_BONUS_QUARTER'] = ['name' => '季度奖金', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_QUARTER'] ?? 0.00)];
+            $data['BONUS_TOURISM'] = ['name' => '旅游奖', 'value' => Tool::formatPrice($calcBonus['BONUS_TOURISM'])];
+            $data['BONUS_GARAGE'] = ['name' => '车房奖', 'value' => Tool::formatPrice($calcBonus['BONUS_GARAGE'])];
             $data['BONUS_TOTAL'] = ['name' => '合计', 'value' => Tool::formatPrice($calcBonus['BONUS_TOTAL'])];
 //            $data[] = ['name' => '管理费', 'value' => Tool::formatPrice($calcBonus['MANAGE_TAX'])];
             $data['BONUS_REAL'] = ['name' => '实发奖金', 'value' => Tool::formatPrice($calcBonus['BONUS_REAL'])];
@@ -373,7 +356,7 @@ class BonusController extends BaseController {
         $calcBonus = CalcBonus::find()->where('USER_ID=:USER_ID AND IS_SENT=1', [':USER_ID' => \Yii::$app->user->id])
         ->select('PERIOD_NUM,ORI_BONUS_QY,ORI_BONUS_YC,ORI_BONUS_VIP,ORI_BONUS_STANDARD,ORI_BONUS_BD,ORI_BONUS_TG,
         ORI_BONUS_XF,BONUS_TOTAL,MANAGE_TAX,BONUS_REAL,BONUS_INCOME,ORI_BONUS_YJ,ORI_BONUS_GX,ORI_BONUS_GL,RECONSUME_POINTS,
-        LAST_DEC_LV,LAST_EMP_LV,EXCHANGE_POINTS,ORI_BONUS_BS,ORI_BONUS_BS_MNT,ORI_BONUS_BS_ABBR,BONUS_TRAVEL,BONUS_CAR,BONUS_HOUSE')
+        LAST_DEC_LV,LAST_EMP_LV,EXCHANGE_POINTS,ORI_BONUS_BS,ORI_BONUS_BS_MNT,ORI_BONUS_BS_ABBR,BONUS_TOURISM,BONUS_GARAGE')
         ->limit($showBonusPeriodNum)
         ->orderBy('PERIOD_NUM DESC')
         ->asArray()
@@ -412,9 +395,8 @@ class BonusController extends BaseController {
                 $calcBonus[$key]['ORI_BONUS_BS_ABBR'] = ['name' => '绩效奖金', 'value' => Tool::formatPrice($calcBonus[$key]['ORI_BONUS_BS_ABBR'])];
 
                 $calcBonus[$key]['ORI_BONUS_QUARTER'] = ['name' => '季度奖金', 'value' => Tool::formatPrice($calcBonus[$key]['ORI_BONUS_QUARTER'] ?? 0)];
-                $calcBonus[$key]['BONUS_TRAVEL'] = ['name' => '旅游奖', 'value' => Tool::formatPrice($calcBonus[$key]['BONUS_TRAVEL'])];
-                $calcBonus[$key]['BONUS_CAR'] = ['name' => '名车奖', 'value' => Tool::formatPrice($calcBonus[$key]['BONUS_CAR'])];
-                $calcBonus[$key]['BONUS_HOUSE'] = ['name' => '豪宅奖', 'value' => Tool::formatPrice($calcBonus[$key]['BONUS_HOUSE'])];
+                $calcBonus[$key]['BONUS_TOURISM'] = ['name' => '旅游奖', 'value' => Tool::formatPrice($calcBonus[$key]['BONUS_TOURISM'])];
+                $calcBonus[$key]['BONUS_GARAGE'] = ['name' => '车房奖', 'value' => Tool::formatPrice($calcBonus[$key]['BONUS_GARAGE'])];
                 // 总奖金
                 $calcBonus[$key]['BONUS_TOTAL'] = ['name' => '合计', 'value' => Tool::formatPrice($calcBonus[$key]['BONUS_TOTAL'])];
 //                $calcBonus[$key]['RECONSUME_POINTS'] = ['name' => '复销积分', 'value' => Tool::formatPrice($calcBonus[$key]['RECONSUME_POINTS'])];

+ 9 - 15
frontendApi/modules/v1/controllers/ShopController.php

@@ -97,19 +97,17 @@ class ShopController extends BaseController {
             }
         }
         $userBalance = [
-            'points' => 0,
+//            'points' => 0,
             'cash' => 0,
-            'exchange' => 0,
-            'travel_points' => 0,
-            'car_points' => 0,
-            'house_points' => 0,
+//            'exchange' => 0,
+            'tourism_points' => 0,
+            'garage_points' => 0,
         ];
         if ($userBonusResult = UserBonus::findOneAsArray(['USER_ID' => $userId])) {
-            $userBalance['points'] = $userBonusResult['RECONSUME_POINTS'];
-            $userBalance['exchange'] = $userBonusResult['EXCHANGE_POINTS'];
-            $userBalance['travel_points'] = $userBonusResult['TRAVEL_POINTS'];
-            $userBalance['car_points'] = $userBonusResult['CAR_POINTS'];
-            $userBalance['house_points'] = $userBonusResult['HOUSE_POINTS'];
+//            $userBalance['points'] = $userBonusResult['RECONSUME_POINTS'];
+//            $userBalance['exchange'] = $userBonusResult['EXCHANGE_POINTS'];
+            $userBalance['tourism_points'] = $userBonusResult['TOURISM_POINTS'];
+            $userBalance['garage_points'] = $userBonusResult['GARAGE_POINTS'];
         }
         if ($userCashResult = UserWallet::findOneAsArray(['USER_ID' => $userId])) {
             $userBalance['cash'] = $userCashResult['CASH'];
@@ -345,11 +343,7 @@ class ShopController extends BaseController {
             ],
             [
                 'name' => '5',
-                'label' => 'Car Bonus Products',//名车积分商品
-            ],
-            [
-                'name' => '6',
-                'label' => 'House Bonus Products',//豪宅积分商品
+                'label' => 'Car House Bonus Products',//名车积分商品
             ],
         ];
         return static::notice($data);

+ 24 - 24
frontendEle/src/router/index.js

@@ -102,30 +102,30 @@ export const constantRouterMap = [
                     ],
                 },
             },
-            {
-                path: '/shop/reconsume',
-                component: _import('shop/reconsume'),
-                name: 'shop_reconsume',
-                meta: {
-                    title: 'Repeat sales products',//复消商品
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},//首页
-                        {title: 'Products Management', path: '/shop/dec-order-list'},//商城管理
-                    ],
-                },
-            },
-            {
-                path: '/shop/reconsume-order',
-                component: _import('shop/reconsume-order'),
-                name: 'reconsume-order',
-                meta: {
-                    title: 'Settlement Repeat sales products',//复消商品结算
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},//首页
-                        {title: 'Products Management', path: '/shop/dec-order-list'}//商城管理
-                    ],
-                },
-            },
+            // {
+            //     path: '/shop/reconsume',
+            //     component: _import('shop/reconsume'),
+            //     name: 'shop_reconsume',
+            //     meta: {
+            //         title: '复消商品',
+            //         breadcrumb: [
+            //             {title: '首页', path: '/dashboard/index'},
+            //             {title: '商城管理', path: '/shop/dec-order-list'},
+            //         ],
+            //     },
+            // },
+            // {
+            //     path: '/shop/reconsume-order',
+            //     component: _import('shop/reconsume-order'),
+            //     name: 'reconsume-order',
+            //     meta: {
+            //         title: '复消商品结算',
+            //         breadcrumb: [
+            //             {title: '首页', path: '/dashboard/index'},
+            //             {title: '商城管理', path: '/shop/dec-order-list'}
+            //         ],
+            //     },
+            // },
         ],
     },
   {

+ 4 - 6
frontendEle/src/views/bonus/other.vue

@@ -14,11 +14,9 @@
         </el-table-column>
         <el-table-column label="Quarter Pool Bank(GPB)" prop="ORI_BONUS_QUARTER.value" width="190px"><!-- 季度分红 -->
         </el-table-column>
-        <el-table-column label="Travel" prop="BONUS_TRAVEL.value"><!-- 旅游奖 -->
+        <el-table-column label="Travel" prop="BONUS_TOURISM.value"><!-- 旅游奖 -->
         </el-table-column>
-        <el-table-column label="Car" prop="BONUS_CAR.value"><!-- 名车奖 -->
-        </el-table-column>
-        <el-table-column label="Villa" prop="BONUS_HOUSE.value"><!-- 豪宅奖 -->
+        <el-table-column label="Car House" prop="BONUS_GARAGE.value"><!-- 豪宅奖 -->
         </el-table-column>
         <el-table-column label="Total bonus" prop="BONUS_TOTAL.value" width="100"><!-- 合计 -->
         </el-table-column>
@@ -43,9 +41,9 @@
           <el-descriptions-item class="bonus-item" label="Team Bonus">{{newData.ORI_BONUS_BS_ABBR.value}}</el-descriptions-item><!-- 绩效奖金 -->
           <el-descriptions-item class="bonus-item" label="Quarter Pool Bank(GPB)">{{newData.ORI_BONUS_QUARTER.value}}</el-descriptions-item><!-- 季度分红 -->
           <el-descriptions-item class="bonus-item" label="Travel">{{newData.BONUS_TRAVEL.value}}</el-descriptions-item><!-- 旅游奖 -->
-          <el-descriptions-item class="bonus-item" label="Car">{{newData.BONUS_CAR.value}}</el-descriptions-item><!-- 名车奖 -->
-          <el-descriptions-item class="bonus-item" label="Villa">{{newData.BONUS_HOUSE.value}}</el-descriptions-item><!-- 豪宅奖 -->
+          <el-descriptions-item class="bonus-item" label="Car House">{{newData.BONUS_GARAGE.value}}</el-descriptions-item><!-- 车房奖 -->
           <el-descriptions-item class="bonus-item" label="Total bonus">{{newData.BONUS_TOTAL.value}}</el-descriptions-item><!-- 合计 -->
+
           <el-descriptions-item class="bonus-item" label="Actual bonus">{{newData.BONUS_REAL.value}}</el-descriptions-item><!-- 实发奖金 -->
           <el-descriptions-item class="bonus-item" label="一市场新增">{{newData.PV_1L.value}}</el-descriptions-item><!-- 一市场新增 -->
           <el-descriptions-item class="bonus-item" label="一市场结余">{{newData.SURPLUS_1L.value}}</el-descriptions-item><!-- 一市场结余 -->

+ 22 - 23
frontendEle/src/views/shop/order.vue

@@ -101,26 +101,16 @@
                             <div>{{ balance.exchange }}</div>
                         </div>
                     </div>
-
                     <div v-if="category_type === 4">
                         <div class="sum_box">
                             <div>Travel bonus</div><!-- 旅游积分 -->
-                            <div>{{ balance.travel_points }}</div>
+                            <div>{{ balance.tourism_points }}</div>
                         </div>
                     </div>
-
                     <div v-if="category_type === 5">
                         <div class="sum_box">
-                            <div>Car bonus</div><!-- 名车积分 -->
-                            <div>{{ balance.car_points }}</div>
-                        </div>
-                    </div>
-
-                    <div v-if="category_type === 6">
-                        <div class="sum_box">
-                            <div>House bonus</div><!-- 豪宅积分 -->
-                            <div>{{ balance.house_points }}</div>
-  			</div>
+                            <div>Car House bonus</div><!-- 名车积分 -->
+                            <div>{{ balance.garage_points }}</div>
                         </div>
                     </div>
                 </div>
@@ -154,6 +144,7 @@
                 :lastname="form.lastname"
                 :amount="form.amount * 100"
                 :email="form.email"
+                :metadata="form.metadata"
                 :currency="form.currency"
                 :paystackkey="form.publicKey"
                 :reference="reference"
@@ -197,7 +188,7 @@
                 category_type: '',
                 prefixSign: '₦',
                 unit: 'NGN',
-
+                sn: '',
                 visible: false,
                 payStackLoading: false,
                 form: {
@@ -208,6 +199,16 @@
                     email: userInfo.userEmail(),
                     amount: 0,  // kobo
                     orderSn: '',
+                    metadata: {
+                        cart_id: this.sn,
+                        custom_fields: [
+                            {
+                                "display_name": "orderSn",
+                                "variable_name": "orderSn",
+                                "value": this.sn
+                            },
+                        ]
+                    },
                 },
             }
         },
@@ -291,18 +292,16 @@
                     } else if (this.payType === 'exchange') {
                         amountBalance = this.balance.exchange
                     }
-                    // amountBalance = (this.payType === 'cash') ? this.balance.cash : this.balance.exchange
                 } else if (this.category_type === 4) {
-                    amountBalance = this.balance.travel_points
+                    amountBalance = this.balance.tourism_points
                 } else if (this.category_type === 5) {
-                    amountBalance = this.balance.car_points
-                } else if (this.category_type === 6) {
-                    amountBalance = this.balance.house_points
+                    amountBalance = this.balance.garage_points
                 }
 
                 // 提示信息
                 let tips = 'Balance' //余额
                 if (this.payType !== 'cash' && this.payType !== 'pay_stack') {
+                    console.log(this.payList, this.payType)
                     let payObj = this.payList.find((item) => {
                         return item.label === this.payType
                     })
@@ -346,15 +345,15 @@
 
                             this.form.orderSn = response.SN
                             this.form.amount = this.cashSum
+                            this.form.metadata.custom_fields[0].value = response.SN
                             this.visible = true
                         }).catch(() => {
                             this.submitButtonStat = true
                         })
                     } else {
                         // 非PayStack支付
-                        return network.postData('shop/sure-order', params).then((response) => {
+                        return network.postData('shop/sure-order', params).then(() => {
                             this.submitButtonStat = false
-
                                 // 非PayStack支付
                                 this.$router.go(-1)
                                 this.$router.push({path: `/shop/order-list`})
@@ -429,7 +428,7 @@
                     }
 
                     // 支付方式的第一项默认选中
-                    this.payType = this.payList[0]
+                    this.payType = Object.values(this.payList)[0]['label']
                 })
             },
             // 切换支付方式
@@ -473,7 +472,7 @@
 
                 this.payStackLoading = true
                 // 支付成功,更新订单
-                return network.postData('shop/verify-order', { sn: this.form.orderSn, remark: response }).then(_ => {
+                return network.postData('shop/verify-order', { sn: this.form.orderSn, remark: response, email: this.form.email }).then(_ => {
                     this.$message({
                         message: 'Success!',
                         type: 'success'