From 2674dcc27ab3b939a972ea0ccfa2b8dfbed079da Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 19 Jul 2023 17:02:20 +0800 Subject: [PATCH] =?UTF-8?q?...=20=E6=AF=8F=E6=97=A5=E7=B2=BE=E9=80=89?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=91=E5=B8=81=E8=B4=AD=E4=B9=B0=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/ShopController.class.php | 45 +++++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index fb8da15e..667c0050 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1201,6 +1201,16 @@ class ShopController extends BaseAuthedController return; } + $token_type = getReqVal('token_type', ''); + switch ($token_type) { + case ShopController::TOKEN_TYPE_GOLD: + case ShopController::TOKEN_TYPE_DIAMOND: + break; + default: + $this->_rspErr(1, "token_type is unsupport, {$token_type}"); + return; + } + $conn = $this->_getMysql(''); $row = SqlHelper::selectOne( @@ -1234,17 +1244,29 @@ class ShopController extends BaseAuthedController $goods = mt\Dailyselection::get($sel_id); - $token_type = $goods['token_type']; + $desired_token_type = $goods['token_type']; + $check_token_type = splitStr1($desired_token_type); + if (!in_array($token_type, $check_token_type)) { + $this->_rspErr(1, "token_type parameter error, desired_token_type: {$desired_token_type}"); + return; + } + $token_pos = array_search($token_type, $check_token_type, true); + + $price_array = splitStr1($goods['price']); + $discount_array = splitStr1($goods['discount']); + + $need_price = $price_array[$token_pos]; + $discount = $discount_array[$token_pos]; + $costItemId = $this->getCostItemIdByTokenType($token_type); - $costItems = $this->makeCostItems($costItemId, $count * $goods['price']); + $costItems = $this->makeCostItems($costItemId, $count * $need_price); $lackItem = null; if (!$this->_hasEnoughItems($costItems, $lackItem)) { $this->_rspErr(2, $this->_getLackItemErrMsg($lackItem)); return; } - $item_id = $goods['goods_id']; $item_num = $goods['goods_num']; @@ -1264,7 +1286,18 @@ class ShopController extends BaseAuthedController 'name' => LogService::SHOP_BUY_ITEM_DAILY, 'val' => $costItems[0]['item_num'] ]; - LogService::consumeDiamond($event); + switch ($token_type) { + case ShopController::TOKEN_TYPE_GOLD: + LogService::consumeGold($event); + break; + case ShopController::TOKEN_TYPE_DIAMOND: + LogService::consumeDiamond($event); + break; + default: + // 这里不应该出现,出现了说明配置表新增了一种货币,但是这里没有处理 + error_log("buyGoodsDS token_type is invalid, token_type: {$token_type}"); + return; + } $goodsDto = array( 'goods_id' => $sel_id, @@ -1275,12 +1308,14 @@ class ShopController extends BaseAuthedController ), 'bought_times' => 0, 'total_buy_times' => 0, - ); { + ); + { $priceInfo = mt\Item::getPriceInfo($itemMeta); if (!empty($priceInfo)) { $goodsDto['price_info'] = $priceInfo['price_info']; } } + $propertyChgService->addUserChg(); $this->_rspData(