This commit is contained in:
aozhiwei 2021-11-30 15:17:41 +08:00
parent 1250c95864
commit eb5e3a3323
6 changed files with 156 additions and 21 deletions

View File

@ -21,10 +21,10 @@ class Shop(object):
]
},
{
'name': 'buy',
'desc': '购买英雄',
'name': 'buyGoods',
'desc': '购买商品',
'group': 'Shop',
'url': 'webapp/index.php?c=Shop&a=buy',
'url': 'webapp/index.php?c=Shop&a=buyGoods',
'params': [
_common.ReqHead(),
['shop_id', 0, '商店id'],
@ -37,4 +37,33 @@ class Shop(object):
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
{
'name': 'outsideBuy',
'desc': '购买道具(商店外购买)',
'group': 'Shop',
'url': 'webapp/index.php?c=Shop&a=outsideBuy',
'params': [
_common.ReqHead(),
['item_id', 0, '商品id'],
['cost_item_id', 0, '支付方式'],
],
'response': [
_common.RspHead(),
['award', _common.Award(), '奖励信息'],
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
{
'name': 'getOutsidePriceInfo',
'desc': '获取价格信息(商店外购买目前只有:英雄、英雄皮肤、枪支皮肤)',
'group': 'Shop',
'url': 'webapp/index.php?c=Shop&a=getOutsidePriceInfo',
'params': [
_common.ReqHead(),
],
'response': [
_common.RspHead(),
['!price_list', [_common.ItemPriceInfo()], '价格信息'],
]
},
]

View File

@ -104,21 +104,38 @@ class PropertyChg(object):
['user_info', UserInfo(), '用户信息变更(用来更新本地客户端字段(有则更新无则不变))']
]
class CostInfo(object):
class CostInfoItem(object):
def __init__(self):
self.fields = [
['cost_item_id', 0, '购买需要消耗的道具id'],
['cost_item_num', 0, '购买需要消耗的道具数量'],
['cost_item_is_discount', 0, '是否参与折扣'],
]
class CostInfo(object):
def __init__(self):
self.fields = [
['!cost_group', [CostInfoItem()], '一组扣费项目,(金币、钻石视为道具,可能有多种价格)'],
]
class PriceInfo(object):
def __init__(self):
self.fields = [
['!cost_items', [CostInfo()], '购买需要扣费道具信息(金币、钻石视为道具,可能有多种价格)'],
['!cost_list', [CostInfo()], '扣费方式列表'],
['discount', 0, '折扣百分比0-100'],
['discount_left_time', 0, '折扣剩余时间(单位秒)'],
['discount_begin_time', 0, '折扣开始时间(utc时间)'],
['discount_end_time', 0, '折扣结束时间(utc时间)'],
]
class ItemPriceInfo(object):
def __init__(self):
self.fields = [
['item_id', 0, '道具id'],
['price_info', PriceInfo(), '价格信息'],
]
class Goods(object):

@ -1 +1 @@
Subproject commit 52c4b5f9309837f702d3ab36b30fef335094b1f6
Subproject commit 6efb9d7831e4e69a2f7e7b75ce44ccfb13b9b685

View File

@ -9,7 +9,7 @@ require_once('services/BaseService.php');
define('TEAMID_KEY', 'team_uuid:');
define('V_ITEM_GOLD', 10001); //金币
define('V_ITEM_DIAMOND', 10003); //钻石
define('V_ITEM_DIAMOND', 10002); //钻石
function getConfigBaseDir()
{

View File

@ -72,9 +72,32 @@ class ShopController extends BaseAuthedController {
));
}
public function buy()
public function outsideBuy()
{
}
public function getOutsidePriceInfo()
{
$items = array();
{
$types = array(mt\Item::HERO_TYPE,
mt\Item::HERO_SKIN_TYPE,
mt\Item::GUN_SKIN_TYPE);
mt\Item::filter(function ($meta) use(&$items, &$types) {
if (in_array($meta['type'], $types)) {
array_push($items, $meta);
}
return true;
});
}
$priceList = array();
array_walk($items, function ($val) use(&$priceList) {
array_push($priceList, mt\Item::getPriceInfo($val));
});
$this->_rspData(array(
'price_list' => $priceList
));
}
}

View File

@ -6,7 +6,52 @@ use phpcommon;
class Item {
const SKIN_TYPE = 12;
/*
0 无功能
1 金币
2 钻石
3 角色账号经验
4 权限类
5 英雄
6 皮肤
7 头像
8 头像框
9 枪械
10 材料
11 改名卡
12 喇叭
13 礼包
14 碎片
15 日活跃
16 周活跃
17 手册经验
18 工会经验
19 工会改名卡
20 英雄熟练度(预留)
*/
const NONE_TYPE = 0;
const GOLD_TYPE = 1;
const DIAMOND_TYPE = 2;
const EXP_TYPE = 3;
const PERMISSION_TYPE = 4;
const HERO_TYPE = 5;
const HERO_SKIN_TYPE = 6;
const HEAD_TYPE = 7;
const HEAD_FRAME_TYPE = 8;
const GUN_TYPE = 9;
const GUN_SKIN_TYPE = 10;
const MATERIAL_TYPE = 11;
const HORN_TYPE = 12;
const RENAME_CARD_TYPE = 13;
const GIFT_PACKAGE_TYPE = 14;
const FRAGMENT_TYPE = 15;
const DAILY_ACTIVE_TYPE = 16;
const WEAKLY_ACTIVE_TYPE = 17;
const HANDBOOK_EXP_TYPE = 18;
const GUILD_EXP_TYPE = 19;
const GUILD_RENAME_CARD_TYPE = 20;
const HERO_EXP_TYPE = 21;
public static function get($id)
{
@ -18,20 +63,41 @@ class Item {
return $meta['type'] == $type;
}
public static function getOldItem($id)
public static function filter($cb)
{
$meta = self::get($id);
if (!$meta) {
return null;
foreach (self::getMetaList() as $meta) {
if (!$cb($meta)) {
return;
}
}
$item = array();
foreach ($meta as $key => $val) {
$item[$key] = $val;
}
public static function getPriceInfo($meta)
{
$info = array(
'item_id' => $meta['id'],
'price_info' => array(
'cost_list' => array(),
'discount' => (int)$meta['discount'],
'discount_begin_time' => phpcommon\datetimeToTimestamp($meta['discount_begin']),
'discount_end_time' => phpcommon\datetimeToTimestamp($meta['discount_end'])
)
);
if ($meta['gold'] > 0) {
array_push($info['price_info']['cost_list'],
array(
'cost_item_id' => V_ITEM_GOLD,
'cost_item_num' => $meta['gold']
));
}
$item['type'] = $item['fuction'];
$item['price'] = $item['gold'];
$item['dprice'] = $item['diamond_price'];
return $item;
if ($meta['diamond_price'] > 0) {
array_push($info['price_info']['cost_list'],
array(
'cost_item_id' => V_ITEM_DIAMOND,
'cost_item_num' => $meta['diamond_price']
));
}
return $info;
}
protected static function getMetaList()