1
This commit is contained in:
parent
bc71f81cbd
commit
639d10d657
@ -110,7 +110,7 @@ class CostInfoItem(object):
|
||||
self.fields = [
|
||||
['item_id', 0, '购买需要消耗的道具id'],
|
||||
['item_num', 0, '购买需要消耗的道具数量'],
|
||||
['is_discount', 0, '是否参与折扣'],
|
||||
['discount', 0, '折扣百分比(0-100)'],
|
||||
]
|
||||
|
||||
class CostInfo(object):
|
||||
@ -125,7 +125,6 @@ class PriceInfo(object):
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['!cost_list', [CostInfo()], '扣费方式列表'],
|
||||
['discount', 0, '折扣百分比(0-100)'],
|
||||
['discount_begin_time', 0, '折扣开始时间(utc时间)'],
|
||||
['discount_end_time', 0, '折扣结束时间(utc时间)'],
|
||||
]
|
||||
@ -134,8 +133,9 @@ class DiscountInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['item_id', 0, '购买需要消耗的道具id'],
|
||||
['discount', 0, '折扣百分比(0-100)'],
|
||||
['item_id', 0, '道具id'],
|
||||
['gold_discount', 0, '金币折扣百分比(0-100)'],
|
||||
['diamond_discount', 0, '钻石折扣百分比(0-100)'],
|
||||
]
|
||||
|
||||
class ItemPriceInfo(object):
|
||||
|
@ -196,6 +196,55 @@ class ShopController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
public function getDiscountList()
|
||||
{
|
||||
$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 (mt\Item::inTypes($meta, $types)) {
|
||||
array_push($items, $meta);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
$goodsDtoList = array();
|
||||
array_walk($items, function ($val) use(&$priceList, &$goodsDtoList) {
|
||||
$goodsDto = array(
|
||||
'item_id' => $val['id'],
|
||||
'gold_discount' => 0,
|
||||
'diamond_discount' => 0,
|
||||
);
|
||||
$priceInfo = mt\Item::getPriceInfo($val);
|
||||
if (!empty($priceInfo)) {
|
||||
foreach ($priceInfo['price_info']['cost_list'] as $cost) {
|
||||
if ($cost['discount'] > 0) {
|
||||
switch ($cost['item_id']) {
|
||||
case V_ITEM_GOLD:
|
||||
{
|
||||
$goodsDto['gold_discount'] = $cost['discount'];
|
||||
}
|
||||
break;
|
||||
case V_ITEM_DIAMOND:
|
||||
{
|
||||
$goodsDto['diamond_discount'] = $cost['discount'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($goodsDto['gold_discount'] > 0 || $goodsDto['diamond_discount'] > 0) {
|
||||
array_push($goodsDtoList, $goodsDto);
|
||||
}
|
||||
}
|
||||
});
|
||||
$this->_rspData(array(
|
||||
'goods_list' => $goodsDtoList,
|
||||
));
|
||||
}
|
||||
|
||||
private function outsideBuy($shopId, $itemId, $itemNum, $costItemId)
|
||||
{
|
||||
$itemMeta = mt\Item::get($itemId);
|
||||
|
@ -87,17 +87,17 @@ class Item {
|
||||
'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'])
|
||||
)
|
||||
);
|
||||
$discount = splitStr1($meta['discount']);
|
||||
if ($meta['gold'] > 0) {
|
||||
array_push($info['price_info']['cost_list'],
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $meta['gold'],
|
||||
'is_discount' => 1
|
||||
'discount' => count($discount) > 0 ? (int)$discount[0] : 0
|
||||
));
|
||||
}
|
||||
if ($meta['diamond_price'] > 0) {
|
||||
@ -105,7 +105,7 @@ class Item {
|
||||
array(
|
||||
'item_id' => V_ITEM_DIAMOND,
|
||||
'item_num' => $meta['diamond_price'],
|
||||
'is_discount' => 1
|
||||
'discount' => count($discount) > 1 ? (int)$discount[1] : 0
|
||||
));
|
||||
}
|
||||
return $info;
|
||||
|
Loading…
x
Reference in New Issue
Block a user