Bläddra i källkod

海外商品汇率转换支付

kevin_zhangl 2 år sedan
förälder
incheckning
0d5de31e2e
2 ändrade filer med 11 tillägg och 4 borttagningar
  1. 1 1
      common/models/Config.php
  2. 10 3
      frontendApi/modules/v1/controllers/ShopController.php

+ 1 - 1
common/models/Config.php

@@ -83,7 +83,7 @@ class Config extends \common\components\ActiveRecord
      * @return array|mixed|\yii\db\ActiveRecord[]
      */
     public static function getFromCache(){
-//        Yii::$app->cache->delete(Cache::SYSTEM_CONFIG_KEY);
+        Yii::$app->cache->delete(Cache::SYSTEM_CONFIG_KEY);
         $config = Yii::$app->cache->get(Cache::SYSTEM_CONFIG_KEY);
         if(!$config){
             // 获取配置

+ 10 - 3
frontendApi/modules/v1/controllers/ShopController.php

@@ -8,6 +8,7 @@
 
 namespace frontendApi\modules\v1\controllers;
 
+use common\helpers\Cache;
 use common\helpers\Date;
 use common\helpers\DingTalk;
 use common\helpers\Form;
@@ -29,6 +30,7 @@ use common\models\ShopGoods;
 use common\models\User;
 use common\models\UserBonus;
 use common\models\UserWallet;
+use Yii;
 use yii\data\Pagination;
 use yii\db\Query;
 use yii\web\HttpException;
@@ -416,12 +418,17 @@ class ShopController extends BaseController {
         // 订单ID
         $paymentParams['RefNo'] = \Yii::$app->request->post('RefNo');
         // 订单金额,元=>分
-        $money = \Yii::$app->request->post('Amount');   // TODO:
-        $amount = number_format(1, 2, '.', '');
+        $money = \Yii::$app->request->post('Amount');
+        // 马来币汇率
+        $exchangeRateMYR = floatval(Cache::getSystemConfig()['exchangeRateMYR']['VALUE'] ?? 0);
+        // 计算马来币
+        $amount = number_format($money * $exchangeRateMYR, 2, '.', '');
+        LoggerTool::info([$money, $amount]);
+//        $amount = number_format(1, 2, '.', ''); // TODO: 测试
         $paymentParams['Amount'] = str_replace('.', '', $amount);
 
         // (Optional) (int)
-        $paymentParams['PaymentId'] = '';   // TODO: 2=MYR
+        $paymentParams['PaymentId'] = '2';   // TODO: 2=MYR
         // Product description. (length 100)
         $paymentParams['ProdDesc'] = 'Pay for sales';
         // Customer name. (length 100)