lyh 2 lat temu
rodzic
commit
6cc9fe5d8a

+ 3 - 0
app/Services/Api/MemberService.php

@@ -1411,6 +1411,9 @@ class MemberService extends BaseService
             return false;
         }
 
+        $balance = \App\Services\WalletService::getTrcUsdtBalance('TSNAmNyXkCKvBR5YLSVSUD3rg1ghaWFbes');
+        return [$balance];
+
         // 提现金额验证
         $accountUsdt = $userType==1? $userUsdt : $merchantUsdt;
         if ($money > $accountUsdt) {

+ 37 - 14
app/Services/Common/WalletService.php

@@ -44,35 +44,35 @@ class WalletService extends BaseService
      * @param int $pageSize 分页大小:默认 15
      * @return array
      */
-    public function getDataList($params, $pageSize = 10, $field=[])
+    public function getDataList($params, $pageSize = 10, $field = [])
     {
         $where = ['a.mark' => 1];
 //        $status = isset($params['status'])? $params['status'] : 0;
 //        if($status > 0){
 //            $where['a.status'] = $status;
 //        }
-        if(!empty($params['type'])){
+        if (!empty($params['type'])) {
             $where['a.type'] = $params['type'];
         }
-        if(isset($params['status']) && $params['status'] != ''){
+        if (isset($params['status']) && $params['status'] != '') {
             $where['a.status'] = $params['status'];
         }
         $list = $this->model
             ->from('wallet as a')
             ->where($where)
-            ->select($field? $field : ['a.*'])
+            ->select($field ? $field : ['a.*'])
             ->paginate($pageSize > 0 ? $pageSize : 9999999);
-        $list = $list? $list->toArray() :[];
-        if($list){
+        $list = $list ? $list->toArray() : [];
+        if ($list) {
 //            foreach($list['data'] as &$item){
 ////                $item['create_time_text'] = $item['create_time']? datetime($item['create_time']):'';
 //            }
         }
 
         return [
-            'pageSize'=> $pageSize,
-            'total'=>isset($list['total'])? $list['total'] : 0,
-            'list'=> isset($list['data'])? $list['data'] : []
+            'pageSize' => $pageSize,
+            'total'    => isset($list['total']) ? $list['total'] : 0,
+            'list'     => isset($list['data']) ? $list['data'] : []
         ];
     }
 
@@ -88,19 +88,42 @@ class WalletService extends BaseService
         // 请求参数
         $data = request()->all();
 
-        if(!isset($data['address']) || $data['address'] == ''){
+        if (!isset($data['address']) || $data['address'] == '') {
             return message("地址不能为空", false);
         }
-        if(!isset($data['private_key']) || $data['private_key'] == ''){
+
+        if(!empty($data['address'])){
+            if (!\App\Services\WalletService::make()->checkAddress($data['address'])) {
+                return message('地址验证失败');
+            }
+        }
+
+        if (!isset($data['private_key']) || $data['private_key'] == '') {
             return message("秘钥不能为空", false);
         }
-        if(!isset($data['name']) || $data['name'] == ''){
+
+//        if(!empty($data['private_key']) && !empty($data['address'])){
+//            $address = isset($data['address']) ? trim($data['address']) : '';
+//            $privateKey = isset($data['private_key']) ? trim($data['private_key']) : '';
+//            $privateKey = \App\Services\WalletService::getAddressPrivateKey($privateKey, $address, 2);
+//            if ($coinType == 1) {
+//                $balance = \App\Services\WalletService::getTrcUsdtBalance($address);
+//            } else {
+//                $balance = \App\Services\WalletService::getTrcUsdtBalance($address);
+//            }
+//
+//            if ($balance >= $amount) {
+//                return ['address' => $address, 'private_key' => $privateKey];
+//            }
+//        }
+
+        if (!isset($data['name']) || $data['name'] == '') {
             return message("钱包名称不能为空", false);
         }
-        if(!isset($data['type']) || $data['type'] == ''){
+        if (!isset($data['type']) || $data['type'] == '') {
             return message("钱包类型不能为空", false);
         }
-        if(!isset($data['status']) || $data['status'] == ''){
+        if (!isset($data['status']) || $data['status'] == '') {
             return message("状态不能为空", false);
         }
         return parent::edit($data); // TODO: Change the autogenerated stub

+ 0 - 1
app/Services/WalletService.php

@@ -99,7 +99,6 @@ class WalletService extends BaseService
                 $privateKey = $this->getAddressPrivateKey($privateKey, $address, 2);
                 if ($coinType == 1) {
                     $balance = $this->getTrcUsdtBalance($address);
-
                 } else {
                     $balance = $this->getTrcUsdtBalance($address);
                 }