1
This commit is contained in:
parent
cb40c60c20
commit
cdedb2059a
@ -52,7 +52,7 @@ class ShopController extends BaseAuthedController {
|
||||
{
|
||||
$shopId = getReqVal('shop_id', 0);
|
||||
$goodsList = ShopService::getGoodsList($shopId);
|
||||
$this->_rspData(
|
||||
myself()->_rspData(
|
||||
array(
|
||||
'goods_list' => $goodsList,
|
||||
)
|
||||
@ -66,34 +66,34 @@ class ShopController extends BaseAuthedController {
|
||||
$goodsNum = getReqVal('goods_num', 0);
|
||||
|
||||
if ($goodsNum < 1) {
|
||||
$this->_rspErr(1, "goods_num parameter error, goods_num: {$goodsNum}");
|
||||
myself()->_rspErr(1, "goods_num parameter error, goods_num: {$goodsNum}");
|
||||
return;
|
||||
}
|
||||
|
||||
$goodsMeta = mt\ShopGoods::getByGoodsUuid($goodsUuid);
|
||||
if (!$goodsMeta) {
|
||||
$this->_rspErr(1, 'goods not found');
|
||||
myself()->_rspErr(1, 'goods not found');
|
||||
return;
|
||||
}
|
||||
if ($goodsNum > $goodsMeta['max_amount']) {
|
||||
$this->_rspErr(1, "goods_num parameter error, max_amount: {$goodsMeta['max_amount']}");
|
||||
myself()->_rspErr(1, "goods_num parameter error, max_amount: {$goodsMeta['max_amount']}");
|
||||
return;
|
||||
}
|
||||
$itemMeta = mt\Item::get($goodsMeta['item_id']);
|
||||
if (!$itemMeta) {
|
||||
$this->_rspErr(1, 'goods not found, goods_id: ' . $goodsMeta['goods_id']);
|
||||
myself()->_rspErr(1, 'goods not found, goods_id: ' . $goodsMeta['goods_id']);
|
||||
return;
|
||||
}
|
||||
$errCode = 0;
|
||||
$errMsg = '';
|
||||
if ($itemMeta['type'] == mt\Item::HERO_SKIN_TYPE) {
|
||||
if (!$this->canBuy($itemMeta, $errCode, $errMsg)) {
|
||||
$this->_rspErr($errCode, $errMsg);
|
||||
myself()->_rspErr($errCode, $errMsg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!ShopService::buyLimitCheck($goodsMeta, $errCode, $errMsg)) {
|
||||
$this->_rspErr($errCode, $errMsg);
|
||||
myself()->_rspErr($errCode, $errMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ class ShopController extends BaseAuthedController {
|
||||
$awardService = new services\AwardService();
|
||||
if ($isFreeBuy) {
|
||||
$awardService->addItem($itemMeta['id'], $goodsNum);
|
||||
$this->_rspData(
|
||||
myself()->_rspData(
|
||||
array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
@ -121,7 +121,7 @@ class ShopController extends BaseAuthedController {
|
||||
return;
|
||||
} else {
|
||||
if (!in_array($tokenType, $checkTokenType)) {
|
||||
$this->_rspErr(1, "token_type parameter error, desired_token_type: {$desiredTokenType}");
|
||||
myself()->_rspErr(1, "token_type parameter error, desired_token_type: {$desiredTokenType}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -134,13 +134,13 @@ class ShopController extends BaseAuthedController {
|
||||
|
||||
$discountBegin = strtotime($goodsMeta['discount_begin']);
|
||||
$discountEnd = strtotime($goodsMeta['discount_end']);
|
||||
$nowTime = $this->_getNowTime();
|
||||
$nowTime = myself()->_getNowTime();
|
||||
|
||||
if ($nowTime >= $discountBegin && $nowTime < $discountEnd) {
|
||||
$needPrice = ceil($needPrice * ($discount / 100.0));
|
||||
}
|
||||
|
||||
$costItemId = $this->getCostItemIdByTokenType($tokenType);
|
||||
$costItemId = myself()->getCostItemIdByTokenType($tokenType);
|
||||
$costItems = array(
|
||||
'item_id' => $costItemId,
|
||||
'item_num' => $goodsNum * $needPrice
|
||||
@ -152,16 +152,16 @@ class ShopController extends BaseAuthedController {
|
||||
mt\Shop::TOKEN_TYPE_DIAMOND
|
||||
)
|
||||
)) {
|
||||
$this->_rspErr(1, "token_type is unsupport, {$tokenType}");
|
||||
myself()->_rspErr(1, "token_type is unsupport, {$tokenType}");
|
||||
return;
|
||||
}
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
|
||||
if (!myself()->_hasEnoughItems($costItems, $lackItem)) {
|
||||
myself()->_rspErr(2, myself()->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
ShopBuyRecord::add($id, $goodsNum);
|
||||
$this->_decItems($costItems);
|
||||
myself()->_decItems($costItems);
|
||||
for ($i = 0; $i < $goodsNum; $i++) {
|
||||
$this->internalAddItem($awardService,
|
||||
$propertyChgService,
|
||||
|
Loading…
x
Reference in New Issue
Block a user