Merge branch 'star' of git.kingsome.cn:server/game2006api into star
This commit is contained in:
commit
2b0365f28a
@ -201,6 +201,7 @@ class Shop(object):
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['cost', 0, '每日精选的当前刷新价格'],
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -246,6 +247,8 @@ class Shop(object):
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!items', [0], '宝箱物品列表'],
|
||||
['free_num', 0, '免费次数'],
|
||||
['pending', 0, '购买中...'],
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -402,6 +402,7 @@ class NewGoods(object):
|
||||
['bought_times', 0, '已购买次数'],
|
||||
['free_type', 0, '免费类型 0:不免费 1:日刷新'],
|
||||
['free_num', 0, '免费次数'],
|
||||
['pending', 0, '购买中...'],
|
||||
]
|
||||
|
||||
class ShopName(object):
|
||||
@ -443,6 +444,7 @@ class DailySelectionGoods(object):
|
||||
['weight', 0, '权重'],
|
||||
['discount', 0, '折扣'],
|
||||
['price', 0, '价格'],
|
||||
['pending', 0, '购买中...'],
|
||||
]
|
||||
|
||||
class Mission(object):
|
||||
|
@ -575,3 +575,45 @@ CREATE TABLE `t_log` (
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
-- Dump completed on 2015-08-19 18:51:22
|
||||
DROP TABLE IF EXISTS `t_market_store`;
|
||||
CREATE TABLE `t_market_store` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`o_link` varchar(64) NOT NULL COMMENT '关联的链上上架单号',
|
||||
`status` int(11) NOT NULL COMMENT '订单状态 0:出售中 1:已下架 2:已售出',
|
||||
`owner_address` varchar(60) NOT NULL COMMENT '当前拥有者',
|
||||
`token_id` varchar(80) NOT NULL COMMENT 'token_id',
|
||||
`nft_token` varchar(64) DEFAULT NULL COMMENT 'nftToken',
|
||||
`token_type` int(11) NOT NULL COMMENT 'nft类型 1:英雄 2:枪支 3:芯片',
|
||||
`item_id` int(11) DEFAULT NULL COMMENT '特殊字段,用于标记中心化道具,用于交易金币',
|
||||
`amount` int(11) NOT NULL DEFAULT '1' COMMENT '堆叠数量',
|
||||
`createtime` int(11) NOT NULL COMMENT '创建时间(上架时间)',
|
||||
`modifytime` int(11) NOT NULL COMMENT '修改时间(更新价格等)',
|
||||
`s_currency` varchar(255) NOT NULL COMMENT '出售时选择的币种地址',
|
||||
`s_price` varchar(64) NOT NULL COMMENT '出售价格',
|
||||
`c_name` varchar(32) NOT NULL COMMENT '缓存-名称',
|
||||
`c_job` int(11) NOT NULL COMMENT '缓存-职业',
|
||||
`c_type` int(11) NOT NULL COMMENT '缓存-碎片类型',
|
||||
`c_lv` int(11) NOT NULL COMMENT '缓存-级别',
|
||||
`c_quality` int(11) NOT NULL COMMENT '缓存-品阶',
|
||||
`c_durability` float NOT NULL COMMENT '缓存-能量',
|
||||
`c_id` int(11) NOT NULL COMMENT '缓存-id',
|
||||
PRIMARY KEY (`idx`,`o_link`) USING BTREE,
|
||||
UNIQUE KEY `o_link` (`o_link`) USING HASH COMMENT '链上合约上架订单号',
|
||||
UNIQUE KEY `idx` (`idx`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=350 DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `t_market_transaction_record`;
|
||||
CREATE TABLE `t_market_transaction_record` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`createtime` int(11) NOT NULL COMMENT '交易成功时间',
|
||||
`orderid` bigint(20) NOT NULL COMMENT 'market 订单id',
|
||||
`o_link` varchar(64) NOT NULL COMMENT '合约订单id',
|
||||
`seller` varchar(64) NOT NULL COMMENT '卖家',
|
||||
`buyer` varchar(64) NOT NULL COMMENT '买家',
|
||||
`tokenid` int(64) NOT NULL COMMENT 'tokenid',
|
||||
`item_id` int(11) DEFAULT NULL COMMENT '如果有,说明是中心化道具交易',
|
||||
`amount` int(11) NOT NULL COMMENT '堆叠数量',
|
||||
`name` varchar(64) NOT NULL COMMENT '商品名称',
|
||||
`type` int(11) NOT NULL COMMENT '商品类型',
|
||||
PRIMARY KEY (`idx`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;
|
||||
|
@ -780,7 +780,7 @@ class MarketController extends BaseController {
|
||||
return '';
|
||||
};
|
||||
|
||||
$conn = myself()->_getMysql('');
|
||||
$conn = myself()->_getMarketMysql('');
|
||||
|
||||
$counts = $conn->execQuery(
|
||||
'SELECT count(*) as count FROM t_market_store '.
|
||||
@ -952,7 +952,7 @@ class MarketController extends BaseController {
|
||||
$signature = getReqVal('signature', '');
|
||||
$net_id = getReqVal('net_id', '');
|
||||
|
||||
$conn = myself()->_getMysql('');
|
||||
$conn = myself()->_getMarketMysql('');
|
||||
$conn->execScript('DELETE FROM t_market_store WHERE '.'token_id=\''.$nft_token.'\'');
|
||||
|
||||
$this->_rspOk();
|
||||
@ -1067,7 +1067,7 @@ class MarketController extends BaseController {
|
||||
)
|
||||
);
|
||||
|
||||
$conn = myself()->_getMysql('');
|
||||
$conn = myself()->_getMarketMysql('');
|
||||
|
||||
// 1. check order status
|
||||
$chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId));
|
||||
@ -1142,7 +1142,7 @@ class MarketController extends BaseController {
|
||||
)
|
||||
);
|
||||
|
||||
$conn = myself()->_getMysql('');
|
||||
$conn = myself()->_getMarketMysql('');
|
||||
|
||||
// 1. check order status
|
||||
$chk = SqlHelper::selectOne($conn, 't_market_store', array('status','idx', 'c_name', 'token_type'), array('o_link' => $orderId));
|
||||
@ -1196,7 +1196,7 @@ class MarketController extends BaseController {
|
||||
)
|
||||
);
|
||||
|
||||
$conn = myself()->_getMysql('');
|
||||
$conn = myself()->_getMarketMysql('');
|
||||
|
||||
// 1. check order status
|
||||
$chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId));
|
||||
@ -1241,7 +1241,7 @@ class MarketController extends BaseController {
|
||||
)
|
||||
);
|
||||
|
||||
$conn = myself()->_getMysql('');
|
||||
$conn = myself()->_getMarketMysql('');
|
||||
|
||||
// 1. check order status
|
||||
$chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId));
|
||||
@ -1308,7 +1308,7 @@ class MarketController extends BaseController {
|
||||
}
|
||||
|
||||
private function attach_market_selling(&$row) {
|
||||
$conn = myself()->_getMysql('');
|
||||
$conn = myself()->_getMarketMysql('');
|
||||
|
||||
$rows = $conn->execQuery(
|
||||
'SELECT * FROM t_market_store '.
|
||||
@ -1333,7 +1333,9 @@ class MarketController extends BaseController {
|
||||
|
||||
private function listMySelledNfts($account, $type)
|
||||
{
|
||||
$conn = myself()->_getMysql('');
|
||||
error_log('listMySelledNfts ' . $account . ' ' . $type);
|
||||
|
||||
$conn = myself()->_getMarketMysql('');
|
||||
|
||||
$rows = $conn->execQuery(
|
||||
'SELECT * FROM t_market_store '.
|
||||
|
@ -432,11 +432,18 @@ class ShopController extends BaseAuthedController
|
||||
|
||||
$conn = myself()->_getMysql('');
|
||||
|
||||
$address = myself()->_getAddress();
|
||||
|
||||
|
||||
if (empty($address)) {
|
||||
$address = myself()->_getAccountId();
|
||||
}
|
||||
|
||||
$chk = SqlHelper::insert(
|
||||
$conn,
|
||||
't_shop_buy_order',
|
||||
array(
|
||||
'address' => myself()->_getAddress(),
|
||||
'address' => $address,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'item_id' => $id,
|
||||
'goods_num' => $goods_num,
|
||||
@ -483,6 +490,9 @@ class ShopController extends BaseAuthedController
|
||||
private function getCostItemIdByTokenType($token_type)
|
||||
{
|
||||
switch ($token_type) {
|
||||
case ShopController::TOKEN_TYPE_GOLD:
|
||||
return V_ITEM_GOLD;
|
||||
break;
|
||||
case ShopController::TOKEN_TYPE_CEG:
|
||||
return V_ITEM_GOLD;
|
||||
break;
|
||||
@ -783,15 +793,35 @@ class ShopController extends BaseAuthedController
|
||||
return;
|
||||
}
|
||||
|
||||
$maxCount = mt\Parameter::getByName('daily_selection_refresh_time')['param_value'];
|
||||
$count = $this->countTodayRefreshTimes($address);
|
||||
if ($count >= 6) {
|
||||
if ($count >= $maxCount) {
|
||||
$this->_rspErr(2, 'The maximum number of refreshes has been reached');
|
||||
return;
|
||||
}
|
||||
|
||||
$count = $this->countTodayRefreshTimes($address);
|
||||
$costs = mt\Parameter::getByName('daily_selection_refresh_cost');
|
||||
$arrCosts = explode('|', $costs['param_value']);
|
||||
$cost = $arrCosts[$count];
|
||||
$costItemId = $this->getCostItemIdByTokenType(ShopController::TOKEN_TYPE_GOLD);
|
||||
$costItems = $this->makeCostItems($costItemId, $cost);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
|
||||
$chk = $this->refreshDailySelectionWithMode($address, 1);
|
||||
if ($chk) {
|
||||
$this->_rspOk();
|
||||
$this->_decItems($costItems);
|
||||
$this->_rspData(
|
||||
array(
|
||||
'cost' => $cost,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$this->_rspErr(3, 'refresh failed');
|
||||
}
|
||||
}
|
||||
|
||||
@ -817,12 +847,13 @@ class ShopController extends BaseAuthedController
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
$goodsList[$i] = mt\Dailyselection::get($selection['grid_' . $i]);
|
||||
$goodsList[$i]['count'] = $selection['count_' . $i];
|
||||
$goodsList[$i]['pending'] = $this->checkPendingBuyGoodsDS($address, $goodsList[$i]['goods_id'], $selection['idx'], $i);
|
||||
}
|
||||
|
||||
$count = $this->countTodayRefreshTimes($address);
|
||||
$costs = mt\Parameter::getByName('daily_selection_refresh_cost');
|
||||
$arrCosts = explode('|', $costs['param_value']);
|
||||
$cost = $arrCosts[$count];
|
||||
$cost = $count < count($arrCosts) ? $arrCosts[$count] : null;
|
||||
|
||||
$this->_rspData(
|
||||
array(
|
||||
@ -852,7 +883,11 @@ class ShopController extends BaseAuthedController
|
||||
$row = mt\ShopGoods::get($id);
|
||||
|
||||
$goods_id = $row['goods_id'];
|
||||
|
||||
$pending = $this->checkPendingBuyGoodsNormal($address, $goods_id, $row['shop_id'], $id);
|
||||
if ($pending) {
|
||||
$this->_rspErr(1, 'pending');
|
||||
return;
|
||||
}
|
||||
$desired_token_type = $row['token_type'];
|
||||
$check_token_type = splitStr1($desired_token_type);
|
||||
$token_pos = array_search($token_type, $check_token_type, true);
|
||||
@ -1100,6 +1135,12 @@ class ShopController extends BaseAuthedController
|
||||
|
||||
$goods = mt\Dailyselection::get($sel_id);
|
||||
|
||||
$pending = $this->checkPendingBuyGoodsDS($address, $goods['goods_id'], $idx, $grid);
|
||||
if ($pending) {
|
||||
$this->_rspErr(2, 'pending');
|
||||
return;
|
||||
}
|
||||
|
||||
$price = $this->normalizeWeb3Price($goods['price'] * $count);
|
||||
$item_id = $goods['goods_id'];
|
||||
$item_count = $goods['goods_num'] * $count;
|
||||
@ -1309,6 +1350,13 @@ class ShopController extends BaseAuthedController
|
||||
}
|
||||
$chestType = $meta['sub_type'];
|
||||
$itemStore = mt\ShopChest::getRandomItemListByChestType($chestType);
|
||||
error_log("getChestItems start1 " . json_encode(
|
||||
array(
|
||||
'goods_id' => $goods_id,
|
||||
'chestType' => $chestType,
|
||||
'items' => $itemStore,
|
||||
)
|
||||
));
|
||||
$record = array();
|
||||
foreach ($itemStore as $key => $value) {
|
||||
foreach ($value as $k => $v) {
|
||||
@ -1516,6 +1564,7 @@ class ShopController extends BaseAuthedController
|
||||
);
|
||||
foreach ($rows as $row) {
|
||||
$extData = json_decode($row['ext_data'], true);
|
||||
error_log("checkPendingBuyGoodsNormal: " . json_encode($extData));
|
||||
if ($extData['mode'] == SHOP_BUY_MODE_NORMAL) {
|
||||
if ($extData['shop_id'] == $shop_id) {
|
||||
if ($extData['id'] == $id) {
|
||||
@ -1527,6 +1576,36 @@ class ShopController extends BaseAuthedController
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function checkPendingBuyGoodsDS($address, $goodsId, $idx, $grid)
|
||||
{
|
||||
$self = myself();
|
||||
if (!$self) return;
|
||||
|
||||
$conn = $self->_getMysql('');
|
||||
|
||||
$rows = SqlHelper::select(
|
||||
$conn,
|
||||
't_bc_order',
|
||||
array('ext_data'),
|
||||
array(
|
||||
'address' => $address,
|
||||
'item_id' => $goodsId,
|
||||
'status' => 0,
|
||||
)
|
||||
);
|
||||
foreach ($rows as $row) {
|
||||
$extData = json_decode($row['ext_data'], true);
|
||||
if ($extData['mode'] == SHOP_BUY_MODE_DAILY_SELECTION) {
|
||||
if ($extData['idx'] == $idx) {
|
||||
if ($extData['grid'] == $grid) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function outsideBuy($shopId, $itemId, $itemNum, $costItemId)
|
||||
{
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
|
Loading…
x
Reference in New Issue
Block a user