Ken 1 неделя назад
Родитель
Сommit
008abe4519

+ 4 - 19
app/Http/Controllers/api/TelegramWebHook.php

@@ -229,31 +229,16 @@ class TelegramWebHook extends BaseController
                         //关键字回复
                         $res = KeyboardService::getKeyWordReply($chatId, $text);
                         if (!empty($res)) return $res;
-
                         $stepStatus = intval(Cache::get(get_step_key($chatId), -1));
-
                         $res = QianBaoWithdrawService::onMessage($chatId, $text, $messageId, $stepStatus);
                         if (empty($res)) $res = SanJinRechargeService::onMessage($chatId, $text, $messageId, $stepStatus);
                         if (empty($res)) $res = SecretService::onMessage($chatId, $text, $messageId, $stepStatus);
+                        if (empty($res)) $res = WithdrawService::onMessage($chatId, $text, $messageId, $stepStatus);
+                        if (empty($res)) $res = TopUpService::onMessage($chatId, $text, $messageId, $stepStatus);
+                        if (empty($res)) $res = BetService::onMessage($chatId, $text, $messageId, $stepStatus);
                         if (!empty($res)) return $res;
-
-
-                        switch ($stepStatus) {
-                            case StepStatus::INPUT_TOP_UP_MONEY:
-                                return TopUpService::inputAmount($chatId, $text, $messageId);
-                            case StepStatus::INPUT_WITHDRAW_MONEY:
-                                return (new WithdrawService())->inputAmount($chatId, $text, $messageId)[0];
-                            case StepStatus::INPUT_ADDRESS_TRC20:
-                                return WithdrawService::inputAddress($chatId, $text, $messageId);
-                            case StepStatus::INPUT_ADDRESS_ALIAS:
-                                return WithdrawService::inputAlias($chatId, $text, $messageId);
-                            default:
-                                $returnMsg = BetService::bet($chatId, $text, $messageId);
-                                break;
-                        }
-
+                        return BetService::bet($chatId, $text, $messageId);
                 }
-
                 return $returnMsg;
             }
         }

+ 12 - 0
app/Services/BetService.php

@@ -3,6 +3,7 @@
 
 namespace App\Services;
 
+use App\Constants\StepStatus;
 use App\Models\Message;
 use App\Models\PcIssue;
 use App\Models\Rebate;
@@ -74,6 +75,17 @@ class BetService extends BaseService
 
     }
 
+    public static function onMessage($chatId, $text, $messageId, $stepStatus): ?array
+    {
+        switch ($stepStatus) {
+
+            default:
+                $res =null;
+                break;
+        }
+        return $res;
+    }
+
 
     public static $OTHER_BET_1 = [
         '大',

+ 12 - 1
app/Services/TopUpService.php

@@ -70,10 +70,21 @@ class TopUpService
                 }
 
 
+                break;
+        }
+    }
 
-
+    public static function onMessage($chatId, $text, $messageId, $stepStatus): ?array
+    {
+        switch ($stepStatus) {
+            case StepStatus::INPUT_TOP_UP_MONEY:
+                $res = TopUpService::inputAmount($chatId, $text, $messageId);
+                break;
+            default:
+                $res = null;
                 break;
         }
+        return $res;
     }
 
 

+ 26 - 4
app/Services/WithdrawService.php

@@ -91,6 +91,27 @@ class WithdrawService
     }
 
 
+    public static function onMessage($chatId, $text, $messageId, $stepStatus)
+    {
+        switch ($stepStatus) {
+            case StepStatus::INPUT_WITHDRAW_MONEY:
+                $res = WithdrawService::inputAmount($chatId, $text, $messageId);
+                $res = $res[0];
+                break;
+            case StepStatus::INPUT_ADDRESS_TRC20:
+                $res = WithdrawService::inputAddress($chatId, $text, $messageId);
+                break;
+            case StepStatus::INPUT_ADDRESS_ALIAS:
+                $res = WithdrawService::inputAlias($chatId, $text, $messageId);
+                break;
+            default:
+                $res = null;
+                break;
+        }
+        return $res;
+    }
+
+
     public static function model(): string
     {
         return Withdraw::class;
@@ -459,7 +480,7 @@ class WithdrawService
 
 
     //用户输入提现金额(USDT)
-    public function inputAmount($chatId, $amount, $messageId)
+    public static function inputAmount($chatId, $amount, $messageId)
     {
         if (!preg_match('/^-?\d+(\.\d+)?$/', $amount)) {
             return [[
@@ -481,10 +502,12 @@ class WithdrawService
         // 汇率
         $rate = Config::where('field', 'exchange_rate_rmb')->first()->val ?? 1;
         $rate_amount = bcdiv($temp, $rate, 2);
-        if ($amount <= $this->serviceCharge) {
+        $serviceCharge = Config::where('field', 'service_charge')->first()->val;
+        $serviceCharge = floatval($serviceCharge);
+        if ($amount <= $serviceCharge) {
             return [[
                 'chat_id' => $chatId,
-                'text' => lang("⚠️提现不能少于") . "{$this->serviceCharge} USDT," . lang('请重试'),
+                'text' => lang("⚠️提现不能少于") . "{$serviceCharge} USDT," . lang('请重试'),
                 'reply_to_message_id' => $messageId
             ]];
         }
@@ -637,7 +660,6 @@ class WithdrawService
     }
 
 
-    
     public static function batchReject()
     {
         $list = Withdraw::where('status', 0)->get();