WIN-2308041133\Administrator 6 meses atrás
pai
commit
74bea35a80

+ 53 - 0
application/api/controller/Pay.php

@@ -3,6 +3,8 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
+use blockchain\TronService;
+use blockchain\Web3Service;
 use fast\Random;
 use think\Validate;
 use think\Db;
@@ -894,4 +896,55 @@ class Pay extends Api
             $this->error(__('金额不对'));
         }
     }
+//    u币充值(展示二维码)
+    public function recharge(){
+        $uid = input('uid');
+        $recharge_type = input('type');
+        $number = date('ymdh', time()) . rand(10000, 99999);//订单编号
+        $user = Db::name('user')->where('id', $uid)->find();
+        if (empty($user)){
+            $this->error(__('用户不存在'));
+        }
+        $data = [
+            'order_id'=> $number,
+            'uid' => $uid,
+            'pid' => 0,
+            'add_time' => time()
+        ];
+        $return = [];
+        $address = Db::name('user_usdt_address')->where('uid',$uid)->find();
+        if ($recharge_type == 'trx'){
+            $data['recharge_type']='trx';
+            $return['address']= $address['trx_address'];
+            $return['16_address'] = $address['trx_16_address'];
+        }elseif ($recharge_type == 'bsc'){
+            $data['recharge_type']='bsc';
+            $return['address'] = $address['bsc_address'];
+        }
+        Db::name('user_recharge')->insert($data);
+        $this->success($return);
+    }
+    // 查询u币转账记录
+    public function search_recharge(){
+        $time=$time24HoursAgo = strtotime("-24 hours", time());
+        $list = Db::name('user_recharge')->where('paid',0)->where('add_time','>',$time)->select();
+        foreach ($list as $k => $v){
+            $user_address = Db::name('user_usdt_address')->where('id', $v['uid'])->find();
+            if ($v['recharge_type'] == 'trx'){
+                $service = TronService::instance('usdt');
+                $info=$service->getTransfer($user_address['trx_address'], $v['add_time']);
+                var_dump($info);die();
+            }elseif ($v['recharge_type'] == 'bsc'){
+                $service = Web3Service::instance('bsc', 'usdt', '');
+//                $info =$service->getLastTransfer([], [$user_address['bsc_address']], $v['add_time']);
+                $info =$service->getLastTransfer([], [0x8f5f8daC38461E5b1A6b230D30433f8A593CCD57], 1748315888);
+                var_dump($info);die();
+            }
+        }
+    }
+    public function test(){
+        $service = Web3Service::instance('bsc', 'usdt', '');
+        $info =$service->getLastTransfer([], [0x8f5f8daC38461E5b1A6b230D30433f8A593CCD57], 1748315888);
+        var_dump($info);die();
+    }
 }

+ 29 - 0
application/common/model/UserRecharge.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 会员模型
+ */
+class UserRecharge extends Model
+{
+    // 表名
+    protected $name = 'user_recharge';
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    // 定义时间戳字段名
+    protected $createTime = 'add_time';
+    protected $updateTime = 'update_time';
+    // 追加属性
+    protected $append = [];
+    public function user()
+    {
+        return $this->belongsTo('User', 'uid', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
+    public function users()
+    {
+        return $this->belongsTo('User', 'uid', 'id', [], 'LEFT')->field('id,avatar,nickname,istel,mobile,isrz,level,group_id')->setEagerlyType(0);
+    }
+}

+ 4 - 0
application/config.php

@@ -280,6 +280,8 @@ return [
         //API接口地址
         'api_url' => 'https://api.fastadmin.net',
     ],
+
+
     'blockchain' => [
         'bsc' => [
             'node' => 'empty-quiet-sunset.bsc.quiknode.pro/69b72a1ee6e3efe4ad03d31b04a9a1b0c8a6e6d3',
@@ -295,6 +297,7 @@ return [
                 ],
             ],
         ],
+//        这个  不要了
         'eth' => [
             'node' => 'mainnet.infura.io',
             'blockTimeArea' => 10,
@@ -309,6 +312,7 @@ return [
                 ],
             ],
         ],
+//        这个还要
         'trc' => [
             'node' => 'https://api.trongrid.io',
             'tokens' => [