WithdrawService.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <?php
  2. namespace App\Services;
  3. use App\Constants\StepStatus;
  4. use App\Models\Address;
  5. use App\Models\BalanceLog;
  6. use App\Models\Bank;
  7. use App\Models\Config;
  8. use App\Models\RoomUser;
  9. use App\Models\User;
  10. use App\Models\Wallet;
  11. use App\Models\Withdraw;
  12. use Illuminate\Support\Facades\Cache;
  13. use LaravelLang\Publisher\Console\Add;
  14. use Telegram\Bot\Api;
  15. use Telegram\Bot\Exceptions\TelegramSDKException;
  16. class WithdrawService
  17. {
  18. private $serviceCharge;
  19. public static function init(Api $telegram, $data, $chatId, $firstName, $messageId): void
  20. {
  21. switch ($data) {
  22. case "withdraw@@address"://地址管理
  23. $res = WithdrawService::getAddress($chatId, $messageId);
  24. $telegram->editMessageText($res);
  25. break;
  26. case "withdrawAddress@@done":
  27. $res = WithdrawService::done($chatId, $messageId, $firstName);
  28. $telegram->editMessageText($res);
  29. break;
  30. case "withdraw@@bill"://点击提现的账单按钮
  31. $res = WithdrawService::bill($chatId, $firstName, $messageId);
  32. $telegram->editMessageText($res);
  33. break;
  34. case "withdrawAddress@@add":
  35. $res = WithdrawService::addAddress($chatId, $messageId);
  36. $telegram->editMessageText($res);
  37. break;
  38. case "withdraw@@apply"://点击提现按钮
  39. $res = WithdrawService::apply($chatId, $messageId);
  40. $telegram->editMessageText($res);
  41. break;
  42. default:
  43. //选择提现地址
  44. $pattern = "/^withdrawAddress@@choose\d+$/";
  45. if (preg_match($pattern, $data)) {
  46. $id = preg_replace('/^withdrawAddress@@choose/', '', $data);
  47. $res = WithdrawService::chooseAddress($chatId, $firstName, $messageId, $id);
  48. $telegram->editMessageText($res);
  49. }
  50. //删除地址
  51. $pattern = "/^withdrawAddress@@del\d+$/";
  52. if (preg_match($pattern, $data)) {
  53. $id = preg_replace('/^withdrawAddress@@del/', '', $data);
  54. $res = WithdrawService::delAddress($chatId, $id, $messageId);
  55. $telegram->editMessageText($res);
  56. }
  57. //地址详情
  58. $pattern = "/^withdrawAddress@@detail\d+$/";
  59. if (preg_match($pattern, $data)) {
  60. $id = preg_replace('/^withdrawAddress@@detail/', '', $data);
  61. $res = WithdrawService::addressDetails($chatId, $messageId, $id);
  62. $telegram->editMessageText($res);
  63. }
  64. //提现账单,下一页
  65. $pattern = "/^withdrawBillNextPage@@\d+$/";
  66. if (preg_match($pattern, $data)) {
  67. $page = preg_replace('/^withdrawBillNextPage@@/', '', $data);
  68. $page = intval($page);
  69. $res = WithdrawService::bill($chatId, $firstName, $messageId, $page);
  70. $telegram->editMessageText($res);
  71. }
  72. break;
  73. }
  74. }
  75. public static function model(): string
  76. {
  77. return Withdraw::class;
  78. }
  79. public static function enum(): string
  80. {
  81. return '';
  82. }
  83. public static function getWhere(array $search = []): array
  84. {
  85. $where = [];
  86. if (isset($search['id']) && !empty($search['id'])) {
  87. $where[] = ['id', '=', $search['id']];
  88. }
  89. if (isset($search['member_id']) && !empty($search['member_id'])) {
  90. $where[] = ['member_id', '=', $search['member_id']];
  91. }
  92. if (isset($search['status']) && $search['status'] != '') {
  93. $where[] = ['status', '=', $search['status']];
  94. }
  95. return $where;
  96. }
  97. public static function findOne(array $search): ?Withdraw
  98. {
  99. return self::model()::where(self::getWhere($search))->first();
  100. }
  101. public static function findAll(array $search = [])
  102. {
  103. return self::model()::where(self::getWhere($search))->get();
  104. }
  105. public static function paginate(array $search = [])
  106. {
  107. $limit = isset($search['limit']) ? $search['limit'] : 10;
  108. $paginator = self::model()::where(self::getWhere($search))
  109. ->orderBy('created_at', 'desc')->paginate($limit);
  110. return ['total' => $paginator->total(), 'data' => $paginator->items()];
  111. }
  112. public function __construct()
  113. {
  114. $serviceCharge = Config::where('field', 'service_charge')->first()->val;
  115. $serviceCharge = floatval($serviceCharge);
  116. $this->serviceCharge = $serviceCharge;
  117. }
  118. public static function getServiceCharge(): float
  119. {
  120. $serviceCharge = Config::where('field', 'service_charge')->first()->val;
  121. return floatval($serviceCharge);
  122. }
  123. public static function notify($data)
  124. {
  125. try {
  126. $telegram = new Api(config('services.telegram.token'));
  127. $telegram->sendMessage($data);
  128. } catch (TelegramSDKException $e) {
  129. return false;
  130. }
  131. return true;
  132. }
  133. //提现账单
  134. public static function bill($chatId, $firstName, $messageId = null, $page = 1, $limit = 5)
  135. {
  136. $list = Withdraw::where('member_id', $chatId)
  137. ->orderBy('id', 'desc')
  138. ->forPage($page, $limit)
  139. ->get();
  140. $count = Withdraw::where('member_id', $chatId)
  141. ->whereIn('status', [0, 1])
  142. ->count();
  143. $status = [lang('等待放行'), lang('已到账'), lang("失败")];
  144. $text = "👤 {$firstName}({$chatId}) " . lang("钱包提现记录") . "\n\n";
  145. foreach ($list as $item) {
  146. $amount = floatval($item->amount);
  147. $balance = floatval($item->after_balance);
  148. $text .= "-------------------------------------\n";
  149. $text .= "➖ {$amount} USDT\n" . lang("余额") . ":{$balance} \n";
  150. $text .= lang("类别") . "类别:" . lang("提现") . "\n";
  151. $text .= lang("状态") . ":{$status[$item->status]}\n";
  152. if ($item->remark) {
  153. $text .= lang("说明") . ":{$item->remark}\n";
  154. }
  155. $text .= lang("日期") . ":{$item->created_at}\n";
  156. }
  157. if ($page > 1) {
  158. $keyboard[] = [
  159. ['text' => lang("👆上一页"), 'callback_data' => "withdrawBillNextPage@@" . ($page - 1)]
  160. ];
  161. }
  162. $allPage = ceil($count / $limit);
  163. if ($allPage > $page) {
  164. if ($page > 1) {
  165. $keyboard[count($keyboard) - 1][] = ['text' => lang("👇下一页"), 'callback_data' => "withdrawBillNextPage@@" . ($page + 1)];
  166. } else {
  167. $keyboard[] = [
  168. ['text' => lang("👇下一页"), 'callback_data' => "withdrawBillNextPage@@" . ($page + 1)]
  169. ];
  170. }
  171. }
  172. $keyboard[] = [
  173. ['text' => lang("↩️返回"), 'callback_data' => "withdraw@@home"]
  174. ];
  175. return [
  176. 'chat_id' => $chatId,
  177. 'text' => $text,
  178. 'message_id' => $messageId,
  179. 'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
  180. ];
  181. }
  182. //删除地址
  183. public static function delAddress($chatId, $id, $messageId)
  184. {
  185. Address::where('id', $id)
  186. ->where('member_id', $chatId)->delete();
  187. return WithdrawService::getAddress($chatId, $messageId);
  188. }
  189. //地址详情
  190. public static function addressDetails($chatId, $messageId, $id)
  191. {
  192. $text = lang("*TRC20 地址管理*") . "\n\n";
  193. $address = Address::where('id', $id)
  194. ->where('member_id', $chatId)->first();
  195. $text .= lang("地址") . ":{$address->address}\n";
  196. $text .= lang("别名") . ":{$address->alias}";
  197. $keyboard = [
  198. [['text' => lang('❌删除该地址'), 'callback_data' => "withdrawAddress@@del{$id}"]],
  199. [['text' => lang('↩️返回列表'), 'callback_data' => 'withdraw@@address']]
  200. ];
  201. return [
  202. 'chat_id' => $chatId,
  203. 'parse_mode' => 'MarkdownV2',
  204. 'text' => $text,
  205. 'reply_markup' => json_encode(['inline_keyboard' => $keyboard]),
  206. 'message_id' => $messageId
  207. ];
  208. }
  209. //输入别名
  210. public static function inputAlias($chatId, $alias, $messageId)
  211. {
  212. if (mb_strlen($alias) > 20) {
  213. return [
  214. 'chat_id' => $chatId,
  215. 'text' => lang("别名不能超过20个字,请重新输入"),
  216. 'reply_to_message_id' => $messageId,
  217. ];
  218. }
  219. $address = Cache::get("{$chatId}_address");
  220. $a = new Address();
  221. $a->address = $address;
  222. $a->alias = $alias;
  223. $a->member_id = $chatId;
  224. $a->save();
  225. Cache::delete("{$chatId}_address");
  226. Cache::delete(get_step_key($chatId));
  227. return self::getAddress($chatId, $messageId);
  228. }
  229. //用户输入TRC20地址
  230. public static function inputAddress($chatId, $address, $messageId)
  231. {
  232. if (!preg_match('/^T[a-zA-Z1-9]{33}$/', $address)) {
  233. return [
  234. 'chat_id' => $chatId,
  235. 'text' => lang("地址输入不正确,请重新输入TRC20地址"),
  236. 'reply_to_message_id' => $messageId,
  237. ];
  238. }
  239. Cache::put("{$chatId}_address", $address);
  240. Cache::put(get_step_key($chatId), StepStatus::INPUT_ADDRESS_ALIAS);
  241. return [
  242. 'chat_id' => $chatId,
  243. 'text' => lang("请输入地址别名,便于区分多个地址"),
  244. ];
  245. }
  246. //添加地址
  247. public static function addAddress($chatId, $messageId)
  248. {
  249. $text = lang('请输入新的TRC20地址') . "\n";
  250. $keyboard = [[
  251. ['text' => lang('❌取消'), 'callback_data' => "message@@close"],
  252. ]];
  253. Cache::put(get_step_key($chatId), StepStatus::INPUT_ADDRESS_TRC20);
  254. return [
  255. 'chat_id' => $chatId,
  256. 'text' => $text,
  257. 'message_id' => $messageId,
  258. 'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
  259. ];
  260. }
  261. //地址管理
  262. public static function getAddress($chatId, $messageId)
  263. {
  264. $text = lang("🏠 地址管理");
  265. $text .= "\n--------------------------\n";
  266. $list = Address::where('member_id', $chatId)
  267. ->get();
  268. $keyboard = [];
  269. foreach ($list as $item) {
  270. $keyboard[] = [['text' => $item->alias, 'callback_data' => "withdrawAddress@@detail{$item->id}"]];
  271. }
  272. if (count($list) < 5) {
  273. $keyboard[] = [['text' => lang("➕ 添加地址"), 'callback_data' => "withdrawAddress@@add"]];
  274. }
  275. $keyboard[] = [['text' => lang("↩️返回"), 'callback_data' => "withdraw@@home"]];
  276. return [
  277. 'chat_id' => $chatId,
  278. 'text' => $text,
  279. 'message_id' => $messageId,
  280. 'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
  281. ];
  282. }
  283. //设置提现地址
  284. public function setAddress($chatId, $address)
  285. {
  286. $address = trim($address);
  287. if (!$address) return [['chat_id' => $chatId, 'text' => lang("提现地址不能为空")]];
  288. $user = User::where('member_id', $chatId)->first();
  289. $user->usdt = $address;
  290. $user->save();
  291. $wallet = Wallet::where('member_id', $chatId)->first();
  292. $temp = floatval($wallet->available_balance);
  293. $rate = Config::where('field', 'exchange_rate_rmb')->first()->val ?? 1;
  294. $exchange_rate_difference = Config::where('field', 'exchange_rate_difference')->first()->val ?? 0;
  295. $rate = bcadd($rate, $exchange_rate_difference, 2);
  296. $amount = bcdiv($temp, $rate, 2);
  297. $text = "✅ " . lang('提现地址已设置') . "\n\n";
  298. $text .= lang("请发送提现金额") . "(USDT) \n";
  299. $text .= "💰 " . lang("当前余额") . ":{$temp} RMB ({$amount} USDT)\n";
  300. $text .= "⚠️ " . lang('提现将收取') . "{$this->serviceCharge}" . lang("U作为手续费") . "\n";
  301. return [['chat_id' => $chatId, 'text' => $text]];
  302. }
  303. public static function done($chatId, $messageId, $firstName)
  304. {
  305. $serviceCharge = (new WithdrawService())->serviceCharge;
  306. $amount = Cache::get("{$chatId}_WITHDRAW_MONEY", '');
  307. $address = Cache::get("{$chatId}_WITHDRAW_ADDRESS", '');
  308. if (!$amount || !$address) return WithdrawService::index($chatId, $firstName, $messageId);
  309. $real = bcsub($amount, $serviceCharge, 10);
  310. $real = floatval($real);
  311. if ($amount <= $serviceCharge) {
  312. return [
  313. 'chat_id' => $chatId,
  314. 'text' => lang("⚠️提现不能少于") . "{$serviceCharge} USDT," . lang("请重试"),
  315. 'message_id' => $messageId
  316. ];
  317. }
  318. $wallet = Wallet::where('member_id', $chatId)->first();
  319. $temp = floatval($wallet->available_balance);
  320. // 汇率
  321. $rate = Config::where('field', 'exchange_rate_rmb')->first()->val ?? 1;
  322. $exchange_rate_difference = Config::where('field', 'exchange_rate_difference')->first()->val ?? 0;
  323. $rate = bcadd($rate, $exchange_rate_difference, 2);
  324. $rate_usdt_amount = bcdiv($temp, $rate, 2); // 钱包可用余额 折合USDT
  325. $rate_rmb_amount = bcmul($amount, $rate, 2); // 提现金额 折合RMB
  326. if ($amount > $rate_usdt_amount) {
  327. return [
  328. 'chat_id' => $chatId,
  329. 'text' => lang("⚠️可用余额不足,请重试"),
  330. 'message_id' => $messageId
  331. ];
  332. }
  333. $ru = RoomUser::where('member_id', $chatId)
  334. ->whereIn('status', [0, 1, 2, 3])
  335. ->first();
  336. if ($ru) {
  337. $text = lang("游戏未结算") . "\n";
  338. $text .= "⚠️ " . lang("您还有进行中的游戏,所有游戏结算后方可提现") . "\n";
  339. return [
  340. 'chat_id' => $chatId,
  341. 'text' => $text,
  342. 'message_id' => $messageId,
  343. 'reply_markup' => json_encode(['inline_keyboard' => [[
  344. ['text' => lang('进入房间'), 'callback_data' => "games@@home{$ru->room_id}"],
  345. ]]])
  346. ];
  347. }
  348. $withdraw = new Withdraw();
  349. $withdraw->member_id = $chatId;
  350. $withdraw->amount = $amount;
  351. $withdraw->service_charge = $serviceCharge;
  352. $withdraw->to_account = $real;
  353. $withdraw->address = $address;
  354. $withdraw->exchange_rate = $rate;
  355. $withdraw->status = 0;
  356. $withdraw->after_balance = bcdiv($wallet->available_balance, $rate, 2);
  357. $withdraw->save();
  358. $wallet = Wallet::where('member_id', $chatId)->first();
  359. $changeAmount = bcmul(($amount * -1), $rate, 2);
  360. $beforeBalance = $wallet->available_balance;
  361. $afterBalance = bcsub($wallet->available_balance, $rate_rmb_amount, 2);
  362. $wallet->available_balance = $afterBalance;
  363. $wallet->save();
  364. BalanceLogService::addLog($chatId, $changeAmount, $beforeBalance, $afterBalance, '提现', $withdraw->id, '');
  365. $temp = floatval($afterBalance);
  366. $text = "✅ " . lang("提现申请已提交!") . "\n\n";
  367. $text .= lang("钱包余额") . ":{$temp} RMB\n";
  368. $text .= lang("汇率") . ":1 USDT = {$rate} RMB\n";
  369. $text .= lang("剩余可用USDT余额") . ":" . number_format(bcdiv($temp, $rate, 2), 2) . " USDT\n";
  370. $text .= lang("提现金额") . ":{$amount} USDT\n";
  371. $text .= lang("实际到账") . ":{$real} USDT\n";
  372. $text .= lang("手续费") . ":{$serviceCharge} USDT\n\n";
  373. $text .= lang("⌛️请等待系统处理, 到账时间可能需要几分钟!") . "\n";
  374. Cache::delete(get_step_key($chatId));
  375. return [
  376. 'chat_id' => $chatId,
  377. 'text' => $text,
  378. 'message_id' => $messageId,
  379. ];
  380. }
  381. public static function chooseAddress($chatId, $firstName, $messageId, $id)
  382. {
  383. $serviceCharge = (new WithdrawService())->serviceCharge;
  384. $amount = Cache::get("{$chatId}_WITHDRAW_MONEY", '');
  385. if (!$amount) return WithdrawService::index($chatId, $firstName, $messageId);
  386. $amount = floatval($amount);
  387. $real = bcsub($amount, $serviceCharge, 10);
  388. $real = floatval($real);
  389. $address = Address::where('id', $id)
  390. ->where('member_id', $chatId)->first();
  391. $text = lang("请确认") . "\n\n";
  392. $text .= lang('手续费') . ":{$serviceCharge} USDT\n";
  393. $text .= lang("提现金额") . ":{$amount} USDT\n";
  394. $text .= lang("实际到账") . ":{$real} USDT\n";
  395. $text .= lang("提现地址") . ":{$address->address}\n";
  396. $keyboard = [
  397. [
  398. ['text' => lang('✅ 确认'), 'callback_data' => "withdrawAddress@@done"],
  399. ],
  400. [
  401. ['text' => lang('❌取消'), 'callback_data' => "message@@close"]
  402. ]
  403. ];
  404. Cache::put("{$chatId}_WITHDRAW_ADDRESS", $address->address);
  405. return [
  406. 'chat_id' => $chatId,
  407. 'text' => $text,
  408. 'message_id' => $messageId,
  409. 'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
  410. ];
  411. }
  412. //用户输入提现金额(USDT)
  413. public function inputAmount($chatId, $amount, $messageId)
  414. {
  415. if (!preg_match('/^-?\d+(\.\d+)?$/', $amount)) {
  416. return [[
  417. 'chat_id' => $chatId,
  418. 'text' => lang("金额输入不正确,请发送提现数字"),
  419. 'reply_to_message_id' => $messageId
  420. ]];
  421. }
  422. if($amount < 100){
  423. return [[
  424. 'chat_id' => $chatId,
  425. 'text' => lang("提现不能少于100 RMB,请重试"),
  426. 'reply_to_message_id' => $messageId
  427. ]];
  428. }
  429. if ($amount > 49999) {
  430. return [
  431. 'chat_id' => $chatId,
  432. 'text' => lang("最多提现 49999 RMB,请重试"),
  433. 'reply_to_message_id' => $messageId
  434. ];
  435. }
  436. $wallet = Wallet::where('member_id', $chatId)->first();
  437. $temp = floatval($wallet->available_balance);
  438. // 汇率
  439. $rate = Config::where('field', 'exchange_rate_rmb')->first()->val ?? 1;
  440. $rate_amount = bcdiv($temp, $rate, 2);
  441. if ($amount <= $this->serviceCharge) {
  442. return [[
  443. 'chat_id' => $chatId,
  444. 'text' => lang("⚠️提现不能少于") . "{$this->serviceCharge} USDT," . lang('请重试'),
  445. 'reply_to_message_id' => $messageId
  446. ]];
  447. }
  448. if ($amount > $rate_amount) {
  449. return [[
  450. 'chat_id' => $chatId,
  451. 'text' => lang("可用余额不足,请重试"),
  452. 'reply_to_message_id' => $messageId
  453. ]];
  454. }
  455. $ru = RoomUser::where('member_id', $chatId)
  456. ->whereIn('status', [0, 1, 2, 3])
  457. ->first();
  458. if ($ru) {
  459. $text = lang('*游戏未结算*') . "\n";
  460. $text .= lang("⚠️ 您还有进行中的游戏,所有游戏结算后方可提现") . "\n";
  461. return [[
  462. 'chat_id' => $chatId,
  463. 'text' => $text,
  464. 'parse_mode' => 'MarkdownV2',
  465. 'reply_markup' => json_encode(['inline_keyboard' => [[
  466. ['text' => lang('进入房间'), 'callback_data' => "games@@home{$ru->room_id}"],
  467. ]]])
  468. ]];
  469. }
  470. $list = Address::where('member_id', $chatId)->get();
  471. $keyboard = [];
  472. foreach ($list as $item) {
  473. $keyboard[] = [['text' => $item->alias, 'callback_data' => "withdrawAddress@@choose{$item->id}"]];
  474. }
  475. $keyboard[] = [
  476. ['text' => lang("🏠 地址管理"), 'callback_data' => "withdraw@@address"],
  477. ['text' => lang('❌取消'), 'callback_data' => "message@@close"]
  478. ];
  479. $text = lang('请直接选择下面的地址') . "\n";
  480. $text .= lang("⚠️提示:请务必确认提现地址正确无误,\n否则资金丢失将无法找回请自负!");
  481. Cache::put("{$chatId}_WITHDRAW_MONEY", $amount);
  482. Cache::put(get_step_key($chatId), StepStatus::CHOOSE_WITHDRAW_ADDRESS);
  483. return [[
  484. 'chat_id' => $chatId,
  485. 'text' => $text,
  486. 'reply_to_message_id' => $messageId,
  487. 'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
  488. ]];
  489. }
  490. //申请提现
  491. public static function apply($chatId, $messageId)
  492. {
  493. $wallet = Wallet::where('member_id', $chatId)->first();
  494. // 汇率
  495. $rate = Config::where('field', 'exchange_rate_rmb')->first()->val ?? 1;
  496. $exchange_rate_difference = Config::where('field', 'exchange_rate_difference')->first()->val ?? 0;
  497. $rate = bcadd($rate, $exchange_rate_difference, 2);
  498. $temp = floatval($wallet->available_balance);
  499. $amount = bcdiv($temp, $rate, 2);
  500. $serviceCharge = static::getServiceCharge();
  501. $text = lang("请发送提现金额");
  502. $text .= " (USDT)";
  503. $text .= "\n💰 " . lang('当前余额') . ":{$temp} RMB ({$amount} USDT)\n";
  504. $text .= "⚠️" . lang('汇率') . ":1 USDT = {$rate} RMB\n";
  505. $text .= "⚠️ " . lang('提现将收取') . "{$serviceCharge}" . lang('U作为手续费') . "\n";
  506. // $keyboard = [[
  507. // ['text' => "🔙返回", 'callback_data' => "withdraw@@home"],
  508. // ]];
  509. Cache::put(get_step_key($chatId), StepStatus::INPUT_WITHDRAW_MONEY);
  510. return [
  511. 'chat_id' => $chatId,
  512. 'text' => $text,
  513. 'message_id' => $messageId,
  514. // 'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
  515. ];
  516. }
  517. //提现管理
  518. public static function index($chatId, $firstName, $messageId = null)
  519. {
  520. $wallet = Wallet::where('member_id', $chatId)->first();
  521. $text = "👤 {$firstName}({$chatId})\n\n";
  522. $text .= "💰钱包余额\n";
  523. $temp = floatval($wallet->available_balance);
  524. $text .= "USDT:{$temp}\n";
  525. $text .= "--------------------------\n";
  526. $serviceAccount = Config::where('field', 'service_account')->first()->val;
  527. $keyboard = [
  528. [
  529. ['text' => '➕ 提现', 'callback_data' => "withdraw@@apply"],
  530. ['text' => '🧾 账单', 'callback_data' => "withdraw@@bill"]
  531. ],
  532. [
  533. ['text' => lang("🏠 地址管理"), 'callback_data' => "withdraw@@address"],
  534. ['text' => lang('👩 客服帮助'), 'url' => "https://t.me/{$serviceAccount}"]
  535. ],
  536. [
  537. ['text' => lang('❌取消'), 'callback_data' => "message@@close"],
  538. ]
  539. ];
  540. return [
  541. 'chat_id' => $chatId,
  542. 'text' => $text,
  543. 'message_id' => $messageId,
  544. 'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
  545. ];
  546. }
  547. }