diff --git a/doc/SeasonCard.py b/doc/SeasonCard.py index 30bb2ea..b67e26b 100644 --- a/doc/SeasonCard.py +++ b/doc/SeasonCard.py @@ -26,6 +26,7 @@ class SeasonCard(object): 'url': 'webapp/index.php?c=SeasonCard&a=getReward', 'params': [ _common.ReqHead(), + ['type', 0, '1:普通 2:精英'], ['level', 0, '手册等级'], ], 'response': [ @@ -56,7 +57,8 @@ class SeasonCard(object): 'url': 'webapp/index.php?c=SeasonCard&a=buyGiftPackage', 'params': [ _common.ReqHead(), - ['pacakge_id', 0, '礼包id(1:普通礼包 2:豪华礼包)'], + ['package_id', 0, '礼包id(1:普通礼包 2:豪华礼包)'], + ['cost_item_id', 0, '支付方式'], ], 'response': [ _common.RspHead(), diff --git a/doc/_common.py b/doc/_common.py index 413d7f2..12ded3e 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -226,6 +226,7 @@ class SeasonCardGiftPackage(object): def __init__(self): self.fields = [ ['package_id', 0, '礼包id'], + ['item_id', 0, '礼包道具表id(目前客户端没用到先不用管)'], ['state', 0, '0:未购买 1:已购买'], ['price_info', PriceInfo(), '价格信息'], ] diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index c9bc92c..9771dce 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -214,6 +214,7 @@ class BaseAuthedController extends BaseController { $heads = array(); $headFrames = array(); foreach ($items as $item) { + $awardService->addItem($item['item_id'], $item['item_num']); if ($this->_isVirtualItem($item['item_id'])) { $this->_addVirtualItem($item['item_id'], $item['item_num']); $propertyService->addUserChg(); @@ -275,8 +276,8 @@ class BaseAuthedController extends BaseController { }//end foreach if (!empty($heads) || !empty($headFrames)) { $userInfo = $this->_getOrmUserInfo(); - $headsDb = emptyReplae(json_decode($userInfo['head_list'], true), array()); - $headFramesDb = emptyReplae(json_decode($userInfo['head_frame_list'], true), array()); + $headsDb = emptyReplace(json_decode($userInfo['head_list'], true), array()); + $headFramesDb = emptyReplace(json_decode($userInfo['head_frame_list'], true), array()); $heads = array_unique(array_merge($heads, $headsDb)); $headFrames = array_unique(array_merge($headFrames, $headFramesDb)); $this->_updateUserInfo(array( @@ -333,8 +334,8 @@ class BaseAuthedController extends BaseController { if (!$itemMeta) { return '道具不足'; } - if (SERVER_ENV != __ONLINE) { - return "${itemMeta['name']}不足 库存:${itemMeta['inventory']} 需求:${itemMeta['item_num']}"; + if (SERVER_ENV != _ONLINE) { + return "${itemMeta['name']}不足 库存:${lackItem['inventory']} 需求:${lackItem['item_num']}"; } else { return "${itemMeta['name']}不足"; } @@ -344,7 +345,7 @@ class BaseAuthedController extends BaseController { { $itemIds = explode('|', $dropMeta['item_id']); $nums = explode('|', $dropMeta['num']); - $weights = explode('|', $dropMeta['weights']); + $weights = explode('|', $dropMeta['weight']); if (count($itemIds) != count($nums) || count($itemIds) != count($weights)) { return; @@ -393,7 +394,7 @@ class BaseAuthedController extends BaseController { array( 'account_id' => myself()->_getAccountId(), 'drop_source' => $dropSource, - 'drop_id' => $dropMeta['id'], + 'drop_id' => $dropMeta['drop_id'], 'drop_items' => json_encode($addItems), 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() @@ -407,10 +408,10 @@ class BaseAuthedController extends BaseController { 'account_id' => $this->_getAccountId(), 'type' => $type, 'subtype' => $subtype, - 'param1' => getXVale($params, 'param1', ''), - 'param2' => getXVale($params, 'param2', ''), - 'param3' => getXVale($params, 'param3', ''), - 'param4' => getXVale($params, 'param4', ''), + 'param1' => getXVal($params, 'param1', ''), + 'param2' => getXVal($params, 'param2', ''), + 'param3' => getXVal($params, 'param3', ''), + 'param4' => getXVal($params, 'param4', ''), 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() ); diff --git a/webapp/controller/SeasonCardController.class.php b/webapp/controller/SeasonCardController.class.php index 431d072..fad2636 100644 --- a/webapp/controller/SeasonCardController.class.php +++ b/webapp/controller/SeasonCardController.class.php @@ -5,6 +5,7 @@ require_once('models/Hero.php'); require_once('models/Season.php'); require_once('models/SeasonCard.php'); +require_once('mt/Item.php'); require_once('mt/Parameter.php'); require_once('mt/Drop.php'); require_once('mt/Season.php'); @@ -39,7 +40,7 @@ class SeasonCardController extends BaseAuthedController { die(); } $this->propertyChgService = new services\PropertyChgService(); - $this->awardService = new services\AwardChgService(); + $this->awardService = new services\AwardService(); $this->userInfo = $this->_safeGetOrmUserInfo(); $this->seasonService = new services\SeasonService(); if (!$this->seasonService->checkSeason($this->userInfo)) { @@ -82,22 +83,30 @@ class SeasonCardController extends BaseAuthedController { public function getReward() { + $type = getReqVal('type', 0); $level = getReqVal('level', 0); $cardMeta = mt\SeasonCard::get($level); if ($level) { $this->_rspErr(1, 'level参数错误'); return; } + if (!in_array($type, array( + SeasonCard::NORMAL_PACKAGE_ID, + SeasonCard::VIP_PACKAGE_ID + ))) { + $this->_rspErr(1, 'type参数错误'); + return; + } if ($level > $this->seasonDb['card_lv']) { $this->_rspErr(2, '等级未解锁不可领取'); return; } - $cardDb = getXVal($this->seasonCardDb, $level); + $cardDb = getXVal($this->seasonCardDb[$type], $level); if ($cardDd) { $this->_rspErr(3, '不能重复领取'); return; } - SeasonCard::add($this->currSeasonMeta['id'], $level); + SeasonCard::add($this->currSeasonMeta['id'], $type, $level); $this->_rspData(array( 'award' => $this->awardService->toDto(), 'property_chg' => $this->propertyChgService->toDto(), @@ -150,12 +159,12 @@ class SeasonCardController extends BaseAuthedController { $this->_rspErr(2, '不能重复购买'); return; } - $priceInfo = $giftPackage['priceInfo']; + $priceInfo = $giftPackage['price_info']; if (empty($priceInfo)) { $this->_rspErr(3, '配置表错误'); return; } - $itemMeta = mt\Item::get($priceInfo['item_id']); + $itemMeta = mt\Item::get($giftPackage['item_id']); if (empty($itemMeta)) { $this->_rspErr(3, '配置表错误1'); return; @@ -165,7 +174,7 @@ class SeasonCardController extends BaseAuthedController { $this->_rspErr(3, '配置表错误3'); return; } - $costItems = $this->getCostItems($priceInfo, $costItemId); + $costItems = mt\Item::getCostItems($priceInfo, $costItemId); if (empty($costItems)) { $this->_rspErr(3, '配置表错误2'); return; @@ -192,9 +201,12 @@ class SeasonCardController extends BaseAuthedController { $itemMeta = mt\Item::get(SeasonCard::VIP_PACKAGE_ITEM_ID); $priceInfo = $itemMeta ? mt\Item::getPriceInfo($itemMeta) : null; $giftPackages = array( - 'package_id' => SeasonCard::VIP_PACKAGE_ID, - 'state' => $this->seasonDb['gift_state2'], - 'price_info' => $priceInfo + array( + 'package_id' => SeasonCard::VIP_PACKAGE_ID, + 'item_id' => SeasonCard::VIP_PACKAGE_ITEM_ID, + 'state' => $this->seasonDb['gift_state2'], + 'price_info' => $priceInfo ? $priceInfo['price_info'] : null + ) ); return $giftPackages; } diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index e9e19a3..5fefe04 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -86,7 +86,7 @@ class ShopController extends BaseAuthedController { } $priceInfo = mt\Item::getPriceInfo($itemMeta); if (!empty($priceInfo)) { - $goodsDto['price_info'] = $priceInfo; + $goodsDto['price_info'] = $priceInfo['price_info']; array_push($goodsDtoList1, $goodsDto); } } @@ -219,7 +219,7 @@ class ShopController extends BaseAuthedController { { $priceInfo = mt\Item::getPriceInfo($itemMeta); if (!empty($priceInfo)) { - $goodsDto['price_info'] = $priceInfo; + $goodsDto['price_info'] = $priceInfo['price_info']; } } $propertyChgService->addUserChg(); @@ -389,7 +389,7 @@ class ShopController extends BaseAuthedController { ); $priceInfo = mt\Item::getPriceInfo($val); if (!empty($priceInfo)) { - $goodsDto['price_info'] = $priceInfo; + $goodsDto['price_info'] = $priceInfo['price_info']; array_push($goodsDtoList1, $goodsDto); } }); diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index 92c00fc..7204883 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -134,6 +134,41 @@ class Item { return $info; } + public static function getCostItems($priceInfo, $costItemId) + { + $costGroup = null; + array_walk($priceInfo['cost_list'], function ($val) use(&$costGroup, $costItemId) { + if ($costGroup) { + return; + } + if (count($val) > 0 && $val[0]['item_id'] == $costItemId) { + $costGroup = $val; + return; + } + }); + if (!$costGroup) { + return null; + } + $costItems = array(); + array_walk($costGroup, function ($val) use (&$costItems, $priceInfo) { + if ($val['discount'] > 0 && + myself()->_getNowTime() >= $priceInfo['discount_begin_time'] && + myself()->_getNowTime() <= $priceInfo['discount_end_time'] + ) { + array_push($costItems, array( + 'item_id' => $val['item_id'], + 'item_num' => (int)($val['item_num'] * ($priceInfo['discount'] / 100)), + )); + } else { + array_push($costItems, array( + 'item_id' => $val['item_id'], + 'item_num' => $val['item_num'], + )); + } + }); + return $costItems; + } + public static function isBagItem($type, $subType) { return in_array($type, array(