|
@@ -9,6 +9,7 @@ use App\Models\PaymentOrder;
|
|
|
use App\Models\Wallet;
|
|
use App\Models\Wallet;
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
use Telegram\Bot\Api;
|
|
use Telegram\Bot\Api;
|
|
|
|
|
+use Telegram\Bot\Exceptions\TelegramSDKException;
|
|
|
|
|
|
|
|
class QianBaoWithdrawService
|
|
class QianBaoWithdrawService
|
|
|
{
|
|
{
|
|
@@ -18,12 +19,10 @@ class QianBaoWithdrawService
|
|
|
* @param $chatId
|
|
* @param $chatId
|
|
|
* @param $firstName
|
|
* @param $firstName
|
|
|
* @param $messageId
|
|
* @param $messageId
|
|
|
- * @throws \Telegram\Bot\Exceptions\TelegramSDKException
|
|
|
|
|
|
|
+ * @throws TelegramSDKException
|
|
|
*/
|
|
*/
|
|
|
- public static function init(Api $telegram, $data, $chatId, $firstName, $messageId)
|
|
|
|
|
|
|
+ public static function init(Api $telegram, $data, $chatId, $firstName, $messageId): void
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
//点击钱宝提现按钮
|
|
//点击钱宝提现按钮
|
|
|
if ($data === "withdraw@@qb_show_channel") {
|
|
if ($data === "withdraw@@qb_show_channel") {
|
|
|
$res = QianBaoWithdrawService::chooseType($chatId, $messageId);
|
|
$res = QianBaoWithdrawService::chooseType($chatId, $messageId);
|
|
@@ -118,30 +117,16 @@ class QianBaoWithdrawService
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static function onMessage($chatId, $text, $messageId, $stepStatus)
|
|
|
|
|
|
|
+ public static function onMessage($chatId, $text, $messageId, $stepStatus): null|array
|
|
|
{
|
|
{
|
|
|
- switch ($stepStatus) {
|
|
|
|
|
- case StepStatus::QB_INPUT_ALIAS:
|
|
|
|
|
- $res = QianBaoWithdrawService::inputAliAs($chatId, $text, $messageId);
|
|
|
|
|
- return $res;
|
|
|
|
|
- break;
|
|
|
|
|
- case StepStatus::INPUT_WITHDRAW_QB_MONEY://输入提现金额
|
|
|
|
|
- $res = QianBaoWithdrawService::inputQbAmount($chatId, $text, $messageId);
|
|
|
|
|
- return $res;
|
|
|
|
|
- break;
|
|
|
|
|
- case StepStatus::QB_INPUT_BANK_NAME://输入银行名称
|
|
|
|
|
- $res = QianBaoWithdrawService::inputBankName($chatId, $text, $messageId);
|
|
|
|
|
- return $res;
|
|
|
|
|
- case StepStatus::QB_INPUT_CARD_NO://输入银行卡号/支付宝账号
|
|
|
|
|
- $res = QianBaoWithdrawService::inputCardNo($chatId, $text, $messageId);
|
|
|
|
|
- return $res;
|
|
|
|
|
- break;
|
|
|
|
|
- case StepStatus::QB_INPUT_ACCOUNT://输入姓名
|
|
|
|
|
- $res = QianBaoWithdrawService::inputAccount($chatId, $text, $messageId);
|
|
|
|
|
- return $res;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ return match ($stepStatus) {
|
|
|
|
|
+ StepStatus::QB_INPUT_ALIAS => QianBaoWithdrawService::inputAliAs($chatId, $text, $messageId),
|
|
|
|
|
+ StepStatus::INPUT_WITHDRAW_QB_MONEY => QianBaoWithdrawService::inputQbAmount($chatId, $text, $messageId),
|
|
|
|
|
+ StepStatus::QB_INPUT_BANK_NAME => QianBaoWithdrawService::inputBankName($chatId, $text, $messageId),
|
|
|
|
|
+ StepStatus::QB_INPUT_CARD_NO => QianBaoWithdrawService::inputCardNo($chatId, $text, $messageId),
|
|
|
|
|
+ StepStatus::QB_INPUT_ACCOUNT => QianBaoWithdrawService::inputAccount($chatId, $text, $messageId),
|
|
|
|
|
+ default => null,
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -402,7 +387,7 @@ class QianBaoWithdrawService
|
|
|
|
|
|
|
|
|
|
|
|
|
//银行卡管理
|
|
//银行卡管理
|
|
|
- private static function banks($chatId, $messageId, $channel)
|
|
|
|
|
|
|
+ private static function banks($chatId, $messageId, $channel = ""): array
|
|
|
{
|
|
{
|
|
|
switch ($channel) {
|
|
switch ($channel) {
|
|
|
case "DF001":
|
|
case "DF001":
|
|
@@ -493,7 +478,7 @@ class QianBaoWithdrawService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//添加银行卡
|
|
//添加银行卡
|
|
|
- private static function addBank($chatId, $messageId)
|
|
|
|
|
|
|
+ private static function addBank($chatId, $messageId): array
|
|
|
{
|
|
{
|
|
|
$text = "请选择 提现通道\n";
|
|
$text = "请选择 提现通道\n";
|
|
|
|
|
|
|
@@ -527,7 +512,6 @@ class QianBaoWithdrawService
|
|
|
'text' => "请输入开户银行卡开户名称",
|
|
'text' => "请输入开户银行卡开户名称",
|
|
|
'message_id' => $messageId,
|
|
'message_id' => $messageId,
|
|
|
];
|
|
];
|
|
|
- break;
|
|
|
|
|
case "DF002"://支付宝
|
|
case "DF002"://支付宝
|
|
|
Cache::put("{$chatId}_QB_WITHDRAW_BANK_NAME", '支付宝');
|
|
Cache::put("{$chatId}_QB_WITHDRAW_BANK_NAME", '支付宝');
|
|
|
Cache::put(get_step_key($chatId), StepStatus::QB_INPUT_CARD_NO);
|
|
Cache::put(get_step_key($chatId), StepStatus::QB_INPUT_CARD_NO);
|
|
@@ -536,7 +520,6 @@ class QianBaoWithdrawService
|
|
|
'text' => "请输入支付宝账号",
|
|
'text' => "请输入支付宝账号",
|
|
|
'message_id' => $messageId,
|
|
'message_id' => $messageId,
|
|
|
];
|
|
];
|
|
|
- break;
|
|
|
|
|
case "DF005"://数字人民币
|
|
case "DF005"://数字人民币
|
|
|
Cache::put("{$chatId}_QB_WITHDRAW_BANK_NAME", '数字人民币');
|
|
Cache::put("{$chatId}_QB_WITHDRAW_BANK_NAME", '数字人民币');
|
|
|
Cache::put(get_step_key($chatId), StepStatus::QB_INPUT_CARD_NO);
|
|
Cache::put(get_step_key($chatId), StepStatus::QB_INPUT_CARD_NO);
|
|
@@ -545,7 +528,6 @@ class QianBaoWithdrawService
|
|
|
'text' => "请输入数字人民币账号",
|
|
'text' => "请输入数字人民币账号",
|
|
|
'message_id' => $messageId,
|
|
'message_id' => $messageId,
|
|
|
];
|
|
];
|
|
|
- break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
default:
|
|
|
return [
|
|
return [
|
|
@@ -553,14 +535,11 @@ class QianBaoWithdrawService
|
|
|
'text' => "选择通道错误",
|
|
'text' => "选择通道错误",
|
|
|
'message_id' => $messageId,
|
|
'message_id' => $messageId,
|
|
|
];
|
|
];
|
|
|
- break;
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//输入银行名称
|
|
//输入银行名称
|
|
|
- private static function inputBankName($chatId, $bankName, $messageId)
|
|
|
|
|
|
|
+ private static function inputBankName($chatId, $bankName, $messageId): array
|
|
|
{
|
|
{
|
|
|
Cache::put("{$chatId}_QB_WITHDRAW_BANK_NAME", $bankName);
|
|
Cache::put("{$chatId}_QB_WITHDRAW_BANK_NAME", $bankName);
|
|
|
Cache::put(get_step_key($chatId), StepStatus::QB_INPUT_CARD_NO);
|
|
Cache::put(get_step_key($chatId), StepStatus::QB_INPUT_CARD_NO);
|
|
@@ -572,7 +551,7 @@ class QianBaoWithdrawService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//输入卡号
|
|
//输入卡号
|
|
|
- private static function inputCardNo($chatId, $cardNo, $messageId)
|
|
|
|
|
|
|
+ private static function inputCardNo($chatId, $cardNo, $messageId): array
|
|
|
{
|
|
{
|
|
|
$channel = Cache::get("{$chatId}_QB_WITHDRAW_CHANNEL");
|
|
$channel = Cache::get("{$chatId}_QB_WITHDRAW_CHANNEL");
|
|
|
if ($channel === 'DF001' && !preg_match('/^\d+$/', $cardNo)) {
|
|
if ($channel === 'DF001' && !preg_match('/^\d+$/', $cardNo)) {
|