This commit is contained in:
songliang 2023-06-07 13:51:45 +08:00
parent 6422a83e21
commit c12d585d8c
3 changed files with 68 additions and 60 deletions

View File

@ -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(),
]
},
]

View File

@ -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){

View File

@ -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;