Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dex-admin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
dex-admin
Commits
6974e94b
Commit
6974e94b
authored
Jul 03, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
f45c307c
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
640 additions
and
84 deletions
+640
-84
app/Http/Controllers/Api/TradeController.php
+13
-3
app/Models/InscriptionTrading.php
+6
-0
app/Models/Inscriptions.php
+16
-0
app/Service/InscriptionService.php
+7
-0
app/Service/TradeService.php
+164
-45
app/Service/TransactionLogService.php
+1
-0
database/migrations/2023_06_29_065643_create_inscription_trading_table.php
+1
-1
database/migrations/2023_07_03_051955_create_inscriptions_table.php
+48
-0
resources/js/Pages/InscriptionShelves/components/MyInscription.vue
+17
-12
resources/js/Pages/InscriptionShelves/components/TradeLog.vue
+334
-3
resources/js/Pages/Trade/components/Market.vue
+21
-19
resources/js/layout/header.vue
+5
-1
resources/js/utils/api/index.ts
+5
-0
routes/api.php
+2
-0
No files found.
app/Http/Controllers/Api/TradeController.php
View file @
6974e94b
...
...
@@ -24,6 +24,15 @@ public function shelves(Request $request)
return
$this
->
success
(
'success'
,
$result
);
}
// 卖家下架铭文
public
function
cancal
(
Request
$request
)
{
$address
=
$request
->
input
(
'address'
,
''
);
$id
=
$request
->
input
(
'id'
,
''
);
$result
=
app
(
TradeService
::
class
)
->
sellerCancel
(
$id
,
$address
);
return
$this
->
success
(
'success'
,
$result
);
}
// 交易检测回调
public
function
check
(
Request
$request
)
{
...
...
@@ -35,15 +44,16 @@ public function check(Request $request)
// 铭文查询
public
function
search
(
Request
$request
)
{
$address
=
$request
->
input
(
'address'
);
$type
=
$request
->
input
(
'type'
);
$pageType
=
$request
->
input
(
'page_type'
,
''
);
$address
=
$request
->
input
(
'address'
,
''
);
$type
=
$request
->
input
(
'type'
,
''
);
$page
=
$request
->
input
(
'page'
,
1
);
$limit
=
$request
->
input
(
'limit'
,
10
);
// 限制最大
if
(
$limit
>
50
)
{
$limit
=
10
;
}
$result
=
app
(
TradeService
::
class
)
->
search
(
$address
,
$type
,
$page
,
$limit
);
$result
=
app
(
TradeService
::
class
)
->
search
(
$
pageType
,
$
address
,
$type
,
$page
,
$limit
);
return
$this
->
success
(
'success'
,
$result
);
}
...
...
app/Models/InscriptionTrading.php
View file @
6974e94b
...
...
@@ -34,4 +34,10 @@ class InscriptionTrading extends Model
protected
$casts
=
[
'inscription'
=>
'array'
,
];
// 一对一
public
function
inscription
()
{
return
$this
->
hasOne
(
Inscriptions
::
class
,
'order_id'
,
'id'
);
}
}
app/Models/Inscriptions.php
0 → 100644
View file @
6974e94b
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
class
Inscriptions
extends
Model
{
use
HasFactory
;
protected
$table
=
'inscriptions'
;
// 允许批量赋值
protected
$fillable
=
[
'transaction_hash'
,
'current_owner'
,
'content_uri'
,
'uri_p'
,
'uri_op'
,
'uri_tick'
,
'uri_id'
,
'uri_amt'
,
'creator'
,
'creation_timestamp'
];
}
app/Service/InscriptionService.php
View file @
6974e94b
...
...
@@ -2,6 +2,7 @@
namespace
App\Service
;
use
App\Models\Inscriptions
;
use
App\Service\RequestService
;
use
Illuminate\Support\Facades\Log
;
...
...
@@ -11,6 +12,12 @@ class InscriptionService
// 铭文请求地址
public
const
InscriptionDomain
=
'https://eth-script-indexer-eca25c4cf43b.herokuapp.com'
;
// 创建铭文信息
public
function
create
(
$data
)
{
Inscriptions
::
query
()
->
create
(
$data
);
}
public
function
getWalletInscription
(
$address
=
''
)
{
if
(
!
$address
)
{
...
...
app/Service/TradeService.php
View file @
6974e94b
...
...
@@ -15,9 +15,14 @@ class TradeService
public
const
ORDER_STATUS_WAIT
=
1
;
// 未上架
public
const
ORDER_STATUS_ON
=
2
;
// 已上架
public
const
ORDER_STATUS_SUCCESS
=
3
;
// 已完成
public
const
ORDER_STATUS_FAIL
=
4
;
// 已取消
public
const
ORDER_STATUS_LOCK
=
5
;
// 锁定中(买家已提交hash,等待检测到账)
public
const
ORDER_STATUS_CANCEL
=
4
;
// 已取消(卖家下架铭文)
public
const
ORDER_STATUS_LOCK
=
5
;
// 锁定中(买家已提交hash,等待检测到账 或 订单交易中)
public
const
ORDER_STATUS_FAIL
=
6
;
// 卖家下架失败(卖家已提交下架申请,平台转移铭文失败)
public
const
ORDER_STATUS_CANCEL_PROGRESS
=
7
;
// 下架中(卖家已提交下架申请)
// 给前台的交易类型
public
const
PAGE_TRADE_TYPE_BUY
=
1
;
// 购买
public
const
PAGE_TRADE_TYPE_SELL
=
2
;
// 卖出
// 卖家状态
public
const
SELLER_STATUS_WAIT
=
1
;
// 未转移
...
...
@@ -27,6 +32,7 @@ class TradeService
public
const
SELLER_STATUS_CANCEL
=
5
;
// 取消转移(下架)
public
const
SELLER_STATUS_RECEIPT_FAIL
=
6
;
// 卖家收款失败(平台支付失败)
public
const
SELLER_STATUS_RECEIPT_SUCCESS
=
7
;
// 卖家收款成功
public
const
SELLER_STATUS_CANCEL_FAIL
=
8
;
// 卖家取消下架失败(平台转移失败)
// 买家状态
public
const
BUYER_STATUS_WAIT
=
1
;
// 未支付
...
...
@@ -97,6 +103,7 @@ public function updateInscription($data)
{
// 铭文信息必须包含指定字段
$fields
=
[
'transaction_hash'
,
'current_owner'
,
'content_uri'
,
'creator'
,
'creation_timestamp'
];
// $content_uri = 'data:,{"p":"erc-20","op":"mint","tick":"eths","id":"11532","amt":"1000"}';
// 校验铭文信息
$inscription
=
app
(
CommonService
::
class
)
->
customValidate
(
$data
,
$fields
,
'缺少必要的铭文信息'
);
return
$inscription
;
...
...
@@ -130,6 +137,7 @@ public function inscriptionList($page, $limit)
return
$model
;
}
// 上架
public
function
userShelves
(
$payment_address
,
$hash
,
$inscription
,
$price
)
{
if
(
blank
(
$payment_address
)
||
blank
(
$hash
)
||
blank
(
$inscription
))
{
...
...
@@ -194,6 +202,50 @@ public function userShelves($payment_address, $hash, $inscription, $price)
throw
new
UserException
(
1
,
'上架失败'
);
}
// 下架
public
function
sellerCancel
(
$id
,
$address
)
{
$order
=
$this
->
model
()
->
where
(
'id'
,
$id
)
->
where
(
'seller_address'
,
$address
)
->
first
();
if
(
blank
(
$order
))
{
throw
new
UserException
(
1
,
'非法操作cancel order'
);
}
// 只有上架中的订单才能下架
if
(
$order
->
status
!=
self
::
ORDER_STATUS_ON
)
{
throw
new
UserException
(
1
,
'订单锁定中,无法取消'
);
}
if
(
!
$order
->
seller_address
)
{
throw
new
UserException
(
1
,
'没有卖家地址'
);
}
// 更新订单
$order
->
status
=
self
::
ORDER_STATUS_CANCEL_PROGRESS
;
$order
->
save
();
// 平台收款地址
$admin_address
=
app
(
AdminConfigService
::
class
)
->
getReceiptAccount
();
// 创建交易日志
$data
=
[
'order_id'
=>
$order
->
id
,
'trade_type'
=>
self
::
TRADE_TYPE_INSCRIPTION
,
'title'
=>
self
::
TRADE_NAME_SELLER_CANCEL
,
'to'
=>
$order
->
seller_address
,
'from'
=>
$admin_address
,
];
$log_id
=
app
(
TransactionLogService
::
class
)
->
create
(
$data
);
// 添加redis
$obj
=
[
'from'
=>
$admin_address
,
'to'
=>
$order
->
seller_address
,
'inscription_hash'
=>
$order
->
inscription
[
'transaction_hash'
],
'id'
=>
$order
->
id
,
'log_id'
=>
$log_id
,
'type'
=>
self
::
TRADE_TYPE_INSCRIPTION
,
'title'
=>
self
::
TRADE_NAME_SELLER_CANCEL
,
'notify_url'
=>
app
(
CommonService
::
class
)
->
getPlatformPayCallbackUrl
(),
];
$this
->
redisAdd
(
$obj
,
self
::
REDIS_KEY_TRANSFER
);
}
// 卖家上架回调更新
public
function
sellerShelvesSuccess
(
$data
)
{
...
...
@@ -321,13 +373,27 @@ public function check($data)
}
// 铭文交易记录
public
function
search
(
$address
,
$type
,
$page
,
$limit
)
public
function
search
(
$
pageType
,
$
address
,
$type
,
$page
,
$limit
)
{
if
(
blank
(
$address
)
||
blank
(
$type
))
{
$filed
=
[
'inscription'
,
'status'
,
'original_amount'
,
'sell_fee'
,
'seller_receive_hash'
];
$model
=
$this
->
model
();
if
(
blank
(
$address
)
||
blank
(
$type
)
||
blank
(
$pageType
))
{
throw
new
UserException
(
1
,
'非法操作'
);
}
$model
=
$this
->
model
()
->
where
(
'status'
,
$type
)
->
where
(
'seller_address'
,
$address
)
->
orderBy
(
'id'
,
'desc'
)
->
paginate
(
$limit
,
[
'inscription'
,
'status'
,
'original_amount'
,
'sell_fee'
,
'seller_receive_hash'
],
'page'
,
$page
);
if
(
$type
==
self
::
ORDER_STATUS_ON
)
{
// 进行中的
$model
=
$model
->
whereIn
(
'status'
,
[
self
::
ORDER_STATUS_ON
,
self
::
ORDER_STATUS_LOCK
]);
}
else
{
$model
=
$model
->
where
(
'status'
,
$type
);
}
if
(
$pageType
==
self
::
PAGE_TRADE_TYPE_SELL
)
{
// 卖家
$model
=
$model
->
where
(
'seller_address'
,
$address
);
}
elseif
(
$pageType
==
self
::
PAGE_TRADE_TYPE_BUY
)
{
// 买家
$model
=
$model
->
where
(
'buyer_address'
,
$address
);
}
$model
=
$model
->
orderBy
(
'id'
,
'desc'
)
->
paginate
(
$limit
,
$filed
,
'page'
,
$page
);
// 分页
return
$model
;
}
...
...
@@ -389,6 +455,87 @@ public function buy($payment_address, $hash, $id)
throw
new
UserException
(
1
,
'非法操作'
);
}
// 订单已完成
public
function
orderSuccess
(
$order
)
{
if
(
$order
->
seller_status
==
self
::
SELLER_STATUS_RECEIPT_SUCCESS
&&
$order
->
buyer_status
==
self
::
BUYER_RECEIVE_SUCCESS
)
{
$order
->
status
=
self
::
ORDER_STATUS_SUCCESS
;
$order
->
save
();
}
}
// 平台转移铭文(给买家)
public
function
platformTransferInscription
(
$status
,
$hash
,
$order
,
$inscription
)
{
$buyer_status
=
self
::
BUYER_STATUS_SUCCESS
;
if
(
$status
==
self
::
TRADE_STATUS_SUCCESS
)
{
// 转账成功
$buyer_status
=
self
::
BUYER_RECEIVE_SUCCESS
;
}
else
if
(
in_array
(
$status
,
[
self
::
TRADE_STATUS_FAIL
,
self
::
TRADE_STATUS_FAIL_2
]))
{
// 转账失败
$buyer_status
=
self
::
BUYER_RECEIVE_FAIL
;
}
$order
->
buyer_receive_inscription_hash
=
$hash
;
// 更新order
$order
->
status
=
self
::
ORDER_STATUS_LOCK
;
$order
->
buyer_status
=
$buyer_status
;
// 更新铭文数据
if
(
$inscription
)
{
$inscription
=
self
::
updateInscription
(
$inscription
);
$order
->
inscription
=
$inscription
;
}
$order
->
save
();
// 订单是否完成
self
::
orderSuccess
(
$order
);
}
// 平台转移铭文(卖家下架)
public
function
platformTransferInscriptionSeller
(
$status
,
$hash
,
$order
,
$inscription
)
{
$seller_status
=
self
::
SELLER_STATUS_SUCCESS
;
$order_status
=
self
::
ORDER_STATUS_LOCK
;
if
(
$status
==
self
::
TRADE_STATUS_SUCCESS
)
{
// 转账成功
$seller_status
=
self
::
SELLER_STATUS_CANCEL
;
// 订单已取消
$order_status
=
self
::
ORDER_STATUS_CANCEL
;
}
else
if
(
in_array
(
$status
,
[
self
::
TRADE_STATUS_FAIL
,
self
::
TRADE_STATUS_FAIL_2
]))
{
// 转账失败
$seller_status
=
self
::
SELLER_STATUS_CANCEL_FAIL
;
$order_status
=
self
::
ORDER_STATUS_FAIL
;
}
if
(
$inscription
)
{
$inscription
=
self
::
updateInscription
(
$inscription
);
$order
->
inscription
=
$inscription
;
}
$order
->
seller_cancel_hash
=
$hash
;
// 更新order
$order
->
status
=
$order_status
;
$order
->
seller_status
=
$seller_status
;
$order
->
save
();
}
// 平台转账给卖家
public
function
platformTransferSeller
(
$status
,
$hash
,
$order
)
{
$seller_status
=
self
::
SELLER_STATUS_SUCCESS
;
if
(
$status
==
self
::
TRADE_STATUS_SUCCESS
)
{
// 转账成功
$seller_status
=
self
::
SELLER_STATUS_RECEIPT_SUCCESS
;
}
else
if
(
in_array
(
$status
,
[
self
::
TRADE_STATUS_FAIL
,
self
::
TRADE_STATUS_FAIL_2
]))
{
// 转账失败
$seller_status
=
self
::
SELLER_STATUS_RECEIPT_FAIL
;
}
$order
->
seller_receive_hash
=
$hash
;
// 更新order
$order
->
status
=
self
::
ORDER_STATUS_LOCK
;
$order
->
seller_status
=
$seller_status
;
$order
->
save
();
// 订单是否完成
self
::
orderSuccess
(
$order
);
}
// 平台转账回调
public
function
adminTransferCallback
(
$data
)
{
...
...
@@ -397,48 +544,20 @@ public function adminTransferCallback($data)
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
;
}
// 铭文信息
$inscription
=
$data
[
'inscriptionInfo'
]
??
''
;
if
(
$title_type
==
self
::
TRADE_NAME_BUYER_RECEIVE
)
{
// 买家接收铭文
self
::
platformTransferInscription
(
$status
,
$hash
,
$order
,
$inscription
);
}
elseif
(
$title_type
==
self
::
TRADE_NAME_SELLER_RECEIPT
)
{
// 卖家收款
self
::
platformTransferSeller
(
$status
,
$hash
,
$order
);
}
elseif
(
$title_type
==
self
::
TRADE_NAME_SELLER_CANCEL
)
{
// 卖家取消
self
::
platformTransferInscriptionSeller
(
$status
,
$hash
,
$order
,
$inscription
);
}
// 更新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'
);
...
...
app/Service/TransactionLogService.php
View file @
6974e94b
...
...
@@ -30,6 +30,7 @@ public function create($params)
$data
[
'hash'
]
=
$params
[
'hash'
];
$res
=
$model
->
where
(
'hash'
,
$data
[
'hash'
])
->
first
();
if
(
$res
)
{
Log
::
info
(
$data
[
'hash'
]);
throw
new
UserException
(
1
,
'支付hash已存在'
);
}
}
...
...
database/migrations/2023_06_29_065643_create_inscription_trading_table.php
View file @
6974e94b
...
...
@@ -19,7 +19,7 @@ public function up()
$table
->
text
(
'inscription'
)
->
comment
(
'铭文数据'
);
// 原始金额--卖家输入的
$table
->
decimal
(
'original_amount'
,
20
,
8
)
->
comment
(
'原始金额'
);
// 卖家卖出时的收款地址
// 卖家卖出时
,平台
的收款地址
$table
->
string
(
'sell_admin_account'
)
->
comment
(
'卖家卖出时的收款地址'
);
// 买家买入时的收款地址
$table
->
string
(
'buy_admin_account'
)
->
nullable
()
->
comment
(
'买家买入时的收款地址'
);
...
...
database/migrations/2023_07_03_051955_create_inscriptions_table.php
0 → 100644
View file @
6974e94b
<?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
(
'inscriptions'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
// 订单id
$table
->
bigInteger
(
'order_id'
)
->
default
(
0
)
->
comment
(
'订单id'
);
// 铭文hash
$table
->
string
(
'transaction_hash'
)
->
comment
(
'铭文hash'
);
$table
->
string
(
'current_owner'
)
->
comment
(
'current_owner'
);
$table
->
string
(
'content_uri'
)
->
comment
(
'content_uri'
);
// "p":"erc-20"
$table
->
string
(
'uri_p'
)
->
nullable
()
->
comment
(
'uri_p'
);
// "op":"mint"
$table
->
string
(
'uri_op'
)
->
nullable
()
->
comment
(
'uri_op'
);
// "tick":"eths"
$table
->
string
(
'uri_tick'
)
->
nullable
()
->
comment
(
'uri_tick'
);
// "id":"11532"
$table
->
bigInteger
(
'uri_id'
)
->
default
(
0
)
->
comment
(
'uri_id'
);
// "amt":"1000"
$table
->
bigInteger
(
'uri_amt'
)
->
default
(
0
)
->
comment
(
'uri_amt'
);
$table
->
string
(
'creator'
)
->
comment
(
'creator'
);
$table
->
dateTime
(
'creation_timestamp'
)
->
comment
(
'creation_timestamp'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'inscriptions'
);
}
};
resources/js/Pages/InscriptionShelves/components/MyInscription.vue
View file @
6974e94b
...
...
@@ -125,7 +125,7 @@ import {
inscriptionListAdminFilter
,
}
from
"@/utils/api/public"
;
import
{
inertia_data
}
from
"@/constants/token"
;
import
{
sellerTradeLog
}
from
"@/utils/api"
;
import
{
sellerTradeLog
,
SellerCancel
}
from
"@/utils/api"
;
const
store
=
useStore
();
const
imgs
=
{
eth
:
new
URL
(
"../../../assets/svg/trade/eth2.svg"
,
import
.
meta
.
url
).
href
,
...
...
@@ -140,6 +140,9 @@ const confirm_dialog = ref(false);
// 全局数据
const
app_info
=
inject
(
inertia_data
);
// 当前选择的取消id
const
cancel_id
=
ref
(
""
);
// 当前选择的按钮
const
currentBtn
=
ref
(
"1"
);
// 按钮组
...
...
@@ -200,16 +203,6 @@ const cardText = (item: any) => {
const
setCurrentList
=
(
list
:
any
[])
=>
{
current_list
.
list
=
JSON
.
parse
(
JSON
.
stringify
(
list
));
};
// 获取本地数据
const
getWalletLocalData
=
(
key
:
"type"
|
"address"
|
"MaskAddress"
=
"type"
)
=>
{
const
res
=
getLocal
(
userWalletKey
,
"session"
);
if
(
res
)
{
return
res
[
key
];
}
return
""
;
};
// 出售
const
sellNow
=
(
item
:
any
)
=>
{
...
...
@@ -266,6 +259,8 @@ const getTradeList = async () => {
try
{
//
const
res
:
any
=
await
sellerTradeLog
({
// 卖出类型
page_type
:
2
,
type
:
currentBtn
.
value
,
address
:
userAddress
.
value
.
address
,
page
:
adminTableList
.
pageNum
,
...
...
@@ -292,11 +287,21 @@ const getTradeList = async () => {
const
onCanel
=
(
item
:
any
)
=>
{
// 打开确认弹窗
confirm_dialog
.
value
=
true
;
// 记录本次的id
cancel_id
.
value
=
item
.
id
;
};
// 确定取消订单
const
ConfirmCancel
=
()
=>
{
const
ConfirmCancel
=
async
()
=>
{
//
try
{
const
res
:
any
=
await
SellerCancel
({
id
:
cancel_id
.
value
,
address
:
userAddress
.
value
.
address
,
});
}
catch
(
e
)
{
console
.
log
(
e
);
}
};
// 查看hash
...
...
resources/js/Pages/InscriptionShelves/components/TradeLog.vue
View file @
6974e94b
<
template
>
<div
class=
""
>
2
</div>
<div
class=
"my-inscription-tabpanel"
>
<div
class=
"inscription-filter-box"
>
<div
class=
"inscription-filter"
>
<GroupButton
v-model=
"currentBtn"
:list=
"groupBtns"
:bordered=
"false"
childHeight=
"30px"
></GroupButton>
</div>
</div>
<template
v-if=
"userAddress.address && current_list.list.length"
>
<t-row
class=
"my-inscription-card-box"
>
<template
v-for=
"item in current_list.list"
:key=
"item.id"
>
<t-col
:span=
"1.5"
>
<CustomCard
:cardData=
"item"
>
<template
#
footer
>
<template
v-if=
"currentBtn === '2'"
>
<div
class=
"inscription-canenl-box inscription-footer-public"
>
<div
class=
"left-price"
>
<div>
价格
</div>
<div>
{{
parseFloat
(
item
.
original_amount
+
""
)
}}
USDT
</div>
</div>
<!--
<t-button
class=
"inscription-canenl-btn"
@
click=
"onCanel(item)"
>
取消
</t-button
>
-->
</div>
</
template
>
<
template
v-if=
"currentBtn === '3'"
>
<div
class=
"inscription-canenl-box inscription-footer-public"
>
<div
class=
"left-price"
>
<div>
价格
</div>
<div>
{{
parseFloat
(
item
.
original_amount
+
""
)
+
parseFloat
(
(
item
.
sell_fee
/
100
)
*
item
.
original_amount
+
""
)
}}
USDT
</div>
</div>
<t-button
class=
"inscription-canenl-btn"
@
click=
"checkHash(item)"
>
查看
</t-button
>
</div>
</
template
>
</template>
<
template
#
pos
>
<div
class=
"custom-inscription-card-pos"
v-if=
"cardText(item)"
>
{{
cardText
(
item
)
}}
</div>
</
template
>
</CustomCard>
</t-col>
</template>
</t-row>
</template>
<
template
v-else-if=
"!userAddress.address"
>
<div
class=
"connect-wallet-tips"
>
请先连接钱包
</div>
</
template
>
<ConfirmDialogVue
v-model=
"confirm_dialog"
@
ConfirmCancel=
"ConfirmCancel"
></ConfirmDialogVue>
</div>
</template>
<
script
lang=
"ts"
setup
></
script
>
<
script
lang=
"ts"
setup
>
import
{
ref
,
reactive
,
onMounted
,
computed
,
inject
,
watch
}
from
"vue"
;
import
{
isDev
,
getLocal
}
from
"@/utils/tool"
;
import
{
userWalletKey
}
from
"@/constants/token"
;
import
{
test_wallet_list
,
my_account_list
}
from
"@/constants/testData"
;
import
GroupButton
from
"@/components/groupButton.vue"
;
import
CustomCard
from
"@/components/card.vue"
;
import
{
useStore
}
from
"vuex"
;
import
ConfirmDialogVue
from
"./confirmDialog.vue"
;
import
{
inscriptionListFilter
,
inscriptionListAdminFilter
,
}
from
"@/utils/api/public"
;
import
{
inertia_data
}
from
"@/constants/token"
;
import
{
sellerTradeLog
}
from
"@/utils/api"
;
const
store
=
useStore
();
const
imgs
=
{
eth
:
new
URL
(
"../../../assets/svg/trade/eth2.svg"
,
import
.
meta
.
url
).
href
,
};
const
confirm_dialog
=
ref
(
false
);
// 全局数据
const
app_info
=
inject
(
inertia_data
);
// 当前选择的按钮
const
currentBtn
=
ref
(
"2"
);
// 按钮组
const
groupBtns
=
[
{
label
:
"进行中"
,
value
:
"2"
,
},
{
label
:
"已完成"
,
value
:
"3"
,
},
];
// 当前显示在页面上的list
const
current_list
=
reactive
({
list
:
[],
});
// 后台铭文列表
const
adminTableList
=
reactive
({
list
:
[],
total
:
0
,
pageNum
:
1
,
pageSize
:
10
,
loading
:
false
,
});
// 卡片上当前应该展示的文字
const
cardText
=
(
item
:
any
)
=>
{
if
(
currentBtn
.
value
==
"2"
)
{
return
"出售"
;
}
else
if
(
currentBtn
.
value
==
"3"
)
{
if
(
item
.
status
==
3
)
{
return
"完成"
;
}
else
if
(
item
.
status
==
4
)
{
return
"已取消"
;
}
}
};
// 修改当前页面展示的list
const
setCurrentList
=
(
list
:
any
[])
=>
{
current_list
.
list
=
JSON
.
parse
(
JSON
.
stringify
(
list
));
};
// 用户钱包
const
userAddress
=
computed
(()
=>
store
.
getters
[
"user/address"
]);
const
getTradeList
=
async
()
=>
{
try
{
//
const
res
:
any
=
await
sellerTradeLog
({
// 买入类型
page_type
:
1
,
type
:
currentBtn
.
value
,
address
:
userAddress
.
value
.
address
,
page
:
adminTableList
.
pageNum
,
limit
:
adminTableList
.
pageSize
,
});
if
(
res
.
code
==
0
)
{
if
(
res
.
data
.
data
.
length
)
{
let
list
=
inscriptionListAdminFilter
(
res
.
data
.
data
);
adminTableList
.
list
=
list
;
adminTableList
.
total
=
res
.
data
.
total
;
setCurrentList
(
list
);
}
else
{
adminTableList
.
list
=
[];
adminTableList
.
total
=
0
;
setCurrentList
([]);
}
}
}
catch
(
e
)
{
console
.
log
(
e
);
}
};
// 取消事件
const
onCanel
=
(
item
:
any
)
=>
{
// 打开确认弹窗
confirm_dialog
.
value
=
true
;
};
// 确定取消订单
const
ConfirmCancel
=
()
=>
{
//
};
// 查看hash
const
checkHash
=
(
item
:
any
)
=>
{
if
(
item
.
buyer_receive_inscription_hash
)
{
window
.
open
(
"https://etherscan.io/tx/"
+
item
.
buyer_receive_inscription_hash
);
}
else
{
console
.
log
(
"没有hash"
);
}
};
watch
(
()
=>
currentBtn
.
value
,
(
v
)
=>
{
if
(
v
==
"2"
||
v
==
"3"
)
{
getTradeList
();
}
}
);
onMounted
(()
=>
{
//
getTradeList
();
});
</
script
>
<
style
lang=
"less"
>
.my-inscription-tabpanel
{
.inscription-filter-box
{
text-align
:
right
;
.inscription-filter
{
margin
:
20px
0
;
display
:
inline-flex
;
align-items
:
center
;
justify-content
:
flex-end
;
white-space
:
nowrap
;
&
>
:last-child
{
margin-left
:
12px
;
}
}
}
.my-inscription-card-box
{
margin-left
:
-30px
!important
;
margin-top
:
-40px
;
display
:
flex
;
justify-content
:
space-between
;
width
:
100%
;
<
style
lang=
"less"
></
style
>
&
>
*
{
margin-left
:
30px
;
margin-top
:
40px
;
}
}
.connect-wallet-tips
{
margin-top
:
100px
;
text-align
:
center
;
font-weight
:
bold
;
font-size
:
16px
;
color
:
red
;
&::after
{
content
:
"!"
;
}
}
.inscription-footer-public
{
height
:
64px
;
padding
:
12px
;
box-sizing
:
border-box
;
border-top
:
1px
solid
#ebebeb
;
}
.inscription-now-box
{
.inscription-now-button
{
width
:
100%
;
height
:
36px
;
border-radius
:
60px
;
background-color
:
#ffffff
;
border
:
1px
solid
#dbdbdb
;
--ripple-color
:
#ddd
!important
;
color
:
#000000
;
transition
:
all
0.2s
;
&:hover
{
border
:
1px
solid
#235ffa
;
color
:
#235ffa
;
transition
:
all
0.2s
;
}
}
}
.inscription-canenl-box
{
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
.left-price
{
font-weight
:
700
;
&
>
:nth-child(2)
{
font-size
:
20px
;
color
:
#235ffa
;
}
}
.inscription-canenl-btn
{
width
:
93px
;
height
:
36px
;
border
:
1px
solid
#dbdbdb
;
border-radius
:
60px
;
background
:
transparent
;
--ripple-color
:
#ddd
!important
;
transition
:
all
0.2s
;
color
:
#000000
;
&:hover
{
border
:
1px
solid
#235ffa
;
color
:
#235ffa
;
transition
:
all
0.2s
;
}
}
}
.custom-inscription-card-pos
{
position
:
absolute
;
right
:
0
;
top
:
0
;
width
:
76px
;
height
:
30px
;
background
:
rgb
(
228
,
234
,
250
);
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
14px
;
font-weight
:
500
;
border-radius
:
4px
4px
0px
4px
;
}
}
</
style
>
resources/js/Pages/Trade/components/Market.vue
View file @
6974e94b
...
...
@@ -12,26 +12,28 @@
</div>
</div>
<t-row
class=
"trade-card-box"
>
<template
v-for=
"item in tableList.list"
:key=
"item.id"
>
<t-col
:span=
"1.5"
>
<CustomCard
:cardData=
"item"
>
<template
#
footer
>
<div
class=
"buy-card-footer"
>
<div
class=
"price"
>
$
{{
item
.
original_amount
}}
<template
v-if=
"tableList.list.length"
>
<t-row
class=
"trade-card-box"
>
<template
v-for=
"item in tableList.list"
:key=
"item.id"
>
<t-col
:span=
"1.5"
>
<CustomCard
:cardData=
"item"
>
<template
#
footer
>
<div
class=
"buy-card-footer"
>
<div
class=
"price"
>
$
{{
item
.
original_amount
}}
</div>
<t-button
@
click=
"buyNow(item)"
class=
"buy-now-button"
>
立即购买
</t-button
>
</div>
<t-button
@
click=
"buyNow(item)"
class=
"buy-now-button"
>
立即购买
</t-button
>
</div>
</
template
>
</CustomCard>
</t-col>
</template>
</t-row>
</
template
>
</CustomCard>
</t-col>
</template>
</t-row>
</template>
<BuyDialog
v-model=
"dialog_info.status"
:info=
"dialog_info.info"
...
...
resources/js/layout/header.vue
View file @
6974e94b
...
...
@@ -29,10 +29,14 @@ const { pathname } = getRoute();
const
currentBtn
=
ref
(
pathname
);
const
btns
=
[
{
label
:
"铭文
市场
"
,
label
:
"铭文"
,
path
:
"/inscription/market"
,
},
{
label
:
"铭文市场"
,
path
:
"/trade"
,
},
{
label
:
"OTC交易"
,
path
:
"/otcTrade"
,
},
...
...
resources/js/utils/api/index.ts
View file @
6974e94b
...
...
@@ -33,3 +33,8 @@ export const buyerPaymentSuccess = (data: any) => {
//
return
request
.
post
(
"/api/inscription/buy"
,
data
);
};
// 卖家取消订单
export
const
SellerCancel
=
(
data
:
any
)
=>
{
return
request
.
post
(
"/api/inscription/sell/cancel"
,
data
);
};
routes/api.php
View file @
6974e94b
...
...
@@ -28,6 +28,8 @@
Route
::
get
(
'/ethscriptions/owned_by'
,
'InscriptionController@wallet'
);
// 铭文上架
Route
::
post
(
'/shelves'
,
'TradeController@shelves'
);
// 下架
Route
::
post
(
'/sell/cancel'
,
'TradeController@shelves'
);
// 交易检测回调
Route
::
post
(
'/admin/check'
,
'TradeController@check'
);
// 卖家交易记录
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment