Quellcode durchsuchen

feat: NG-15: 新会员注册时增加国家与语言选项.

zhangl vor 1 Jahr
Ursprung
Commit
c07a62a70a

+ 9 - 22
common/models/UserPerformance.php

@@ -6,7 +6,7 @@ use Yii;
 use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
 
 /**
- * This is the model class for table "{{%USER_WALLET}}".
+ * This is the model class for table "{{%USER_PERFORMANCE}}".
  *
  * @property string $ID
  * @property string $USER_ID
@@ -48,8 +48,8 @@ class UserPerformance extends \common\components\ActiveRecord
     {
         return [
             [['USER_ID'], 'required'],
-            [['CASH'], 'number'],
-            [['UPDATED_AT', 'CLEAR_BY_CLOSED_AT'], 'integer'],
+            [['AMOUNTS', 'ORIGINAL'], 'number'],
+            [['UPDATED_AT', 'STATUS_ID'], 'integer'],
             [['ID','USER_ID'], 'string', 'max' => 32],
             [['USER_ID'], 'unique'],
         ];
@@ -63,23 +63,9 @@ class UserPerformance extends \common\components\ActiveRecord
         return [
             'ID' => 'ID',
             'USER_ID' => '用户id',
-            'CASH' => '现金',
+            'AMOUNTS' => '当前余额',
+            'ORIGINAL' => '原始金额',
             'UPDATED_AT' => '修改时间',
-            'CLEAR_BY_CLOSED_AT' => '清空关停会员钱包时间',
-        ];
-    }
-
-    /**
-     * 操作日志记录条件
-     * @return array
-     */
-    public function attrLabelsWithLogType(){
-        return [
-            'USER_ID' => '用户id',
-            'CLEAR_BY_CLOSED_AT' => [
-                'label' => '清空关停会员钱包时间',
-                'type' => ValueTypeConfig::DATE_TIME_TYPE,
-            ],
         ];
     }
 
@@ -88,12 +74,13 @@ class UserPerformance extends \common\components\ActiveRecord
      * @param $userId
      * @return array|null
      */
-    public static function getCashByUserId($userId){
-        $data = UserPerformance::findOneAsArray('USER_ID=:USER_ID', [':USER_ID'=>$userId], 'USER_ID,CASH');
+    public static function getAmountByUserId($userId)
+    {
+        $data = UserPerformance::find()->select('SUM(AMOUNTS) AS AMOUNTS')->where('USER_ID=:USER_ID AND STATUS_ID<(:STATUS_ID)', [':USER_ID' => $userId, ':STATUS_ID' => self::FINISHED])->asArray()->one();
         if(!$data){
             $data = [
                 'USER_ID' => $userId,
-                'CASH' => 0,
+                'AMOUNTS' => 0,
             ];
         }
         return $data;

+ 50 - 0
common/models/UserPerformanceLogs.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace common\models;
+
+/**
+ * This is the model class for table "{{%USER_PERFORMANCE_LOGS}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID
+ * @property string $CASH
+ * @property integer $UPDATED_AT
+ * @property integer $CLEAR_BY_CLOSED_AT
+ * @property User $user
+ */
+class UserPerformanceLogs extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%USER_PERFORMANCE_LOGS}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['USER_PERFORMANCE_ID'], 'required'],
+            [['AMOUNTS'], 'number'],
+            [['UPDATED_AT', 'PERIOD_NUM'], 'integer'],
+            [['ID','USER_ID'], 'string', 'max' => 32],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'USER_ID' => '用户id',
+            'AMOUNTS' => '消耗金额',
+            'CREATED_AT' => '修改时间',
+        ];
+    }
+}

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

@@ -85,36 +85,13 @@ class BonusController extends BaseController {
         $country = Countries::getById($user['COUNTRY_ID']);
         $currency = Currency::getById($country['LOCAL_CURRENCY_ID']);
 
-        // TODO: PRP账户
-        $userPerformance = UserPerformance::find()->select('SUM(AMOUNTS) AS AMOUNT_SUM')->where('USER_ID=:USER_ID AND STATUS_ID<(:STATUS_ID)', [':USER_ID' => $user['ID'], ':STATUS_ID' => UserPerformance::FINISHED])->asArray()->one();
-        $data['PRP'] = $userPerformance['AMOUNT_SUM'] ?? 0;
+        // PRP账户
+        $userPerformance = UserPerformance::getAmountByUserId($userId);
+        $data['PRP'] = $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' => 'point', 'walletName' => '会员积分', 'amount' => Tool::formatPrice($data['RECONSUME_POINTS'])];
-//        $wallet[] = ['walletType' => 'exchange', 'walletName' => 'Exchange points', 'amount' => Tool::formatPrice($data['EXCHANGE_POINTS'])];//兑换点数
-//        $wallet[] = ['walletType' => 'tourism_points', 'walletName' => 'Travel points', 'amount' => Tool::formatPrice($data['TOURISM_POINTS'])];//旅游积分
-//        $wallet[] = ['walletType' => 'garage_points', 'walletName' => Yii::t('app', 'carPoints'), 'amount' => Tool::formatPrice($data['GARAGE_POINTS'])];//车奖积分
-//        $wallet[] = ['walletType' => 'villa_points', 'walletName' => Yii::t('app', 'villaPoints'), 'amount' => Tool::formatPrice($data['VILLA_POINTS'])];//房奖积分
-//        if ($showCFLX) {
-//            $wallet[] = ['walletType' => 'cf', 'walletName' => '福利积分一', 'amount' => Tool::formatPrice($data['CF'])];
-//            $wallet[] = ['walletType' => 'lx', 'walletName' => '福利积分二', 'amount' => Tool::formatPrice($data['LX'])];
-//        }
-        //是否显示报单中心
-//        $showBt = true;
-//        $showFl = true;
-//        $userInfo = User::getEnCodeInfo(\Yii::$app->user->id);
-//        if ($userInfo['IS_DEC'] != 1) {
-//            $showBt = false;
-//            $showFl = false;
-//        }else{
-//            $sysConfig = Cache::getSystemConfig();
-//            if(!$sysConfig['openBT']['VALUE']&&!$sysConfig['openPROD']['VALUE']) $showBt = false;
-//            if(!$sysConfig['openFL']['VALUE']) $showFl = false;
-//            $decRole = DecRole::find()->where('1=1')->indexBy('ID')->asArray()->all()[$userInfo['DEC_ROLE_ID']];
-//            if ($decRole['GOODS_SUBSIDY'] <= 0) $showFl = false;
-//        }
+        $wallet[] = ['walletType' => 'prp', 'walletName' => Yii::t('app', 'memberPrp'), 'amount' => Tool::formatPrice($data['PRP']), 'coin' => $currency['CODE']];//绩效奖金
 
         $dealSwitch = isset(Cache::getSystemConfig()['dealSwitch']) ? Cache::getSystemConfig()['dealSwitch']['VALUE'] : '';
 

+ 2 - 2
frontendApi/modules/v1/controllers/ShopController.php

@@ -152,8 +152,8 @@ class ShopController extends BaseController {
             $userBalance['cash'] = $userCashResult['CASH'];
         }
 
-        if ($userPerformance = UserPerformance::find()->select('SUM(AMOUNTS) AS AMOUNT_SUM')->where('USER_ID=:USER_ID AND STATUS_ID<(:STATUS_ID)', [':USER_ID' => $user['ID'], ':STATUS_ID' => UserPerformance::FINISHED])->asArray()->one()) {
-            $userBalance['prp'] = $userPerformance['AMOUNT_SUM'];
+        if ($userPerformance = UserPerformance::getAmountByUserId($user['ID'])) {
+            $userBalance['prp'] = $userPerformance['AMOUNTS'];
         }
 
         // 运费模板