This commit is contained in:
aozhiwei 2021-12-24 14:37:35 +08:00
parent 1d35055236
commit 2d0f82241a
2 changed files with 5 additions and 6 deletions

View File

@ -185,6 +185,7 @@ class BagController extends BaseAuthedController {
return; return;
} }
$costItems = mt\Item::getUseCostItems($itemMeta); $costItems = mt\Item::getUseCostItems($itemMeta);
error_log(json_encode($costItems));
$lackItem = null; $lackItem = null;
if (!$this->_hasEnoughItems($costItems, $lackItem)) { if (!$this->_hasEnoughItems($costItems, $lackItem)) {
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));

View File

@ -172,13 +172,11 @@ class Item {
public static function getUseCostItems($itemMeta) public static function getUseCostItems($itemMeta)
{ {
$costItems = array(); $costItems = array();
$tmpStrs1 = splitStr1($itemMeta['use_cost']); foreach (splitStr2($itemMeta['use_cost']) as $arr) {
foreach ($tmpStrs1 as $tmpStr1) { if (count($arr) >= 2) {
$tmpStrs2 = splitStr2($tmpStr1);
if (count($tmpStrs2) >= 2) {
array_push($costItems, array( array_push($costItems, array(
'item_id' => $tmpStrs2[0], 'item_id' => $arr[0],
'item_num' => $tmpStrs2[1] 'item_num' => $arr[1]
)); ));
} }
} }