Commit 6974e94b by haojie

1

parent f45c307c
...@@ -24,6 +24,15 @@ public function shelves(Request $request) ...@@ -24,6 +24,15 @@ public function shelves(Request $request)
return $this->success('success', $result); 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) public function check(Request $request)
{ {
...@@ -35,15 +44,16 @@ public function check(Request $request) ...@@ -35,15 +44,16 @@ public function check(Request $request)
// 铭文查询 // 铭文查询
public function search(Request $request) public function search(Request $request)
{ {
$address = $request->input('address'); $pageType = $request->input('page_type', '');
$type = $request->input('type'); $address = $request->input('address', '');
$type = $request->input('type', '');
$page = $request->input('page', 1); $page = $request->input('page', 1);
$limit = $request->input('limit', 10); $limit = $request->input('limit', 10);
// 限制最大 // 限制最大
if ($limit > 50) { if ($limit > 50) {
$limit = 10; $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); return $this->success('success', $result);
} }
......
...@@ -34,4 +34,10 @@ class InscriptionTrading extends Model ...@@ -34,4 +34,10 @@ class InscriptionTrading extends Model
protected $casts = [ protected $casts = [
'inscription' => 'array', 'inscription' => 'array',
]; ];
// 一对一
public function inscription()
{
return $this->hasOne(Inscriptions::class, 'order_id', 'id');
}
} }
<?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'];
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Service; namespace App\Service;
use App\Models\Inscriptions;
use App\Service\RequestService; use App\Service\RequestService;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
...@@ -11,6 +12,12 @@ class InscriptionService ...@@ -11,6 +12,12 @@ 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)
{
Inscriptions::query()->create($data);
}
public function getWalletInscription($address = '') public function getWalletInscription($address = '')
{ {
if (!$address) { if (!$address) {
......
...@@ -30,6 +30,7 @@ public function create($params) ...@@ -30,6 +30,7 @@ public function create($params)
$data['hash'] = $params['hash']; $data['hash'] = $params['hash'];
$res = $model->where('hash', $data['hash'])->first(); $res = $model->where('hash', $data['hash'])->first();
if ($res) { if ($res) {
Log::info($data['hash']);
throw new UserException(1, '支付hash已存在'); throw new UserException(1, '支付hash已存在');
} }
} }
......
...@@ -19,7 +19,7 @@ public function up() ...@@ -19,7 +19,7 @@ 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('sell_admin_account')->comment('卖家卖出时的收款地址'); $table->string('sell_admin_account')->comment('卖家卖出时的收款地址');
// 买家买入时的收款地址 // 买家买入时的收款地址
$table->string('buy_admin_account')->nullable()->comment('买家买入时的收款地址'); $table->string('buy_admin_account')->nullable()->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('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');
}
};
...@@ -125,7 +125,7 @@ import { ...@@ -125,7 +125,7 @@ import {
inscriptionListAdminFilter, inscriptionListAdminFilter,
} from "@/utils/api/public"; } from "@/utils/api/public";
import { inertia_data } from "@/constants/token"; import { inertia_data } from "@/constants/token";
import { sellerTradeLog } from "@/utils/api"; import { sellerTradeLog, SellerCancel } from "@/utils/api";
const store = useStore(); const store = useStore();
const imgs = { const imgs = {
eth: new URL("../../../assets/svg/trade/eth2.svg", import.meta.url).href, eth: new URL("../../../assets/svg/trade/eth2.svg", import.meta.url).href,
...@@ -140,6 +140,9 @@ const confirm_dialog = ref(false); ...@@ -140,6 +140,9 @@ const confirm_dialog = ref(false);
// 全局数据 // 全局数据
const app_info = inject(inertia_data); const app_info = inject(inertia_data);
// 当前选择的取消id
const cancel_id = ref("");
// 当前选择的按钮 // 当前选择的按钮
const currentBtn = ref("1"); const currentBtn = ref("1");
// 按钮组 // 按钮组
...@@ -200,16 +203,6 @@ const cardText = (item: any) => { ...@@ -200,16 +203,6 @@ const cardText = (item: any) => {
const setCurrentList = (list: any[]) => { const setCurrentList = (list: any[]) => {
current_list.list = JSON.parse(JSON.stringify(list)); 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) => { const sellNow = (item: any) => {
...@@ -266,6 +259,8 @@ const getTradeList = async () => { ...@@ -266,6 +259,8 @@ const getTradeList = async () => {
try { try {
// //
const res: any = await sellerTradeLog({ const res: any = await sellerTradeLog({
// 卖出类型
page_type: 2,
type: currentBtn.value, type: currentBtn.value,
address: userAddress.value.address, address: userAddress.value.address,
page: adminTableList.pageNum, page: adminTableList.pageNum,
...@@ -292,11 +287,21 @@ const getTradeList = async () => { ...@@ -292,11 +287,21 @@ const getTradeList = async () => {
const onCanel = (item: any) => { const onCanel = (item: any) => {
// 打开确认弹窗 // 打开确认弹窗
confirm_dialog.value = true; 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 // 查看hash
......
...@@ -12,26 +12,28 @@ ...@@ -12,26 +12,28 @@
</div> </div>
</div> </div>
<t-row class="trade-card-box"> <template v-if="tableList.list.length">
<template v-for="item in tableList.list" :key="item.id"> <t-row class="trade-card-box">
<t-col :span="1.5"> <template v-for="item in tableList.list" :key="item.id">
<CustomCard :cardData="item"> <t-col :span="1.5">
<template #footer> <CustomCard :cardData="item">
<div class="buy-card-footer"> <template #footer>
<div class="price"> <div class="buy-card-footer">
${{ item.original_amount }} <div class="price">
${{ item.original_amount }}
</div>
<t-button
@click="buyNow(item)"
class="buy-now-button"
>立即购买</t-button
>
</div> </div>
<t-button </template>
@click="buyNow(item)" </CustomCard>
class="buy-now-button" </t-col>
>立即购买</t-button </template>
> </t-row>
</div> </template>
</template>
</CustomCard>
</t-col>
</template>
</t-row>
<BuyDialog <BuyDialog
v-model="dialog_info.status" v-model="dialog_info.status"
:info="dialog_info.info" :info="dialog_info.info"
......
...@@ -29,10 +29,14 @@ const { pathname } = getRoute(); ...@@ -29,10 +29,14 @@ const { pathname } = getRoute();
const currentBtn = ref(pathname); const currentBtn = ref(pathname);
const btns = [ const btns = [
{ {
label: "铭文市场", label: "铭文",
path: "/inscription/market", path: "/inscription/market",
}, },
{ {
label: "铭文市场",
path: "/trade",
},
{
label: "OTC交易", label: "OTC交易",
path: "/otcTrade", path: "/otcTrade",
}, },
......
...@@ -33,3 +33,8 @@ export const buyerPaymentSuccess = (data: any) => { ...@@ -33,3 +33,8 @@ export const buyerPaymentSuccess = (data: any) => {
// //
return request.post("/api/inscription/buy", data); return request.post("/api/inscription/buy", data);
}; };
// 卖家取消订单
export const SellerCancel = (data: any) => {
return request.post("/api/inscription/sell/cancel", data);
};
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
Route::get('/ethscriptions/owned_by', 'InscriptionController@wallet'); Route::get('/ethscriptions/owned_by', 'InscriptionController@wallet');
// 铭文上架 // 铭文上架
Route::post('/shelves', 'TradeController@shelves'); Route::post('/shelves', 'TradeController@shelves');
// 下架
Route::post('/sell/cancel', 'TradeController@shelves');
// 交易检测回调 // 交易检测回调
Route::post('/admin/check', 'TradeController@check'); Route::post('/admin/check', 'TradeController@check');
// 卖家交易记录 // 卖家交易记录
......
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