1
This commit is contained in:
parent
4a23448961
commit
6fe6eac13d
@ -221,19 +221,9 @@ class ShopController extends BaseAuthedController {
|
|||||||
|
|
||||||
public function queryInAppBalance()
|
public function queryInAppBalance()
|
||||||
{
|
{
|
||||||
$recordDb = InAppRecord::get();
|
|
||||||
$upLimit = mt\Parameter::getVal('inapp_up_limit', 0);
|
|
||||||
if (!$recordDb) {
|
|
||||||
myself()-_rspData(
|
|
||||||
array(
|
|
||||||
'balance' => $upLimit
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
myself()-_rspData(
|
myself()-_rspData(
|
||||||
array(
|
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);
|
$goodsId = getReqVal('goods_id', 0);
|
||||||
$goodsNum = getReqVal('goods_num', 0);
|
$goodsNum = getReqVal('goods_num', 0);
|
||||||
|
$balance = $this->getInAppBalance();
|
||||||
|
|
||||||
$goods = mt\ShopGoods::getByGoodsUuid($goodsId);
|
$goods = mt\ShopGoods::getByGoodsUuid($goodsId);
|
||||||
if (!$goods) {
|
if (!$goods) {
|
||||||
$this->_rspErr(2, "inapp purchase failed");
|
$this->_rspErr(2, "inapp purchase failed");
|
||||||
@ -251,11 +243,10 @@ class ShopController extends BaseAuthedController {
|
|||||||
$this->_rspErr(3, "inapp purchase failed");
|
$this->_rspErr(3, "inapp purchase failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($goodsNum != 1) {
|
||||||
$item_id = $goods['goods_id'];
|
$this->_rspErr(3, "goods_num error");
|
||||||
$item_num = $goods['goods_num'] * $goodsNum;
|
return;
|
||||||
|
}
|
||||||
$conn = $self->_getMysql('');
|
|
||||||
|
|
||||||
$chk = SqlHelper::insert($conn, 't_web2_order', array(
|
$chk = SqlHelper::insert($conn, 't_web2_order', array(
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
@ -429,4 +420,11 @@ class ShopController extends BaseAuthedController {
|
|||||||
$cbService->dispatch($action);
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user