Przeglądaj źródła

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

zhangl 1 rok temu
rodzic
commit
41757e6e12

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

@@ -33,7 +33,8 @@ return [
     'instalmentGoodsNoError' => 'Products No. error',
     'instalmentOrderInProcess' => '分期商品订单未完成',
     'productsDoesSoldOut' => 'Products has sold out!',
-    'cashDoesNotAdequate' => '余额不足,无法购买商品',
+    'cashDoesNotAdequate' => 'Insufficient balance, unable to make the payment.',
+    'userPerformanceDoesNotAdequate' => 'User Performance, unable to make the payment.',
     'exchangePointDoesNotAdequate' => '兑换积分不足,无法购买商品',
     'travelPointDoesNotAdequate' => '旅游积分不足,无法购买商品',
     'carFundPointDoesNotAdequate' => '车奖积分不足,无法购买商品',

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

@@ -34,6 +34,7 @@ return [
     'instalmentOrderInProcess' => '分期商品订单未完成',
     'productsDoesSoldOut' => '商品已下架',
     'cashDoesNotAdequate' => '余额不足,无法购买商品',
+    'userPerformanceDoesNotAdequate' => '绩效奖金不足,无法购买商品',
     'exchangePointDoesNotAdequate' => '兑换积分不足,无法购买商品',
     'travelPointDoesNotAdequate' => '旅游积分不足,无法购买商品',
     'carFundPointDoesNotAdequate' => '车奖积分不足,无法购买商品',

+ 7 - 0
common/models/UserPerformance.php

@@ -85,4 +85,11 @@ class UserPerformance extends \common\components\ActiveRecord
         }
         return $data;
     }
+
+    public static function getAmounts($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();
+
+        return $data['AMOUNTS'] ?? 0;
+    }
 }

+ 5 - 2
common/models/forms/OrderForm.php

@@ -28,6 +28,7 @@ use common\models\User;
 use common\models\UserNetwork;
 use common\models\RemainPv;
 use common\models\FlowRemainPv;
+use common\models\UserPerformance;
 use Yii;
 use yii\base\Exception;
 
@@ -595,8 +596,6 @@ class OrderForm extends Model
         // 普通商品免运费阈值
         $freeShipping = $freeTemplate['free_shipping'] ?? 0;
 
-        LoggerTool::debug(json_encode(['FreeTemplate', $user['COUNTRY_ID'], $totalAmount, $freeTemplate, $freight, $freeShipping, $this->_address]));
-
         $this->_decAmount = $totalAmount;
         $this->_decPv = $totalPv;
         $this->_realPv = $totalRealPv;
@@ -704,6 +703,10 @@ class OrderForm extends Model
 //            if ($payAmount > Balance::getBalanceReconsumePoints($loginUserId)) {
 //                return ['code' => 500, 'message' => '复消积分不足,无法购买商品'];
 //            }
+        } else if ($payType == 'user_performance') {
+            if ($payAmount > UserPerformance::getAmounts($loginUserId)) {
+                return ['code' => 500, 'message' => Yii::t('app', 'userPerformanceDoesNotAdequate')];
+            }
         }
 
         return ['code' => 200];

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

@@ -152,7 +152,7 @@ class ShopController extends BaseController {
             $userBalance['cash'] = $userCashResult['CASH'];
         }
 
-        if ($userPerformance = UserPerformance::getAmountByUserId($user['ID'])) {
+        if ($userPerformance = UserPerformance::getAmounts($user['ID'])) {
             $userBalance['prp'] = $userPerformance['AMOUNTS'];
         }