diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index fa6cbc6a..d79bf6b4 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -221,19 +221,9 @@ class ShopController extends BaseAuthedController { public function queryInAppBalance() { - $recordDb = InAppRecord::get(); - $upLimit = mt\Parameter::getVal('inapp_up_limit', 0); - if (!$recordDb) { - myself()-_rspData( - array( - 'balance' => $upLimit - ) - ); - return; - } myself()-_rspData( array( - 'balance' => max(0, $recordDb ? $upLimit - $recordDb['amount'] : 0) + 'balance' => $this->getInAppBalance() ) ); } @@ -242,6 +232,8 @@ class ShopController extends BaseAuthedController { { $goodsId = getReqVal('goods_id', 0); $goodsNum = getReqVal('goods_num', 0); + $balance = $this->getInAppBalance(); + $goods = mt\ShopGoods::getByGoodsUuid($goodsId); if (!$goods) { $this->_rspErr(2, "inapp purchase failed"); @@ -251,11 +243,10 @@ class ShopController extends BaseAuthedController { $this->_rspErr(3, "inapp purchase failed"); return; } - - $item_id = $goods['goods_id']; - $item_num = $goods['goods_num'] * $goodsNum; - - $conn = $self->_getMysql(''); + if ($goodsNum != 1) { + $this->_rspErr(3, "goods_num error"); + return; + } $chk = SqlHelper::insert($conn, 't_web2_order', array( 'status' => 0, @@ -429,4 +420,11 @@ class ShopController extends BaseAuthedController { $cbService->dispatch($action); } + private function getInAppBalance() + { + $recordDb = InAppRecord::get(); + $upLimit = mt\Parameter::getVal('inapp_up_limit', 0); + return max(0, $recordDb ? $upLimit - $recordDb['amount'] : 0); + } + }