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
ea0fcc46
Commit
ea0fcc46
authored
Jul 03, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
6974e94b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
6 deletions
+52
-6
app/Models/InscriptionTrading.php
+1
-1
app/Models/Inscriptions.php
+5
-0
app/Service/InscriptionService.php
+11
-2
app/Service/TradeService.php
+24
-3
app/Service/test.php
+11
-0
No files found.
app/Models/InscriptionTrading.php
View file @
ea0fcc46
...
@@ -36,7 +36,7 @@ class InscriptionTrading extends Model
...
@@ -36,7 +36,7 @@ class InscriptionTrading extends Model
];
];
// 一对一
// 一对一
public
function
inscription
()
public
function
inscription
s
()
{
{
return
$this
->
hasOne
(
Inscriptions
::
class
,
'order_id'
,
'id'
);
return
$this
->
hasOne
(
Inscriptions
::
class
,
'order_id'
,
'id'
);
}
}
...
...
app/Models/Inscriptions.php
View file @
ea0fcc46
...
@@ -13,4 +13,9 @@ class Inscriptions extends Model
...
@@ -13,4 +13,9 @@ class Inscriptions extends Model
// 允许批量赋值
// 允许批量赋值
protected
$fillable
=
[
'transaction_hash'
,
'current_owner'
,
'content_uri'
,
'uri_p'
,
'uri_op'
,
'uri_tick'
,
'uri_id'
,
'uri_amt'
,
'creator'
,
'creation_timestamp'
];
protected
$fillable
=
[
'transaction_hash'
,
'current_owner'
,
'content_uri'
,
'uri_p'
,
'uri_op'
,
'uri_tick'
,
'uri_id'
,
'uri_amt'
,
'creator'
,
'creation_timestamp'
];
public
function
order
()
{
return
$this
->
belongsTo
(
InscriptionTrading
::
class
,
'order_id'
,
'id'
);
}
}
}
app/Service/InscriptionService.php
View file @
ea0fcc46
...
@@ -13,9 +13,18 @@ class InscriptionService
...
@@ -13,9 +13,18 @@ class InscriptionService
public
const
InscriptionDomain
=
'https://eth-script-indexer-eca25c4cf43b.herokuapp.com'
;
public
const
InscriptionDomain
=
'https://eth-script-indexer-eca25c4cf43b.herokuapp.com'
;
// 创建铭文信息
// 创建铭文信息
public
function
create
(
$data
)
public
function
create
OrUpdate
(
$data
)
{
{
Inscriptions
::
query
()
->
create
(
$data
);
$order_id
=
$data
[
'order_id'
]
??
''
;
if
(
$order_id
)
{
$model
=
Inscriptions
::
query
()
->
where
(
'order_id'
,
$order_id
)
->
first
();
if
(
$model
)
{
$model
->
update
(
$data
);
}
else
{
return
Inscriptions
::
query
()
->
create
(
$data
);
}
}
return
false
;
}
}
public
function
getWalletInscription
(
$address
=
''
)
public
function
getWalletInscription
(
$address
=
''
)
...
...
app/Service/TradeService.php
View file @
ea0fcc46
...
@@ -99,13 +99,33 @@ public function getRedisTask($user)
...
@@ -99,13 +99,33 @@ public function getRedisTask($user)
}
}
// 更新铭文数据
// 更新铭文数据
public
function
updateInscription
(
$data
)
public
function
updateInscription
(
$data
,
$order_id
=
0
)
{
{
// 铭文信息必须包含指定字段
// 铭文信息必须包含指定字段
$fields
=
[
'transaction_hash'
,
'current_owner'
,
'content_uri'
,
'creator'
,
'creation_timestamp'
];
$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
,
'缺少必要的铭文信息'
);
$inscription
=
app
(
CommonService
::
class
)
->
customValidate
(
$data
,
$fields
,
'缺少必要的铭文信息'
);
// 过滤出铭文信息
preg_match
(
'/{.*}/'
,
$inscription
[
'content_uri'
],
$matches
);
$content_uri
=
$matches
[
0
];
if
(
$content_uri
&&
$order_id
!=
0
)
{
$content_uri
=
json_decode
(
$content_uri
,
true
);
// 获取对应的
$inscriptionInfo
=
[];
$inscriptionInfo
[
'order_id'
]
=
$order_id
;
$inscriptionInfo
[
'transaction_hash'
]
=
$inscription
[
'transaction_hash'
];
$inscriptionInfo
[
'current_owner'
]
=
$inscription
[
'current_owner'
];
$inscriptionInfo
[
'content_uri'
]
=
$inscription
[
'content_uri'
];
$inscriptionInfo
[
'creator'
]
=
$inscription
[
'creator'
];
$inscriptionInfo
[
'creation_timestamp'
]
=
$inscription
[
'creation_timestamp'
];
$inscriptionInfo
[
'uri_p'
]
=
$content_uri
[
'p'
]
??
''
;
$inscriptionInfo
[
'uri_op'
]
=
$content_uri
[
'op'
]
??
''
;
$inscriptionInfo
[
'uri_tick'
]
=
$content_uri
[
'tick'
]
??
''
;
$inscriptionInfo
[
'uri_id'
]
=
$content_uri
[
'id'
]
??
''
;
$inscriptionInfo
[
'uri_amt'
]
=
$content_uri
[
'amt'
]
??
''
;
app
(
InscriptionService
::
class
)
->
createOrUpdate
(
$inscriptionInfo
);
}
return
$inscription
;
return
$inscription
;
}
}
...
@@ -376,7 +396,8 @@ public function check($data)
...
@@ -376,7 +396,8 @@ public function check($data)
public
function
search
(
$pageType
,
$address
,
$type
,
$page
,
$limit
)
public
function
search
(
$pageType
,
$address
,
$type
,
$page
,
$limit
)
{
{
$filed
=
[
'inscription'
,
'status'
,
'original_amount'
,
'sell_fee'
,
'seller_receive_hash'
];
$filed
=
[
'inscription'
,
'status'
,
'original_amount'
,
'sell_fee'
,
'seller_receive_hash'
];
$model
=
$this
->
model
();
$model
=
InscriptionTrading
::
with
([
'inscriptions'
]);
// $model = InscriptionTrading::query();
if
(
blank
(
$address
)
||
blank
(
$type
)
||
blank
(
$pageType
))
{
if
(
blank
(
$address
)
||
blank
(
$type
)
||
blank
(
$pageType
))
{
throw
new
UserException
(
1
,
'非法操作'
);
throw
new
UserException
(
1
,
'非法操作'
);
}
}
...
...
app/Service/test.php
0 → 100644
View file @
ea0fcc46
<?php
$content_uri
=
'data:,{"p":"erc-20","op":"mint","tick":"eths","id":"11532","amt":"1000"}'
;
// 获取 $content_uri 中的 {} 内容
preg_match
(
'/{.*}/'
,
$content_uri
,
$matches
);
$content_uri
=
$matches
[
0
];
// 转换为php数组
$content_uri
=
json_decode
(
$content_uri
,
true
);
var_dump
(
$content_uri
);
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