minQuantity > 0 && $item->maxQuantity > 0) { if($multiplier> 1){ throw new LogicException('倍率下,不能随机!'); } $minQty = max(1, $item->minQuantity); $maxQty = max($minQty, $item->maxQuantity); $processedItem->quantity = mt_rand($minQty, $maxQty); } else { $processedItem->quantity = max(1, $item->quantity) * $multiplier; } return $processedItem; } }