Ken il y a 2 jours
Parent
commit
05a47a453a
2 fichiers modifiés avec 25 ajouts et 5 suppressions
  1. 1 0
      app/Constants/StepStatus.php
  2. 24 5
      app/Services/QianBaoWithdrawService.php

+ 1 - 0
app/Constants/StepStatus.php

@@ -32,6 +32,7 @@ class StepStatus
     const QB_INPUT_BANK_NAME = 18;//输入 银行名称
     const QB_INPUT_CARD_NO = 19;//输入 银行卡号/支付宝账号
     const QB_INPUT_ACCOUNT = 20;//输入 姓名
+    const QB_INPUT_ALIAS = 22;//输入账号别名
 
     const INPUT_RECHARGE_SJ_MONEY = 21;//输入 三斤充值金额
 }

+ 24 - 5
app/Services/QianBaoWithdrawService.php

@@ -92,7 +92,6 @@ class QianBaoWithdrawService
 //        }
 
 
-
         //银行卡详情
         $pattern = "/^withdrawAddress@@bank_detail\d+$/";
         if (preg_match($pattern, $data)) {
@@ -109,8 +108,6 @@ class QianBaoWithdrawService
         }
 
 
-
-
         $pattern = "/^withdrawAddress@@bank_choose_channel_.*$/";
         if (preg_match($pattern, $data)) {
             $channel = preg_replace('/^withdrawAddress@@bank_choose_channel_/', '', $data);
@@ -124,6 +121,10 @@ class QianBaoWithdrawService
     public static function onMessage($chatId, $text, $messageId, $stepStatus)
     {
         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;
@@ -570,17 +571,35 @@ class QianBaoWithdrawService
 
     //输入姓名,并保存到数据库
     private static function inputAccount($chatId, $account, $messageId)
+    {
+
+        Cache::put("{$chatId}_QB_ACCOUNT", $account);
+        Cache::put(get_step_key($chatId), StepStatus::QB_INPUT_ALIAS);
+
+        return [
+            'chat_id' => $chatId,
+            'text' => "请输入账号别名",
+            'message_id' => $messageId,
+        ];
+
+
+    }
+
+    private static function inputAliAs($chatId, $alias, $messageId)
     {
         $channel = Cache::get("{$chatId}_QB_WITHDRAW_CHANNEL");
         $cardNo = Cache::get("{$chatId}_QB_WITHDRAW_CARD_NO");
         $bankName = Cache::get("{$chatId}_QB_WITHDRAW_BANK_NAME");
+        $account = Cache::get("{$chatId}_QB_ACCOUNT");
         Bank::create([
             'member_id' => $chatId,
             'account' => $account,
             'channel' => $channel,
             'card_no' => $cardNo,
-            'bank_name' => $bankName
+            'bank_name' => $bankName,
+            'alias' => $alias
         ]);
-        return static::banks($chatId, $messageId,$channel);
+        Cache::delete(get_step_key($chatId));
+        return static::banks($chatId, $messageId, $channel);
     }
 }