diff --git a/doc/Shop.py b/doc/Shop.py index 0b72127..3a69501 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -29,12 +29,27 @@ class Shop(object): _common.ReqHead(), ['shop_id', 0, '商店id shop_id=100特殊商店id'], ['goods_id', 0, '商品id'], + ['goods_num', 0, '商品数量'], ['cost_item_id', 0, '支付方式'], ], 'response': [ _common.RspHead(), ['award', _common.Award(), '奖励信息'], ['property_chg', _common.PropertyChg(), '属性变更'], + ['goods_chg', _common.Goods(), '购买后更新商品的最新信息'], + ] + }, + { + 'name': 'getDiscountList', + 'desc': '获取商品折扣列表', + 'group': 'Shop', + 'url': 'webapp/index.php?c=Shop&a=getDiscountList', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!goods_list', [_common.DiscountInfo()], '折扣的商品列表'], ] }, ] diff --git a/doc/_common.py b/doc/_common.py index f066ccb..f61027e 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -130,6 +130,14 @@ class PriceInfo(object): ['discount_end_time', 0, '折扣结束时间(utc时间)'], ] +class DiscountInfo(object): + + def __init__(self): + self.fields = [ + ['item_id', 0, '购买需要消耗的道具id'], + ['discount', 0, '折扣百分比(0-100)'], + ] + class ItemPriceInfo(object): def __init__(self): diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 8103f7f..b31ef6c 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -97,8 +97,13 @@ class ShopController extends BaseAuthedController { $goodsId = getReqVal('goods_id', 0); $itemNum = getReqVal('goods_num', 0); $costItemId = getReqVal('cost_item_id', 0); - $itemId = $goodsId; + + if ($shopId == mt\Shop::OUTSIDE_SHOP) { + $this->outsideBuy($shopId, $itemId, $itemNum, $costItemId); + return; + } + $itemMeta = mt\Item::get($itemId); if (!$itemMeta) { $this->_rspErr(1, 'goods_id参数错误'); @@ -191,12 +196,8 @@ class ShopController extends BaseAuthedController { )); } - private function outsideBuy() + private function outsideBuy($shopId, $itemId, $itemNum, $costItemId) { - $itemId = getReqVal('item_id', 0); - $itemNum = getReqVal('item_num', 0); - $costItemId = getReqVal('cost_item_id', 0); - $itemMeta = mt\Item::get($itemId); if (!$itemMeta) { $this->_rspErr(1, 'item_id参数错误');