Merge branch 'star' of git.kingsome.cn:server/game2006api into star
This commit is contained in:
commit
1659875f28
@ -2,6 +2,7 @@
|
||||
|
||||
import _common
|
||||
|
||||
|
||||
class Shop(object):
|
||||
|
||||
def __init__(self):
|
||||
@ -240,7 +241,7 @@ class Shop(object):
|
||||
'url': 'webapp/index.php?c=Shop&a=getChestItems',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['goods_id', 0, '宝箱物品id item_id'],
|
||||
['id', 0, '商品唯一id,参见shopGoods表'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
|
@ -143,9 +143,14 @@ class ShopController extends BaseAuthedController
|
||||
$goods['goods_num'] = 1;
|
||||
}
|
||||
if (!empty($goods['free_type'])) {
|
||||
$count = $this->countFreeBuyTimes($goods);
|
||||
$count = $this->countFreeBuyTimes($goods['free_type'], $goods['id'], $goods['goods_id']);
|
||||
$goods['free_num'] = $goods['free_num'] - $count;
|
||||
}
|
||||
|
||||
$address = $this->_getAddress();
|
||||
if ($address) {
|
||||
$goods['pending'] = $this->checkPendingBuyGoodsNormal($address, $goods['goods_id'], $goods['shop_id'], $goods['id']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_rspData(
|
||||
@ -408,7 +413,8 @@ class ShopController extends BaseAuthedController
|
||||
$itemMeta = mt\Item::get($row['goods_id']);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
for ($i = 0; $i < $goods_num; $i++) {
|
||||
$this->internalAddItem($propertyChgService, $itemMeta, $goods_count, 0);
|
||||
// 既然这种货币是在链上的,那么这里不应该增加任何物品,
|
||||
// $this->internalAddItem($propertyChgService, $itemMeta, $goods_count, 0);
|
||||
}
|
||||
$awardService = new services\AwardService();
|
||||
// $awardService->addItem($row['goods_id'], $goods_num);
|
||||
@ -852,7 +858,7 @@ class ShopController extends BaseAuthedController
|
||||
$token_pos = array_search($token_type, $check_token_type, true);
|
||||
$isFreeBuy = false;
|
||||
if (!empty($row['free_type'])) {
|
||||
$count = $this->countFreeBuyTimes($row);
|
||||
$count = $this->countFreeBuyTimes($row['free_type'], $row['id'], $row['goods_id']);
|
||||
if ($count < $row['free_num']) {
|
||||
$isFreeBuy = true;
|
||||
}
|
||||
@ -874,7 +880,6 @@ class ShopController extends BaseAuthedController
|
||||
|
||||
$buyRecordHash = ShopBuyRecord::allToHash();
|
||||
$boughtTimes = 1;
|
||||
$row['limit_type'] = 1;
|
||||
switch ($row['limit_type']) {
|
||||
case ShopController::DAILY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
@ -1168,7 +1173,7 @@ class ShopController extends BaseAuthedController
|
||||
$cost = $shop['price'] * $num;
|
||||
$isFreeBuy = false;
|
||||
if (!empty($shop['free_type'])) {
|
||||
$count = $this->countFreeBuyTimes($shop);
|
||||
$count = $this->countFreeBuyTimes($shop['free_type'], $shop['id'], $shop['goods_id']);
|
||||
if ($count < $shop['free_num']) {
|
||||
$isFreeBuy = true;
|
||||
}
|
||||
@ -1286,7 +1291,16 @@ class ShopController extends BaseAuthedController
|
||||
|
||||
public function getChestItems()
|
||||
{
|
||||
$goods_id = getReqVal('goods_id', 0);
|
||||
$address = $this->_getAddress();
|
||||
// if (!$address) {
|
||||
// $this->_rspErr(2, 'address is invalid');
|
||||
// return;
|
||||
// }
|
||||
|
||||
$id = getReqVal('id', 0);
|
||||
$goods = mt\ShopGoods::get($id);
|
||||
$goods_id = $goods['goods_id'];
|
||||
$shop_id = $goods['shop_id'];
|
||||
|
||||
$meta = mt\Item::get($goods_id);
|
||||
if ($meta['type'] != mt\Item::CHEST_BOX_TYPE) {
|
||||
@ -1298,25 +1312,35 @@ class ShopController extends BaseAuthedController
|
||||
$record = array();
|
||||
foreach ($itemStore as $key => $value) {
|
||||
foreach ($value as $k => $v) {
|
||||
if (empty($record[$v['item_id']])) {
|
||||
$record[$v['item_id']] = 0;
|
||||
}
|
||||
$record[$v['item_id']] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
$free_num = $goods['free_num'] - $this->countFreeBuyTimes($address, $id, $goods_id);
|
||||
$pending = $this->checkPendingBuyGoodsNormal($address, $goods_id, $shop_id, $id);
|
||||
error_log("getChestItems start " . json_encode(
|
||||
array(
|
||||
'goods_id' => $goods_id,
|
||||
'items' => array_keys($record),
|
||||
'free_num' => $free_num,
|
||||
'pending' => $pending,
|
||||
)
|
||||
));
|
||||
|
||||
$this->_rspData(
|
||||
array(
|
||||
'items' => array_keys($record),
|
||||
'free_num' => $free_num,
|
||||
'pending' => $pending,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getMyBlindBoxs() {
|
||||
public function getMyBlindBoxs()
|
||||
{
|
||||
|
||||
$itemDb = Bag::getAllByType(mt\Item::CHEST_BOX_TYPE);
|
||||
$items = array();
|
||||
@ -1473,6 +1497,36 @@ class ShopController extends BaseAuthedController
|
||||
return $row[0]['cnt'];
|
||||
}
|
||||
|
||||
private function checkPendingBuyGoodsNormal($address, $goodsId, $shop_id, $id)
|
||||
{
|
||||
$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_NORMAL) {
|
||||
if ($extData['shop_id'] == $shop_id) {
|
||||
if ($extData['id'] == $id) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function outsideBuy($shopId, $itemId, $itemNum, $costItemId)
|
||||
{
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
@ -1776,16 +1830,16 @@ class ShopController extends BaseAuthedController
|
||||
return phpcommon\bnToStr($ret_price);
|
||||
}
|
||||
|
||||
private function countFreeBuyTimes($goods)
|
||||
private function countFreeBuyTimes($free_type, $id, $goods_id)
|
||||
{
|
||||
$conn = myself()->_getMysql('');
|
||||
$account = myself()->_getAccountId();
|
||||
|
||||
switch ($goods['free_type']) {
|
||||
switch ($free_type) {
|
||||
case 1: {
|
||||
$dayTime = myself()->_getNowDaySeconds();
|
||||
$sql = 'SELECT COUNT(*) as cnt FROM t_shop_free_record WHERE account_id = ? AND `id` = ? AND goods_id = ? AND createtime >= ?';
|
||||
$row = $conn->execQueryOne($sql, array($account, $goods['id'], $goods['goods_id'], $dayTime));
|
||||
$row = $conn->execQueryOne($sql, array($account, $id, $goods_id, $dayTime));
|
||||
return $row['cnt'];
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user