Ken 1 settimana fa
parent
commit
70b563fa7c

+ 11 - 6
app/Http/Controllers/api/TelegramWebHook.php

@@ -9,6 +9,7 @@ use App\Http\Controllers\Controller;
 use App\Models\Message;
 use App\Models\User;
 use App\Services\OnLineService;
+use App\Services\QianBaoWithdrawService;
 use App\Services\RecordService;
 use App\Services\RoomService;
 use App\Services\SettlementService;
@@ -198,16 +199,16 @@ class TelegramWebHook extends Controller
                     $telegram->editMessageText($res);
                 }
 
-                //点击提现按钮
+                //点击钱宝提现按钮
                 if ($data === "withdraw@@qb_apply") {
-                    $res =WithdrawService::qbApply($chatId, $messageId);
+                    $res = QianBaoWithdrawService::qbApply($chatId, $messageId);
                     $telegram->editMessageText($res);
                 }
 
 
                 //银行卡管理
                 if ($data === 'withdraw@@banks') {
-                    $res = WithdrawService::banks($chatId, $messageId);
+                    $res = QianBaoWithdrawService::banks($chatId, $messageId);
                     $telegram->editMessageText($res);
                 }
 
@@ -295,8 +296,12 @@ class TelegramWebHook extends Controller
                 $pattern = "/^withdrawAddress@@choose_qb_\d+$/";
                 if (preg_match($pattern, $data)) {
                     $id = preg_replace('/^withdrawAddress@@choose_qb_/', '', $data);
-                    $res = WithdrawService::chooseBank($chatId, $firstName, $messageId, $id);
-                    $telegram->editMessageText($res);
+                    $res = QianBaoWithdrawService::chooseBank($chatId, $firstName, $messageId, $id);
+                    $telegram->deleteMessage([
+                        'chat_id' => $chatId,
+                        'message_id' => $messageId,
+                    ]);
+                    $telegram->sendMessage($res);
                 }
 
                 //选择提现地址
@@ -642,7 +647,7 @@ class TelegramWebHook extends Controller
                                 return $res[0];
                                 break;
                             case StepStatus::INPUT_WITHDRAW_QB_MONEY:
-                                $res =  WithdrawService::inputQbAmount($chatId, $text, $messageId);
+                                $res = QianBaoWithdrawService::inputQbAmount($chatId, $text, $messageId);
                                 return $res;
                                 break;
                             case StepStatus::INPUT_ADDRESS_TRC20:

+ 152 - 0
app/Services/QianBaoWithdrawService.php

@@ -0,0 +1,152 @@
+<?php
+
+
+namespace App\Services;
+
+
+use App\Constants\StepStatus;
+use App\Models\Bank;
+use App\Models\Config;
+use App\Models\Wallet;
+use Illuminate\Support\Facades\Cache;
+
+class QianBaoWithdrawService
+{
+    //1.钱宝提现
+    static function qbApply($chatId, $messageId)
+    {
+        $three_payment_switch = Config::where('field', 'three_payment_switch')->first()->val;
+        if ($three_payment_switch != 1) {
+            $res = WalletService::getBalance($chatId);
+            $res['message_id'] = $messageId;
+            return $res;
+        }
+
+        $wallet = Wallet::where('member_id', $chatId)->first();
+        $temp = floatval($wallet->available_balance);
+        $text = "请发送提现金额\n";
+        $text .= "💰 当前余额{$temp} RMB\n";
+
+
+        Cache::put(get_step_key($chatId), StepStatus::INPUT_WITHDRAW_QB_MONEY);
+        return [
+            'chat_id' => $chatId,
+            'text' => $text,
+            'message_id' => $messageId,
+        ];
+    }
+
+    //2.输入钱宝提现金额
+    static function inputQbAmount($chatId, $amount, $messageId)
+    {
+        if (!preg_match('/^\d+(\.\d{1,2})?$/', $amount)) {
+            return [
+                'chat_id' => $chatId,
+                'text' => "金额输入不正确,请发送提现数字",
+                'reply_to_message_id' => $messageId
+            ];
+        }
+        $amount = floatval($amount);
+        $wallet = Wallet::where('member_id', $chatId)->first();
+        $temp = floatval($wallet->available_balance);
+
+        if ($amount > $temp) {
+            return [
+                'chat_id' => $chatId,
+                'text' => "⚠️可用余额不足,请重试",
+                'reply_to_message_id' => $messageId
+            ];
+        }
+
+
+        if ($amount < 100) {
+            return [
+                'chat_id' => $chatId,
+                'text' => "⚠️提现不能少于100 RMB,请重试",
+                'reply_to_message_id' => $messageId
+            ];
+        }
+        if ($amount > 49999) {
+            return [
+                'chat_id' => $chatId,
+                'text' => "⚠️最多提现 49999 RMB,请重试",
+                'reply_to_message_id' => $messageId
+            ];
+        }
+
+
+        Cache::put("{$chatId}_WITHDRAW_MONEY", $amount);
+        $list = Bank::where('member_id', $chatId)->get();
+        $keyboard = [];
+        foreach ($list as $item) {
+            $keyboard[] = [['text' => "$item->card_no($item->bank_name)", 'callback_data' => "withdrawAddress@@choose_qb_{$item->id}"]];
+        }
+        $keyboard[] = [
+            ['text' => '🏠 银行卡管理', 'callback_data' => "withdraw@@banks"],
+            ['text' => '❌取消', 'callback_data' => "message@@close"]
+        ];
+
+        $text = "请直接选择下面的地址\n";
+        $text .= "⚠️提示:请务必确认提现地址正确无误,\n否则资金丢失将无法找回请自负!";
+        Cache::put("{$chatId}_WITHDRAW_QB_MONEY", $amount);
+        Cache::put(get_step_key($chatId), StepStatus::CHOOSE_WITHDRAW_QB_ADDRESS);
+        return [
+            'chat_id' => $chatId,
+            'text' => $text,
+            'reply_to_message_id' => $messageId,
+            'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
+        ];
+    }
+
+    //3.选择银行卡号
+    static function chooseBank($chatId, $firstName, $messageId, $id)
+    {
+        $amount = Cache::get("{$chatId}_WITHDRAW_QB_MONEY", '');
+        if ($amount) return WithdrawService::index($chatId, $firstName, $messageId);
+
+        $bank = Bank::where('id', $id)->first();
+
+        /**
+         * @description: 创建代付订单
+         * @param {*} $memberId 会员
+         * @param {*} $amount   金额
+         * @param {*} $channel  提现通道 DF001 支付宝转卡/DF002 支付宝转支付宝
+         * @param {*} $bank_name  银行名称/支付宝
+         * @param {*} $account  姓名
+         * @param {*} $card_no  银行卡号/支付宝账号
+         * @return {*}
+         */
+        $result = PaymentOrderService::createPayout($chatId, $amount, $bank->channel, $bank->bank_name, $bank->account, $bank->card_no);
+        return [
+
+        ];
+
+
+    }
+
+
+    //银行卡管理
+    static function banks($chatId, $messageId)
+    {
+        $text = "🏠 银行卡管理\n";
+        $text .= "--------------------------\n";
+
+        $list = Bank::where('member_id', $chatId)
+            ->get();
+
+        $keyboard = [];
+        foreach ($list as $item) {
+            $keyboard[] = [['text' => "$item->card_no($item->bank_name)", 'callback_data' => "withdrawAddress@@bank_detail{$item->id}"]];
+        }
+        if (count($list) < 5) {
+            $keyboard[] = [['text' => "➕ 添加银行卡", 'callback_data' => "withdrawAddress@@bang_add"]];
+        }
+        $keyboard[] = [['text' => "↩️返回", 'callback_data' => "withdraw@@home"]];
+        return [
+            'chat_id' => $chatId,
+            'text' => $text,
+            'message_id' => $messageId,
+            'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
+        ];
+    }
+}

+ 0 - 122
app/Services/WithdrawService.php

@@ -475,136 +475,14 @@ class WithdrawService
         ]];
     }
 
-    //银行卡管理
-    static function banks($chatId, $messageId)
-    {
-        $text = "🏠 银行卡管理\n";
-        $text .= "--------------------------\n";
 
-        $list = Bank::where('member_id', $chatId)
-            ->get();
 
-        $keyboard = [];
-        foreach ($list as $item) {
-            $keyboard[] = [['text' => "$item->card_no($item->bank_name)", 'callback_data' => "withdrawAddress@@bank_detail{$item->id}"]];
-        }
-        if (count($list) < 5) {
-            $keyboard[] = [['text' => "➕ 添加银行卡", 'callback_data' => "withdrawAddress@@bang_add"]];
-        }
-        $keyboard[] = [['text' => "↩️返回", 'callback_data' => "withdraw@@home"]];
-        return [
-            'chat_id' => $chatId,
-            'text' => $text,
-            'message_id' => $messageId,
-            'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
-        ];
-    }
 
 
-    //选择银行卡号
-    static function chooseBank($chatId, $firstName, $messageId, $id)
-    {
-        /**
-         * @description: 创建代付订单
-         * @param {*} $memberId 会员
-         * @param {*} $amount   金额
-         * @param {*} $channel  提现通道 DF001 支付宝转卡/DF002 支付宝转支付宝
-         * @param {*} $bank_name  银行名称/支付宝
-         * @param {*} $account  姓名
-         * @param {*} $card_no  银行卡号/支付宝账号
-         * @return {*}
-         */
-//        PaymentOrderService::createPayout($chatId, $amount, $channel, $bank_name, $account, $card_no);
-
-        $amount = Cache::get("{$chatId}_WITHDRAW_QB_MONEY", '');
-        if ($amount) return WithdrawService::index($chatId, $firstName, $messageId);
-    }
 
-    //输入钱宝提现金额
-    static function inputQbAmount($chatId, $amount, $messageId)
-    {
-        if (!preg_match('/^\d+(\.\d{1,2})?$/', $amount)) {
-            return [
-                'chat_id' => $chatId,
-                'text' => "金额输入不正确,请发送提现数字",
-                'reply_to_message_id' => $messageId
-            ];
-        }
-        $amount = floatval($amount);
-        $wallet = Wallet::where('member_id', $chatId)->first();
-        $temp = floatval($wallet->available_balance);
 
-        if ($amount > $temp) {
-            return [
-                'chat_id' => $chatId,
-                'text' => "⚠️可用余额不足,请重试",
-                'reply_to_message_id' => $messageId
-            ];
-        }
 
 
-        if ($amount < 100) {
-            return [
-                'chat_id' => $chatId,
-                'text' => "⚠️提现不能少于100 RMB,请重试",
-                'reply_to_message_id' => $messageId
-            ];
-        }
-        if ($amount > 49999) {
-            return [
-                'chat_id' => $chatId,
-                'text' => "⚠️最多提现 49999 RMB,请重试",
-                'reply_to_message_id' => $messageId
-            ];
-        }
-
-
-        Cache::put("{$chatId}_WITHDRAW_MONEY", $amount);
-        $list = Bank::where('member_id', $chatId)->get();
-        $keyboard = [];
-        foreach ($list as $item) {
-            $keyboard[] = [['text' =>"$item->card_no($item->bank_name)", 'callback_data' => "withdrawAddress@@choose_qb_{$item->id}"]];
-        }
-        $keyboard[] = [
-            ['text' => '🏠 银行卡管理', 'callback_data' => "withdraw@@banks"],
-            ['text' => '❌取消', 'callback_data' => "message@@close"]
-        ];
-
-        $text = "请直接选择下面的地址\n";
-        $text .= "⚠️提示:请务必确认提现地址正确无误,\n否则资金丢失将无法找回请自负!";
-        Cache::put("{$chatId}_WITHDRAW_QB_MONEY", $amount);
-        Cache::put(get_step_key($chatId), StepStatus::CHOOSE_WITHDRAW_QB_ADDRESS);
-        return [
-            'chat_id' => $chatId,
-            'text' => $text,
-            'reply_to_message_id' => $messageId,
-            'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
-        ];
-    }
-
-    //钱宝提现
-    static function qbApply($chatId, $messageId)
-    {
-        $three_payment_switch = Config::where('field', 'three_payment_switch')->first()->val;
-        if ($three_payment_switch != 1) {
-            $res = WalletService::getBalance($chatId);
-            $res['message_id'] = $messageId;
-            return $res;
-        }
-
-        $wallet = Wallet::where('member_id', $chatId)->first();
-        $temp = floatval($wallet->available_balance);
-        $text = "请发送提现金额\n";
-        $text .= "💰 当前余额{$temp} RMB\n";
-
-
-        Cache::put(get_step_key($chatId), StepStatus::INPUT_WITHDRAW_QB_MONEY);
-        return [
-            'chat_id' => $chatId,
-            'text' => $text,
-            'message_id' => $messageId,
-        ];
-    }
 
     //申请提现
     public function apply($chatId, $messageId)