本文整理汇总了PHP中Inventory::Model方法的典型用法代码示例。如果您正苦于以下问题:PHP Inventory::Model方法的具体用法?PHP Inventory::Model怎么用?PHP Inventory::Model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::Model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: subtractStock
public function subtractStock($orderRow, $quantity, $walletID)
{
//Grab the characters from the db
try {
$trackingGroup = $this->getUsersGroup($walletID);
} catch (Exception $e) {
$trackingGroup = 1;
}
$members = $this->getMembersAsArray($trackingGroup);
$sqlarray = '(' . implode(',', $members) . ')';
$criteria = new CDbCriteria();
$criteria->condition = "typeID=:typeID AND remaining > 0 AND characterID IN " . $sqlarray;
$criteria->params = array(":typeID" => $orderRow->typeID);
$criteria->order = "transactionDateTime DESC";
$stock = Inventory::Model()->find($criteria);
if ($stock != NULL) {
//Check to see if the quantity we need to subtract is greater than this record
if ($quantity >= $stock->remaining) {
$stockLeft = $stock->remaining;
$stock->remaining = 0;
$stock->save();
$log = new InventoryLog();
$log->sourceTransactionID = $orderRow->transactionID;
$log->targetTransactionID = $stock->transactionID;
$log->quantity = $stockLeft;
$log->save();
} else {
$stock->remaining = $stock->remaining - $quantity;
$stock->save();
$log = new InventoryLog();
$log->sourceTransactionID = $orderRow->transactionID;
$log->targetTransactionID = $stock->transactionID;
$log->quantity = $quantity;
$log->save();
}
$quantity = $quantity - $stock->quantity;
//If we're out of stock to remove
if ($quantity <= 0) {
return;
} else {
$this->subtractStock($orderRow, $quantity);
}
}
}
示例2: actionPersonal
public function actionPersonal($page, $id)
{
//Fetch the sale
$criteria = new CDbCriteria();
$criteria->condition = 'transactionID=:transactionID';
$criteria->params = array(':transactionID' => $id);
$transaction = Wallet::Model()->find($criteria);
$stock = Inventory::Model()->findByPk($id);
if ($transaction->personal) {
$transaction->personal = 0;
$transaction->save();
if ($stock != NULL) {
$stock->personal = 0;
$stock->save();
}
} else {
$transaction->personal = 1;
$transaction->save();
if ($stock != NULL) {
$stock->personal = 1;
$stock->save();
}
}
$this->redirect("index.php?r=wallet/index&Wallet_page={$page}");
}