From c12d585d8c63ce5208a0c36c9901fb78fdf42d94 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 7 Jun 2023 13:51:45 +0800 Subject: [PATCH] ... --- doc/Shop.py | 16 +++ .../controller/BaseAuthedController.class.php | 4 +- webapp/controller/ShopController.class.php | 108 ++++++++---------- 3 files changed, 68 insertions(+), 60 deletions(-) diff --git a/doc/Shop.py b/doc/Shop.py index eb20a346..ec2c3f7e 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -96,5 +96,21 @@ class Shop(object): ['goods_chg', _common.NewGoods(), '购买后更新商品的最新信息(可能为null客户端需要做容错处理)'], ] }, + { + 'name': 'buyGoodsDirect', + 'desc': '直接购买(充值,gold)', + 'group': 'Shop', + 'url': 'webapp/index.php?c=Shop&a=buyGoodsDirect', + 'params': [ + _common.ReqHead(), + ['id', 0, '商品唯一id,参见shopGoods表'], + ['token_type', '', "选用币种"], + ['goods_num', 0, '商品数量'], + ], + 'response': [ + _common.RspHead(), + ] + }, + ] diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index e435fd0a..7323e755 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -35,7 +35,7 @@ use models\Chip; class BaseAuthedController extends BaseController { - private $accountId = ''; + protected $accountId = ''; private $sessionId = ''; private $mysqlConn = null; private $address = null; @@ -106,7 +106,7 @@ class BaseAuthedController extends BaseController { }*/ } - private function _userLvRestriction(){ + protected function _userLvRestriction(){ $userDb = $this->_getOrmUserInfo(); $controller = getReqVal('c', ''); switch ($controller){ diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 1f264daa..58146cbf 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -50,24 +50,27 @@ class ShopController extends BaseAuthedController public function _handlePre() { -// if (SERVER_ENV == _ONLINE) { -// if (getReqVal('client_uuid', '') != '499af8a0-a1bc-0b0e-dc79-a42cb3f103dc') { -// if ((getReqVal('c', '') != 'Battle')) { -// phpcommon\sendError(1001, 'session expiration'); -// die(); -// } -// } -// } - + // if (SERVER_ENV == _ONLINE) { + // if (getReqVal('client_uuid', '') != '499af8a0-a1bc-0b0e-dc79-a42cb3f103dc') { + // if ((getReqVal('c', '') != 'Battle')) { + // phpcommon\sendError(1001, 'session expiration'); + // die(); + // } + // } + // } + + $this->accountId = getReqVal('account_id', ''); if (getReqVal('c', '') == 'Shop' && getReqVal('a', '') == 'buyGoodsDirect') { $this->_userLvRestriction(); return; } - $this->accountId = getReqVal('account_id', ''); + // $this->accountId = getReqVal('account_id', ''); $this->sessionId = getReqVal('session_id', ''); - if (!phpcommon\isValidSessionId($this->accountId, - $this->sessionId)) { + if (!phpcommon\isValidSessionId( + $this->accountId, + $this->sessionId + )) { phpcommon\sendError(500, 'invalid session_id'); die(); } @@ -78,8 +81,10 @@ class ShopController extends BaseAuthedController $r = $this->_getRedis($this->_getAccountId()); $sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId()); if (empty($sessionId)) { - $this->updateSession(myself()->_getAccountId(), - myself()->_getSessionId()); + $this->updateSession( + myself()->_getAccountId(), + myself()->_getSessionId() + ); } else if ($sessionId != $this->_getSessionId()) { error_log('session expiration' . json_encode( $_REQUEST @@ -452,46 +457,28 @@ class ShopController extends BaseAuthedController $awardService->addItem($row['goods_id'], $goods_num); ShopBuyRecord::add($id, $goods_num); - $goodsDto = array( - 'goods_id' => $id, - 'item_id' => $row['goods_id'], - 'price_info' => array( - 'item_id' => $row['goods_id'], - 'cost_list' => array(), - 'discount_begin_time' => phpcommon\datetimeToTimestamp($row['discount_begin']), - 'discount_end_time' => phpcommon\datetimeToTimestamp($row['discount_end']) - ), - 'flag_icon' => $row['tag'], - 'limit_type' => $row['limit_type'], - 'bought_times' => $boughtTimes, - 'total_buy_times' => $row['limit_num'], - ); { - $priceInfo = mt\Item::getPriceInfo($itemMeta); - if (!empty($priceInfo)) { - $goodsDto['price_info'] = $priceInfo['price_info']; - } - } - $propertyChgService->addUserChg(); - - $aa = $awardService->toDto(); - $bb = $propertyChgService->toDto(); - $cc = $goodsDto; + // $goodsDto = array( + // 'goods_id' => $id, + // 'item_id' => $row['goods_id'], + // 'price_info' => array( + // 'item_id' => $row['goods_id'], + // 'cost_list' => array(), + // 'discount_begin_time' => phpcommon\datetimeToTimestamp($row['discount_begin']), + // 'discount_end_time' => phpcommon\datetimeToTimestamp($row['discount_end']) + // ), + // 'flag_icon' => $row['tag'], + // 'limit_type' => $row['limit_type'], + // 'bought_times' => $boughtTimes, + // 'total_buy_times' => $row['limit_num'], + // ); { + // $priceInfo = mt\Item::getPriceInfo($itemMeta); + // if (!empty($priceInfo)) { + // $goodsDto['price_info'] = $priceInfo['price_info']; + // } + // } + // $propertyChgService->addUserChg(); - $this->_rspData( - array( - 'award' => $aa, - 'property_chg' => $bb, - 'goods_chg' => $cc - ) - ); - - // $this->_rspData( - // array( - // 'award' => $awardService->toDto(), - // 'property_chg' => $propertyChgService->toDto(), - // 'goods_chg' => $goodsDto - // ) - // ); + $this->_rspOk(); break; case ShopController::TOKEN_TYPE_BUSD: case ShopController::TOKEN_TYPE_MATIC: @@ -983,11 +970,16 @@ class ShopController extends BaseAuthedController } break; default: { - Bag::addItem($itemMeta['id'], $count); - $propertyChgService->addBagChg(); - // 充值就尝试开启首充活动 - if ($itemMeta['id'] == 10001) { - $this->beginFirstTupop(); + if ($this->_isVirtualItem($itemMeta['id'])) { + $this->_addVirtualItem($itemMeta['id'], $count, null, $propertyChgService); + $propertyChgService->addUserChg(); + // 充值就尝试开启首充活动 + if ($itemMeta['id'] == 10001) { + $this->beginFirstTupop(); + } + } else { + Bag::addItem($itemMeta['id'], $count); + $propertyChgService->addBagChg(); } } break;