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

feat: UN-71: 会员-奖金列表调整

kevin 1 год назад
Родитель
Сommit
742d6e0ced

+ 1 - 1
common/messages/en-US/app.php

@@ -229,7 +229,7 @@ return [
     # 奖金
     'memberBonus' => 'Member Bonus',
     'memberEcoin' => 'Member Ecoin',
-    'memberPrp' => 'Performance Bonus',
+    'userPerformanceBonus' => 'Performance Bonus',
     'carPoints' => 'Car Points',
     'villaPoints' => 'Villa Points',
     'increase' => 'increase',

+ 1 - 1
common/messages/zh-CN/app.php

@@ -233,7 +233,7 @@ return [
     # 奖金
     'memberBonus' => '收益积分',
     'memberEcoin' => '电子币',
-    'memberPrp' => '绩效奖金',
+    'userPerformanceBonus' => '绩效奖金',
     'carPoints' => '车奖积分',
     'villaPoints' => '房奖积分',
     'increase' => '增加',

+ 4 - 1
common/models/UserPerformance.php

@@ -201,6 +201,9 @@ class UserPerformance extends \common\components\ActiveRecord
             return true;
         }
 
+        // 会员国家
+        $countryCode = Countries::getById(User::getEnCodeInfo($userId)['COUNTRY_ID'])['CODE'];
+
         $period = Period::instance();
         $periodNum = $period->getNowPeriodNum();
 
@@ -208,7 +211,7 @@ class UserPerformance extends \common\components\ActiveRecord
         $transaction = $db->beginTransaction();
         try {
             // 奖金发放
-            $id = Tool::generateId();
+            $id = 'PRP' . $countryCode . Tool::generateId();
             self::insertOne([
                 'ID' => $id,
                 'USER_ID' => $userId,

+ 20 - 29
frontendApi/modules/v1/controllers/BonusController.php

@@ -87,13 +87,13 @@ class BonusController extends BaseController {
         $country = Countries::getById($user['COUNTRY_ID']);
         $currency = Currency::getById($country['LOCAL_CURRENCY_ID']);
 
-        // PRP账户
+        // 绩效奖金
         $userPerformance = UserPerformance::getAmountByUserId($userId);
-        $data['PRP'] = $userPerformance['AMOUNTS'] ?? 0;
+        $data['userPerformanceBonus'] = $userPerformance['AMOUNTS'] ?? 0;
 
         $wallet[] = ['walletType' => 'bonus', 'walletName' => Yii::t('app', 'memberBonus'), 'amount' => Tool::formatPrice($data['BONUS'])];//会员奖金
         $wallet[] = ['walletType' => 'cash', 'walletName' => Yii::t('app', 'memberEcoin'), 'amount' => Tool::formatPrice($data['CASH']), 'coin' => $currency['CODE']];//会员余额
-        $wallet[] = ['walletType' => 'prp', 'walletName' => Yii::t('app', 'memberPrp'), 'amount' => Tool::formatPrice($data['PRP']), 'coin' => $currency['CODE']];//绩效奖金
+        $wallet[] = ['walletType' => 'userPerformanceBonus', 'walletName' => Yii::t('app', 'userPerformanceBonus'), 'amount' => Tool::formatPrice($data['userPerformanceBonus']), 'coin' => $currency['CODE']];//绩效奖金
 
         $dealSwitch = isset(Cache::getSystemConfig()['dealSwitch']) ? Cache::getSystemConfig()['dealSwitch']['VALUE'] : '';
 
@@ -200,7 +200,7 @@ class BonusController extends BaseController {
      */
     public function actionWalletFlow(){
         $walletType = \Yii::$app->request->get('walletType');
-        if(!in_array($walletType,['bonus', 'cash', 'exchange', 'prp'])) {
+        if(!in_array($walletType,['bonus', 'cash', 'userPerformanceBonus'])) {
             return static::notice('walletType error',400);
         }
 
@@ -208,7 +208,7 @@ class BonusController extends BaseController {
         $createAt = \Yii::$app->request->get('createAt');
         $remark = \Yii::$app->request->get('remark');
 
-        //获取可以查看几期流水
+        // 获取可以查看几期流水
         $showFlowPeriodNum = Cache::getSystemConfig()['showFlowPeriodNum']['VALUE'];
         $periodArr = Period::getNearlyPeriodNum($showFlowPeriodNum);
         $condition = ' AND USER_ID=:USER_ID AND PERIOD_NUM>=:PERIOD_NUM_MIN AND PERIOD_NUM<=:PERIOD_NUM_MAX';
@@ -254,39 +254,30 @@ class BonusController extends BaseController {
                 'select' => 'AMOUNT,TOTAL,IS_INCR,REMARK,PERIOD_NUM,CALC_MONTH,CREATED_AT',
                 '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();
-            $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',
-            ]);
-        }else if ($walletType == 'prp') {
-            $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',
+        }else if ($walletType == 'userPerformanceBonus') {
+            $condition = 'USER_ID=:USER_ID AND STATUS_ID<20 AND AMOUNTS>0';
+            $params = [':USER_ID' => \Yii::$app->user->id];
+            $data = UserPerformance::lists($condition, $params, [
+                'select' => 'ID,USER_ID,AMOUNTS,ORIGINAL,EXPIRED_AT',
+                'orderBy' => 'EXPIRED_AT ASC, CREATED_AT ASC',
             ]);
         } else {
             return static::notice('walletType error',400);
         }
 
-        if($data) {
-            if($walletType != 'cash') {
-                foreach ($data['list'] as $key => $value) {
-                    if ($value['DEAL_TYPE_IS_PRESET'] == 0) {
-                        $data['list'][$key]['DEAL_TYPE_NAME'] = $value['AMOUNT'] > 0 ? Yii::t('app', 'increase') : Yii::t('app', 'reduce');
-                    } else {
-                        $data['list'][$key]['DEAL_TYPE_NAME'] = DealType::getAllTypesForShow()[$value['DEAL_TYPE_ID']]['TYPE_NAME'] ?? '';
-                    }
-
-                    if ($value['REMARK_IS_SHOW'] == 0) $data['list'][$key]['REMARK'] = '';
+        if($data && $walletType == 'bonus') {
+            foreach ($data['list'] as $key => $value) {
+                if ($value['DEAL_TYPE_IS_PRESET'] == 0) {
+                    $data['list'][$key]['DEAL_TYPE_NAME'] = $value['AMOUNT'] > 0 ? Yii::t('app', 'increase') : Yii::t('app', 'reduce');
+                } else {
+                    $data['list'][$key]['DEAL_TYPE_NAME'] = DealType::getAllTypesForShow()[$value['DEAL_TYPE_ID']]['TYPE_NAME'] ?? '';
                 }
+
+                if ($value['REMARK_IS_SHOW'] == 0) $data['list'][$key]['REMARK'] = '';
             }
         }
 
-        if($dealLists){
+        if ($dealLists  && $walletType != 'userPerformanceBonus') {
             foreach ($dealLists as $key=>$value){
                 if(!$value['DEAL_TYPE_ID']) continue;
                 $dealType = DealType::getAllTypesForShow()[$value['DEAL_TYPE_ID']];