Commit f45c307c by haojie

1

parent b05f894e
...@@ -116,5 +116,22 @@ public static function invalidJson(self $exception) ...@@ -116,5 +116,22 @@ public static function invalidJson(self $exception)
$exception->getHeaders()); $exception->getHeaders());
} }
public static function invalid($request, self $exception)
{
$data = [
'errors' => $exception->errors,
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
'status_code' => $exception->getStatusCode(),
'data' => $exception->getData(),
];
if (app()->environment(['local'])) {
$data['trace'] = $exception->getTrace();
$data['time'] = microtime(true) - LARAVEL_START;
}
return response()->json($data, $exception->getStatusCode(),
$exception->getHeaders());
}
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Log;
use Throwable; use Throwable;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
......
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Service\TransferUserService;
use Illuminate\Http\Request;
class AuthController extends Controller
{
public function login(Request $request)
{
$data = $request->input();
$result = app(TransferUserService::class)->login($data);
return $this->success('success', $result);
}
}
...@@ -70,4 +70,19 @@ public function buy(Request $request) ...@@ -70,4 +70,19 @@ public function buy(Request $request)
return $this->success('success', $result); return $this->success('success', $result);
} }
// 本地打款获取redis任务
public function getRedisTask(Request $request)
{
$user = $request->user();
$result = app(TradeService::class)->getRedisTask($user);
return $this->success('success', $result);
}
// 打款回调
public function transferCallback(Request $request)
{
$data = $request->input();
$result = app(TradeService::class)->adminTransferCallback($data);
return $this->success('success', $result);
}
} }
...@@ -3,19 +3,20 @@ ...@@ -3,19 +3,20 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware; use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Support\Facades\Log;
class Authenticate extends Middleware class Authenticate extends Middleware
{ {
/** /**
* Get the path the user should be redirected to when they are not authenticated. * Get the path the user should be redirected to when they are not authenticated.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return string|null * @return string|null
*/ */
protected function redirectTo($request) protected function redirectTo($request)
{ {
if (! $request->expectsJson()) { // if (!$request->expectsJson()) {
return route('login'); // return route('login');
} // }
} }
} }
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use PHPOpenSourceSaver\JWTAuth\Contracts\JWTSubject;
class TransferUser extends Authenticatable implements JWTSubject
{
use HasApiTokens, HasFactory, Notifiable;
protected $table = 'transfer_user';
protected $guarded = [];
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [
'role' => 'user'
];
}
}
...@@ -40,4 +40,18 @@ public function getTradeCheckCallbackUrl() ...@@ -40,4 +40,18 @@ public function getTradeCheckCallbackUrl()
} }
return $notify_url; return $notify_url;
} }
// 平台打款回调地址
public function getPlatformPayCallbackUrl()
{
$notify_url = '';
$api = '/api/inscription/local/task/callback';
// 判断是否本地环境
if (app()->environment('local')) {
$notify_url = 'http://192.168.1.5:8080' . $api;
} else {
$notify_url = config('app.url') . $api;
}
return $notify_url;
}
} }
...@@ -16,6 +16,7 @@ class TradeService ...@@ -16,6 +16,7 @@ class TradeService
public const ORDER_STATUS_ON = 2; // 已上架 public const ORDER_STATUS_ON = 2; // 已上架
public const ORDER_STATUS_SUCCESS = 3; // 已完成 public const ORDER_STATUS_SUCCESS = 3; // 已完成
public const ORDER_STATUS_FAIL = 4; // 已取消 public const ORDER_STATUS_FAIL = 4; // 已取消
public const ORDER_STATUS_LOCK = 5; // 锁定中(买家已提交hash,等待检测到账)
// 卖家状态 // 卖家状态
...@@ -39,7 +40,7 @@ class TradeService ...@@ -39,7 +40,7 @@ class TradeService
public const TRADE_TYPE_INSCRIPTION = 1; // 铭文转移 public const TRADE_TYPE_INSCRIPTION = 1; // 铭文转移
public const TRADE_TYPE_PAY = 2; // 支付 public const TRADE_TYPE_PAY = 2; // 支付
// 日志的交易状态 // 交易状态
public const TRADE_STATUS_WAIT = 1; // 未开始 public const TRADE_STATUS_WAIT = 1; // 未开始
public const TRADE_STATUS_SUCCESS = 2; // 已完成 public const TRADE_STATUS_SUCCESS = 2; // 已完成
public const TRADE_STATUS_FAIL = 3; // 失败 public const TRADE_STATUS_FAIL = 3; // 失败
...@@ -64,6 +65,7 @@ class TradeService ...@@ -64,6 +65,7 @@ class TradeService
// redis key // redis key
public const REDIS_KEY_RECEIPT = 'admin_check_receipt'; // 到账查询 public const REDIS_KEY_RECEIPT = 'admin_check_receipt'; // 到账查询
public const REDIS_KEY_TRANSFER = 'admin_transfer'; // 平台转账
// 查询 // 查询
...@@ -83,6 +85,13 @@ public function redisAdd($data, $key = self::REDIS_KEY_RECEIPT) ...@@ -83,6 +85,13 @@ public function redisAdd($data, $key = self::REDIS_KEY_RECEIPT)
Redis::rpush($key, json_encode($data)); Redis::rpush($key, json_encode($data));
} }
// 获取打款任务
public function getRedisTask($user)
{
// 从redis中取,从头开始
return Redis::lpop(self::REDIS_KEY_TRANSFER);
}
// 更新铭文数据 // 更新铭文数据
public function updateInscription($data) public function updateInscription($data)
{ {
...@@ -93,13 +102,30 @@ public function updateInscription($data) ...@@ -93,13 +102,30 @@ public function updateInscription($data)
return $inscription; return $inscription;
} }
// 铭文列表 // 买家应该支付的金额
public function getBuyRealAmount($original_amount)
{
// 获取买入手续费
$buy_fee = app(AdminConfigService::class)->getBuyFee();
return $original_amount + $original_amount * ($buy_fee / 100);
}
// 铭文可交易列表
public function inscriptionList($page, $limit) public function inscriptionList($page, $limit)
{ {
// 获取买入手续费
$buy_fee = app(AdminConfigService::class)->getBuyFee();
// 指定返回的字段 // 指定返回的字段
$field = ['id', 'inscription', 'status', 'original_amount']; $field = ['id', 'inscription', 'status', 'original_amount'];
$model = $this->model()->where('status', self::ORDER_STATUS_ON)->where('buyer_address', null) // $item->buy_real_amount = $item->original_amount + $item->original_amount * ($buy_fee / 100);
$model = $this->model()->where('status', self::ORDER_STATUS_ON)
->orderBy('id', 'desc')->paginate($limit, $field, 'page', $page); ->orderBy('id', 'desc')->paginate($limit, $field, 'page', $page);
// 获取分页后的data
$data = $model->items();
foreach ($data as $item) {
// 买家应该支付的金额
$item->buy_real_amount = self::getBuyRealAmount($item->original_amount);
}
// 分页 // 分页
return $model; return $model;
} }
...@@ -117,18 +143,18 @@ public function userShelves($payment_address, $hash, $inscription, $price) ...@@ -117,18 +143,18 @@ public function userShelves($payment_address, $hash, $inscription, $price)
} }
// 卖家手续费比例 // 卖家手续费比例
$sell_fee = app(AdminConfigService::class)->getSellFee(); $sell_fee = app(AdminConfigService::class)->getSellFee();
// 手续费具体金额 // 卖出成功,转账时应该转移的金额
$sell_fee_amount = $price * $sell_fee; $sell_real_amount = $price - $price * $sell_fee;
// 平台收款账号 // 平台收款账号
$admin_address = app(AdminConfigService::class)->getReceiptAccount(); $admin_address = app(AdminConfigService::class)->getReceiptAccount();
// 创建 // 创建
$data = [ $data = [
'inscription' => $inscription, 'inscription' => $inscription,
'original_amount' => $price, 'original_amount' => $price,
// 收款账号 // 卖家卖出时的收款账号
'admin_account' => $admin_address, 'sell_admin_account' => $admin_address,
'sell_fee' => $sell_fee, 'sell_fee' => $sell_fee,
'sell_fee_amount' => $sell_fee_amount, 'sell_real_amount' => $sell_real_amount,
'status' => self::ORDER_STATUS_WAIT, 'status' => self::ORDER_STATUS_WAIT,
'seller_status' => self::SELLER_STATUS_PROGRESS, 'seller_status' => self::SELLER_STATUS_PROGRESS,
'buyer_status' => self::BUYER_STATUS_WAIT, 'buyer_status' => self::BUYER_STATUS_WAIT,
...@@ -145,7 +171,7 @@ public function userShelves($payment_address, $hash, $inscription, $price) ...@@ -145,7 +171,7 @@ public function userShelves($payment_address, $hash, $inscription, $price)
$data['to'] = $admin_address; $data['to'] = $admin_address;
$data['from'] = $payment_address; $data['from'] = $payment_address;
$data['hash'] = $hash; $data['hash'] = $hash;
app(TransactionLogService::class)->create($data); $log_id = app(TransactionLogService::class)->create($data);
// 回调地址 // 回调地址
$notify_url = app(CommonService::class)->getTradeCheckCallbackUrl(); $notify_url = app(CommonService::class)->getTradeCheckCallbackUrl();
// 铭文转移查铭文数据里的hash就可以了 // 铭文转移查铭文数据里的hash就可以了
...@@ -155,6 +181,7 @@ public function userShelves($payment_address, $hash, $inscription, $price) ...@@ -155,6 +181,7 @@ public function userShelves($payment_address, $hash, $inscription, $price)
'hash' => $hash, 'hash' => $hash,
'inscription_hash' => $inscription['transaction_hash'], 'inscription_hash' => $inscription['transaction_hash'],
'id' => $result->id, 'id' => $result->id,
'log_id' => $log_id,
'type' => self::TRADE_TYPE_INSCRIPTION, 'type' => self::TRADE_TYPE_INSCRIPTION,
// log标题 // log标题
'title' => self::TRADE_NAME_SELLER_INSCRIPTION, 'title' => self::TRADE_NAME_SELLER_INSCRIPTION,
...@@ -199,9 +226,81 @@ public function sellerShelvesSuccess($data) ...@@ -199,9 +226,81 @@ public function sellerShelvesSuccess($data)
} }
// 买家支付修改状态 // 买家支付修改状态
public function buyerPaymentStatus() public function buyerPaymentStatus($data)
{ {
$status = $data['status'];
// 订单状态
$order_status = self::ORDER_STATUS_LOCK;
// 买家状态
$buyer_status = self::BUYER_STATUS_PROGRESS;
if ($status == self::TRADE_STATUS_SUCCESS) {
// 支付成功
$buyer_status = self::BUYER_STATUS_SUCCESS;
} elseif ($status == self::TRADE_STATUS_FAIL || $status == self::TRADE_STATUS_FAIL_2) {
// 支付失败--解锁
$order_status = self::ORDER_STATUS_ON;
$buyer_status = self::BUYER_STATUS_FAIL;
}
$order = $this->model()->where('id', $data['id'])->first();
if ($order) {
// 更新
$order->update(['status' => $order_status, 'buyer_status' => $buyer_status]);
} else {
throw new UserException(1, '非法操作-buyer');
}
if ($status == self::TRADE_STATUS_SUCCESS) {
// 添加两条转账日志--卖家收款-买家收铭文
$inscription_log = [];
$inscription_log['order_id'] = $data['id'];
// 买家 接收铭文地址
$inscription_log['to'] = $order->buyer_address;
// 平台地址
$inscription_log['from'] = app(AdminConfigService::class)->getReceiptAccount();
// 交易类型-铭文转移
$inscription_log['trade_type'] = self::TRADE_TYPE_INSCRIPTION;
// 标题类型- 买家接收铭文
$inscription_log['title'] = self::TRADE_NAME_BUYER_RECEIVE;
$inscription_log_id = app(TransactionLogService::class)->create($inscription_log);
// 添加redis任务
$obj = [
'from' => $inscription_log['from'],
'to' => $inscription_log['to'],
'inscription_hash' => $order->inscription['transaction_hash'],
'id' => $order->id,
'log_id' => $inscription_log_id,
'type' => $inscription_log['trade_type'],
'title' => $inscription_log['title'],
'notify_url' => app(CommonService::class)->getPlatformPayCallbackUrl(),
];
$this->redisAdd($obj, self::REDIS_KEY_TRANSFER);
// 卖家收款
$transfer_log = [];
// 卖家应收金额
$amount = $order->original_amount - ($order->original_amount * ($order->sell_fee / 100));
$transfer_log['amount'] = $amount;
$transfer_log['order_id'] = $data['id'];
$transfer_log['to'] = $order->seller_address;
$transfer_log['from'] = $inscription_log['from'];
$transfer_log['trade_type'] = self::TRADE_TYPE_PAY;
// 卖家收款
$transfer_log['title'] = self::TRADE_NAME_SELLER_RECEIPT;
$transfer_log_id = app(TransactionLogService::class)->create($transfer_log);
$obj2 = [
'from' => $transfer_log['from'],
'to' => $transfer_log['to'],
'amount' => $amount,
'id' => $order->id,
'log_id' => $transfer_log_id,
'type' => $transfer_log['trade_type'],
'title' => $transfer_log['title'],
'notify_url' => app(CommonService::class)->getPlatformPayCallbackUrl(),
];
$this->redisAdd($obj2, self::REDIS_KEY_TRANSFER);
}
} }
// 到账检测回调 // 到账检测回调
...@@ -216,7 +315,7 @@ public function check($data) ...@@ -216,7 +315,7 @@ public function check($data)
self::sellerShelvesSuccess($data); self::sellerShelvesSuccess($data);
} else if ($title_type == self::TRADE_NAME_BUYER_PAY) { } else if ($title_type == self::TRADE_NAME_BUYER_PAY) {
// 买家支付 // 买家支付
self::buyerPaymentStatus(); self::buyerPaymentStatus($data);
} }
return true; return true;
} }
...@@ -239,7 +338,110 @@ public function buy($payment_address, $hash, $id) ...@@ -239,7 +338,110 @@ public function buy($payment_address, $hash, $id)
if (blank($payment_address) || blank($hash) || blank($id)) { if (blank($payment_address) || blank($hash) || blank($id)) {
throw new UserException(1, '非法操作'); throw new UserException(1, '非法操作');
} }
// 加字段,卖家卖出时收款地址,买家 购买时收款地址 //
$order = $this->model()->find($id);
if ($order) {
// 创建日志
$data = [];
$data['order_id'] = $order->id;
$data['trade_type'] = self::TRADE_TYPE_PAY;
$data['title'] = self::TRADE_NAME_BUYER_PAY;
$data['to'] = $order->buy_admin_account;
$data['from'] = $payment_address;
$data['hash'] = $hash;
$data['amount'] = $order->buy_real_amount;
$log_id = app(TransactionLogService::class)->create($data);
// 更新买家应该支付的金额
$order->buy_real_amount = self::getBuyRealAmount($order->original_amount);
// 更新买家支付手续费比例
$order->buy_fee = app(AdminConfigService::class)->getBuyFee();
// 买家地址
$order->buyer_address = $payment_address;
// 买家支付hash
$order->buyer_pay_hash = $hash;
// 买家状态
$order->buyer_status = self::BUYER_STATUS_PROGRESS;
// 订单状态 -lock
$order->status = self::ORDER_STATUS_LOCK;
// 获取当前收款地址
$order->buy_admin_account = app(AdminConfigService::class)->getReceiptAccount();
$order->save();
$notify_url = app(CommonService::class)->getTradeCheckCallbackUrl();
// 提交redis
$obj = [
'from' => $payment_address,
'to' => $order->buy_admin_account,
'amount' => $order->buy_real_amount,
'hash' => $hash,
'inscription_hash' => '',
'id' => $order->id,
'log_id' => $log_id,
'type' => self::TRADE_TYPE_PAY,
// log标题
'title' => self::TRADE_NAME_BUYER_PAY,
'notify_url' => $notify_url
];
// 添加reids队列
self::redisAdd($obj);
return true;
}
throw new UserException(1, '非法操作');
} }
// 平台转账回调
public function adminTransferCallback($data)
{
$hash = $data['hash'] ?? '';
// 更新日志
app(TransactionLogService::class)->update($data);
$status = $data['status'];
$title_type = $data['title'];
// 订单状态
$order_status = self::ORDER_STATUS_LOCK;
// 卖家状态
$seller_status = self::SELLER_STATUS_SUCCESS;
// 买家状态
$buyer_status = self::BUYER_STATUS_SUCCESS;
$order = $this->model()->where('id', $data['id']);
if ($order) {
if ($status == self::TRADE_STATUS_SUCCESS) {
// 转账成功
if ($title_type == self::TRADE_NAME_BUYER_RECEIVE) {
// 买家接收铭文
$buyer_status = self::BUYER_RECEIVE_SUCCESS;
$order->buyer_receive_inscription_hash = $hash;
} elseif ($title_type == self::TRADE_NAME_SELLER_RECEIPT) {
// 卖家收款
$seller_status = self::SELLER_STATUS_RECEIPT_SUCCESS;
$order->seller_receive_hash = $hash;
}
// 订单状态修改为已完成
$order_status = self::ORDER_STATUS_SUCCESS;
} else if (in_array($status, [self::TRADE_STATUS_FAIL, self::TRADE_STATUS_FAIL_2])) {
// 转账失败
if ($title_type == self::TRADE_NAME_BUYER_RECEIVE) {
// 买家接收铭文
$buyer_status = self::BUYER_RECEIVE_FAIL;
} elseif ($title_type == self::TRADE_NAME_SELLER_RECEIPT) {
// 卖家收款
$seller_status = self::SELLER_STATUS_RECEIPT_FAIL;
}
}
// 更新order
$order->status = $order_status;
$order->seller_status = $seller_status;
$order->buyer_status = $buyer_status;
// 订单状态修改为已完成
if ($order->seller_status == self::SELLER_STATUS_RECEIPT_SUCCESS && $order->buyer_status == self::BUYER_RECEIVE_SUCCESS) {
$order->status = self::ORDER_STATUS_SUCCESS;
}
$order->save();
} else {
//
throw new UserException(1, '非法操作order');
}
}
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Service; namespace App\Service;
use App\Exceptions\UserException;
use App\Models\TransactionLog; use App\Models\TransactionLog;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
...@@ -11,32 +12,59 @@ class TransactionLogService ...@@ -11,32 +12,59 @@ class TransactionLogService
// 新增日志 // 新增日志
public function create($params) public function create($params)
{ {
$model = TransactionLog::query();
$data = []; $data = [];
$data['to'] = $params['to']; $data['to'] = $params['to'];
$data['from'] = $params['from']; $data['from'] = $params['from'];
$data['hash'] = $params['hash'];
$data['order_id'] = $params['order_id']; $data['order_id'] = $params['order_id'];
// 状态 // 状态
$data['status'] = TradeService::TRADE_STATUS_WAIT; $data['status'] = TradeService::TRADE_STATUS_WAIT;
$data['type'] = $params['trade_type']; $data['type'] = $params['trade_type'];
$data['title'] = $params['title']; $data['title'] = $params['title'];
// amount // 判断金额字段是否存在
// error_message if (array_key_exists('amount', $params)) {
TransactionLog::query()->create($data); $data['amount'] = $params['amount'];
}
// hash是否存在
if (array_key_exists('hash', $params)) {
$data['hash'] = $params['hash'];
$res = $model->where('hash', $data['hash'])->first();
if ($res) {
throw new UserException(1, '支付hash已存在');
}
}
// error_message
$create = TransactionLog::query()->create($data);
if ($create) {
return $create->id;
}
throw new UserException(1, '日志创建失败');
} }
public function update($data) public function update($data)
{ {
// callback status 1:失败 2:成功 3:支付成功,接收地址错误 $message = $data['message'] ?? '';
$model = TransactionLog::query()->where('order_id', $data['id']) $model = TransactionLog::query()->where('id', $data['log_id'])
->where('type', $data['type']) ->where('type', $data['type'])
->where('to', $data['to']) ->where('to', $data['to'])
->where('from', $data['from']) ->where('from', $data['from']);
->where('hash', $data['hash']);
if ($data['type'] == TradeService::TRADE_TYPE_PAY) { if ($data['type'] == TradeService::TRADE_TYPE_PAY) {
// 添加金额 // 添加金额
$model->where('amount', $data['amount']); $model->where('amount', $data['amount']);
} }
$model->update(['status' => $data['status']]); $update = ['status' => $data['status']];
if (array_key_exists('hash', $data)) {
$update['hash'] = $data['hash'];
}
// 判断message
$log = $model->first();
if ($log) {
if ($message) {
$error_message = $log->error_message ?? [];
$error_message[] = $message;
$update['error_message'] = $error_message;
}
$log->update($update);
}
} }
} }
<?php
namespace App\Service;
use App\Exceptions\UserException;
use App\Models\TransferUser;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log;
class TransferUserService
{
protected function respondWithToken($token)
{
return [
'access_token' => $token,
'token_type' => 'bearer',
'expires_in' => auth('api')->factory()->getTTL() * 60 * 24
];
}
public function login($data)
{
$credentials = Arr::only($data, ['username', 'password']);
$username = $credentials['username'] ?? '';
$password = $credentials['password'] ?? '';
$adminUsers = TransferUser::where('username', $username)->first();
if (blank($adminUsers)) {
throw new UserException(1, '账号不存在');
}
// if (!\Hash::check($password, $adminUsers->password)) {
// throw new UserException(1, '密码错误');
// }
if ($password !== $adminUsers->password) {
throw new UserException(1, '密码错误');
}
$token = auth('api')->login($adminUsers);
// 查询电脑管理
return $this->respondWithToken($token);
}
}
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
"inertiajs/inertia-laravel": "^0.6.9", "inertiajs/inertia-laravel": "^0.6.9",
"laravel/framework": "^9.19", "laravel/framework": "^9.19",
"laravel/sanctum": "^3.0", "laravel/sanctum": "^3.0",
"laravel/tinker": "^2.7" "laravel/tinker": "^2.7",
"php-open-source-saver/jwt-auth": "^2.1"
}, },
"require-dev": { "require-dev": {
"fakerphp/faker": "^1.9.1", "fakerphp/faker": "^1.9.1",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "324d35974af6fcfda8456402aef0c488", "content-hash": "00d8763531f376251ebb1101fb8e5563",
"packages": [ "packages": [
{ {
"name": "brick/math", "name": "brick/math",
...@@ -1852,6 +1852,143 @@ ...@@ -1852,6 +1852,143 @@
"time": "2023-02-15T16:40:09+00:00" "time": "2023-02-15T16:40:09+00:00"
}, },
{ {
"name": "lcobucci/clock",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/clock.git",
"reference": "fb533e093fd61321bfcbac08b131ce805fe183d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/clock/zipball/fb533e093fd61321bfcbac08b131ce805fe183d3",
"reference": "fb533e093fd61321bfcbac08b131ce805fe183d3",
"shasum": ""
},
"require": {
"php": "^8.0",
"stella-maris/clock": "^0.1.4"
},
"require-dev": {
"infection/infection": "^0.26",
"lcobucci/coding-standard": "^8.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Lcobucci\\Clock\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Luís Cobucci",
"email": "lcobucci@gmail.com"
}
],
"description": "Yet another clock abstraction",
"support": {
"issues": "https://github.com/lcobucci/clock/issues",
"source": "https://github.com/lcobucci/clock/tree/2.2.0"
},
"funding": [
{
"url": "https://github.com/lcobucci",
"type": "github"
},
{
"url": "https://www.patreon.com/lcobucci",
"type": "patreon"
}
],
"time": "2022-04-19T19:34:17+00:00"
},
{
"name": "lcobucci/jwt",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/jwt.git",
"reference": "55564265fddf810504110bd68ca311932324b0e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/55564265fddf810504110bd68ca311932324b0e9",
"reference": "55564265fddf810504110bd68ca311932324b0e9",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-openssl": "*",
"lcobucci/clock": "^2.0",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"infection/infection": "^0.20",
"lcobucci/coding-standard": "^6.0",
"mikey179/vfsstream": "^1.6",
"phpbench/phpbench": "^0.17",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/php-invoker": "^3.1",
"phpunit/phpunit": "^9.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
}
},
"autoload": {
"psr-4": {
"Lcobucci\\JWT\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Luís Cobucci",
"email": "lcobucci@gmail.com",
"role": "Developer"
}
],
"description": "A simple library to work with JSON Web Token and JSON Web Signature",
"keywords": [
"JWS",
"jwt"
],
"support": {
"issues": "https://github.com/lcobucci/jwt/issues",
"source": "https://github.com/lcobucci/jwt/tree/4.0.4"
},
"funding": [
{
"url": "https://github.com/lcobucci",
"type": "github"
},
{
"url": "https://www.patreon.com/lcobucci",
"type": "patreon"
}
],
"time": "2021-09-28T19:18:28+00:00"
},
{
"name": "league/commonmark", "name": "league/commonmark",
"version": "2.4.0", "version": "2.4.0",
"source": { "source": {
...@@ -2285,6 +2422,73 @@ ...@@ -2285,6 +2422,73 @@
"time": "2023-02-06T13:44:46+00:00" "time": "2023-02-06T13:44:46+00:00"
}, },
{ {
"name": "namshi/jose",
"version": "7.2.3",
"source": {
"type": "git",
"url": "https://github.com/namshi/jose.git",
"reference": "89a24d7eb3040e285dd5925fcad992378b82bcff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/namshi/jose/zipball/89a24d7eb3040e285dd5925fcad992378b82bcff",
"reference": "89a24d7eb3040e285dd5925fcad992378b82bcff",
"shasum": ""
},
"require": {
"ext-date": "*",
"ext-hash": "*",
"ext-json": "*",
"ext-pcre": "*",
"ext-spl": "*",
"php": ">=5.5",
"symfony/polyfill-php56": "^1.0"
},
"require-dev": {
"phpseclib/phpseclib": "^2.0",
"phpunit/phpunit": "^4.5|^5.0",
"satooshi/php-coveralls": "^1.0"
},
"suggest": {
"ext-openssl": "Allows to use OpenSSL as crypto engine.",
"phpseclib/phpseclib": "Allows to use Phpseclib as crypto engine, use version ^2.0."
},
"type": "library",
"autoload": {
"psr-4": {
"Namshi\\JOSE\\": "src/Namshi/JOSE/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alessandro Nadalin",
"email": "alessandro.nadalin@gmail.com"
},
{
"name": "Alessandro Cinelli (cirpo)",
"email": "alessandro.cinelli@gmail.com"
}
],
"description": "JSON Object Signing and Encryption library for PHP.",
"keywords": [
"JSON Web Signature",
"JSON Web Token",
"JWS",
"json",
"jwt",
"token"
],
"support": {
"issues": "https://github.com/namshi/jose/issues",
"source": "https://github.com/namshi/jose/tree/master"
},
"time": "2016-12-05T07:27:31+00:00"
},
{
"name": "nesbot/carbon", "name": "nesbot/carbon",
"version": "2.66.0", "version": "2.66.0",
"source": { "source": {
...@@ -2678,6 +2882,100 @@ ...@@ -2678,6 +2882,100 @@
"time": "2023-02-08T01:06:31+00:00" "time": "2023-02-08T01:06:31+00:00"
}, },
{ {
"name": "php-open-source-saver/jwt-auth",
"version": "2.1.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-Open-Source-Saver/jwt-auth.git",
"reference": "5b4e3eec31c8da03d58b64c4e28c469b334bec4c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-Open-Source-Saver/jwt-auth/zipball/5b4e3eec31c8da03d58b64c4e28c469b334bec4c",
"reference": "5b4e3eec31c8da03d58b64c4e28c469b334bec4c",
"shasum": ""
},
"require": {
"ext-json": "*",
"illuminate/auth": "^6|^7|^8.67|^9|^10",
"illuminate/contracts": "^6|^7|^8.67|^9|^10",
"illuminate/http": "^6|^7|^8.67|^9|^10",
"illuminate/support": "^6|^7|^8.67|^9|^10",
"lcobucci/jwt": "^4.0",
"namshi/jose": "^7.0",
"nesbot/carbon": "^1.0|^2.0",
"php": "^7.4|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"illuminate/console": "^6|^7|^8.67|^9|^10",
"illuminate/routing": "^6|^7|^8.67|^9|^10",
"mockery/mockery": "^1.4.4",
"orchestra/testbench": "^4.18|^5.8|^6.3|^7|^8",
"phpstan/phpstan": "^1",
"phpunit/phpunit": "^8.5|^9.4|^10",
"rector/rector": "^0.12.4",
"vlucas/phpdotenv": "^5.2.0",
"yoast/phpunit-polyfills": "^1.0.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-develop": "2.0-dev"
},
"laravel": {
"aliases": {
"JWTAuth": "PHPOpenSourceSaver\\JWTAuth\\Facades\\JWTAuth",
"JWTFactory": "PHPOpenSourceSaver\\JWTAuth\\Facades\\JWTFactory"
},
"providers": [
"PHPOpenSourceSaver\\JWTAuth\\Providers\\LaravelServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"PHPOpenSourceSaver\\JWTAuth\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sean Tymon",
"email": "tymon148@gmail.com",
"homepage": "https://tymon.xyz",
"role": "Forked package creator | Developer"
},
{
"name": "Eric Schricker",
"email": "eric.schricker@adiutabyte.de",
"role": "Developer"
},
{
"name": "Fabio William Conceição",
"email": "messhias@gmail.com",
"role": "Developer"
}
],
"description": "JSON Web Token Authentication for Laravel and Lumen",
"homepage": "https://github.com/PHP-Open-Source-Saver/jwt-auth",
"keywords": [
"Authentication",
"JSON Web Token",
"auth",
"jwt",
"laravel"
],
"support": {
"issues": "https://github.com/PHP-Open-Source-Saver/jwt-auth/issues",
"source": "https://github.com/PHP-Open-Source-Saver/jwt-auth"
},
"time": "2023-02-17T11:42:33+00:00"
},
{
"name": "phpoption/phpoption", "name": "phpoption/phpoption",
"version": "1.9.1", "version": "1.9.1",
"source": { "source": {
...@@ -2802,6 +3100,54 @@ ...@@ -2802,6 +3100,54 @@
"time": "2021-02-03T23:26:27+00:00" "time": "2021-02-03T23:26:27+00:00"
}, },
{ {
"name": "psr/clock",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/clock.git",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Psr\\Clock\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for reading the clock.",
"homepage": "https://github.com/php-fig/clock",
"keywords": [
"clock",
"now",
"psr",
"psr-20",
"time"
],
"support": {
"issues": "https://github.com/php-fig/clock/issues",
"source": "https://github.com/php-fig/clock/tree/1.0.0"
},
"time": "2022-11-25T14:36:26+00:00"
},
{
"name": "psr/container", "name": "psr/container",
"version": "2.0.2", "version": "2.0.2",
"source": { "source": {
...@@ -3601,6 +3947,53 @@ ...@@ -3601,6 +3947,53 @@
"time": "2023-04-27T08:09:01+00:00" "time": "2023-04-27T08:09:01+00:00"
}, },
{ {
"name": "stella-maris/clock",
"version": "0.1.7",
"source": {
"type": "git",
"url": "https://github.com/stella-maris-solutions/clock.git",
"reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stella-maris-solutions/clock/zipball/fa23ce16019289a18bb3446fdecd45befcdd94f8",
"reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8",
"shasum": ""
},
"require": {
"php": "^7.0|^8.0",
"psr/clock": "^1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"StellaMaris\\Clock\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Heigl",
"role": "Maintainer"
}
],
"description": "A pre-release of the proposed PSR-20 Clock-Interface",
"homepage": "https://gitlab.com/stella-maris/clock",
"keywords": [
"clock",
"datetime",
"point in time",
"psr20"
],
"support": {
"source": "https://github.com/stella-maris-solutions/clock/tree/0.1.7"
},
"time": "2022-11-25T16:15:06+00:00"
},
{
"name": "symfony/console", "name": "symfony/console",
"version": "v6.0.19", "version": "v6.0.19",
"source": { "source": {
...@@ -4879,6 +5272,74 @@ ...@@ -4879,6 +5272,74 @@
"time": "2022-11-03T14:55:06+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-php56",
"version": "v1.20.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php56.git",
"reference": "54b8cd7e6c1643d78d011f3be89f3ef1f9f4c675"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/54b8cd7e6c1643d78d011f3be89f3ef1f9f4c675",
"reference": "54b8cd7e6c1643d78d011f3be89f3ef1f9f4c675",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "metapackage",
"extra": {
"branch-alias": {
"dev-main": "1.20-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php56/tree/v1.20.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-10-23T14:02:19+00:00"
},
{
"name": "symfony/polyfill-php72", "name": "symfony/polyfill-php72",
"version": "v1.27.0", "version": "v1.27.0",
"source": { "source": {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
'defaults' => [ 'defaults' => [
'guard' => 'web', 'guard' => 'api',
'passwords' => 'users', 'passwords' => 'users',
], ],
...@@ -38,7 +38,11 @@ ...@@ -38,7 +38,11 @@
'guards' => [ 'guards' => [
'web' => [ 'web' => [
'driver' => 'session', 'driver' => 'session',
'provider' => 'users', 'provider' => 'transfer_user',
],
'api' => [
'driver' => 'jwt',
'provider' => 'transfer_user',
], ],
], ],
...@@ -65,10 +69,10 @@ ...@@ -65,10 +69,10 @@
'model' => App\Models\User::class, 'model' => App\Models\User::class,
], ],
// 'users' => [ 'transfer_user' => [
// 'driver' => 'database', 'driver' => 'database',
// 'table' => 'users', 'table' => 'transfer_user',
// ], ],
], ],
/* /*
...@@ -93,6 +97,12 @@ ...@@ -93,6 +97,12 @@
'expire' => 60, 'expire' => 60,
'throttle' => 60, 'throttle' => 60,
], ],
'transfer_user' => [
'provider' => 'transfer_user',
'table' => 'transfer_user',
'expire' => 60,
'throttle' => 60,
],
], ],
/* /*
......
<?php
return [
/*
|--------------------------------------------------------------------------
| JWT Authentication Secret
|--------------------------------------------------------------------------
|
| Don't forget to set this in your .env file, as it will be used to sign
| your tokens. A helper command is provided for this:
| `php artisan jwt:secret`
|
| Note: This will be used for Symmetric algorithms only (HMAC),
| since RSA and ECDSA use a private/public key combo (See below).
|
*/
'secret' => env('JWT_SECRET'),
/*
|--------------------------------------------------------------------------
| JWT Authentication Keys
|--------------------------------------------------------------------------
|
| The algorithm you are using, will determine whether your tokens are
| signed with a random string (defined in `JWT_SECRET`) or using the
| following public & private keys.
|
| Symmetric Algorithms:
| HS256, HS384 & HS512 will use `JWT_SECRET`.
|
| Asymmetric Algorithms:
| RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below.
|
*/
'keys' => [
/*
|--------------------------------------------------------------------------
| Public Key
|--------------------------------------------------------------------------
|
| A path or resource to your public key.
|
| E.g. 'file://path/to/public/key'
|
*/
'public' => env('JWT_PUBLIC_KEY'),
/*
|--------------------------------------------------------------------------
| Private Key
|--------------------------------------------------------------------------
|
| A path or resource to your private key.
|
| E.g. 'file://path/to/private/key'
|
*/
'private' => env('JWT_PRIVATE_KEY'),
/*
|--------------------------------------------------------------------------
| Passphrase
|--------------------------------------------------------------------------
|
| The passphrase for your private key. Can be null if none set.
|
*/
'passphrase' => env('JWT_PASSPHRASE'),
],
/*
|--------------------------------------------------------------------------
| JWT time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token will be valid for.
| Defaults to 1 hour.
|
| You can also set this to null, to yield a never expiring token.
| Some people may want this behaviour for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
| Notice: If you set this to null you should remove 'exp' element from 'required_claims' list.
|
*/
'ttl' => env('JWT_TTL', 60),
/*
|--------------------------------------------------------------------------
| Refresh time to live
|--------------------------------------------------------------------------
|
| Specify the length of time (in minutes) that the token can be refreshed
| within. I.E. The user can refresh their token within a 2 week window of
| the original token being created until they must re-authenticate.
| Defaults to 2 weeks.
|
| You can also set this to null, to yield an infinite refresh time.
| Some may want this instead of never expiring tokens for e.g. a mobile app.
| This is not particularly recommended, so make sure you have appropriate
| systems in place to revoke the token if necessary.
|
*/
'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
/*
|--------------------------------------------------------------------------
| JWT hashing algorithm
|--------------------------------------------------------------------------
|
| Specify the hashing algorithm that will be used to sign the token.
|
| See here: https://github.com/namshi/jose/tree/master/src/Namshi/JOSE/Signer/OpenSSL
| for possible values.
|
*/
'algo' => env('JWT_ALGO', 'HS256'),
/*
|--------------------------------------------------------------------------
| Required Claims
|--------------------------------------------------------------------------
|
| Specify the required claims that must exist in any token.
| A TokenInvalidException will be thrown if any of these claims are not
| present in the payload.
|
*/
'required_claims' => [
'iss',
'iat',
'exp',
'nbf',
'sub',
'jti',
],
/*
|--------------------------------------------------------------------------
| Persistent Claims
|--------------------------------------------------------------------------
|
| Specify the claim keys to be persisted when refreshing a token.
| `sub` and `iat` will automatically be persisted, in
| addition to the these claims.
|
| Note: If a claim does not exist then it will be ignored.
|
*/
'persistent_claims' => [
// 'foo',
// 'bar',
],
/*
|--------------------------------------------------------------------------
| Lock Subject
|--------------------------------------------------------------------------
|
| This will determine whether a `prv` claim is automatically added to
| the token. The purpose of this is to ensure that if you have multiple
| authentication models e.g. `App\User` & `App\OtherPerson`, then we
| should prevent one authentication request from impersonating another,
| if 2 tokens happen to have the same id across the 2 different models.
|
| Under specific circumstances, you may want to disable this behaviour
| e.g. if you only have one authentication model, then you would save
| a little on token size.
|
*/
'lock_subject' => true,
/*
|--------------------------------------------------------------------------
| Leeway
|--------------------------------------------------------------------------
|
| This property gives the jwt timestamp claims some "leeway".
| Meaning that if you have any unavoidable slight clock skew on
| any of your servers then this will afford you some level of cushioning.
|
| This applies to the claims `iat`, `nbf` and `exp`.
|
| Specify in seconds - only if you know you need it.
|
*/
'leeway' => env('JWT_LEEWAY', 0),
/*
|--------------------------------------------------------------------------
| Blacklist Enabled
|--------------------------------------------------------------------------
|
| In order to invalidate tokens, you must have the blacklist enabled.
| If you do not want or need this functionality, then set this to false.
|
*/
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
/*
| -------------------------------------------------------------------------
| Blacklist Grace Period
| -------------------------------------------------------------------------
|
| When multiple concurrent requests are made with the same JWT,
| it is possible that some of them fail, due to token regeneration
| on every request.
|
| Set grace period in seconds to prevent parallel request failure.
|
*/
'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
/*
|--------------------------------------------------------------------------
| Show blacklisted token option
|--------------------------------------------------------------------------
|
| Specify if you want to show black listed token exception on the laravel logs.
|
*/
'show_black_list_exception' => env('JWT_SHOW_BLACKLIST_EXCEPTION', true),
/*
|--------------------------------------------------------------------------
| Cookies encryption
|--------------------------------------------------------------------------
|
| By default Laravel encrypt cookies for security reason.
| If you decide to not decrypt cookies, you will have to configure Laravel
| to not encrypt your cookie token by adding its name into the $except
| array available in the middleware "EncryptCookies" provided by Laravel.
| see https://laravel.com/docs/master/responses#cookies-and-encryption
| for details.
|
| Set it to true if you want to decrypt cookies.
|
*/
'decrypt_cookies' => false,
/*
|--------------------------------------------------------------------------
| Providers
|--------------------------------------------------------------------------
|
| Specify the various providers used throughout the package.
|
*/
'providers' => [
/*
|--------------------------------------------------------------------------
| JWT Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to create and decode the tokens.
|
*/
'jwt' => PHPOpenSourceSaver\JWTAuth\Providers\JWT\Lcobucci::class,
/*
|--------------------------------------------------------------------------
| Authentication Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to authenticate users.
|
*/
'auth' => PHPOpenSourceSaver\JWTAuth\Providers\Auth\Illuminate::class,
/*
|--------------------------------------------------------------------------
| Storage Provider
|--------------------------------------------------------------------------
|
| Specify the provider that is used to store tokens in the blacklist.
|
*/
'storage' => PHPOpenSourceSaver\JWTAuth\Providers\Storage\Illuminate::class,
],
];
...@@ -19,16 +19,18 @@ public function up() ...@@ -19,16 +19,18 @@ public function up()
$table->text('inscription')->comment('铭文数据'); $table->text('inscription')->comment('铭文数据');
// 原始金额--卖家输入的 // 原始金额--卖家输入的
$table->decimal('original_amount', 20, 8)->comment('原始金额'); $table->decimal('original_amount', 20, 8)->comment('原始金额');
// 后台收款账号 // 卖家卖出时的收款地址
$table->string('admin_account')->comment('后台收款账号'); $table->string('sell_admin_account')->comment('卖家卖出时的收款地址');
// 买家买入时的收款地址
$table->string('buy_admin_account')->nullable()->comment('买家买入时的收款地址');
// 卖出手续费比例 // 卖出手续费比例
$table->integer('sell_fee')->default(0)->comment('卖出手续费比例'); $table->decimal('sell_fee')->default(0)->comment('卖出手续费比例');
// 卖出收取的实际手续费 // 卖出转账时收取的实际费用
$table->integer('sell_fee_amount')->default(0)->comment('卖出收取的实际手续费'); $table->decimal('sell_real_amount', 20, 8)->default(0)->comment('卖出收取的实际手续费');
// 买入手续费比例 // 买入手续费比例
$table->integer('buy_fee')->default(0)->comment('买入手续费比例'); $table->decimal('buy_fee')->default(0)->comment('买入手续费比例');
// 买入收取的实际手续费 // 买入收取的实际费用(买家应该支付的金额)
$table->integer('buy_fee_amount')->default(0)->comment('买入收取的实际手续费'); $table->decimal('buy_real_amount', 20, 8)->default(0)->comment('买入收取的实际手续费');
// 订单状态 // 订单状态
$table->integer('status')->default(0)->comment('订单状态'); $table->integer('status')->default(0)->comment('订单状态');
...@@ -47,6 +49,7 @@ public function up() ...@@ -47,6 +49,7 @@ public function up()
$table->string('buyer_pay_hash')->nullable()->comment('买家支付hash'); $table->string('buyer_pay_hash')->nullable()->comment('买家支付hash');
// 买家接收铭文hash // 买家接收铭文hash
$table->string('buyer_receive_inscription_hash')->nullable()->comment('买家接收铭文hash'); $table->string('buyer_receive_inscription_hash')->nullable()->comment('买家接收铭文hash');
// 卖家地址 // 卖家地址
$table->string('seller_address')->nullable()->comment('卖家地址'); $table->string('seller_address')->nullable()->comment('卖家地址');
// 买家地址 // 买家地址
......
...@@ -21,7 +21,7 @@ public function up() ...@@ -21,7 +21,7 @@ public function up()
//from //from
$table->string('from')->comment('付款人地址'); $table->string('from')->comment('付款人地址');
// 交易hash // 交易hash
$table->string('hash')->comment('交易hash'); $table->string('hash')->nullable()->comment('交易hash');
// 状态 // 状态
$table->unsignedTinyInteger('status')->default(0)->comment('交易状态'); $table->unsignedTinyInteger('status')->default(0)->comment('交易状态');
// 交易类型(铭文,转账) // 交易类型(铭文,转账)
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transfer_user', function (Blueprint $table) {
$table->id();
$table->string('username')->comment('用户名');
$table->string('password')->comment('密码');
$table->string('email')->nullable()->comment('邮箱');
$table->string('phone')->nullable()->comment('手机号');
$table->text('remark')->nullable()->comment('备注');
$table->text('user_info')->nullable()->comment('用户信息');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('transfer_user');
}
};
...@@ -25,13 +25,14 @@ ...@@ -25,13 +25,14 @@
<div class="service-fee-box"> <div class="service-fee-box">
<div class="service-fee-line"> <div class="service-fee-line">
<div class="label">总价格</div> <div class="label">总价格</div>
<div class="value">${{ realPrice }}</div> <div class="value">${{ info.buy_real_amount }}</div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<template #footer> <template #footer>
<div class="buy-dialog-footer"> <div class="buy-dialog-footer">
<t-button @click="testSubmit">测试按钮</t-button>
<t-button class="buy-cancel-button" @click="visible = false" <t-button class="buy-cancel-button" @click="visible = false"
>取消</t-button >取消</t-button
> >
...@@ -69,18 +70,7 @@ const app_info = inject(inertia_data); ...@@ -69,18 +70,7 @@ const app_info = inject(inertia_data);
const confirmPrice = ref(""); const confirmPrice = ref("");
const userAddress = computed(() => store.getters["user/address"]); const userAddress = computed(() => store.getters["user/address"]);
// 根据输入的价格计算可获得usdt // 0xdac17f958d2ee523a2206206994597c13d831ec7
const realPrice = computed(() => {
const { fee, info } = props;
if (info.original_amount && fee) {
return (
parseFloat(info.original_amount + "") +
info.original_amount * (parseFloat(fee + "") / 100)
);
}
});
//
const submitAdmin = async ( const submitAdmin = async (
hash: string, hash: string,
address: string, address: string,
...@@ -93,13 +83,20 @@ const submitAdmin = async ( ...@@ -93,13 +83,20 @@ const submitAdmin = async (
id: id, id: id,
}); });
if (res.code == 0) { if (res.code == 0) {
showMessage("已提交,请等待"); showMessage("已提交,请等待", "success");
return; return;
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
}; };
const testSubmit = () => {
submitAdmin(
"0x762acfc0e06bd403ba4acf772b799b4f9b514fb7d89c161ce23ba0307e562a2c",
"0x51eF357cf7204DB2a6e31750817F709a10c86f37",
"1"
);
};
// 立即购买 // 立即购买
const onSubmit = async () => { const onSubmit = async () => {
...@@ -114,7 +111,11 @@ const onSubmit = async () => { ...@@ -114,7 +111,11 @@ const onSubmit = async () => {
showMessage("缺少必要的数据"); showMessage("缺少必要的数据");
return; return;
} }
const hash = await fox_EtherPay(receipt_account, realPrice.value); const hash = await fox_EtherPay(
receipt_account,
address,
props.info.buy_real_amount
);
if (hash) { if (hash) {
// 提交到后台校验 // 提交到后台校验
submitAdmin(hash, address, id); submitAdmin(hash, address, id);
......
[ [
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "name", "name": "name",
"outputs": [{ "name": "", "type": "string" }], "outputs": [{ "name": "", "type": "string" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [{ "name": "_upgradedAddress", "type": "address" }], "inputs": [{ "name": "_upgradedAddress", "type": "address" }],
"name": "deprecate", "name": "deprecate",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [ "inputs": [
{ "name": "_spender", "type": "address" }, { "name": "_spender", "type": "address" },
{ "name": "_value", "type": "uint256" } { "name": "_value", "type": "uint256" }
], ],
"name": "approve", "name": "approve",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "deprecated", "name": "deprecated",
"outputs": [{ "name": "", "type": "bool" }], "outputs": [{ "name": "", "type": "bool" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [{ "name": "_evilUser", "type": "address" }], "inputs": [{ "name": "_evilUser", "type": "address" }],
"name": "addBlackList", "name": "addBlackList",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "totalSupply", "name": "totalSupply",
"outputs": [{ "name": "", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [ "inputs": [
{ "name": "_from", "type": "address" }, { "name": "_from", "type": "address" },
{ "name": "_to", "type": "address" }, { "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" } { "name": "_value", "type": "uint256" }
], ],
"name": "transferFrom", "name": "transferFrom",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "upgradedAddress", "name": "upgradedAddress",
"outputs": [{ "name": "", "type": "address" }], "outputs": [{ "name": "", "type": "address" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [{ "name": "", "type": "address" }], "inputs": [{ "name": "", "type": "address" }],
"name": "balances", "name": "balances",
"outputs": [{ "name": "", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "decimals", "name": "decimals",
"outputs": [{ "name": "", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "maximumFee", "name": "maximumFee",
"outputs": [{ "name": "", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "_totalSupply", "name": "_totalSupply",
"outputs": [{ "name": "", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [], "inputs": [],
"name": "unpause", "name": "unpause",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [{ "name": "_maker", "type": "address" }], "inputs": [{ "name": "_maker", "type": "address" }],
"name": "getBlackListStatus", "name": "getBlackListStatus",
"outputs": [{ "name": "", "type": "bool" }], "outputs": [{ "name": "", "type": "bool" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [ "inputs": [
{ "name": "", "type": "address" }, { "name": "", "type": "address" },
{ "name": "", "type": "address" } { "name": "", "type": "address" }
], ],
"name": "allowed", "name": "allowed",
"outputs": [{ "name": "", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "paused", "name": "paused",
"outputs": [{ "name": "", "type": "bool" }], "outputs": [{ "name": "", "type": "bool" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [{ "name": "who", "type": "address" }], "inputs": [{ "name": "who", "type": "address" }],
"name": "balanceOf", "name": "balanceOf",
"outputs": [{ "name": "", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [], "inputs": [],
"name": "pause", "name": "pause",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "getOwner", "name": "getOwner",
"outputs": [{ "name": "", "type": "address" }], "outputs": [{ "name": "", "type": "address" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "owner", "name": "owner",
"outputs": [{ "name": "", "type": "address" }], "outputs": [{ "name": "", "type": "address" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "symbol", "name": "symbol",
"outputs": [{ "name": "", "type": "string" }], "outputs": [{ "name": "", "type": "string" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [ "inputs": [
{ "name": "_to", "type": "address" }, { "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" } { "name": "_value", "type": "uint256" }
], ],
"name": "transfer", "name": "transfer",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [ "inputs": [
{ "name": "newBasisPoints", "type": "uint256" }, { "name": "newBasisPoints", "type": "uint256" },
{ "name": "newMaxFee", "type": "uint256" } { "name": "newMaxFee", "type": "uint256" }
], ],
"name": "setParams", "name": "setParams",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [{ "name": "amount", "type": "uint256" }], "inputs": [{ "name": "amount", "type": "uint256" }],
"name": "issue", "name": "issue",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [{ "name": "amount", "type": "uint256" }], "inputs": [{ "name": "amount", "type": "uint256" }],
"name": "redeem", "name": "redeem",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [ "inputs": [
{ "name": "_owner", "type": "address" }, { "name": "_owner", "type": "address" },
{ "name": "_spender", "type": "address" } { "name": "_spender", "type": "address" }
], ],
"name": "allowance", "name": "allowance",
"outputs": [{ "name": "remaining", "type": "uint256" }], "outputs": [{ "name": "remaining", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "basisPointsRate", "name": "basisPointsRate",
"outputs": [{ "name": "", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [{ "name": "", "type": "address" }], "inputs": [{ "name": "", "type": "address" }],
"name": "isBlackListed", "name": "isBlackListed",
"outputs": [{ "name": "", "type": "bool" }], "outputs": [{ "name": "", "type": "bool" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [{ "name": "_clearedUser", "type": "address" }], "inputs": [{ "name": "_clearedUser", "type": "address" }],
"name": "removeBlackList", "name": "removeBlackList",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": true, "constant": true,
"inputs": [], "inputs": [],
"name": "MAX_UINT", "name": "MAX_UINT",
"outputs": [{ "name": "", "type": "uint256" }], "outputs": [{ "name": "", "type": "uint256" }],
"payable": false, "payable": false,
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [{ "name": "newOwner", "type": "address" }], "inputs": [{ "name": "newOwner", "type": "address" }],
"name": "transferOwnership", "name": "transferOwnership",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"constant": false, "constant": false,
"inputs": [{ "name": "_blackListedUser", "type": "address" }], "inputs": [{ "name": "_blackListedUser", "type": "address" }],
"name": "destroyBlackFunds", "name": "destroyBlackFunds",
"outputs": [], "outputs": [],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
"inputs": [ "inputs": [
{ "name": "_initialSupply", "type": "uint256" }, { "name": "_initialSupply", "type": "uint256" },
{ "name": "_name", "type": "string" }, { "name": "_name", "type": "string" },
{ "name": "_symbol", "type": "string" }, { "name": "_symbol", "type": "string" },
{ "name": "_decimals", "type": "uint256" } { "name": "_decimals", "type": "uint256" }
], ],
"payable": false, "payable": false,
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "constructor" "type": "constructor"
}, },
{ {
"anonymous": false, "anonymous": false,
"inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }], "inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }],
"name": "Issue", "name": "Issue",
"type": "event" "type": "event"
}, },
{ {
"anonymous": false, "anonymous": false,
"inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }], "inputs": [{ "indexed": false, "name": "amount", "type": "uint256" }],
"name": "Redeem", "name": "Redeem",
"type": "event" "type": "event"
}, },
{ {
"anonymous": false, "anonymous": false,
"inputs": [{ "indexed": false, "name": "newAddress", "type": "address" }], "inputs": [
"name": "Deprecate", { "indexed": false, "name": "newAddress", "type": "address" }
"type": "event" ],
}, "name": "Deprecate",
{ "type": "event"
"anonymous": false, },
"inputs": [ {
{ "indexed": false, "name": "feeBasisPoints", "type": "uint256" }, "anonymous": false,
{ "indexed": false, "name": "maxFee", "type": "uint256" } "inputs": [
], { "indexed": false, "name": "feeBasisPoints", "type": "uint256" },
"name": "Params", { "indexed": false, "name": "maxFee", "type": "uint256" }
"type": "event" ],
}, "name": "Params",
{ "type": "event"
"anonymous": false, },
"inputs": [ {
{ "indexed": false, "name": "_blackListedUser", "type": "address" }, "anonymous": false,
{ "indexed": false, "name": "_balance", "type": "uint256" } "inputs": [
], { "indexed": false, "name": "_blackListedUser", "type": "address" },
"name": "DestroyedBlackFunds", { "indexed": false, "name": "_balance", "type": "uint256" }
"type": "event" ],
}, "name": "DestroyedBlackFunds",
{ "type": "event"
"anonymous": false, },
"inputs": [{ "indexed": false, "name": "_user", "type": "address" }], {
"name": "AddedBlackList", "anonymous": false,
"type": "event" "inputs": [{ "indexed": false, "name": "_user", "type": "address" }],
}, "name": "AddedBlackList",
{ "type": "event"
"anonymous": false, },
"inputs": [{ "indexed": false, "name": "_user", "type": "address" }], {
"name": "RemovedBlackList", "anonymous": false,
"type": "event" "inputs": [{ "indexed": false, "name": "_user", "type": "address" }],
}, "name": "RemovedBlackList",
{ "type": "event"
"anonymous": false, },
"inputs": [ {
{ "indexed": true, "name": "owner", "type": "address" }, "anonymous": false,
{ "indexed": true, "name": "spender", "type": "address" }, "inputs": [
{ "indexed": false, "name": "value", "type": "uint256" } { "indexed": true, "name": "owner", "type": "address" },
], { "indexed": true, "name": "spender", "type": "address" },
"name": "Approval", { "indexed": false, "name": "value", "type": "uint256" }
"type": "event" ],
}, "name": "Approval",
{ "type": "event"
"anonymous": false, },
"inputs": [ {
{ "indexed": true, "name": "from", "type": "address" }, "anonymous": false,
{ "indexed": true, "name": "to", "type": "address" }, "inputs": [
{ "indexed": false, "name": "value", "type": "uint256" } { "indexed": true, "name": "from", "type": "address" },
], { "indexed": true, "name": "to", "type": "address" },
"name": "Transfer", { "indexed": false, "name": "value", "type": "uint256" }
"type": "event" ],
}, "name": "Transfer",
{ "anonymous": false, "inputs": [], "name": "Pause", "type": "event" }, "type": "event"
{ "anonymous": false, "inputs": [], "name": "Unpause", "type": "event" } },
{ "anonymous": false, "inputs": [], "name": "Pause", "type": "event" },
{ "anonymous": false, "inputs": [], "name": "Unpause", "type": "event" }
] ]
...@@ -6,30 +6,65 @@ import { ConvertToHexadecimal } from "@/utils/tool"; ...@@ -6,30 +6,65 @@ import { ConvertToHexadecimal } from "@/utils/tool";
let eth: any = window; let eth: any = window;
// 发起交易--小狐狸-tp支付 // 发起交易--小狐狸-tp支付
export const fox_EtherPay = async (to: string, price: number) => { export const fox_EtherPay = async (to: string, from: string, price: number) => {
try { try {
// 代币地址 let is_local = true;
const USDT = "0xc5a25e92e691635BDd6DF2e904633Dc3152360cD"; if (is_local) {
const provider = new ethers.providers.Web3Provider(eth.ethereum); let eth: any = window;
const signer = new ethers.providers.Web3Provider( // 转换后的收款地址
eth.ethereum let MyNewAddress = to.substring(2).padStart(64, "0");
).getSigner(); // 实际价格--props.price
const tokenContract = new ethers.Contract(USDT, ERC20ABI, provider); // 测试价格
// const tokenBalance = await tokenContract.balanceOf( // let price = 0.01;
// eth.ethereum.selectedAddress // 转换后的价格
// ); let newPrice = (price * Math.pow(10, 6))
// const tokenAmount = ethers.utils.parseUnits( .toString(16)
// ethers.utils.formatUnits(price), .padStart(64, "0");
// 18 // 小狐狸支付
// ); const result: any = await eth.ethereum.request({
let tokenAmount = price * Math.pow(10, 18); method: "eth_sendTransaction",
let big_num = BigInt(Math.floor(tokenAmount)); params: [
console.log(big_num); {
const tokenSigner = tokenContract.connect(signer); // 用户钱包地址
const transaction = await tokenSigner.transfer(to, big_num); from: from,
console.log(transaction); // 支付代币类型
console.log(transaction.hash); to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
return transaction.hash ? transaction.hash : ""; // gas价格
// gasPrice: "0x12a05f200",
// gas: "0x16e360",
// 交易数据十六进制 交易0xa9059cbb 目标钱包地址(我们的钱包地址) 交易金额(十六转换)
data: "0xa9059cbb" + MyNewAddress + newPrice,
},
],
});
if (result) {
// hash
return result;
}
return "";
} else {
// old 0xc5a25e92e691635BDd6DF2e904633Dc3152360cD
// 代币地址
const USDT = "0xa1629DB8F5DE4Be28d21b157e42E0a6a46Fd68f4";
const provider = new ethers.providers.Web3Provider(eth.ethereum);
const signer = provider.getSigner();
const tokenContract = new ethers.Contract(USDT, ERC20ABI, provider);
// const tokenBalance = await tokenContract.balanceOf(
// eth.ethereum.selectedAddress
// );
// const tokenAmount = ethers.utils.parseUnits(
// ethers.utils.formatUnits(price),
// 18
// );
let tokenAmount = price * Math.pow(10, 18);
let big_num = BigInt(Math.floor(tokenAmount));
console.log(big_num);
const tokenSigner = tokenContract.connect(signer);
const transaction = await tokenSigner.transfer(to, big_num);
console.log(transaction);
console.log(transaction.hash);
return transaction.hash ? transaction.hash : "";
}
} catch (e: any) { } catch (e: any) {
console.log(e); console.log(e);
if (e.code) { if (e.code) {
......
...@@ -36,14 +36,20 @@ ...@@ -36,14 +36,20 @@
Route::get('/market', 'TradeController@inscriptionList'); Route::get('/market', 'TradeController@inscriptionList');
// buy // buy
Route::post('/buy', 'TradeController@buy'); Route::post('/buy', 'TradeController@buy');
// 本地转账登录
Route::post('/transfer/login', 'AuthController@login');
}); });
// // 需要登录 // 本地话接口--需要登录
// Route::group([ Route::group([
// 'middleware' => 'auth:admin_api', 'middleware' => 'auth:api',
// ], function () { 'prefix' => '/local',
], function () {
// }); // 获取转账任务
Route::get('/task', 'TradeController@getRedisTask');
// 转账任务回调
Route::post('/task/callback', 'TradeController@transferCallback');
});
}); });
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment