From 04a4426e4c31f1ca59edbee80497ec418bde2415 Mon Sep 17 00:00:00 2001 From: yangduo Date: Wed, 25 Sep 2024 11:44:41 +0800 Subject: [PATCH 1/5] vip details --- doc/AAMarket.py | 18 ++++++++++++++++-- doc/_common.py | 9 +++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/AAMarket.py b/doc/AAMarket.py index cd5ae833..5ad03109 100644 --- a/doc/AAMarket.py +++ b/doc/AAMarket.py @@ -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', diff --git a/doc/_common.py b/doc/_common.py index 9085bfc8..e65e11f3 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -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则已是最高等级'], + ] From 92ce24b773ec737480ac128ed5ed5d894538a667 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 25 Sep 2024 11:48:29 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E5=85=85=E5=80=BC?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/controller/ShopController.class.php | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 1f054cfd..6cc46eb8 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -196,6 +196,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 +312,5 @@ class ShopController extends BaseAuthedController { $propertyChgService); } + } From 020b0e92bb69cb758f6be80614882d701b634df7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 25 Sep 2024 14:20:28 +0800 Subject: [PATCH 3/5] 1 --- doc/Shop.py | 48 +++++++++++++++++++++- webapp/controller/ShopController.class.php | 2 +- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/doc/Shop.py b/doc/Shop.py index 060283a8..dce3005d 100644 --- a/doc/Shop.py +++ b/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:支付失败'], + ] + }, ] diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 6cc46eb8..14bb9908 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -197,7 +197,7 @@ class ShopController extends BaseAuthedController { } -public function inappPurchase() + public function inappPurchase() { $goodsId = getReqVal('goods_id', 0); $goodsNum = getReqVal('goods_num', 0); From 7d40e0e06c7d1d8670c18d26723c9f8320227d55 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 25 Sep 2024 14:23:57 +0800 Subject: [PATCH 4/5] 1 --- webapp/controller/ShopController.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 14bb9908..4ebc825a 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -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; From 69fb15167379c555685908a23ddf89dc2474225d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 25 Sep 2024 14:59:08 +0800 Subject: [PATCH 5/5] 1 --- doc/AALogin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/AALogin.py b/doc/AALogin.py index b1f213f4..a667caed 100644 --- a/doc/AALogin.py +++ b/doc/AALogin.py @@ -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(),