This commit is contained in:
aozhiwei 2023-07-31 19:21:43 +08:00
parent 4a23448961
commit 6fe6eac13d

View File

@ -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);
}
}