Просмотр исходного кода

Weenier 168otc项目部署 0630

wesmiler 3 лет назад
Родитель
Сommit
3376c47eab

+ 11 - 0
app/Http/Controllers/Admin/ActionLogController.php

@@ -33,4 +33,15 @@ class ActionLogController extends Backend
         parent::__construct();
         $this->service = new ActionLogService();
     }
+
+    public function index()
+    {
+        $username = '';
+        if($this->userInfo['user_type'] == 2){
+            $username = $this->userInfo['username'];
+        }
+        request()->merge(['username'=> $username]);
+        $result = $this->service->getList();
+        return $result;
+    }
 }

+ 9 - 0
app/Http/Controllers/Admin/CoinLogController.php

@@ -62,4 +62,13 @@ class CoinLogController extends Backend
             return message(CoinLogService::make()->getError(), true);
         }
     }
+
+    /**
+     * 提币审核
+     * @return array
+     */
+    public function confirm()
+    {
+        return message(1002, true);
+    }
 }

+ 50 - 3
app/Http/Controllers/Admin/IndexController.php

@@ -19,6 +19,7 @@ use App\Services\Common\TradeOrderService;
 use App\Services\Common\UserService;
 use App\Services\ConfigService;
 use App\Services\RedisService;
+use App\Services\UsdtWalletService;
 use Earnp\GoogleAuthenticator\GoogleAuthenticator;
 use Illuminate\Support\Facades\Cache;
 
@@ -192,10 +193,56 @@ class IndexController extends Backend
     }
 
 
-    public function googleCode()
+    /**
+     * 平台钱包
+     */
+    public function wallet()
+    {
+        $data = ConfigService::make()->getConfigOptionByGroup(5);
+        if(isset($data['trc_address']) && $data['trc_address']){
+            $qrcode = \App\Services\Api\MemberService::make()->makeQrcode($data['trc_address']);
+            $data['trc_qrcode'] = $qrcode? get_image_url($qrcode) : '';
+            $data['wallet']['trc_usdt'] = UsdtWalletService::make()->getTrc20Usdt($data['trc_address']);
+        }
+        if(isset($data['erc_address']) && $data['erc_address']){
+            $qrcode = \App\Services\Api\MemberService::make()->makeQrcode($data['erc_address']);
+            $data['erc_qrcode'] = $qrcode? get_image_url($qrcode) : '';
+            $data['wallet']['erc_usdt'] = UsdtWalletService::make()->getErc20Usdt($data['erc_address']);
+        }
+        if(isset($data['trc_out_address']) && $data['trc_out_address']){
+            $qrcode = \App\Services\Api\MemberService::make()->makeQrcode($data['trc_out_address']);
+            $data['trc_out_qrcode'] = $qrcode? get_image_url($qrcode) : '';
+            $data['wallet']['trc_out_usdt'] = UsdtWalletService::make()->getTrc20Usdt($data['trc_out_address']);
+        }
+        if(isset($data['erc_out_address']) && $data['erc_out_address']){
+            $qrcode = \App\Services\Api\MemberService::make()->makeQrcode($data['erc_out_address']);
+            $data['erc_out_qrcode'] = $qrcode? get_image_url($qrcode) : '';
+            $data['wallet']['erc_out_usdt'] = UsdtWalletService::make()->getErc20Usdt($data['erc_out_address']);
+        }
+
+        return message(MESSAGE_OK, true, $data);
+    }
+
+    /**
+     * 获取钱包地址交易记录
+     * @return array
+     */
+    public function transfer()
     {
-       $googleSecret = GoogleAuthenticator::CreateSecret();
+        $contactType = request()->post('contact_type', 1);
+        $type = request()->post('type', 1);
+        $address = request()->post('address', 1);
+        $limit = request()->post('limit', 15);
+        if(empty($address)){
+            return message(MESSAGE_OK, false);
+        }
 
-       var_dump($googleSecret);
+        // trc
+        if($contactType == 1){
+            $datas = UsdtWalletService::make()->getTrc20TransferLog($address,$type, $limit);
+        }else {
+            $datas = UsdtWalletService::make()->getErc20TransferLog($address,$type, $limit);
+        }
+        return message(MESSAGE_OK, true, is_array($datas)? $datas : []);
     }
 }

+ 10 - 0
app/Http/Controllers/Admin/LoginLogController.php

@@ -33,4 +33,14 @@ class LoginLogController extends Backend
         parent::__construct();
         $this->service = new LoginLogService();
     }
+
+    public function index()
+    {
+        $username = '';
+        if($this->userInfo['user_type'] == 2){
+            $username = $this->userInfo['username'];
+        }
+        $result = $this->service->getList($username);
+        return $result;
+    }
 }

+ 227 - 11
app/Services/Common/AdvertOrderService.php

@@ -13,6 +13,7 @@ namespace App\Services\Common;
 
 use App\Models\AdvertModel;
 use App\Models\AdvertOrderModel;
+use App\Services\Api\MemberPaymentService;
 use App\Services\BaseService;
 
 /**
@@ -58,7 +59,8 @@ class AdvertOrderService extends BaseService
     public function buy($userId, $params)
     {
         $id = isset($params['id']) ? intval($params['id']) : 0;
-        if ($id <= 0) {
+        $num = isset($params['num']) ? intval($params['num']) : 0;
+        if ($id <= 0 || $num<=0) {
             $this->error = '1013';
             return false;
         }
@@ -95,11 +97,12 @@ class AdvertOrderService extends BaseService
         }
 
         // 验证数量或金额
-        $total = 0;
         if ($priceType == 2) {
             $price = floatval($tradePrice + $price);
         }
 
+        $total = floatval($price * $num);
+
         // 用户信息
         $userInfo = MemberService::make()->getInfo($userId);
         $status = isset($userInfo['status']) ? $userInfo['status'] : 0;
@@ -110,10 +113,6 @@ class AdvertOrderService extends BaseService
             return false;
         }
 
-        if ($idcardCheck != 1) {
-            $this->error = '2014';
-            return false;
-        }
 
         // 未处理订单
         $noCatchOrder = $this->checkOrderNoCatch($userId, 1);
@@ -122,15 +121,15 @@ class AdvertOrderService extends BaseService
             return false;
         }
 
-        // 匹配交易商家
-        $businessInfo = \App\Services\Api\MemberService::make()->getTradeMember($num, 1, $userId);
+        // 交易商家
+        $businessInfo = MemberService::make()->getInfo($businessId);
         if (empty($businessInfo)) {
             $this->error = '3004';
             return false;
         }
 
 
-        // 客户身份信息
+        // 购买者身份信息
         $idcardData = [
             'idcard' => isset($userInfo['idcard']) ? $userInfo['idcard'] : '',
             'idcard_check' => isset($userInfo['idcard_check']) ? $userInfo['idcard_check'] : 0,
@@ -139,7 +138,7 @@ class AdvertOrderService extends BaseService
             'idcard_hand_img' => isset($userInfo['idcard_hand_img']) ? $userInfo['idcard_hand_img'] : '',
         ];
 
-        // 币商收款方式
+        // 收款方式
         $payment = MemberPaymentService::make()->getPayment($businessInfo['id']);
         if (empty($payment)) {
             $this->error = '3015';
@@ -154,7 +153,7 @@ class AdvertOrderService extends BaseService
             'order_no' => $orderNo,
             'type' => 1,
             'pay_type' => isset($params['pay_type']) ? floatval($params['pay_type']) : 1,
-            'price' => $tradePrice,
+            'price' => $price,
             'num' => $num,
             'total' => $total,
             'payment_id' => isset($payment['id']) ? intval($payment['id']) : 0,
@@ -172,6 +171,36 @@ class AdvertOrderService extends BaseService
             return false;
         }
 
+
+        if(!$this->memberModel->where(['id'=> $businessInfo['id']])->decrement('usdt_num', $num)){
+            $this->model->rollBack();
+            $this->error = '3020';
+            return false;
+        }
+
+        $data = [
+            'order_no'=> $orderNo,
+            'user_id'=> $businessInfo['id'],
+            'type'=> 2,
+            'pay_type'=> 1,
+            'trade_type'=> 2,
+            'change_type'=> 2,
+            'num'=> $num,
+            'total'=> $total,
+            'balance'=> floatval($businessInfo['usdt_num']-$num),
+            'create_time'=> time(),
+            'update_time'=> time(),
+            'status'=> 1,
+            'mark'=>1,
+            'remark'=> '交易员卖出',
+        ];
+
+        if(!$this->capitalModel->edit($data)){
+            $this->model->rollBack();
+            $this->error = '3014';
+            return false;
+        }
+
         // 订单通知
         $data = [
             'from_uid' => $userId,
@@ -195,4 +224,191 @@ class AdvertOrderService extends BaseService
         $this->model->commit();
         return $order;
     }
+
+    /**
+     * 购买
+     * @param $userId
+     * @param $params
+     * @return false|int|number
+     */
+    public function sell($userId, $params)
+    {
+        $id = isset($params['id']) ? intval($params['id']) : 0;
+        $num = isset($params['num']) ? intval($params['num']) : 0;
+        if ($id <= 0 || $num<=0) {
+            $this->error = '1013';
+            return false;
+        }
+
+        // 验证参数
+        $config = \App\Services\ConfigService::make()->getConfigOptionByGroup(5);
+        $tradeOpen = isset($config['trade_usdt_open']) ? $config['trade_usdt_open'] : 0;
+        $tradeMinNum = isset($config['trade_min_num']) ? $config['trade_min_num'] : 0;
+        $tradeMaxNum = isset($config['trade_max_num']) ? $config['trade_max_num'] : 0;
+        $trademinMoney = isset($config['trade_min_money']) ? $config['trade_min_money'] : 0;
+        $tradeMaxMoney = isset($config['trade_max_money']) ? $config['trade_max_money'] : 0;
+        $tradePrice = isset($config['usdt_buy_price']) ? $config['usdt_sell_price'] : 0;
+        $tradeLimitNum = isset($config['trade_no_catch']) ? $config['trade_no_catch'] : 0;
+
+        // 是否开启交易
+        if ($tradeOpen != 1) {
+            $this->error = '1013';
+            return false;
+        }
+
+        $info = AdvertService::make()->getInfo($id);
+        $tradeType = isset($info['type'])? $info['type'] : 0;
+        $priceType = isset($info['price_type'])? $info['price_type'] : 0;
+        $price = isset($info['price'])? $info['price'] : 0;
+        $businessId = isset($info['business_id'])? $info['business_id'] : 0;
+        if(empty($info) || $info['status'] != 1){
+            $this->error = '4001';
+            return false;
+        }
+
+        if ($tradePrice <= 0 &&  $priceType == 2) {
+            $this->error = '3002';
+            return false;
+        }
+
+        // 验证数量或金额
+        if ($priceType == 2) {
+            $price = floatval($tradePrice + $price);
+        }
+
+        $total = floatval($price * $num);
+
+        // 用户信息
+        $userInfo = MemberService::make()->getInfo($userId);
+        $status = isset($userInfo['status']) ? $userInfo['status'] : 0;
+        $idcardCheck = isset($userInfo['idcard_check']) ? $userInfo['idcard_check'] : 0;
+        $username = isset($userInfo['username']) && $userInfo['username'] ? format_account($userInfo['username']) : '';
+        if ($status != 1) {
+            $this->error = '2009';
+            return false;
+        }
+
+
+        // 未处理订单
+        $noCatchOrder = $this->checkOrderNoCatch($userId, 2);
+        if ($tradeLimitNum > 0 && $noCatchOrder >= $tradeLimitNum) {
+            $this->error = lang(3005, ['num' => $tradeLimitNum]);
+            return false;
+        }
+
+        // 交易商家
+        $businessInfo = MemberService::make()->getInfo($businessId);
+        if (empty($businessInfo)) {
+            $this->error = '3004';
+            return false;
+        }
+
+
+        // 购买者身份信息
+        $idcardData = [
+            'idcard' => isset($userInfo['idcard']) ? $userInfo['idcard'] : '',
+            'idcard_check' => isset($userInfo['idcard_check']) ? $userInfo['idcard_check'] : 0,
+            'idcard_front_img' => isset($userInfo['idcard_front_img']) ? $userInfo['idcard_front_img'] : '',
+            'idcard_back_img' => isset($userInfo['idcard_back_img']) ? $userInfo['idcard_back_img'] : '',
+            'idcard_hand_img' => isset($userInfo['idcard_hand_img']) ? $userInfo['idcard_hand_img'] : '',
+        ];
+
+        // 收款方式
+        $payment = MemberPaymentService::make()->getPayment($userId);
+        if (empty($payment)) {
+            $this->error = '3015';
+            return false;
+        }
+
+        $this->model->startTrans();
+        $orderNo = get_order_num('OT');
+        $data = [
+            'user_id' => $userId,
+            'business_id' => isset($businessInfo['id']) ? $businessInfo['id'] : 0,
+            'order_no' => $orderNo,
+            'type' => 1,
+            'pay_type' => isset($params['pay_type']) ? floatval($params['pay_type']) : 1,
+            'price' => $price,
+            'num' => $num,
+            'total' => $total,
+            'payment_id' => isset($payment['id']) ? intval($payment['id']) : 0,
+            'idcard_data' => $idcardData ? json_encode($idcardData, 256) : '',
+            'payment_data' => $payment ? json_encode($payment, 256) : '',
+            'create_time' => time(),
+            'update_time' => time(),
+            'status' => 1,
+            'mark' => 1,
+        ];
+
+        if (!$order = $this->model->edit($data)) {
+            $this->model->rollBack();
+            $this->error = '3023';
+            return false;
+        }
+
+
+        if(!$this->memberModel->where(['id'=> $businessInfo['id']])->decrement('usdt_num', $num)){
+            $this->model->rollBack();
+            $this->error = '3020';
+            return false;
+        }
+
+        $data = [
+            'order_no'=> $orderNo,
+            'user_id'=> $businessInfo['id'],
+            'type'=> 2,
+            'pay_type'=> 1,
+            'trade_type'=> 2,
+            'change_type'=> 2,
+            'num'=> $num,
+            'total'=> $total,
+            'balance'=> floatval($businessInfo['usdt_num']-$num),
+            'create_time'=> time(),
+            'update_time'=> time(),
+            'status'=> 1,
+            'mark'=>1,
+            'remark'=> '交易员卖出',
+        ];
+
+        if(!$this->capitalModel->edit($data)){
+            $this->model->rollBack();
+            $this->error = '3014';
+            return false;
+        }
+
+        // 订单通知
+        $data = [
+            'from_uid' => $userId,
+            'to_uid' => $businessInfo['id'],
+            'type' => 2,
+            'order_no' => $orderNo,
+            'chat_key' => ChatMessageService::make()->getChatKey($userId, $businessInfo['id']),
+            'message' => "来自用户{$username}的购买订单,金额{$total},单号{$orderNo},时间" . date('Y-m-d H:i:s'),
+            'message_type' => 1,
+            'create_time' => time(),
+            'update_time' => time(),
+            'status' => 1,
+            'mark' => 1,
+        ];
+        if (!ChatMessageService::make()->pushMessage($data)) {
+            $this->model->rollBack();
+            $this->error = '3031';
+            return false;
+        }
+
+        $this->model->commit();
+        return $order;
+    }
+
+    /**
+     * 获取未支付或处理的订单数
+     * @param $userId
+     * @param int $type
+     * @return mixed
+     */
+    public function checkOrderNoCatch($userId, $type = 1)
+    {
+        return $this->model->where(['user_id' => $userId, 'type' => $type, 'mark' => 1])->whereIn('status', [1, 2, 7])->count('id');
+    }
+
 }

+ 1 - 0
app/Services/Common/AdvertService.php

@@ -85,6 +85,7 @@ class AdvertService extends BaseService
                // 固定价格和市场浮动价格处理
                $item['logo_index'] = intval($item['business_id']%5);
                $item['username_text'] = $item['username']? mb_substr($item['username'], 0,1, 'utf-8'):'';
+               $item['username_hidden'] = $item['username']? format_account($item['username']):'';
                $item['create_time_text'] = $item['create_time']? datetime($item['create_time']):'';
                $item['limit_min'] = moneyFormat($item['limit_min'], 2);
                $item['limit_max'] = moneyFormat($item['limit_max'], 2);

+ 18 - 5
app/Services/Common/CapitalLogService.php

@@ -68,22 +68,35 @@ class CapitalLogService extends BaseService
             $where['a.user_id'] = $userId;
         }
 
-        $list = $this->model->from('capital_log as a')
+        $list = $this->model->from('capital_logs as a')
             ->leftJoin('member as m', 'm.id', '=', 'a.user_id')
             ->where($where)
             ->where(function ($query) use($params){
                 $keyword = isset($params['keyword'])? $params['keyword'] : '';
                 if($keyword){
-                    $query->where('a.order_no','like',"{$keyword}")->orWhere('m.username','like',"%{$keyword}%");
+                    $query->where('a.order_no','like',"{$keyword}");
+                }
+
+                // 日期
+                $date = isset($params['date']) ? $params['date'] : [];
+                $start = isset($date[0])? $date[0] : '';
+                $end = isset($date[1])? $date[1] : '';
+                $end = $start>=$end? '' : $end;
+                if ($start) {
+                    $query->where('a.create_time','>=', strtotime($start));
+                }
+                if($end){
+                    $query->where('a.create_time','<', strtotime($end));
                 }
             })
             ->select(['a.*', 'm.username'])
+            ->orderBy('a.create_time','desc')
             ->paginate($pageSize > 0 ? $pageSize : 9999999);
         $list = $list? $list->toArray() :[];
         if($list){
-//            foreach($list['data'] as &$item){
-//
-//            }
+            foreach($list['data'] as &$item){
+                $item['time_text'] = $item['create_time']? datetime(strtotime($item['create_time']), 'm-d H:i'):'';
+            }
         }
 
         return [

+ 17 - 1
app/Services/Common/CoinLogService.php

@@ -62,6 +62,7 @@ class CoinLogService extends BaseService
     {
         $where = ['a.mark' => 1];
         $type = isset($params['type'])? $params['type'] : 1;
+        $status = isset($params['status'])? $params['status'] : 0;
         $changeType = isset($params['change_type'])? $params['change_type'] : 1;
         $contactType = isset($params['contact_type'])? $params['contact_type'] : 1;
         $coinType = isset($params['coin_type'])? $params['coin_type'] : 1;
@@ -69,6 +70,9 @@ class CoinLogService extends BaseService
         if($type>0){
             $where['a.type'] = $type;
         }
+        if($status>0){
+            $where['a.status'] = $status;
+        }
         if($contactType>0){
             $where['a.contact_type'] = $contactType;
         }
@@ -90,6 +94,18 @@ class CoinLogService extends BaseService
                 if($keyword){
                     $query->where('a.order_no','like',"{$keyword}")->orWhere('m.username','like',"%{$keyword}%");
                 }
+
+                // 日期
+                $date = isset($params['date']) ? $params['date'] : [];
+                $start = isset($date[0])? $date[0] : '';
+                $end = isset($date[1])? $date[1] : '';
+                $end = $start>=$end? '' : $end;
+                if ($start) {
+                    $query->where('a.create_time','>=', strtotime($start));
+                }
+                if($end){
+                    $query->where('a.create_time','<', strtotime($end));
+                }
             })
             ->select(['a.*', 'm.username'])
             ->orderBy('a.create_time','desc')
@@ -143,7 +159,7 @@ class CoinLogService extends BaseService
         }
 
         $data = $this->model->where(['txid' => $txid])
-            ->select(['id', 'user_id', 'num', 'coin_type', 'change_type', 'status'])
+            ->select(['id', 'user_id','order_no', 'num','free', 'coin_type', 'balance', 'change_type', 'status'])
             ->first();
         if($data){
             RedisService::set($cacheKey, $data, rand(3,5));

+ 2 - 2
app/Services/Common/LoginLogService.php

@@ -40,7 +40,7 @@ class LoginLogService extends BaseService
      * @since 2020/11/12
      * @author laravel开发员
      */
-    public function getList()
+    public function getList($username='')
     {
         // 查询条件
         $param = request()->all();
@@ -51,7 +51,7 @@ class LoginLogService extends BaseService
                 ->orWhere('title', 'like', '%注销系统%');
         });
         // 用户账号
-        $username = getter($param, "username");
+        $username = $username? $username : getter($param, "username");
         if ($username) {
             $query = $query->where("username", "=", $username);
         }

+ 1 - 1
app/Services/Common/TradeOrderService.php

@@ -379,7 +379,7 @@ class TradeOrderService extends BaseService
      */
     public function checkOrderNoCatch($userId, $type = 1)
     {
-        return $this->model->where(['user_id' => $userId, 'type' => $type, 'mark' => 1])->whereIn('status', [1, 2])->count('id');
+        return $this->model->where(['user_id' => $userId, 'type' => $type, 'mark' => 1])->whereIn('status', [1, 2, 7])->count('id');
     }
 
     /**

+ 119 - 10
app/Services/UsdtWalletService.php

@@ -11,6 +11,7 @@
 
 namespace App\Services;
 
+use App\Models\CapitalLogModel;
 use App\Models\CoinLogModel;
 use App\Models\MemberModel;
 use App\Services\Api\MemberService;
@@ -56,6 +57,7 @@ class UsdtWalletService extends BaseService
     {
         $this->memberModel = new MemberModel();
         $this->coinModel = new CoinLogModel();
+        $this->capitalModel = new CapitalLogModel();
         $this->config = ConfigService::make()->getConfigOptionByGroup(4);
         $this->apiUrl = isset($this->config['usdt_api_url']) ? $this->config['usdt_api_url'] : '';
         if (empty($this->config) || empty($this->apiUrl)) {
@@ -396,12 +398,13 @@ class UsdtWalletService extends BaseService
             $txid = isset($v['transaction_id']) ? $v['transaction_id'] : '';
             if (!CoinLogService::make()->checkExists('txid', $txid) && $time > time() - 12 * 3600) {
                 $balance = $this->memberModel->where(['id' => $userId])->value('usdt_num');
+                $orderNo = get_order_num('TR');
                 $log = [
                     'user_id' => $userId,
                     'change_type' => 1,
                     'coin_type' => $coinType,
                     'contact_type' => 1,
-                    'order_no' => get_order_num('TR'),
+                    'order_no' => $orderNo,
                     'from_address' => isset($v['from']) ? $v['from'] : '',
                     'to_address' => isset($v['to']) ? $v['to'] : '',
                     'txid' => $txid,
@@ -416,6 +419,25 @@ class UsdtWalletService extends BaseService
                 if ($amount >= $coinInMin && $this->memberModel->where(['id' => $userId])->increment('usdt_num', $amount)) {
                     $this->memberModel->where(['id' => $userId])->increment('trc_usdt', $amount);
                     $log['status'] = 1;
+
+                    $data = [
+                        'order_no' => $orderNo,
+                        'user_id' => $userId,
+                        'type' => 4,
+                        'pay_type' => 1,
+                        'trade_type' => 3,
+                        'change_type' => 1,
+                        'num' => $amount,
+                        'total' => 0,
+                        'balance' => floatval($balance+$amount),
+                        'create_time' => time(),
+                        'update_time' => time(),
+                        'remark' => '存币',
+                        'status' => 1,
+                        'mark' => 1,
+                    ];
+
+                    $this->capitalModel->edit($data);
                 }
 
                 $logs[] = $log;
@@ -442,11 +464,11 @@ class UsdtWalletService extends BaseService
 
         // 存币
         if($type == 1){
-            $url = sprintf($this->apiUrls['usdt_trx2_transfer_logs'], $address, $limit, 'true', 'false');
+            $url = sprintf($this->apiUrls['usdt_trx2_transfer_log'], $address, $limit, 'true', 'false');
         }
         // 提币
         else{
-            $url = sprintf($this->apiUrls['usdt_trx2_transfer_logs'], $address, $limit, 'false', 'true');
+            $url = sprintf($this->apiUrls['usdt_trx2_transfer_log'], $address, $limit, 'false', 'true');
         }
         $headers = ["TRON-PRO-API-KEY" => $this->config['tron_api_key']];
         RedisService::set("caches:wallets:transfer_temp_otc_{$type}", ['url' => $this->config['tron_api_url'] . $url], 600);
@@ -459,6 +481,18 @@ class UsdtWalletService extends BaseService
             return false;
         }
 
+        if($datas){
+            foreach ($datas as &$item){
+                $time = ($item['block_timestamp']/1000);
+                $item['time_text'] = $time? datetime($time, 'm-d H:i') : '';
+                $item['num'] = floatval($item['value']/1000000);
+                $item['contact_type'] = 1;
+                $item['change_type'] = $type;
+                $item['status'] = 1;
+            }
+        }
+
+
         return $datas;
     }
 
@@ -503,6 +537,27 @@ class UsdtWalletService extends BaseService
                     // 直接更新提币状态
                     CoinLogModel::where(['txid' => $txid, 'user_id' => $userId])->update(['status' => 1, 'update_time' => time()]);
 
+                    // 明细处理
+                    $num = floatval($coinInfo['num'] + $coinInfo['free']);
+                    $data = [
+                        'order_no' => $coinInfo['order_no'],
+                        'user_id' => $userId,
+                        'type' => 5,
+                        'pay_type' => 1,
+                        'trade_type' => 3,
+                        'change_type' => 2,
+                        'num' => $num,
+                        'total' => 0,
+                        'balance' => floatval($coinInfo['balance']-$num),
+                        'create_time' => time(),
+                        'update_time' => time(),
+                        'remark' => '提币',
+                        'status' => 1,
+                        'mark' => 1,
+                    ];
+
+                    $this->capitalModel->edit($data);
+
                     $logs[] = ['log'=> $v,'order'=> $coinInfo];
                 }
             }
@@ -548,12 +603,13 @@ class UsdtWalletService extends BaseService
             $txid = isset($v['transaction_id']) ? $v['transaction_id'] : '';
             if (!CoinLogService::make()->checkExists('txid', $txid) && $time > time() - 12 * 3600) {
                 $balance = $this->memberModel->where(['id' => $userId])->value('usdt_num');
+                $orderNo = get_order_num('TW');
                 $log = [
                     'user_id' => $userId,
                     'change_type' => 2,
                     'coin_type' => $coinType,
                     'contact_type' => 1,
-                    'order_no' => get_order_num('TW'),
+                    'order_no' => $orderNo,
                     'from_address' => isset($v['from']) ? $v['from'] : '',
                     'to_address' => isset($v['to']) ? $v['to'] : '',
                     'txid' => $txid,
@@ -568,6 +624,27 @@ class UsdtWalletService extends BaseService
                 if ($amount >= $coinOutMin && $this->memberModel->where(['id' => $userId])->decrement('usdt_num', $amount)) {
                     $this->memberModel->where(['id' => $userId])->decrement('trc_usdt', $amount);
                     $log['status'] = 1;
+
+                    // 明细处理
+                    $data = [
+                        'order_no' => $orderNo,
+                        'user_id' => $userId,
+                        'type' => 5,
+                        'pay_type' => 1,
+                        'trade_type' => 3,
+                        'change_type' => 2,
+                        'num' => $amount,
+                        'total' => 0,
+                        'balance' => floatval($balance - $amount),
+                        'create_time' => time(),
+                        'update_time' => time(),
+                        'remark' => '提币',
+                        'status' => 1,
+                        'mark' => 1,
+                    ];
+
+                    $this->capitalModel->edit($data);
+
                 }
 
                 $logs[] = $log;
@@ -626,11 +703,6 @@ class UsdtWalletService extends BaseService
      */
     public function getTrc20Usdt($address)
     {
-        $cacheKey = "caches:wallet:balance:{$address}";
-        if (RedisService::get($cacheKey)) {
-            return false;
-        }
-
         if (empty($address)) {
             $this->error = '1018';
             return false;
@@ -651,7 +723,6 @@ class UsdtWalletService extends BaseService
             $address = $tron->getAddress();
             $address = new \Tron\Address($address['base58'], '', $address['hex']);
             $result = $trxWallet->balance($address);
-
             return $result ? floatval($result) : '0.00';
 
         } catch (\Exception $exception) {
@@ -720,4 +791,42 @@ class UsdtWalletService extends BaseService
 
     }
 
+    /**
+     * USDT-ERC20余额
+     * @param $address
+     * @return false|float|string
+     */
+    public function getErc20Usdt($address)
+    {
+        $cacheKey = "caches:wallet:balance:{$address}";
+        if (RedisService::get($cacheKey)) {
+            return false;
+        }
+
+        if (empty($address)) {
+            $this->error = '1018';
+            return false;
+        }
+
+        try {
+            return '0.00';
+
+        } catch (\Exception $exception) {
+            $this->error = $exception->getMessage();
+            return false;
+        }
+    }
+
+    /**
+     * 获取USDT-ERC2.0交易记录(进出账)
+     * @param $address 用户钱包地址
+     * @param int $coinType 币种:1-usdt
+     * @param int $limit 转账记录数,最新的
+     * @return array|false
+     */
+    public function getErc20TransferLog($address, $type = 1, $limit = 50)
+    {
+
+    }
+
 }