当前位置: 首页>>代码示例>>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;未经允许,请勿转载。