|
@@ -9,9 +9,53 @@ use App\Models\Bank;
|
|
|
use App\Models\Config;
|
|
use App\Models\Config;
|
|
|
use App\Models\Wallet;
|
|
use App\Models\Wallet;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
+use Telegram\Bot\Api;
|
|
|
|
|
|
|
|
class QianBaoWithdrawService
|
|
class QianBaoWithdrawService
|
|
|
{
|
|
{
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param Api $telegram
|
|
|
|
|
+ * @param $data
|
|
|
|
|
+ * @param $chatId
|
|
|
|
|
+ * @param $firstName
|
|
|
|
|
+ * @param $messageId
|
|
|
|
|
+ * @throws \Telegram\Bot\Exceptions\TelegramSDKException
|
|
|
|
|
+ */
|
|
|
|
|
+ static function init(Api $telegram, $data, $chatId, $firstName, $messageId)
|
|
|
|
|
+ {
|
|
|
|
|
+ //点击钱宝提现按钮
|
|
|
|
|
+ if ($data === "withdraw@@qb_apply") {
|
|
|
|
|
+ $res = QianBaoWithdrawService::qbApply($chatId, $messageId);
|
|
|
|
|
+ $telegram->editMessageText($res);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //选择银行卡号
|
|
|
|
|
+ $pattern = "/^withdrawAddress@@choose_qb_\d+$/";
|
|
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
|
|
+ $id = preg_replace('/^withdrawAddress@@choose_qb_/', '', $data);
|
|
|
|
|
+ $res = QianBaoWithdrawService::chooseBank($chatId, $id);
|
|
|
|
|
+ $telegram->deleteMessage([
|
|
|
|
|
+ 'chat_id' => $chatId,
|
|
|
|
|
+ 'message_id' => $messageId,
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $telegram->sendMessage($res);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //银行卡管理
|
|
|
|
|
+ if ($data === 'withdraw@@banks') {
|
|
|
|
|
+ $res = QianBaoWithdrawService::banks($chatId, $messageId);
|
|
|
|
|
+ $telegram->editMessageText($res);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //添加银行卡
|
|
|
|
|
+ if ($data = "withdrawAddress@@bank_add") {
|
|
|
|
|
+ $res = QianBaoWithdrawService::addBank($chatId, $messageId);
|
|
|
|
|
+ $telegram->editMessageText($res);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//1.钱宝提现
|
|
//1.钱宝提现
|
|
|
static function qbApply($chatId, $messageId)
|
|
static function qbApply($chatId, $messageId)
|
|
|
{
|
|
{
|
|
@@ -99,7 +143,7 @@ class QianBaoWithdrawService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//3.选择银行卡号
|
|
//3.选择银行卡号
|
|
|
- static function chooseBank($chatId, $firstName, $messageId, $id)
|
|
|
|
|
|
|
+ static function chooseBank($chatId, $id)
|
|
|
{
|
|
{
|
|
|
$amount = Cache::get("{$chatId}_WITHDRAW_QB_MONEY", '');
|
|
$amount = Cache::get("{$chatId}_WITHDRAW_QB_MONEY", '');
|
|
|
if (!$amount) return WalletService::getBalance($chatId);
|
|
if (!$amount) return WalletService::getBalance($chatId);
|
|
@@ -129,7 +173,7 @@ class QianBaoWithdrawService
|
|
|
$keyboard[] = [['text' => "$item->card_no($item->bank_name)", 'callback_data' => "withdrawAddress@@bank_detail{$item->id}"]];
|
|
$keyboard[] = [['text' => "$item->card_no($item->bank_name)", 'callback_data' => "withdrawAddress@@bank_detail{$item->id}"]];
|
|
|
}
|
|
}
|
|
|
if (count($list) < 5) {
|
|
if (count($list) < 5) {
|
|
|
- $keyboard[] = [['text' => "➕ 添加银行卡", 'callback_data' => "withdrawAddress@@bang_add"]];
|
|
|
|
|
|
|
+ $keyboard[] = [['text' => "➕ 添加银行卡", 'callback_data' => "withdrawAddress@@bank_add"]];
|
|
|
}
|
|
}
|
|
|
$keyboard[] = [['text' => "↩️返回", 'callback_data' => "withdraw@@home"]];
|
|
$keyboard[] = [['text' => "↩️返回", 'callback_data' => "withdraw@@home"]];
|
|
|
return [
|
|
return [
|
|
@@ -140,6 +184,26 @@ class QianBaoWithdrawService
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ static function addBank($chatId, $messageId)
|
|
|
|
|
+ {
|
|
|
|
|
+ $text = "请选择 提现通道\n";
|
|
|
|
|
+
|
|
|
|
|
+ $keyboard = [
|
|
|
|
|
+ [
|
|
|
|
|
+ ['text' => '银行卡', 'callback_data' => "withdrawAddress@@bank_choose_channel_DF001"]
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ ['text' => '支付宝', 'callback_data' => "withdrawAddress@@bank_choose_channel_DF002"]
|
|
|
|
|
+ ]
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ return [
|
|
|
|
|
+ 'chat_id' => $chatId,
|
|
|
|
|
+ 'text' => $text,
|
|
|
|
|
+ 'message_id' => $messageId,
|
|
|
|
|
+ 'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|