From e0cf6486ec15ce1efa099c1e2bb5ecfcd6fefddb Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 18:42:38 +0800 Subject: [PATCH] 1 --- .../controller/BigwheelController.class.php | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php index 19c2f9d5..c59186f1 100644 --- a/webapp/controller/BigwheelController.class.php +++ b/webapp/controller/BigwheelController.class.php @@ -245,6 +245,21 @@ class BigwheelController extends BaseAuthedController { } array_push($data['grid_list'], $grid1); array_push($data['grid_list'], $grid2); + + $costItems = array( + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => $costItemNum + ), + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); + $this->propertyChgService->addUserChg(); + myself()->_addItems($hashItems, $this->awardService, $this->propertyChgService); myself()->_callModelStatic('MidData', 'setData', $key, json_encode($data)); { @@ -267,6 +282,52 @@ class BigwheelController extends BaseAuthedController { { $key = $this->getMidDataKey(); $data = $this->getAndCreateData($key); + $gridRef = null; + $gridId = getReqVal('grid_id', 0); + $this->getGridRefByGridId($data, $gridId, $gridRef); + error_log(json_encode($gridRef)); + if (empty($gridRef) || + $gridRef['grid_state'] != 2) { + myself()->_rspErr(1, 'cant buy'); + return; + } + $costItems = array( + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => $gridRef['buy_price'] + ), + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); + $gridRef['grid_state'] = 1; + foreach ($data['grid_list'] as &$grid) { + if ($grid['grid_id'] == $gridId) { + $grid['grid_state'] = 1; + } + } + error_log(json_encode($gridRef)); + error_log(json_encode($data)); + myself()->_callModelStatic('MidData', 'setData', $key, json_encode($data)); + $this->awardService->addItem($gridRef['item_id'], $gridRef['item_num']); + $this->propertyChgService->addUserChg(); + + $priceInfo = $this->getPriceInfo($data['drawed_times']); + if (empty($priceInfo)) { + myself()->_rspErr(500, 'server internal error'); + return; + } + $info = array(); + $this->fillInfo($info, $data, $priceInfo); + + myself()->_rspData(array( + 'award' => $this->awardService->toDto(), + 'property_chg' => $this->propertyChgService->toDto(), + 'info' => $info + )); } private function getMidDataKey()