Merge branch 'hjb' of git.kingsome.cn:server/game2006api into hjb
This commit is contained in:
commit
88a601e477
@ -90,7 +90,7 @@ class AALogin(object):
|
||||
'is_json_params': True,
|
||||
'params': [
|
||||
['channel', '', '渠道id 1:immutable 2:游客'],
|
||||
['data', '', 'channel==1时传jwt channel=2时传客户端本地生成的id该id'],
|
||||
['data', '', 'channel==1时传jwt channel=2时传客户端本地生成的id该id channel=3洪亮聚合登录的jwt'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
|
@ -536,7 +536,7 @@ class AAMarket(object):
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': '/api/vip/bind',
|
||||
'desc': '充值-历史',
|
||||
'desc': '绑定vip',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/vip/bind',
|
||||
'is_json_params': True,
|
||||
@ -553,7 +553,7 @@ class AAMarket(object):
|
||||
{
|
||||
'method': 'GET',
|
||||
'name': '/api/vip/info',
|
||||
'desc': '充值-历史',
|
||||
'desc': 'vip绑定信息',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/vip/info',
|
||||
'headers': _common.JcJwtHeader,
|
||||
@ -564,6 +564,20 @@ class AAMarket(object):
|
||||
['info', _common.VipInfo(), 'vip信息'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'GET',
|
||||
'name': '/api/vip/details',
|
||||
'desc': 'vip等级详情',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/vip/details',
|
||||
'headers': _common.JcJwtHeader,
|
||||
'params': [
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['info', _common.VipLevelInfo(), 'vip等级信息'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'GET',
|
||||
'name': '/api/server_switch',
|
||||
|
48
doc/Shop.py
48
doc/Shop.py
@ -50,5 +50,51 @@ class Shop(object):
|
||||
['!items', [0], '宝箱物品列表'],
|
||||
['free_num', 0, '免费次数'],
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'queryInAppBalance',
|
||||
'desc': '查询当天内购限制余额',
|
||||
'group': 'Shop',
|
||||
'url': 'webapp/index.php?c=Shop&a=queryInAppBalance',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['balance', '', '美元'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'inappPurchase',
|
||||
'desc': '发起一个内购(购买钻石)',
|
||||
'group': 'Shop',
|
||||
'url': 'webapp/index.php?c=Shop&a=inappPurchase',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['goods_id', '', '商品唯一id'],
|
||||
['goods_num', 0, '商品数量'],
|
||||
['platform', 0, '平台 1:android 2:ios'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['order_id', '', '订单id'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'queryInAppPurchase',
|
||||
'desc': '查询内购(购买钻石)状态',
|
||||
'group': 'Shop',
|
||||
'url': 'webapp/index.php?c=Shop&a=queryInAppPurchase',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['order_id', '', '订单id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['order_id', '', '订单id'],
|
||||
['item_id', '', '商品id'],
|
||||
['item_num', 0, '商品数量'],
|
||||
['status', 0, '订单状态 0:未支付 1:已支付 2:支付失败'],
|
||||
]
|
||||
},
|
||||
]
|
||||
|
@ -1925,3 +1925,12 @@ class VipInfo(object):
|
||||
['bind_passport_address', 0, '绑定的passport地址'],
|
||||
['bind_email', 0, '绑定的email地址'],
|
||||
]
|
||||
|
||||
class VipLevelInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['level', 0, '当前等级'],
|
||||
['curpoint', 0, '当前点数'],
|
||||
['target', 0, '升级所需点数,如为-1则已是最高等级'],
|
||||
]
|
||||
|
@ -9,9 +9,9 @@ require_once('mt/ShopChest.php');
|
||||
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/ShopBuyRecord.php');
|
||||
require_once('models/InAppRecord.php');
|
||||
require_once('models/InAppOrder.php');
|
||||
require_once('models/OutAppOrder.php');
|
||||
require_once('models/InAppRecord.php');
|
||||
require_once('models/OrderId.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
@ -27,6 +27,8 @@ use mt\ShopGoods;
|
||||
use models\Hero;
|
||||
use models\ShopBuyRecord;
|
||||
use models\OrderId;
|
||||
use models\InAppRecord;
|
||||
use models\InAppOrder;
|
||||
|
||||
use services\LogService;
|
||||
use services\ShopService;
|
||||
@ -196,6 +198,105 @@ class ShopController extends BaseAuthedController {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function inappPurchase()
|
||||
{
|
||||
$goodsId = getReqVal('goods_id', 0);
|
||||
$goodsNum = getReqVal('goods_num', 0);
|
||||
$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");
|
||||
return;
|
||||
}
|
||||
if (!in_array($goodsMeta['shop_id'],
|
||||
array(
|
||||
mt\Shop::INAPP_SHOP_DIAMOND
|
||||
)
|
||||
)) {
|
||||
$this->_rspErr(3, "inapp purchase failed");
|
||||
return;
|
||||
}
|
||||
if ($goodsNum != 1) {
|
||||
$this->_rspErr(3, "goods_num error");
|
||||
return;
|
||||
}
|
||||
if ($goodsMeta['token_type'] != mt\Shop::TOKEN_TYPE_USD) {
|
||||
$this->_rspErr(3, "token_type config error");
|
||||
return;
|
||||
}
|
||||
if (!InAppOrder::isValidPlatform($platform)) {
|
||||
$this->_rspErr(1, "error paramater platform");
|
||||
return;
|
||||
}
|
||||
$price = $goodsMeta['price'];
|
||||
if (empty($price) || $price < 0.001) {
|
||||
$this->_rspErr(1, "config error");
|
||||
return;
|
||||
}
|
||||
|
||||
$orderId = OrderId::genInappOrderId();
|
||||
InAppOrder::add(
|
||||
$orderId,
|
||||
$platform,
|
||||
$goodsId,
|
||||
$price
|
||||
);
|
||||
InAppRecord::addAmount($price);
|
||||
$this->_rspData(array(
|
||||
'order_id' => $orderId,
|
||||
));
|
||||
}
|
||||
|
||||
public function queryInAppPurchase()
|
||||
{
|
||||
$orderId = getReqVal('order_id', '');
|
||||
$orderDb = InAppOrder::find($orderId);
|
||||
if (!$orderDb) {
|
||||
myself()->_rspErr(1, 'order not found');
|
||||
return;
|
||||
}
|
||||
$goodsMeta = mt\ShopGoods::get($orderDb['goods_id']);
|
||||
error_log(json_encode($orderDb));
|
||||
error_log(json_encode($goodsMeta));
|
||||
$this->_rspData(array(
|
||||
'order_id' => $orderDb['order_id'],
|
||||
'item_id' => $goodsMeta['item_id'],
|
||||
'item_num' => $goodsMeta['item_num'],
|
||||
'status' => $orderDb['status'],
|
||||
));
|
||||
}
|
||||
|
||||
public function queryInAppBalance()
|
||||
{
|
||||
myself()->_rspData(
|
||||
array(
|
||||
'balance' => $this->getInAppBalance()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function getInAppBalance()
|
||||
{
|
||||
$totalAmount = InAppRecord::getTotalAmount();
|
||||
$recordDb = InAppRecord::get();
|
||||
$upLimit = mt\Parameter::getVal('inapp_daily_up_limit', 0);
|
||||
$totalUpLimit = mt\Parameter::getVal('inapp_total_up_limit', 0);
|
||||
$todayAmount = 0;
|
||||
if ($recordDb) {
|
||||
$todayAmount = max($recordDb['amount'], $recordDb['amount_ok']);
|
||||
}
|
||||
$dailyBalance = max(0, $upLimit - $todayAmount);
|
||||
$totalBalance = max(0, $totalUpLimit - $totalAmount);
|
||||
return min($dailyBalance, $totalBalance);
|
||||
}
|
||||
|
||||
private function internalAddItem($awardService,
|
||||
$propertyChgService,
|
||||
$itemMeta,
|
||||
@ -213,4 +314,5 @@ class ShopController extends BaseAuthedController {
|
||||
$propertyChgService);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user