This commit is contained in:
aozhiwei 2021-11-30 16:44:41 +08:00
parent de97c91d2a
commit 6a35185fdf
3 changed files with 19 additions and 19 deletions

View File

@ -108,9 +108,9 @@ class CostInfoItem(object):
def __init__(self): def __init__(self):
self.fields = [ self.fields = [
['cost_item_id', 0, '购买需要消耗的道具id'], ['item_id', 0, '购买需要消耗的道具id'],
['cost_item_num', 0, '购买需要消耗的道具数量'], ['item_num', 0, '购买需要消耗的道具数量'],
['cost_item_is_discount', 0, '是否参与折扣'], ['is_discount', 0, '是否参与折扣'],
] ]
class CostInfo(object): class CostInfo(object):

View File

@ -76,7 +76,7 @@ class ShopController extends BaseAuthedController {
{ {
$itemId = getReqVal('item_id', 0); $itemId = getReqVal('item_id', 0);
$itemNum = getReqVal('item_num', 0); $itemNum = getReqVal('item_num', 0);
$costItemId = getReqVal('cost_item_id', 0); $costItemId = getReqVal('item_id', 0);
$itemMeta = mt\Item::get($itemId); $itemMeta = mt\Item::get($itemId);
if (!$itemMeta) { if (!$itemMeta) {
@ -89,14 +89,14 @@ class ShopController extends BaseAuthedController {
} }
$costItemMeta = mt\Item::get($costItemId); $costItemMeta = mt\Item::get($costItemId);
if (!$costItemMeta) { if (!$costItemMeta) {
$this->_rspErr(1, 'cost_item_id参数错误'); $this->_rspErr(1, 'item_id参数错误');
return; return;
} }
$types = array(mt\Item::HERO_TYPE, $types = array(mt\Item::HERO_TYPE,
mt\Item::HERO_SKIN_TYPE, mt\Item::HERO_SKIN_TYPE,
mt\Item::GUN_SKIN_TYPE); mt\Item::GUN_SKIN_TYPE);
if (!mt\Item::inTypes($itemMeta, $types)) { if (!mt\Item::inTypes($itemMeta, $types)) {
$this->_rspErr(1, 'cost_item_id参数错误'); $this->_rspErr(1, 'item_id参数错误');
return; return;
} }
{ {
@ -130,7 +130,7 @@ class ShopController extends BaseAuthedController {
break; break;
default: default:
{ {
$this->_rspErr(1, 'cost_item_id参数错误'); $this->_rspErr(1, 'item_id参数错误');
return; return;
} }
break; break;
@ -193,7 +193,7 @@ class ShopController extends BaseAuthedController {
if ($costGroup) { if ($costGroup) {
return; return;
} }
if (count($val) > 0 && $val[0]['cost_item_id'] == $costItemId) { if (count($val) > 0 && $val[0]['item_id'] == $costItemId) {
$costGroup = $val; $costGroup = $val;
return; return;
} }
@ -203,19 +203,19 @@ class ShopController extends BaseAuthedController {
} }
$costItems = array(); $costItems = array();
array_walk($costGroup, function ($val) use (&$costItems, $priceInfo) { array_walk($costGroup, function ($val) use (&$costItems, $priceInfo) {
if ($val['cost_item_is_discount'] && if ($val['is_discount'] &&
$priceInfo['discount'] > 0 && $priceInfo['discount'] > 0 &&
$this->_getNowTime() >= $priceInfo['discount_begin_time'] && $this->_getNowTime() >= $priceInfo['discount_begin_time'] &&
$this->_getNowTime() <= $priceInfo['discount_end_time'] $this->_getNowTime() <= $priceInfo['discount_end_time']
) { ) {
array_push($costItems, array( array_push($costItems, array(
'item_id' => $val['cost_item_id'], 'item_id' => $val['item_id'],
'item_num' => (int)($val['cost_item_num'] * ($priceInfo['discount'] / 100)), 'item_num' => (int)($val['item_num'] * ($priceInfo['discount'] / 100)),
)); ));
} else { } else {
array_push($costItems, array( array_push($costItems, array(
'item_id' => $val['cost_item_id'], 'item_id' => $val['item_id'],
'item_num' => $val['cost_item_num'], 'item_num' => $val['item_num'],
)); ));
} }
}); });

View File

@ -91,17 +91,17 @@ class Item {
if ($meta['gold'] > 0) { if ($meta['gold'] > 0) {
array_push($info['price_info']['cost_list'], array_push($info['price_info']['cost_list'],
array( array(
'cost_item_id' => V_ITEM_GOLD, 'item_id' => V_ITEM_GOLD,
'cost_item_num' => $meta['gold'], 'item_num' => $meta['gold'],
'cost_item_is_discount' => 1 'is_discount' => 1
)); ));
} }
if ($meta['diamond_price'] > 0) { if ($meta['diamond_price'] > 0) {
array_push($info['price_info']['cost_list'], array_push($info['price_info']['cost_list'],
array( array(
'cost_item_id' => V_ITEM_DIAMOND, 'item_id' => V_ITEM_DIAMOND,
'cost_item_num' => $meta['diamond_price'], 'item_num' => $meta['diamond_price'],
'cost_item_is_discount' => 1 'is_discount' => 1
)); ));
} }
return $info; return $info;