1
This commit is contained in:
parent
d702a908cd
commit
bae8c2dd35
@ -80,6 +80,23 @@ CREATE TABLE `t_nft` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `t_buy_record`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `t_buy_record`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `t_buy_record` (
|
||||||
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
|
`blobdata` mediumblob COMMENT 'blobdata',
|
||||||
|
`buyer_address` mediumblob COMMENT 'buyer_address',
|
||||||
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`idx`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `t_log`
|
-- Table structure for table `t_log`
|
||||||
--
|
--
|
||||||
|
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 80d7222a4a31e295fffbf09fc1880940b4eb630b
|
Subproject commit e42a7b732c806c4cc8060a101f9a13ae579039e3
|
@ -9,10 +9,14 @@ require_once('mt/Hero.php');
|
|||||||
|
|
||||||
require_once('models/BoxOrder.php');
|
require_once('models/BoxOrder.php');
|
||||||
require_once('models/Nft.php');
|
require_once('models/Nft.php');
|
||||||
|
require_once('models/BuyRecord.php');
|
||||||
|
|
||||||
|
require_once('phpcommon/bchelper.php');
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\BoxOrder;
|
use models\BoxOrder;
|
||||||
use models\Nft;
|
use models\Nft;
|
||||||
|
use models\BuyRecord;
|
||||||
|
|
||||||
class MarketController extends BaseController {
|
class MarketController extends BaseController {
|
||||||
|
|
||||||
@ -120,6 +124,7 @@ class MarketController extends BaseController {
|
|||||||
$nonce = getReqVal('nonce', '');
|
$nonce = getReqVal('nonce', '');
|
||||||
$signature = getReqVal('signature', '');
|
$signature = getReqVal('signature', '');
|
||||||
$gameId = 2006;
|
$gameId = 2006;
|
||||||
|
$funcId = 1;
|
||||||
|
|
||||||
if (empty($type) ||
|
if (empty($type) ||
|
||||||
empty($buyerAddress) ||
|
empty($buyerAddress) ||
|
||||||
@ -137,14 +142,29 @@ class MarketController extends BaseController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!phpcommon\isValidBcGameId($gameId)) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!phpcommon\isValidBcTime(myself()->_getNowTime())) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!phpcommon\isValidBcFunc($funcId)) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*if (!$this->isTestMode() && BoxOrder::isBuyed($buyerAddress, $currBatchMeta['batch_id'])) {
|
/*if (!$this->isTestMode() && BoxOrder::isBuyed($buyerAddress, $currBatchMeta['batch_id'])) {
|
||||||
myself()->_rspErr(1, 'account can only choose 1 hero to purchase');
|
myself()->_rspErr(1, 'account can only choose 1 hero to purchase');
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
$orderId = BuyRecord::genOrderId($gameId, $funcId, myself()->_getNowTime(), $buyerAddress);
|
||||||
|
$tokenId = $orderId;
|
||||||
if ($this->isTestMode()) {
|
if ($this->isTestMode()) {
|
||||||
$orderId = myself()->_getNowTime();
|
|
||||||
$tokenId = $orderId;
|
|
||||||
$itemId = $type;
|
$itemId = $type;
|
||||||
SqlHelper::insert
|
SqlHelper::insert
|
||||||
(myself()->_getMarketMysql(),
|
(myself()->_getMarketMysql(),
|
||||||
@ -181,8 +201,6 @@ class MarketController extends BaseController {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$orderId = myself()->_getNowTime();
|
|
||||||
$tokenId = $orderId;
|
|
||||||
$itemId = $type;
|
$itemId = $type;
|
||||||
SqlHelper::insert
|
SqlHelper::insert
|
||||||
(myself()->_getMarketMysql(),
|
(myself()->_getMarketMysql(),
|
||||||
|
41
webapp/models/BuyRecord.php
Normal file
41
webapp/models/BuyRecord.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
require_once('phpcommon/bchelper.php');
|
||||||
|
|
||||||
|
use mt;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
class BuyRecord extends BaseModel {
|
||||||
|
|
||||||
|
public static function genOrderId($gameId, $funcId, $time, $buyerAddress)
|
||||||
|
{
|
||||||
|
SqlHelper::insert
|
||||||
|
(myself()->_getMarketMysql(),
|
||||||
|
't_buy_record',
|
||||||
|
array(
|
||||||
|
'blobdata' => json_encode($_REQUEST),
|
||||||
|
'buyer_address' => $buyerAddress,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$lastIdx = SqlHelper::getLastInsertId(myself()->_getMarketMysql());
|
||||||
|
if (empty($lastIdx)) {
|
||||||
|
die(json_encode(array(
|
||||||
|
'errcode' => 500,
|
||||||
|
'errmsg' => 'server internal error'
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
$orderId = phpcommon\genOrderId($gameId, $funcId, $time, $lastIdx);
|
||||||
|
if (!phpcommon\isValidOrderId($orderId)) {
|
||||||
|
die(json_encode(array(
|
||||||
|
'errcode' => 500,
|
||||||
|
'errmsg' => 'server internal error'
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
return $orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user