This commit is contained in:
aozhiwei 2023-08-02 13:00:33 +08:00
parent d76d663e04
commit 1914112edf
2 changed files with 18 additions and 2 deletions

View File

@ -1307,9 +1307,9 @@ DROP TABLE IF EXISTS `t_inapp_record`;
CREATE TABLE `t_inapp_record` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`amount` bigint NOT NULL DEFAULT '0' COMMENT '充值总额',
`amount` double NOT NULL DEFAULT '0' COMMENT '充值总额',
`buy_times` int(11) NOT NULL DEFAULT '0' COMMENT '充值次数',
`amount_ok` bigint NOT NULL DEFAULT '0' COMMENT '充值成功总额',
`amount_ok` double NOT NULL DEFAULT '0' COMMENT '充值成功总额',
`buy_ok_times` int(11) NOT NULL DEFAULT '0' COMMENT '充值成功次数',
`daytime` int(11) NOT NULL DEFAULT '0' COMMENT '时间',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',

View File

@ -237,6 +237,10 @@ class ShopController extends BaseAuthedController {
$platform = getReqVal('platform', 0);
$balance = $this->getInAppBalance();
if ($balance <= 0) {
$this->_rspErr(2, "insufficient available balance");
return;
}
$goodsMeta = mt\ShopGoods::getByGoodsUuid($goodsId);
if (!$goodsMeta) {
$this->_rspErr(2, "inapp purchase failed");
@ -258,8 +262,20 @@ class ShopController extends BaseAuthedController {
$this->_rspErr(1, "error paramater platform");
return;
}
$price = $goodsMeta['price'];
if (empty($price) || $pirce < 0.001) {
$this->_rspErr(1, "config error");
return;
}
$orderId = OrderId::gen();
InAppOrder::add(
$orderId,
$platform,
$goodsId,
$price
);
InAppRecord::addAmount($price);
$this->_rspData(array(
'order_id' => $order_id,
));