|
|
@@ -0,0 +1,81 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Http\Controllers\api;
|
|
|
+
|
|
|
+use App\Services\WalletService;
|
|
|
+use App\Services\ConfigService;
|
|
|
+use App\Models\Config;
|
|
|
+use App\Models\Recharge;
|
|
|
+use Illuminate\Validation\ValidationException;
|
|
|
+
|
|
|
+use Exception;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 充值提现接口
|
|
|
+ */
|
|
|
+class Wallet extends BaseController
|
|
|
+{
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取充值二维码(微信、支付宝、扫码充值)
|
|
|
+ */
|
|
|
+ function scan()
|
|
|
+ {
|
|
|
+ $member_id = '';
|
|
|
+ $type = 'TRC20';
|
|
|
+ $receivingType = ConfigService::getVal("receiving_type");
|
|
|
+ //自动充值
|
|
|
+ if ($receivingType == 1) {
|
|
|
+ $res = WalletService::getRechargeImageAddress($member_id);
|
|
|
+ $address = $res['address'];
|
|
|
+ $qrCode = $res['full_path'];
|
|
|
+ } else {
|
|
|
+ //手动充值
|
|
|
+ if ($type === "TRC20") {
|
|
|
+ $address = Config::where('field', 'receiving_address')->first()->val;
|
|
|
+ } else {//if ($type === "ERC20")
|
|
|
+ $address = Config::where('field', 'receiving_address_erc20')->first()->val;
|
|
|
+ }
|
|
|
+ $res = WalletService::getPlatformImageAddress($address);
|
|
|
+ $res['net'] = $type;
|
|
|
+ $qrCode = $res['full_path'];
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success([
|
|
|
+ 'qrcode' => $qrCode,
|
|
|
+ // 'photo' => InputFile::create($qrCode),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交充值凭证
|
|
|
+ */
|
|
|
+ public function recharge()
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $params = request()->validate([
|
|
|
+ 'net' => ['required', 'string'],
|
|
|
+ 'amount' => ['required', 'float'],
|
|
|
+ 'toAddress' => ['required', 'string'],
|
|
|
+ 'image' => ['required', 'url'],
|
|
|
+ ]);
|
|
|
+ $member_id = '';
|
|
|
+ $recharge = new Recharge();
|
|
|
+ $recharge->member_id = $member_id;
|
|
|
+ $recharge->net = $params['net'];
|
|
|
+ $recharge->coin = "USDT";
|
|
|
+ $recharge->amount = $params['amount'];
|
|
|
+ $recharge->to_address = $params['toAddress'];
|
|
|
+ $recharge->status = 0;
|
|
|
+ $recharge->type = 2;
|
|
|
+ $recharge->image = $params['image'];
|
|
|
+ $recharge->save();
|
|
|
+
|
|
|
+ } catch (ValidationException $e) {
|
|
|
+ return $this->error($e->validator->errors()->first());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ return $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|