1
This commit is contained in:
parent
43f57720f8
commit
ae0dcd2c92
@ -31,6 +31,7 @@ CREATE TABLE `t_box_order` (
|
|||||||
`order_id` varchar(60) NOT NULL DEFAULT '' COMMENT '订单id',
|
`order_id` varchar(60) NOT NULL DEFAULT '' COMMENT '订单id',
|
||||||
`game_id` int(11) NOT NULL DEFAULT '0' COMMENT 'game id',
|
`game_id` int(11) NOT NULL DEFAULT '0' COMMENT 'game id',
|
||||||
`batch_id` int(11) NOT NULL DEFAULT '0' COMMENT '批次号',
|
`batch_id` int(11) NOT NULL DEFAULT '0' COMMENT '批次号',
|
||||||
|
`type` varchar(60) NOT NULL DEFAULT '' COMMENT 'type',
|
||||||
`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:已上链',
|
||||||
|
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
|||||||
Subproject commit e42a7b732c806c4cc8060a101f9a13ae579039e3
|
Subproject commit 195376f820d8882e8fe10c14f219cebcfd908dcf
|
@ -5,6 +5,7 @@ use phpcommon\SqlHelper;
|
|||||||
class BaseController {
|
class BaseController {
|
||||||
|
|
||||||
private $nowtime = 0;
|
private $nowtime = 0;
|
||||||
|
private $marketDbConn = null;
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
@ -89,15 +90,18 @@ class BaseController {
|
|||||||
|
|
||||||
public function _getMarketMysql()
|
public function _getMarketMysql()
|
||||||
{
|
{
|
||||||
|
if ($this->marketDbConn) {
|
||||||
|
return $this->marketDbConn;
|
||||||
|
}
|
||||||
$mysql_conf = getMarketMysqlConfig(crc32(''));
|
$mysql_conf = getMarketMysqlConfig(crc32(''));
|
||||||
$conn = new phpcommon\Mysql(array(
|
$this->marketDbConn = new phpcommon\Mysql(array(
|
||||||
'host' => $mysql_conf['host'],
|
'host' => $mysql_conf['host'],
|
||||||
'port' => $mysql_conf['port'],
|
'port' => $mysql_conf['port'],
|
||||||
'user' => $mysql_conf['user'],
|
'user' => $mysql_conf['user'],
|
||||||
'passwd' => $mysql_conf['passwd'],
|
'passwd' => $mysql_conf['passwd'],
|
||||||
'dbname' => 'marketdb2006'
|
'dbname' => 'marketdb2006'
|
||||||
));
|
));
|
||||||
return $conn;
|
return $this->marketDbConn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _getRedis($data)
|
public function _getRedis($data)
|
||||||
|
@ -84,8 +84,9 @@ class MarketController extends BaseController {
|
|||||||
if ($batchMetas) {
|
if ($batchMetas) {
|
||||||
foreach ($batchMetas as $meta) {
|
foreach ($batchMetas as $meta) {
|
||||||
$heroMeta = mt\Hero::get($meta['item_id']);
|
$heroMeta = mt\Hero::get($meta['item_id']);
|
||||||
|
$boxId = phpcommon\genBoxId($currBatchMeta['batch_id'], $meta['id'], $meta['item_id']);
|
||||||
$saleBox = array(
|
$saleBox = array(
|
||||||
'box_id' => $meta['item_id'],
|
'box_id' => $boxId,
|
||||||
'item_id' => $meta['item_id'],
|
'item_id' => $meta['item_id'],
|
||||||
'name' => emptyReplace($heroMeta['name'], 'Hill'),
|
'name' => emptyReplace($heroMeta['name'], 'Hill'),
|
||||||
'job' => emptyReplace($heroMeta['herotype'], '1'),
|
'job' => emptyReplace($heroMeta['herotype'], '1'),
|
||||||
@ -126,6 +127,14 @@ class MarketController extends BaseController {
|
|||||||
$gameId = 2006;
|
$gameId = 2006;
|
||||||
$funcId = 1;
|
$funcId = 1;
|
||||||
|
|
||||||
|
$batchId = 0;
|
||||||
|
$idx = 0;
|
||||||
|
$itemId = 0;
|
||||||
|
if (!phpcommon\extractBoxId($type, $batchId, $idx, $itemId)) {
|
||||||
|
myself()->_rspErr(2, 'type parameter error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($type) ||
|
if (empty($type) ||
|
||||||
empty($buyerAddress) ||
|
empty($buyerAddress) ||
|
||||||
empty($price) ||
|
empty($price) ||
|
||||||
@ -141,6 +150,14 @@ class MarketController extends BaseController {
|
|||||||
myself()->_rspErr(500, 'server internal error');
|
myself()->_rspErr(500, 'server internal error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($batchId != $currBatchMeta['batch_id']) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!mt\MarketGoods::isOnSaleItem($batchId, $idx, $itemId)) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!phpcommon\isValidBcGameId($gameId)) {
|
if (!phpcommon\isValidBcGameId($gameId)) {
|
||||||
myself()->_rspErr(500, 'server internal error');
|
myself()->_rspErr(500, 'server internal error');
|
||||||
@ -152,7 +169,7 @@ class MarketController extends BaseController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!phpcommon\isValidBcFunc($funcId)) {
|
if (!phpcommon\isValidBcFuncId($funcId)) {
|
||||||
myself()->_rspErr(500, 'server internal error');
|
myself()->_rspErr(500, 'server internal error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -163,7 +180,7 @@ class MarketController extends BaseController {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
$orderId = BuyRecord::genOrderId($gameId, $funcId, myself()->_getNowTime(), $buyerAddress);
|
$orderId = BuyRecord::genOrderId($gameId, $funcId, myself()->_getNowTime(), $buyerAddress);
|
||||||
$tokenId = '';
|
$tokenId = $orderId;
|
||||||
if ($this->isTestMode()) {
|
if ($this->isTestMode()) {
|
||||||
$itemId = $type;
|
$itemId = $type;
|
||||||
SqlHelper::insert
|
SqlHelper::insert
|
||||||
@ -173,6 +190,7 @@ class MarketController extends BaseController {
|
|||||||
'batch_id' => $currBatchMeta['batch_id'],
|
'batch_id' => $currBatchMeta['batch_id'],
|
||||||
'game_id' => $gameId,
|
'game_id' => $gameId,
|
||||||
'order_id' => $orderId,
|
'order_id' => $orderId,
|
||||||
|
'type' => $type,
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'state' => 1,
|
'state' => 1,
|
||||||
'buyer_address' => $buyerAddress,
|
'buyer_address' => $buyerAddress,
|
||||||
@ -208,6 +226,7 @@ class MarketController extends BaseController {
|
|||||||
array(
|
array(
|
||||||
'batch_id' => $currBatchMeta['batch_id'],
|
'batch_id' => $currBatchMeta['batch_id'],
|
||||||
'order_id' => $orderId,
|
'order_id' => $orderId,
|
||||||
|
'type' => $type,
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'state' => 0,
|
'state' => 0,
|
||||||
'buyer_address' => $buyerAddress,
|
'buyer_address' => $buyerAddress,
|
||||||
|
@ -5,6 +5,7 @@ namespace models;
|
|||||||
require_once('phpcommon/bchelper.php');
|
require_once('phpcommon/bchelper.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
|
use phpcommon;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
class BuyRecord extends BaseModel {
|
class BuyRecord extends BaseModel {
|
||||||
|
@ -27,6 +27,19 @@ class MarketGoods {
|
|||||||
return getXVal(self::$batchHash, $batchId, null);
|
return getXVal(self::$batchHash, $batchId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isOnSaleItem($batchId, $idx, $itemId)
|
||||||
|
{
|
||||||
|
$metas = self::getBatchMetas($batchId);
|
||||||
|
if (!empty($metas)) {
|
||||||
|
foreach ($metas as $meta) {
|
||||||
|
if ($meta['id'] == $idx && $meta['item_id'] == $itemId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected static function getMetaList()
|
protected static function getMetaList()
|
||||||
{
|
{
|
||||||
if (!self::$metaList) {
|
if (!self::$metaList) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user