lip 2 дней назад
Родитель
Сommit
dd4a803ab2
2 измененных файлов с 32 добавлено и 4 удалено
  1. 24 2
      app/Http/Controllers/api/Wallet.php
  2. 8 2
      app/Services/WalletService.php

+ 24 - 2
app/Http/Controllers/api/Wallet.php

@@ -37,9 +37,30 @@ class Wallet extends BaseController
         $product = SanJinService::$PRODUCT;
         $list = [];
         foreach($data as $k => $v) {
+            $config = [];
             foreach($product as $pv) {
                 if ($k == $pv['type']) {
-                    $config = $pv;
+                    if ($config) {
+                        if (empty($config['range'])) {
+                            $config['range'][] = $config;
+                        }
+                        if ($pv['min'] < $config['min']) {
+                            $config['min'] = $pv['min'];
+                        } 
+                        if ($pv['max'] > $config['max']) {
+                            $config['max'] = $pv['max'];
+                        }
+                        if ($pv['rate'] < $config['rate']) {
+                            $config['max_rate'] = $config['rate'];
+                            $config['min_rate'] = $pv['rate'];
+                        }
+                        if ($pv['rate'] > $config['rate']) {
+                            $config['max_rate'] = $pv['rate'];
+                        }
+                        $config['range'][] = $pv;
+                    } else {
+                        $config = $pv;
+                    }
                 }
             }
             $list[] = [
@@ -48,6 +69,7 @@ class Wallet extends BaseController
                 'config' => $config ?? [],
             ];
         }
+            
         return $this->success([
             'list' => $list,
         ]);
@@ -98,7 +120,7 @@ class Wallet extends BaseController
             $receivingType = ConfigService::getVal("receiving_type");
             //自动充值
             if ($receivingType == 1) {
-                $res = WalletService::getRechargeImageAddress($member_id, $address);
+                $res = WalletService::getRechargeImageAddress($member_id);
                 $qrCode = $res['full_path'];
             } else {
                 //手动充值

+ 8 - 2
app/Services/WalletService.php

@@ -263,12 +263,18 @@ class WalletService extends BaseService
      * @param {*} $memberId
      * @return {*}
      */
-    public static function getRechargeImageAddress($memberId, $address = '')
+    public static function getRechargeImageAddress($memberId)
     {
         self::getUserWallet($memberId);
         $info = self::findOne(['member_id' => $memberId]);
         
-        $address = $address ?? $info->address;
+        if (empty($info->address)) {
+            $trons = TronHelper::createAddress($memberId);
+            $info->address = $trons['address'] ?? '';
+            $info->private_key = $trons['private_key'] ?? '';
+            $info->save();
+        }
+        $address = $info->address;
         $path = self::rechargeQrCodeExists($address);
         if (empty($path)) {
             $path = self::createRechargeQrCode($address);