當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inventory::Model方法代碼示例

本文整理匯總了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);
         }
     }
 }
開發者ID:Covert-Inferno,項目名稱:prohd,代碼行數:44,代碼來源:APITransactions.php

示例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}");
 }
開發者ID:Covert-Inferno,項目名稱:prohd,代碼行數:25,代碼來源:WalletController.php


注:本文中的Inventory::Model方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。