diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index 94e132a0..a47c83a7 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -250,6 +250,17 @@ class BagController extends BaseAuthedController { { $errCode = 0; $errMsg = ''; + $targetUniId = $param1; + $targetDb = Bag::findByUniId($targetUniId); + if (!$targetDb) { + $this->_rspErr(1, "You don't have the item yet"); + return; + } + Bag::decItemByUnIid($itemDb['item_uniid'], $itemNum); + $this->propertyChgService->addBagChg(); + $this->_rspData(array( + 'property_chg' => $this->propertyChgService->toDto(), + )); } } diff --git a/webapp/models/Bag.php b/webapp/models/Bag.php index cb1d180b..9ed0a12f 100644 --- a/webapp/models/Bag.php +++ b/webapp/models/Bag.php @@ -24,6 +24,19 @@ class Bag extends BaseModel { return $row; } + public static function findByUniId($itemUniId) + { + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_bag', + array( + 'account_id' => myself()->_getAccountId(), + 'idx' => $itemUniId, + ) + ); + return $row; + } + public static function findByType($type, $subType = null) { foreach (self::all() as $itemDto) {