From d33fea4988ee431ffb075faa99006914b0c9b3b1 Mon Sep 17 00:00:00 2001 From: songliang Date: Fri, 30 Jun 2023 16:49:54 +0800 Subject: [PATCH] ... --- doc/_common.py | 1 + webapp/controller/ShopController.class.php | 45 +++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/doc/_common.py b/doc/_common.py index 078f72da..09c8d995 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -444,6 +444,7 @@ class DailySelectionGoods(object): ['weight', 0, '权重'], ['discount', 0, '折扣'], ['price', 0, '价格'], + ['pending', 0, '购买中...'], ] class Mission(object): diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index d866812d..64d34864 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -847,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( @@ -882,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); @@ -1130,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; @@ -1557,6 +1568,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();