Merge branch 'star' of git.kingsome.cn:server/game2006api into star
This commit is contained in:
commit
83af3a1812
@ -346,7 +346,8 @@ class Market(object):
|
|||||||
['lv_filter', 0, '等级过滤'],
|
['lv_filter', 0, '等级过滤'],
|
||||||
['quality_filter', 0, '品阶顾虑'],
|
['quality_filter', 0, '品阶顾虑'],
|
||||||
['durability_filter', 0, '能量过滤'],
|
['durability_filter', 0, '能量过滤'],
|
||||||
['price_filter', '', '价格过滤(用|分割)']
|
['price_filter', '', '价格过滤(用|分割)'],
|
||||||
|
['amount_filter', '', '数量过滤(低|高)']
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
|
14
doc/Shop.py
14
doc/Shop.py
@ -117,6 +117,20 @@ class Shop(object):
|
|||||||
['goods_chg', _common.NewGoods(), '购买后更新商品的最新信息(可能为null客户端需要做容错处理)'],
|
['goods_chg', _common.NewGoods(), '购买后更新商品的最新信息(可能为null客户端需要做容错处理)'],
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'name': 'buyDiamond',
|
||||||
|
'desc': '购买钻石',
|
||||||
|
'group': 'Shop',
|
||||||
|
'url': 'webapp/index.php?c=Shop&a=buyDiamond',
|
||||||
|
'params': [
|
||||||
|
_common.ReqHead(),
|
||||||
|
['num', 0, '购买数量'],
|
||||||
|
],
|
||||||
|
'response': [
|
||||||
|
_common.RspHead(),
|
||||||
|
['block_chain', _common.ShopTrans(), '链上购买订单信息'],
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'name': 'buyGoodsDirect',
|
'name': 'buyGoodsDirect',
|
||||||
'desc': '直接购买(充值,gold)',
|
'desc': '直接购买(充值,gold)',
|
||||||
|
@ -1197,6 +1197,7 @@ CREATE TABLE `t_bc_order` (
|
|||||||
`ext_data` mediumblob COMMENT '扩展数据自定义',
|
`ext_data` mediumblob COMMENT '扩展数据自定义',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
`price` varchar(60) COLLATE utf8_bin NOT NULL COMMENT '价格',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
UNIQUE KEY `order_id` (`order_id`)
|
UNIQUE KEY `order_id` (`order_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||||
|
5
sql/gamedb2006_migrate_230707_01.sql
Normal file
5
sql/gamedb2006_migrate_230707_01.sql
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
begin;
|
||||||
|
|
||||||
|
alter table t_bc_order add column `price` varchar(60) COMMENT '价格';
|
||||||
|
|
||||||
|
commit;
|
@ -24,6 +24,8 @@ require_once('services/BlockChainService.php');
|
|||||||
require_once('phpcommon/bchelper.php');
|
require_once('phpcommon/bchelper.php');
|
||||||
|
|
||||||
// use phpcommon as phpcommon;
|
// use phpcommon as phpcommon;
|
||||||
|
|
||||||
|
use models\BcOrder;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
use models\BoxOrder;
|
use models\BoxOrder;
|
||||||
use models\Nft;
|
use models\Nft;
|
||||||
@ -765,6 +767,8 @@ class MarketController extends BaseAuthedController
|
|||||||
$lv_filter = getReqVal('lv_filter', 0);
|
$lv_filter = getReqVal('lv_filter', 0);
|
||||||
$quality_filter = getReqVal('quality_filter', 0);
|
$quality_filter = getReqVal('quality_filter', 0);
|
||||||
$durability_filter = getReqVal('durability_filter', 0);
|
$durability_filter = getReqVal('durability_filter', 0);
|
||||||
|
$amount_filter = getReqVal('amount_filter', 0);
|
||||||
|
$amount_filter_array = explode('|', $amount_filter);
|
||||||
$price_filter = getReqVal('price_filter', '');
|
$price_filter = getReqVal('price_filter', '');
|
||||||
$price_filter_array = explode('|', $price_filter);
|
$price_filter_array = explode('|', $price_filter);
|
||||||
|
|
||||||
@ -790,6 +794,14 @@ class MarketController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
$amount_filter_fn = function ($f) {
|
||||||
|
if (count($f) == 2) {
|
||||||
|
$low = $f[0];
|
||||||
|
$top = $f[1];
|
||||||
|
return 'AND amount>=' . $low . ' AND amount<=' . $top . ' ';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
};
|
||||||
$lv_filter_fn = function ($f) {
|
$lv_filter_fn = function ($f) {
|
||||||
$f = (int) $f;
|
$f = (int) $f;
|
||||||
return 'AND c_lv>=' . $f . ' ';
|
return 'AND c_lv>=' . $f . ' ';
|
||||||
@ -851,6 +863,7 @@ class MarketController extends BaseAuthedController
|
|||||||
$quality_filter_fn($quality_filter) .
|
$quality_filter_fn($quality_filter) .
|
||||||
$durability_filter_fn($durability_filter) .
|
$durability_filter_fn($durability_filter) .
|
||||||
$price_filter_fn($price_filter_array) .
|
$price_filter_fn($price_filter_array) .
|
||||||
|
$amount_filter_fn($amount_filter_array) .
|
||||||
$search_filter_fn($search_filter_array) .
|
$search_filter_fn($search_filter_array) .
|
||||||
$order_fn($order_method, $order_asc),
|
$order_fn($order_method, $order_asc),
|
||||||
array(
|
array(
|
||||||
@ -875,6 +888,7 @@ class MarketController extends BaseAuthedController
|
|||||||
$quality_filter_fn($quality_filter) .
|
$quality_filter_fn($quality_filter) .
|
||||||
$durability_filter_fn($durability_filter) .
|
$durability_filter_fn($durability_filter) .
|
||||||
$price_filter_fn($price_filter_array) .
|
$price_filter_fn($price_filter_array) .
|
||||||
|
$amount_filter_fn($amount_filter_array) .
|
||||||
$search_filter_fn($search_filter_array) .
|
$search_filter_fn($search_filter_array) .
|
||||||
$order_fn($order_method, $order_asc) .
|
$order_fn($order_method, $order_asc) .
|
||||||
'LIMIT ' . $start . ',' . $page_size,
|
'LIMIT ' . $start . ',' . $page_size,
|
||||||
@ -1164,6 +1178,23 @@ class MarketController extends BaseAuthedController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->markOrderBuyStatus($idx)) {
|
||||||
|
$this->_rspErr(1, 'buy failed, update order status failed, idx:' . $idx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item_id = $goods['item_id'];
|
||||||
|
$item_count = $goods['amount'];
|
||||||
|
|
||||||
|
BcOrder::upsert($response['trans_id'], array(
|
||||||
|
'item_id' => $item_id,
|
||||||
|
'item_num' => $item_count,
|
||||||
|
'order_type' => 1,
|
||||||
|
'ext_data' => json_encode(array(
|
||||||
|
'mode' => SHOP_BUY_MODE_NORMAL,
|
||||||
|
)),
|
||||||
|
));
|
||||||
|
|
||||||
$this->_rspData(array(
|
$this->_rspData(array(
|
||||||
'block_chain' => $response,
|
'block_chain' => $response,
|
||||||
));
|
));
|
||||||
@ -1885,4 +1916,29 @@ class MarketController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function markOrderBuyStatus($idx)
|
||||||
|
{
|
||||||
|
$self = myself();
|
||||||
|
if (!$self) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$r = SqlHelper::update(
|
||||||
|
$self->_getMarketMysql(''),
|
||||||
|
't_market_store',
|
||||||
|
array(
|
||||||
|
'idx' => $idx,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'status' => 3,
|
||||||
|
'buytime' => $self->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (!$r) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -700,6 +700,41 @@ class ShopController extends BaseAuthedController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function buyDiamond()
|
||||||
|
{
|
||||||
|
$num = getReqVal('num', 0);
|
||||||
|
$price = $this->normalizeWeb3Price($num);
|
||||||
|
$item_id = V_ITEM_DIAMOND;
|
||||||
|
$item_count = $num;
|
||||||
|
|
||||||
|
$response = services\BlockChainService::gameItemMallBuy(
|
||||||
|
Transaction::BUY_GOODS_ACTION_TYPE,
|
||||||
|
$price,
|
||||||
|
$item_id,
|
||||||
|
$item_count
|
||||||
|
);
|
||||||
|
|
||||||
|
BcOrder::upsert($response['trans_id'], array(
|
||||||
|
'item_id' => $item_id,
|
||||||
|
'item_num' => $item_count,
|
||||||
|
'order_type' => 1,
|
||||||
|
'ext_data' => json_encode(array(
|
||||||
|
'mode' => SHOP_BUY_MODE_NORMAL,
|
||||||
|
)),
|
||||||
|
));
|
||||||
|
|
||||||
|
$response['item_id'] = $item_id;
|
||||||
|
$response['item_num'] = $item_count;
|
||||||
|
|
||||||
|
error_log("buy diamond, item_id = " . $item_id . " item_count = " . $item_count . " num = " . $num . " price = " . $price . " response = " . json_encode($response));
|
||||||
|
|
||||||
|
$this->_rspData(
|
||||||
|
array(
|
||||||
|
"block_chain" => $response
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function buyGoodsDS()
|
public function buyGoodsDS()
|
||||||
{
|
{
|
||||||
$idx = getReqVal('idx', 0);
|
$idx = getReqVal('idx', 0);
|
||||||
@ -760,7 +795,7 @@ class ShopController extends BaseAuthedController
|
|||||||
|
|
||||||
$sql = "UPDATE t_shop_dailyselection SET count_$grid = count_$grid - $count WHERE idx = $idx";
|
$sql = "UPDATE t_shop_dailyselection SET count_$grid = count_$grid - $count WHERE idx = $idx";
|
||||||
$chk = $conn->execScript($sql);
|
$chk = $conn->execScript($sql);
|
||||||
|
|
||||||
$itemMeta = mt\Item::get($item_id);
|
$itemMeta = mt\Item::get($item_id);
|
||||||
$propertyChgService = new services\PropertyChgService();
|
$propertyChgService = new services\PropertyChgService();
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
|
@ -83,6 +83,79 @@ class BlockChainService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
注意!!!:
|
||||||
|
调用方调用前需要校验actionType和myself()->_getAddress,
|
||||||
|
非法的参数,或者签名服挂了,该函数直接中断请求,不会运行到调用方后续逻辑
|
||||||
|
|
||||||
|
trans_id:订单id
|
||||||
|
|
||||||
|
gameItemMallBuy
|
||||||
|
setv
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static function gameItemMarketBuy($actionType, $price, $itemId, $itemNum)
|
||||||
|
{
|
||||||
|
if (!($actionType > Transaction::BUY_BEGIN_ACTION_TYPE &&
|
||||||
|
$actionType < Transaction::BUY_END_ACTION_TYPE)) {
|
||||||
|
error_log('gameItemMarketBuy action_type error:' . $actionType);
|
||||||
|
myself()->_rspErr(500, 'server internal error 1');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$account = myself()->_getAddress();
|
||||||
|
if (empty($account)) {
|
||||||
|
error_log('gameItemMarketBuy address is emtpy:' . myself()->_getAccountId());
|
||||||
|
myself()->_rspErr(500, 'server internal error 2');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$params = array(
|
||||||
|
'c' => 'GameItemMarket',
|
||||||
|
'a' => 'buy',
|
||||||
|
'account' => $account,
|
||||||
|
'price' => $price,
|
||||||
|
);
|
||||||
|
{
|
||||||
|
$url = self::getWeb3ServiceUrl();
|
||||||
|
$response = '';
|
||||||
|
if (!phpcommon\HttpClient::get
|
||||||
|
($url,
|
||||||
|
$params,
|
||||||
|
$response)) {
|
||||||
|
myself()->_rspErr(500, 'server internal error 3, url:' . $url);
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error_log("gameItemMarketBuy:" . $response . "url:" . $url);
|
||||||
|
$rspObj = json_decode($response, true);
|
||||||
|
if ($rspObj['errcode'] == 0) {
|
||||||
|
$transId = $rspObj['trans_id'];
|
||||||
|
Transaction::add(
|
||||||
|
$transId,
|
||||||
|
$actionType,
|
||||||
|
'', //$tokenId,
|
||||||
|
'', //$tokenType,
|
||||||
|
0, //$itemUniId,
|
||||||
|
$itemId, //$itemId,
|
||||||
|
$itemNum,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
return array(
|
||||||
|
'trans_id' => $transId,
|
||||||
|
'params' => $rspObj['params']
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
myself()->_rspErr(500, 'server internal error 4');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$price 是一个小数精确到小数点后5位
|
$price 是一个小数精确到小数点后5位
|
||||||
*/
|
*/
|
||||||
|
@ -132,12 +132,12 @@ class BuyShopGoodsCbService
|
|||||||
$itemService = new ShopAddItemService();
|
$itemService = new ShopAddItemService();
|
||||||
$item_id = $goods['goods_id'];
|
$item_id = $goods['goods_id'];
|
||||||
$goods_num = $goods['goods_num'];
|
$goods_num = $goods['goods_num'];
|
||||||
|
|
||||||
$id = null;
|
$id = null;
|
||||||
if ($goods['id']) {
|
if ($goods['id']) {
|
||||||
$id = $goods['id'];
|
$id = $goods['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log(json_encode($goods));
|
error_log(json_encode($goods));
|
||||||
error_log('_addGoods ' . $address . ' item_id ' . $item_id . ' goods_num ' . $goods_num . ' id ' . $id);
|
error_log('_addGoods ' . $address . ' item_id ' . $item_id . ' goods_num ' . $goods_num . ' id ' . $id);
|
||||||
$itemService->addItem($address, $item_id, $goods_num);
|
$itemService->addItem($address, $item_id, $goods_num);
|
||||||
@ -146,17 +146,17 @@ class BuyShopGoodsCbService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAccountId($address){
|
private function getAccountId($address)
|
||||||
|
{
|
||||||
|
|
||||||
$row = SqlHelper::ormSelectOne
|
$row = SqlHelper::ormSelectOne(
|
||||||
(myself()->_getMysql($address),
|
myself()->_getMysql($address),
|
||||||
't_user',
|
't_user',
|
||||||
array(
|
array(
|
||||||
'address' => $address
|
'address' => $address
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $row['account_id'];
|
return $row['account_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,14 @@ class ShopAddItemService
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case V_ITEM_DIAMOND:
|
||||||
|
{
|
||||||
|
$this->_updateUserInfo($conn,$accountId,array(
|
||||||
|
'diamond' => function () use($itemNum) {
|
||||||
|
return "diamond + ${itemNum}";
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user