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
ee7839ef
Commit
ee7839ef
authored
Jul 05, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
8b479c80
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
309 additions
and
27 deletions
+309
-27
app/Http/Controllers/Api/TradeLogController.php
+22
-0
app/Models/InscriptionTrading.php
+7
-0
app/Models/TransactionLog.php
+6
-0
app/Service/TradeService.php
+3
-4
app/Service/TransactionLogService.php
+21
-0
database/migrations/2023_06_29_065643_create_inscription_trading_table.php
+1
-1
resources/js/Pages/InscriptionShelves/components/SellDialog.vue
+22
-9
resources/js/Pages/Trade/components/BuyDialog.vue
+8
-7
resources/js/Pages/Trade/components/TradeLog.vue
+176
-3
resources/js/components/pagination.vue
+33
-2
resources/js/utils/api/index.ts
+7
-0
routes/api.php
+3
-1
No files found.
app/Http/Controllers/Api/TradeLogController.php
0 → 100644
View file @
ee7839ef
<?php
namespace
App\Http\Controllers\Api
;
use
App\Http\Controllers\Controller
;
use
App\Service\TransactionLogService
;
use
Illuminate\Http\Request
;
class
TradeLogController
extends
Controller
{
public
function
getLog
(
Request
$request
)
{
$status
=
$request
->
input
(
'status'
,
''
);
$page
=
$request
->
input
(
'page'
,
1
);
$limit
=
$request
->
input
(
'limit'
,
10
);
if
(
$limit
>
50
)
{
$limit
=
10
;
}
$result
=
app
(
TransactionLogService
::
class
)
->
getLog
(
$page
,
$limit
,
$status
);
return
$this
->
success
(
'success'
,
$result
);
}
}
app/Models/InscriptionTrading.php
View file @
ee7839ef
...
...
@@ -20,6 +20,7 @@ class InscriptionTrading extends Model
'buy_fee'
,
'buy_fee_amount'
,
'status'
,
'sell_admin_account'
,
'seller_status'
,
'buyer_status'
,
'seller_transfer_inscription_hash'
,
...
...
@@ -40,4 +41,10 @@ public function inscriptions()
{
return
$this
->
hasOne
(
Inscriptions
::
class
,
'order_id'
,
'id'
);
}
// 日志一对多
public
function
transactionLog
()
{
return
$this
->
hasMany
(
TransactionLog
::
class
,
'order_id'
,
'id'
);
}
}
app/Models/TransactionLog.php
View file @
ee7839ef
...
...
@@ -4,6 +4,7 @@
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
class
TransactionLog
extends
Model
{
...
...
@@ -28,4 +29,9 @@ class TransactionLog extends Model
protected
$casts
=
[
'error_message'
=>
'array'
,
];
public
function
inscriptionTrading
()
:
BelongsTo
{
return
$this
->
belongsTo
(
InscriptionTrading
::
class
,
'order_id'
,
'id'
);
}
}
app/Service/TradeService.php
View file @
ee7839ef
...
...
@@ -77,12 +77,13 @@ class TradeService
public
function
model
()
{
return
new
InscriptionTrading
();
return
InscriptionTrading
::
query
();
}
// 创建铭文交易
public
function
create
(
$data
)
{
Log
::
info
(
$data
);
return
$this
->
model
()
->
create
(
$data
);
}
...
...
@@ -181,15 +182,13 @@ public function userShelves($payment_address, $hash, $inscription, $price)
$data
=
[
'inscription'
=>
$inscription
,
'original_amount'
=>
$price
,
// 卖家卖出时的收款账号
'sell_admin_account'
=>
$admin_address
,
'sell_admin_account'
=>
$admin_address
??
''
,
'sell_fee'
=>
$sell_fee
,
'sell_real_amount'
=>
$sell_real_amount
,
'status'
=>
self
::
ORDER_STATUS_WAIT
,
'seller_status'
=>
self
::
SELLER_STATUS_PROGRESS
,
'buyer_status'
=>
self
::
BUYER_STATUS_WAIT
,
'seller_transfer_inscription_hash'
=>
$hash
,
// 卖家地址
'seller_address'
=>
$payment_address
,
];
$result
=
$this
->
create
(
$data
);
...
...
app/Service/TransactionLogService.php
View file @
ee7839ef
...
...
@@ -68,4 +68,25 @@ public function update($data)
$log
->
update
(
$update
);
}
}
// 查询日志
public
function
getLog
(
$page
,
$limit
,
$status
)
{
$field
=
[
'*'
];
$model
=
TransactionLog
::
with
([
'inscriptionTrading'
]);
if
(
$status
==
TradeService
::
ORDER_STATUS_ON
)
{
// 上架--卖家转移铭文类型-和转移成功的
$model
->
where
(
'title'
,
TradeService
::
TRADE_NAME_SELLER_INSCRIPTION
)
->
where
(
'status'
,
TradeService
::
TRADE_STATUS_SUCCESS
);
}
elseif
(
$status
==
TradeService
::
ORDER_STATUS_SUCCESS
)
{
// 已完成--订单交易完成的
$model
->
where
(
'title'
,
TradeService
::
TRADE_NAME_BUYER_PAY
)
->
where
(
'status'
,
TradeService
::
TRADE_STATUS_SUCCESS
);
}
else
{
// 全部-上架,买
$model
->
whereIn
(
'title'
,
[
TradeService
::
TRADE_NAME_SELLER_INSCRIPTION
,
TradeService
::
TRADE_NAME_BUYER_PAY
])
->
where
(
'status'
,
TradeService
::
TRADE_STATUS_SUCCESS
);
}
return
$model
->
paginate
(
$limit
,
$field
,
'page'
,
$page
);
}
}
database/migrations/2023_06_29_065643_create_inscription_trading_table.php
View file @
ee7839ef
...
...
@@ -20,7 +20,7 @@ public function up()
// 原始金额--卖家输入的
$table
->
decimal
(
'original_amount'
,
20
,
8
)
->
comment
(
'原始金额'
);
// 卖家卖出时,平台的收款地址
$table
->
string
(
'sell_admin_account'
)
->
comment
(
'卖家卖出时的收款地址'
);
$table
->
string
(
'sell_admin_account'
)
->
nullable
()
->
comment
(
'卖家卖出时的收款地址'
);
// 买家买入时的收款地址
$table
->
string
(
'buy_admin_account'
)
->
nullable
()
->
comment
(
'买家买入时的收款地址'
);
// 卖出手续费比例
...
...
resources/js/Pages/InscriptionShelves/components/SellDialog.vue
View file @
ee7839ef
...
...
@@ -75,7 +75,7 @@
import
{
computed
,
inject
,
ref
,
watch
}
from
"vue"
;
import
CustomCard
from
"@/components/card.vue"
;
import
CustomInput
from
"@/components/input/index.vue"
;
import
{
showMessage
}
from
"@/utils/tool"
;
import
{
showMessage
,
isDev
}
from
"@/utils/tool"
;
import
{
inertia_data
}
from
"@/constants/token"
;
import
{
inscriptionTransfer
}
from
"@/utils/ethers"
;
import
{
useStore
}
from
"vuex"
;
...
...
@@ -183,15 +183,28 @@ const onSubmit = async () => {
let
current_price
=
price
.
value
;
// 本次铭文信息
let
current_inscription
=
props
.
info
;
// 可以转移
const
res
=
await
inscriptionTransfer
(
receipt_account
,
from
,
data
);
if
(
res
&&
res
.
hash
)
{
if
(
isDev
())
{
let
res
=
{
from
:
"0x53d05d2f8BDbB5ce389D313CD6d320fb0Fb1C397"
,
hash
:
"0x32360056d88b1bc44eaa6da76a8334c868ec8891ac00abe99f5116468a3bb377"
,
};
// 本地直接提交
let
status
=
await
submitAdmin
(
res
,
current_price
,
current_inscription
);
if
(
status
)
{
// 关闭弹窗
visible
.
value
=
false
;
// 通知页面更新我的铭文列表
emit
(
"updateList"
);
}
else
{
// 可以转移
const
res
=
await
inscriptionTransfer
(
receipt_account
,
from
,
data
);
if
(
res
&&
res
.
hash
)
{
let
status
=
await
submitAdmin
(
res
,
current_price
,
current_inscription
);
if
(
status
)
{
// 关闭弹窗
visible
.
value
=
false
;
// 通知页面更新我的铭文列表
emit
(
"updateList"
);
}
}
}
};
...
...
resources/js/Pages/Trade/components/BuyDialog.vue
View file @
ee7839ef
...
...
@@ -33,6 +33,7 @@
<
template
#
footer
>
<div
class=
"buy-dialog-footer"
>
<!-- -->
<!--
<t-button
@
click=
"testSubmit"
>
测试按钮
</t-button>
-->
<t-button
class=
"buy-cancel-button"
@
click=
"visible = false"
>
取消
</t-button
>
...
...
@@ -92,13 +93,13 @@ const submitAdmin = async (
console
.
log
(
e
);
}
};
//
const testSubmit = () => {
//
submitAdmin(
//
"0x762acfc0e06bd403ba4acf772b799b4f9b514fb7d89c161ce23ba0307e562a2c",
//
"0x51eF357cf7204DB2a6e31750817F709a10c86f37",
//
"1"
//
);
//
};
const
testSubmit
=
()
=>
{
//
submitAdmin(
//
"0x762acfc0e06bd403ba4acf772b799b4f9b514fb7d89c161ce23ba0307e562a2c",
//
"0x51eF357cf7204DB2a6e31750817F709a10c86f37",
//
"1"
//
);
};
// 立即购买
const
onSubmit
=
async
()
=>
{
...
...
resources/js/Pages/Trade/components/TradeLog.vue
View file @
ee7839ef
<
template
>
<div
class=
""
>
2
</div>
<div
class=
"tabs-panel-trade-log"
>
<div
class=
"chose-btns"
>
<CustomGroupButton
:list=
"groupBtns"
v-model=
"currentBtn"
parentHeight=
"36px"
childHeight=
"26px"
:bordered=
"false"
></CustomGroupButton>
</div>
<div
class=
"trade-log-table-box"
>
<CustomTable
:data=
"tableList"
:columns=
"columns"
:loading=
"loading"
className=
"trade-log-table"
></CustomTable>
<div
class=
"pagination-box"
>
<CustomPagination
:total=
"total"
:pageNum=
"pageNum"
:pageSize=
"pageSize"
align=
"right"
@
pageChange=
"pageChange"
></CustomPagination>
</div>
</div>
</div>
</
template
>
<
script
lang=
"ts"
setup
></
script
>
<
script
lang=
"tsx"
setup
>
import
CustomGroupButton
from
"@/components/groupButton.vue"
;
import
{
ref
,
onMounted
}
from
"vue"
;
import
CustomPagination
from
"@/components/pagination.vue"
;
import
CustomTable
from
"@/components/table.vue"
;
import
{
getTradeLog
}
from
"@/utils/api"
;
<
style
lang=
"less"
></
style
>
// 页面展示的列表
const
tableList
=
ref
([]);
const
loading
=
ref
(
false
);
const
pageNum
=
ref
(
1
);
const
pageSize
=
ref
(
10
);
const
total
=
ref
(
0
);
const
currentBtn
=
ref
(
""
);
const
groupBtns
=
[
{
label
:
"所有"
,
value
:
""
,
},
{
label
:
"进行中"
,
value
:
"2"
,
},
{
label
:
"已完成"
,
value
:
"3"
,
},
];
const
columns
=
[
{
colKey
:
"Protocol"
,
title
:
"协议"
,
align
:
"center"
,
className
:
"font700 font16"
,
width
:
"10%"
,
},
{
colKey
:
"Name"
,
title
:
"名称"
,
align
:
"center"
,
className
:
"font700 font16"
,
width
:
"10%"
,
},
{
colKey
:
"DeployTime"
,
title
:
"部署时间"
,
align
:
"center"
,
className
:
()
=>
"font14"
,
},
{
colKey
:
"TotalSupply"
,
title
:
"总供应量"
,
align
:
"center"
,
className
:
"public-style font14"
,
},
{
colKey
:
"LimitPerMint"
,
title
:
"每个铭文数量"
,
align
:
"center"
,
className
:
"public-style font14"
,
},
{
colKey
:
"ValidMinted"
,
title
:
"有效铸造"
,
align
:
"center"
,
className
:
"public-style font14"
,
},
{
colKey
:
"Holders"
,
title
:
"持有者"
,
align
:
"center"
,
className
:
"public-style font14"
,
},
{
colKey
:
"Progress"
,
title
:
"状态"
,
align
:
"center"
,
cell
:
(
h
,
{
col
,
row
})
=>
(
<
div
class
=
"custom-progress"
>
<
span
class
=
"label"
>
{
row
[
col
.
colKey
]}
%<
/span
>
<
CustomProgress
num
=
{
parseFloat
(
row
[
col
.
colKey
]
+
""
)}
label
=
{
false
}
width
=
"100%"
strokeWidth
=
"8px"
><
/CustomProgress
>
<
/div
>
),
},
{
colKey
:
"TotalMinted"
,
title
:
"总铸造"
,
align
:
"center"
,
className
:
"public-style font14"
,
},
{
colKey
:
"Minters"
,
title
:
"铸造者"
,
align
:
"center"
,
className
:
"public-style font14"
,
},
{
colKey
:
"Transactions"
,
title
:
"交易笔数"
,
align
:
"center"
,
className
:
"public-style font14"
,
},
];
const
getList
=
async
()
=>
{
try
{
let
params
:
any
=
{
status
:
currentBtn
.
value
,
page
:
pageNum
.
value
,
limit
:
pageSize
.
value
,
};
loading
.
value
=
true
;
const
res
:
any
=
await
getTradeLog
(
params
);
if
(
res
.
code
==
0
)
{
res
.
data
.
data
.
forEach
((
item
:
any
)
=>
{});
tableList
.
value
=
res
.
data
.
data
;
total
.
value
=
res
.
data
.
total
;
}
loading
.
value
=
false
;
}
catch
(
e
)
{
console
.
log
(
e
);
loading
.
value
=
false
;
}
};
const
pageChange
=
(
value
:
number
)
=>
{
pageNum
.
value
=
value
;
getList
();
};
onMounted
(()
=>
{
getList
();
});
</
script
>
<
style
lang=
"less"
>
.tabs-panel-trade-log
{
.chose-btns
{
margin
:
20px
0
;
text-align
:
right
;
}
}
</
style
>
resources/js/components/pagination.vue
View file @
ee7839ef
<
template
>
<t-pagination
class=
"custom-default-pagination"
:class=
"
{
'pagination-align-center': align === 'center',
}"
v-model="cpageNum"
v-model:pageSize="cpageSize"
:total="total"
show-sizer
@currentChange="onCurrentChange"
:pageSizeOptions="pageSizeOptions"
/>
>
<template
#
totalContent
>
<span
v-if=
"showTotal"
>
共
{{
total
}}
条数据
</span>
</
template
>
</t-pagination>
</template>
<
script
lang=
"ts"
setup
>
...
...
@@ -19,9 +27,13 @@ const props = withDefaults(
pageSize
:
number
;
total
:
number
;
pageSizeOptions
?:
any
[];
align
?:
string
;
showTotal
?:
boolean
;
}
>
(),
{
pageSizeOptions
:
[],
align
:
"center"
,
showTotal
:
false
,
}
);
const
emit
=
defineEmits
([
"pageChange"
]);
...
...
@@ -43,4 +55,23 @@ watch(
);
</
script
>
<
style
lang=
"less"
></
style
>
<
style
lang=
"less"
>
.custom-default-pagination
{
.t-pagination__number
{
color
:
#474d57
;
border-color
:
transparent
;
&:active
{
background
:
transparent
;
}
}
.t-pagination__number.t-is-current
{
background
:
#eaecef
;
border-color
:
#eaecef
;
border-radius
:
4px
;
color
:
#1e2329
;
}
}
.pagination-align-center
{
justify-content
:
center
;
}
</
style
>
resources/js/utils/api/index.ts
View file @
ee7839ef
...
...
@@ -45,3 +45,10 @@ export const getOutSiteMarketInscription = (data: any) => {
params
:
data
,
});
};
// 获取交易日志
export
const
getTradeLog
=
(
data
:
any
)
=>
{
return
request
.
get
(
"/api/inscription/log"
,
{
params
:
data
,
});
};
routes/api.php
View file @
ee7839ef
...
...
@@ -42,8 +42,10 @@
Route
::
post
(
'/buy'
,
'TradeController@buy'
);
// 本地转账登录
Route
::
post
(
'/transfer/login'
,
'AuthController@login'
);
// 交易日志
Route
::
get
(
'/log'
,
'TradeLogController@getLog'
);
});
// 本地话接口--需要登录
Route
::
group
([
'middleware'
=>
'auth:api'
,
...
...
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