1
This commit is contained in:
parent
6796aad0a8
commit
1085b4fba5
@ -413,7 +413,9 @@ class PreSaleInfo(object):
|
|||||||
['batch_id', 0, '批次id(目前客户端没用到先不用管)'],
|
['batch_id', 0, '批次id(目前客户端没用到先不用管)'],
|
||||||
['countdown', 0, '预售倒计时'],
|
['countdown', 0, '预售倒计时'],
|
||||||
['sold_num', 0, '已售数'],
|
['sold_num', 0, '已售数'],
|
||||||
['total_num', 0, '库存数'],
|
['total_num', 0, '总数'],
|
||||||
|
['state', 0, '0:预售未开始(tilte文字) 1:预售准备开始(有倒计时) 2:预售开始(title文字) 3:预售结束(title)'],
|
||||||
|
['title', '', '预售文字标题描述 '],
|
||||||
['hint', '', '预售文字描述'],
|
['hint', '', '预售文字描述'],
|
||||||
['buyed', 0, '自己是否已购'],
|
['buyed', 0, '自己是否已购'],
|
||||||
]
|
]
|
||||||
|
@ -30,7 +30,6 @@ CREATE TABLE `t_box_order` (
|
|||||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`batch_id` int(11) NOT NULL DEFAULT '0' COMMENT '批次号',
|
`batch_id` int(11) NOT NULL DEFAULT '0' COMMENT '批次号',
|
||||||
`order_id` varchar(60) NOT NULL DEFAULT '' COMMENT '订单id',
|
`order_id` varchar(60) NOT NULL DEFAULT '' COMMENT '订单id',
|
||||||
`box_id` varchar(60) NOT NULL DEFAULT '' COMMENT '箱子唯一id',
|
|
||||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||||
`state` int(11) NOT NULL DEFAULT '0' COMMENT 'state 0:待支付 1:支付成功',
|
`state` int(11) NOT NULL DEFAULT '0' COMMENT 'state 0:待支付 1:支付成功',
|
||||||
`bc_synced` int(11) NOT NULL DEFAULT '0' COMMENT '0:未上链 1:已上链',
|
`bc_synced` int(11) NOT NULL DEFAULT '0' COMMENT '0:未上链 1:已上链',
|
||||||
|
@ -46,6 +46,8 @@ class MarketController extends BaseController {
|
|||||||
'countdown' => max(0, $currBatchMeta['_start_time_utc'] - myself()->_getNowTime()),
|
'countdown' => max(0, $currBatchMeta['_start_time_utc'] - myself()->_getNowTime()),
|
||||||
'sold_num' => 0,
|
'sold_num' => 0,
|
||||||
'total_num' => $currBatchMeta['number_of_props'],
|
'total_num' => $currBatchMeta['number_of_props'],
|
||||||
|
'state' => 2,
|
||||||
|
'title' => '',
|
||||||
'hint' => str_replace("\n", '\n', $currBatchMeta['hint']),
|
'hint' => str_replace("\n", '\n', $currBatchMeta['hint']),
|
||||||
'buyed' => rand() % 2 < 1 ? 0 : 1
|
'buyed' => rand() % 2 < 1 ? 0 : 1
|
||||||
);
|
);
|
||||||
|
@ -48,6 +48,8 @@ class NewMarketController extends BaseController {
|
|||||||
'countdown' => max(0, $currBatchMeta['_start_time_utc'] - myself()->_getNowTime()),
|
'countdown' => max(0, $currBatchMeta['_start_time_utc'] - myself()->_getNowTime()),
|
||||||
'sold_num' => min(BoxOrder::getSoldNum($currBatchMeta['batch_id']), $currBatchMeta['number_of_props']),
|
'sold_num' => min(BoxOrder::getSoldNum($currBatchMeta['batch_id']), $currBatchMeta['number_of_props']),
|
||||||
'total_num' => $currBatchMeta['number_of_props'],
|
'total_num' => $currBatchMeta['number_of_props'],
|
||||||
|
'state' => 2,
|
||||||
|
'title' => '',
|
||||||
'hint' => str_replace("\n", '\n', $currBatchMeta['hint']),
|
'hint' => str_replace("\n", '\n', $currBatchMeta['hint']),
|
||||||
'buyed' => $this->isTestMode() ? 0 : BoxOrder::isBuyed($account, $currBatchMeta['batch_id'])
|
'buyed' => $this->isTestMode() ? 0 : BoxOrder::isBuyed($account, $currBatchMeta['batch_id'])
|
||||||
);
|
);
|
||||||
@ -91,12 +93,70 @@ class NewMarketController extends BaseController {
|
|||||||
public function buyBox()
|
public function buyBox()
|
||||||
{
|
{
|
||||||
$type = getReqVal('type', '');
|
$type = getReqVal('type', '');
|
||||||
$buyer_address = getReqVal('buyer_address', '');
|
$buyerAddress = getReqVal('buyer_address', '');
|
||||||
$price = getReqVal('price', '');
|
$price = getReqVal('price', '');
|
||||||
$payment_token_address = getReqVal('payment_token_address', '');
|
$paymentTokenAddress = getReqVal('payment_token_address', '');
|
||||||
$nonce = getReqVal('nonce', '');
|
$nonce = getReqVal('nonce', '');
|
||||||
$signature = getReqVal('signature', '');
|
$signature = getReqVal('signature', '');
|
||||||
|
|
||||||
|
if (empty($type) ||
|
||||||
|
empty($buyerAddress) ||
|
||||||
|
empty($price) ||
|
||||||
|
empty($paymentTokenAddress) ||
|
||||||
|
empty($signature) ||
|
||||||
|
empty($nonce)) {
|
||||||
|
myself()->_rspErr(2, 'parameter error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$currBatchMeta = mt\MarketBatch::getCurrentBatch();
|
||||||
|
if (!$currBatchMeta) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->isTestMode() || BoxOrder::isBuyed($account, $currBatchMeta['batch_id'])) {
|
||||||
|
myself()->_rspErr(1, 'account can only choose 1 hero to purchase');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->isTestMode()) {
|
||||||
|
$orderId = myself()->_getNowTime();
|
||||||
|
$tokenId = $orderId;
|
||||||
|
$itemId = $type;
|
||||||
|
SqlHelper::insert
|
||||||
|
(myself()->_getMarketMysql(),
|
||||||
|
't_box_order_bag',
|
||||||
|
array(
|
||||||
|
'batch_id' => $currBatchMeta['batch_id'],
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'state' => 1,
|
||||||
|
'buyer_address' => $buyerAddress,
|
||||||
|
'token_id' => $tokenId,
|
||||||
|
'price' => $price,
|
||||||
|
'payment_token_address' => $paymentTokenAddress,
|
||||||
|
'nonce' => $nonce,
|
||||||
|
'signature' => $signature,
|
||||||
|
'expired' => 0,
|
||||||
|
'done' => 1,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
SqlHelper::insert
|
||||||
|
(myself()->_getMarketMysql(),
|
||||||
|
't_nft',
|
||||||
|
array(
|
||||||
|
'token_id' => $tokenId,
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'owner_id' => $buyerAddress,
|
||||||
|
'owner_address' => $buyerAddress,
|
||||||
|
'owner_name' => '',
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
myself()->_rspOk();
|
myself()->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,12 @@ class BoxOrder extends BaseModel {
|
|||||||
|
|
||||||
public function getSoldNum($batchId)
|
public function getSoldNum($batchId)
|
||||||
{
|
{
|
||||||
return 0;
|
$row = myself()->_getMarketMysql()->execQueryOne
|
||||||
|
('SELECT COUNT(*) AS sold_num FROM t_box_order',
|
||||||
|
array(
|
||||||
|
':batch_id' => $batchId
|
||||||
|
));
|
||||||
|
return $row && $row['sold_num'] ? $row['sold_num'] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isBuyed($buyerAddress, $batchId)
|
public function isBuyed($buyerAddress, $batchId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user