From 136834da48235b7398adb3c4ff9dd74ccf8597c9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 11:01:03 +0800 Subject: [PATCH 01/11] 1 --- doc/AAGameLog.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/AAGameLog.py b/doc/AAGameLog.py index f32180a8..627a922c 100644 --- a/doc/AAGameLog.py +++ b/doc/AAGameLog.py @@ -5,19 +5,23 @@ class AAGameLog(object): def __init__(self): self.apis = [ { + 'method': 'POST', 'name': 'customReport', - 'desc': '上报自定义日志', + 'desc': '上报自定义日志(httpbody自定义)', 'group': '!AAGameLog', 'url': 'https://gamelog-test.kingsome.cn/webapp/index.php?c=GameLog&a=customReport', - 'params': [ + 'is_json_params': True, + 'request_params': [ _common.ReqHead(), ['gameid', '', '游戏id'], ['channel', '', '渠道编号'], ['event_name', '', '事件名'], - ['account_id', '', '账号Id'], - ['session_id', '', '会话id'], + ['account_id', '', '[可选]账号id(web端不要传该字段)'], + ['session_id', '', '[可选]会话id(web端不要传该字段)'], ['localuuid', '', '本地唯一Id'], ], + 'params': [ + ], 'response': [ _common.RspHead(), ] From d04f973cf16eb10ed7bf8e45eb51dc0ae93297b7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 11:42:43 +0800 Subject: [PATCH 02/11] 1 --- doc/Bigwheel.py | 53 +++++++++++++++++++ doc/_common.py | 23 ++++++++ .../controller/BigwheelController.class.php | 29 ++++++++++ 3 files changed, 105 insertions(+) create mode 100644 doc/Bigwheel.py create mode 100644 webapp/controller/BigwheelController.class.php diff --git a/doc/Bigwheel.py b/doc/Bigwheel.py new file mode 100644 index 00000000..f94dbfc7 --- /dev/null +++ b/doc/Bigwheel.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +import _common + +class Bigwheel(object): + + def __init__(self): + self.apis = [ + { + 'name': 'info', + 'desc': '转盘信息', + 'group': 'Bigwheel', + 'url': 'webapp/index.php?c=Bigwheel&a=info', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['info', _common.BigwheelInfo(), '转盘信息'], + ] + }, + { + 'name': 'drawS', + 'desc': '抽奖', + 'group': 'Bigwheel', + 'url': 'webapp/index.php?c=Bigwheel&a=drawS', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['award', _common.Award(), '奖励信息'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ['info', _common.BigwheelInfo(), '转盘信息'], + ] + }, + { + 'name': 'buyS', + 'desc': '购买', + 'group': 'Bigwheel', + 'url': 'webapp/index.php?c=Bigwheel&a=buyS', + 'params': [ + _common.ReqHead(), + ['grid_id', 0, '格子id'] + ], + 'response': [ + _common.RspHead(), + ['award', _common.Award(), '奖励信息'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ['info', _common.BigwheelInfo(), '转盘信息'], + ] + } + ] diff --git a/doc/_common.py b/doc/_common.py index c40164f6..69996831 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1845,3 +1845,26 @@ class RechargeHistory(object): ['amount', '', '货币数'], ['createtime', 0, '成交时间'], ] + +class BigwheelGrid(object): + + def __init__(self): + self.fields = [ + ['grid_id', 0, '格子id(Bigwheel表里的id字段)'], + ['grid_state', 0, '0:未抽 1:已抽到且商品属于你 2:已抽到且商品还未属于你(需要购买)'], + ['item_id', 0, '道具id(state>0时有效)'], + ['item_num', 0, '道具数量(state>0时有效)'], + ['buy_price', 0, '购买价格(state=2时有效)'], + ] + +class BigwheelInfo(object): + + def __init__(self): + self.fields = [ + ['drawed_times', 0, '已抽次数'], + ['total_times', 0, '总次数'], + ['single_cost', 0, '单次抽奖消耗(钻石)'], + ['double_cost', 0, '双次抽奖消耗(钻石)'], + ['!items1', [BigwheelGrid()], '档位1'], + ['!items2', [BigwheelGrid()], '档位2'], + ] diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php new file mode 100644 index 00000000..9bb009b9 --- /dev/null +++ b/webapp/controller/BigwheelController.class.php @@ -0,0 +1,29 @@ + Date: Thu, 1 Aug 2024 12:03:21 +0800 Subject: [PATCH 03/11] 1 --- webapp/controller/BaseController.class.php | 18 +++++++++++++--- webapp/mt/Bigwheel.php | 24 ++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 webapp/mt/Bigwheel.php diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index b521ca20..76e90de3 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -276,15 +276,27 @@ class BaseController { return $channel == "0000"; } + public function _getServiceConstant($serviceName, $name) + { + $this->_mustBeLoadService($serviceName); + $reflectionConstant = new ReflectionClassConstant('services\\' . $serviceName, $name); + return $reflectionConstant->getValue();; + } + public function _callServiceStatic($serviceName, $funcName, ...$args) + { + $this->_mustBeLoadService($serviceName); + $method = new ReflectionMethod('services\\' . $serviceName, $funcName); + $ret = $method->invoke(null, ...$args); + return $ret; + } + + private function _mustBeLoadService($serviceName) { if (!array_key_exists($serviceName, $this->serviceHash)) { require_once('services/' . $serviceName . '.php'); $this->serviceHash[$serviceName] = $this->_getNowTime(); } - $method = new ReflectionMethod('services\\' . $serviceName, $funcName); - $ret = $method->invoke(null, ...$args); - return $ret; } public function _getGameId() { diff --git a/webapp/mt/Bigwheel.php b/webapp/mt/Bigwheel.php new file mode 100644 index 00000000..fb7257f0 --- /dev/null +++ b/webapp/mt/Bigwheel.php @@ -0,0 +1,24 @@ + Date: Thu, 1 Aug 2024 12:48:25 +0800 Subject: [PATCH 04/11] 1 --- sql/gamedb.sql | 19 ++++++++ .../controller/BigwheelController.class.php | 4 -- webapp/models/MidData.php | 47 +++++++++++++++++++ 3 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 webapp/models/MidData.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index c54c180e..fbadd09d 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1948,3 +1948,22 @@ CREATE TABLE `t_box_alloc` ( KEY `idx_createtime` (`createtime`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_middata` +-- + +DROP TABLE IF EXISTS `t_middata`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_middata` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id', + `type` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'type', + `data` text COMMENT 'data', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_id_type` (`account_id`, `type`) +) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php index 9bb009b9..f2986488 100644 --- a/webapp/controller/BigwheelController.class.php +++ b/webapp/controller/BigwheelController.class.php @@ -1,17 +1,13 @@ _getSelfMysql(), + 't_middata', + array( + 'account_id' => myself()->_getAccountId(), + 'type' => $type, + ) + ); + return $row ? json_decode($row['data'], true) : null; + } + + + public static function setData($type, $data) + { + SqlHelper::upsert + (myself()->_getSelfMysql(), + 't_middata', + array( + 'account_id' => myself()->_getAccountId(), + 'type' => $type + ), + array( + 'data' => $data, + 'modifytime' => myself()->_getNowTime() + ), + array( + 'account_id' => myself()->_getAccountId(), + 'type' => $type, + 'data' => $data, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } + +} From b4b97656e693674d5ec43a64f94393cde9bb8eed Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 13:11:40 +0800 Subject: [PATCH 05/11] 1 --- webapp/controller/BaseController.class.php | 52 +++++++++++++++---- .../controller/BigwheelController.class.php | 5 ++ webapp/models/MidData.php | 2 + 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 76e90de3..5f73657f 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -10,7 +10,7 @@ class BaseController { private $relationDbConn = null; private $mailDbConn = null; private $timeOffset = 0; - private $serviceHash = array(); + private $moduleHash = array(); function __construct() { @@ -278,24 +278,56 @@ class BaseController { public function _getServiceConstant($serviceName, $name) { - $this->_mustBeLoadService($serviceName); - $reflectionConstant = new ReflectionClassConstant('services\\' . $serviceName, $name); - return $reflectionConstant->getValue();; + return $this->_internalGetModuleConstant('services', $serviceName, $name); } public function _callServiceStatic($serviceName, $funcName, ...$args) { - $this->_mustBeLoadService($serviceName); - $method = new ReflectionMethod('services\\' . $serviceName, $funcName); + return $this->_internalCallModuleStatic('services', $serviceName, $funcName, ... $args); + } + + public function _getModelConstant($modelName, $name) + { + return $this->_internalGetModuleConstant('models', $modelName, $name); + } + + public function _callModelStatic($modelName, $funcName, ...$args) + { + return $this->_internalCallModuleStatic('models', $modelName, $funcName, ... $args); + } + + public function _getMtConstant($modelName, $name) + { + return $this->_internalGetModuleConstant('mt', $modelName, $name); + } + + public function _callMtStatic($modelName, $funcName, ...$args) + { + return $this->_internalCallModuleStatic('mt', $modelName, $funcName, ... $args); + } + + private function _internalGetModuleConstant($dir, $moduleName, $name) + { + $fullName = $dir . '\\' . $moduleName; + $this->_internalMustBeLoadModule($fullName); + $reflectionConstant = new ReflectionClassConstant($fullName, $name); + return $reflectionConstant->getValue();; + } + + private function _internalCallModuleStatic($dir, $moduleName, $funcName, ...$args) + { + $fullName = $dir . '\\' . $moduleName; + $this->_internalMustBeLoadModule($fullName); + $method = new ReflectionMethod($fullName, $funcName); $ret = $method->invoke(null, ...$args); return $ret; } - private function _mustBeLoadService($serviceName) + private function _internalMustBeLoadModule($fullName) { - if (!array_key_exists($serviceName, $this->serviceHash)) { - require_once('services/' . $serviceName . '.php'); - $this->serviceHash[$serviceName] = $this->_getNowTime(); + if (!array_key_exists($fullName, $this->moduleHash)) { + require_once($fullName . '.php'); + $this->moduleHash[$fullName] = $this->_getNowTime(); } } diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php index f2986488..0b344a0c 100644 --- a/webapp/controller/BigwheelController.class.php +++ b/webapp/controller/BigwheelController.class.php @@ -22,4 +22,9 @@ class BigwheelController extends BaseAuthedController public function buyS(){ } + private function getMidDataKey() + { + return myself()->_getServiceConstant(); + } + } diff --git a/webapp/models/MidData.php b/webapp/models/MidData.php index 8c5a61b0..f94aed26 100644 --- a/webapp/models/MidData.php +++ b/webapp/models/MidData.php @@ -7,6 +7,8 @@ use phpcommon\SqlHelper; class MidData extends BaseModel { + const BIG_WHEEL_TYPE = 'offer.reward.missions'; + public static function getData($type) { $row = SqlHelper::ormSelectOne( From d1dd03656ef1065ad1a893a7a0c6f0d59c3882a7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 13:15:56 +0800 Subject: [PATCH 06/11] 1 --- doc/AAMarket.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/AAMarket.py b/doc/AAMarket.py index de0fd897..04cc40bf 100644 --- a/doc/AAMarket.py +++ b/doc/AAMarket.py @@ -418,16 +418,15 @@ class AAMarket(object): }, { 'method': 'POST', - 'name': '/api/recharge/history', + 'name': '/api/recharge/history/:net_id/:account_address', 'desc': '充值-历史', 'group': '!AAMarket', - 'url': 'https://market-test.kingsome.cn/api/recharge/history', + 'url': 'https://market-test.kingsome.cn/api/recharge/history/:net_id/:account_address', 'headers': _common.JwtHeader, 'is_json_params': True, 'request_params': [ ], 'params': [ - ['net_id', 0, '链id'], ], 'response': [ _common.RspHead(), From 623a7b0bbd45324a8c1484d2be7ed283acd90fba Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 13:22:03 +0800 Subject: [PATCH 07/11] 1 --- webapp/controller/BaseController.class.php | 2 +- webapp/controller/BigwheelController.class.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 5f73657f..0c56937b 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -326,7 +326,7 @@ class BaseController { private function _internalMustBeLoadModule($fullName) { if (!array_key_exists($fullName, $this->moduleHash)) { - require_once($fullName . '.php'); + require_once(str_replace('\\', '/', $fullName) . '.php'); $this->moduleHash[$fullName] = $this->_getNowTime(); } } diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php index 0b344a0c..c3452eda 100644 --- a/webapp/controller/BigwheelController.class.php +++ b/webapp/controller/BigwheelController.class.php @@ -14,6 +14,7 @@ class BigwheelController extends BaseAuthedController { public function info(){ + echo myself()->_getModelConstant('MidData', 'BIG_WHEEL_TYPE'); } public function drawS(){ From a7f15e2f9bd9486485abe545461ff845b45b06d7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 13:56:40 +0800 Subject: [PATCH 08/11] 1 --- .../controller/BigwheelController.class.php | 42 ++++++++++++++++++- webapp/mt/Bigwheel.php | 9 ++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php index c3452eda..196fb071 100644 --- a/webapp/controller/BigwheelController.class.php +++ b/webapp/controller/BigwheelController.class.php @@ -1,6 +1,7 @@ _getModelConstant('MidData', 'BIG_WHEEL_TYPE'); + $key = $this->getMidDataKey(); + $data = $this->getAndCreateData($key); + mt\Bigwheel::traverseMeta( + function ($meta) use(&$data) { + return true; + }); + myself()->_rspData($data); } public function drawS(){ + $key = $this->getMidDataKey(); + $data = $this->getAndCreateData($key); } public function buyS(){ + $key = $this->getMidDataKey(); + $data = $this->getAndCreateData($key); } private function getMidDataKey() { - return myself()->_getServiceConstant(); + return myself()->_getModelConstant('MidData', 'BIG_WHEEL_TYPE'); + } + + private function getAndCreateData($key) + { + $data = myself()->_callModelStatic('MidData', 'getData', $key); + if (!empty($data)) { + $data = json_decode($data, true); + } + if (empty($data)) { + $data = array( + "grid_list" => array() + ); + } + return $data; } } diff --git a/webapp/mt/Bigwheel.php b/webapp/mt/Bigwheel.php index fb7257f0..9d1900fe 100644 --- a/webapp/mt/Bigwheel.php +++ b/webapp/mt/Bigwheel.php @@ -20,5 +20,14 @@ class Bigwheel return self::$metaList; } + public static function traverseMeta($cb) + { + foreach (self::getMetaList() as $meta) { + if (!$cb($meta)) { + break; + } + } + } + protected static $metaList; } From 9d8620734f632c46afc6da96bfc3528f0c102051 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 14:24:53 +0800 Subject: [PATCH 09/11] 1 --- .../controller/BigwheelController.class.php | 58 +++++++++++++++++-- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php index 196fb071..d47597ec 100644 --- a/webapp/controller/BigwheelController.class.php +++ b/webapp/controller/BigwheelController.class.php @@ -30,11 +30,11 @@ class BigwheelController extends BaseAuthedController public function info(){ $key = $this->getMidDataKey(); $data = $this->getAndCreateData($key); - mt\Bigwheel::traverseMeta( - function ($meta) use(&$data) { - return true; - }); - myself()->_rspData($data); + $info = array(); + $this->fillInfo($info, $data); + myself()->_rspData(array( + 'info' => $info + )); } public function drawS(){ @@ -66,4 +66,52 @@ class BigwheelController extends BaseAuthedController return $data; } + private function fillInfo(&$info, &$data) + { + $info = array( + 'drawed_times' => 0, + 'total_times' => 9, + 'single_cost' => 0, + 'double_cost' => 0, + 'items1' => array(), + 'items2' => array(), + ); + mt\Bigwheel::traverseMeta( + function ($meta) use(&$data, &$info) { + $item = array( + 'grid_id' => $meta['id'], + 'grid_state' => 0, + 'item_id' => 0, + 'item_num' => 0, + 'buy_price' => 0, + ); + $gridRef = null; + $this->getGridRefByGridId($data, $meta['id'], $girdRef); + if (!empty($gridRef)) { + $item = $gridRef; + } + switch ($meta['Wheel_type']) { + case 1:{ + array_push($info['items1'], $item); + } + break; + case 2:{ + array_push($info['items2'], $item); + } + break; + } + return true; + }); + } + + private function getGridRefByGridId(&$data, $gridId, &$gridRefOut) + { + foreach ($data['grid_list'] as &$grid) { + if ($grid['grid_id'] == $girdId) { + $gridRefOut = $grid; + break; + } + } + } + } From 918fdaaf9cbc2b54cb1406c8e8052fb0a7b57557 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 14:28:24 +0800 Subject: [PATCH 10/11] 1 --- .../controller/BigwheelController.class.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php index d47597ec..1598562f 100644 --- a/webapp/controller/BigwheelController.class.php +++ b/webapp/controller/BigwheelController.class.php @@ -24,10 +24,12 @@ use services\LogService; } */ -class BigwheelController extends BaseAuthedController -{ +class BigwheelController extends BaseAuthedController { - public function info(){ + const MAX_DRAW_TIMES = 9; + + public function info() + { $key = $this->getMidDataKey(); $data = $this->getAndCreateData($key); $info = array(); @@ -37,12 +39,14 @@ class BigwheelController extends BaseAuthedController )); } - public function drawS(){ + public function drawS() + { $key = $this->getMidDataKey(); $data = $this->getAndCreateData($key); } - public function buyS(){ + public function buyS() + { $key = $this->getMidDataKey(); $data = $this->getAndCreateData($key); } @@ -60,6 +64,7 @@ class BigwheelController extends BaseAuthedController } if (empty($data)) { $data = array( + 'drawed_times' => 0, "grid_list" => array() ); } @@ -69,8 +74,8 @@ class BigwheelController extends BaseAuthedController private function fillInfo(&$info, &$data) { $info = array( - 'drawed_times' => 0, - 'total_times' => 9, + 'drawed_times' => $data['drawed_times'], + 'total_times' => self::MAX_DRAW_TIMES, 'single_cost' => 0, 'double_cost' => 0, 'items1' => array(), From 8933b31dcc72f6a1e82bb0fe54c752787614a3ad Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 15:35:30 +0800 Subject: [PATCH 11/11] 1 --- doc/Bigwheel.py | 1 + .../controller/BigwheelController.class.php | 84 +++++++++++++++++-- 2 files changed, 80 insertions(+), 5 deletions(-) diff --git a/doc/Bigwheel.py b/doc/Bigwheel.py index f94dbfc7..8acb8529 100644 --- a/doc/Bigwheel.py +++ b/doc/Bigwheel.py @@ -26,6 +26,7 @@ class Bigwheel(object): 'url': 'webapp/index.php?c=Bigwheel&a=drawS', 'params': [ _common.ReqHead(), + ['type', 0, '0:双勾选 1:第1档 2:第2档'] ], 'response': [ _common.RspHead(), diff --git a/webapp/controller/BigwheelController.class.php b/webapp/controller/BigwheelController.class.php index 1598562f..37a06085 100644 --- a/webapp/controller/BigwheelController.class.php +++ b/webapp/controller/BigwheelController.class.php @@ -19,7 +19,8 @@ use services\LogService; "grid_state": 0, "item_id": 123, "item_num": 314, - "buy_price": 314 + "buy_price": 314, + "draw_times": 1, } } */ @@ -32,8 +33,13 @@ class BigwheelController extends BaseAuthedController { { $key = $this->getMidDataKey(); $data = $this->getAndCreateData($key); + $priceInfo = $this->getPriceInfo($data['drawed_times']); + if (empty($priceInfo)) { + myself()->_rspErr(500, 'server internal error'); + return; + } $info = array(); - $this->fillInfo($info, $data); + $this->fillInfo($info, $data, $priceInfo); myself()->_rspData(array( 'info' => $info )); @@ -41,8 +47,43 @@ class BigwheelController extends BaseAuthedController { public function drawS() { + $drawType = getReqVal('type', 0); + if (!($drawType == 0 || $drawType == 1 || $drawType == 2)) { + myself()->_rspErr(2, 'type param error'); + return; + } $key = $this->getMidDataKey(); $data = $this->getAndCreateData($key); + if ($data['drawed_times'] >= self::MAX_DRAW_TIMES) { + myself()->_rspErr(1, 'The maximum number of lucky draws has been reached'); + return; + } + $priceInfo = $this->getPriceInfo($data['drawed_times']); + if (empty($priceInfo)) { + myself()->_rspErr(500, 'server internal error'); + return; + } + if ($priceInfo['cost_item_id'] != V_ITEM_DIAMOND) { + myself()->_rspErr(500, 'server internal error'); + return; + } + $costItemNum = 0; + if ($drawType == 0) { + $costItemNum = $priceInfo['price_double'] * $priceInfo['discount_double']; + if (empty($costItemNum)) { + myself()->_rspErr(3, 'config error'); + return; + } + } else if ($drawType == 1 || $drawType == 2) { + $costItemNum = $priceInfo['price_single'] * $priceInfo['discount_single']; + if (empty($costItemNum)) { + myself()->_rspErr(3, 'config error'); + return; + } + } else { + myself()->_rspErr(2, 'type param error'); + return; + } } public function buyS() @@ -71,13 +112,13 @@ class BigwheelController extends BaseAuthedController { return $data; } - private function fillInfo(&$info, &$data) + private function fillInfo(&$info, &$data, $priceInfo) { $info = array( 'drawed_times' => $data['drawed_times'], 'total_times' => self::MAX_DRAW_TIMES, - 'single_cost' => 0, - 'double_cost' => 0, + 'single_cost' => $priceInfo['price_single'] * $priceInfo['discount_single'], + 'double_cost' => $priceInfo['price_double'] * $priceInfo['discount_double'], 'items1' => array(), 'items2' => array(), ); @@ -119,4 +160,37 @@ class BigwheelController extends BaseAuthedController { } } + private function getPriceInfo($drawedTimes) + { + $costItem = mt\Parameter::getVal('gacha_cost_item', 0); + $gachaPriceSingles = mt\Parameter::getListValue('gacha_price_single'); + $gachaDiscountSingles = mt\Parameter::getListValue('gacha_discount_single'); + $gachaPriceDoubles = mt\Parameter::getListValue('gacha_price_double'); + $gachaDiscountDoubles = mt\Parameter::getListValue('gacha_discount_double'); + $gachaPriceBuys = mt\Parameter::getListValue('gacha_price_buy'); + $gachaDiscountBuys = mt\Parameter::getListValue('gacha_discount_buy'); + if (count($gachaPriceSingles) != count($gachaDiscountSingles) && + count($gachaPriceDoubles) != count($gachaDiscountDoubles) && + count($gachaPriceBuys) != count($gachaDiscountBuys) && + count($gachaDiscountBuys) != self::MAX_DRAW_TIMES) { + return null; + } + if ($drawedTimes < 0) { + return null; + } + if ($drawedTimes > self::MAX_DRAW_TIMES) { + $drawedTimes = self::MAX_DRAW_TIMES - 1; + } + $priceInfo = array( + 'cost_item_id' => $costItem, + 'price_single' => $gachaPriceSingles[$drawedTimes], + 'discount_single' => $gachaDiscountSingles[$drawedTimes], + 'price_double' => $gachaPriceDoubles[$drawedTimes], + 'discount_double' => $gachaDiscountSingles[$drawedTimes], + 'price_buy' => $gachaPriceBuys[$drawedTimes], + 'discount_buy' => $gachaDiscountBuys[$drawedTimes], + ); + return $priceInfo; + } + }