1
This commit is contained in:
parent
075cf3e29e
commit
69366ec028
@ -10,7 +10,7 @@ class DailySelection(object):
|
||||
'name': 'info',
|
||||
'desc': '获取每日精选列表',
|
||||
'group': 'DailySelection',
|
||||
'url': 'webapp/index.php?c=DailySelection&a=getDailySelectionList',
|
||||
'url': 'webapp/index.php?c=DailySelection&a=info',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
@ -25,7 +25,7 @@ class DailySelection(object):
|
||||
'name': 'refresh',
|
||||
'desc': '刷新每日精选',
|
||||
'group': 'DailySelection',
|
||||
'url': 'webapp/index.php?c=DailySelection&a=refreshDailySelection',
|
||||
'url': 'webapp/index.php?c=DailySelection&a=refresh',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
|
@ -111,7 +111,92 @@ class DailySelectionController extends BaseAuthedController {
|
||||
|
||||
public function buy()
|
||||
{
|
||||
$grid = getReqVal('grid', 0);
|
||||
$tokenType = getReqVal('token_type', 0);
|
||||
|
||||
if ($grid < 0 || $grid >= count($this->data['grid_list'])) {
|
||||
$this->_rspErr(1, 'paramater error grid');
|
||||
return;
|
||||
}
|
||||
if (!in_array(
|
||||
$tokenType,
|
||||
array(
|
||||
mt\Shop::TOKEN_TYPE_GOLD,
|
||||
mt\Shop::TOKEN_TYPE_DIAMOND,
|
||||
)
|
||||
)) {
|
||||
$this->_rspErr(1, 'paramater error token_type');
|
||||
return;
|
||||
}
|
||||
|
||||
$gridInfo = &$this->data['grid_list'][$grid];
|
||||
if ($girdInfo['count'] <= 0) {
|
||||
$this->_rspErr(1, 'goods not enought');
|
||||
return;
|
||||
}
|
||||
$goodsMeta = mt\Dailyselection::get($gridInfo['id']);
|
||||
if (!$goodsMeta) {
|
||||
$this->_rspErr(1, 'config error grid');
|
||||
return;
|
||||
}
|
||||
$arrPrice = splitStr1($goodsMeta['price']);
|
||||
$arrTokenType = splitStr1($goodsMeta['token_type']);
|
||||
if (count($arrPrice) != count($arrTokenType)) {
|
||||
$this->_rspErr(1, 'config error price');
|
||||
return;
|
||||
}
|
||||
if (!in_arary(
|
||||
$tokenType,
|
||||
$arrTokenType
|
||||
)) {
|
||||
$this->_rspErr(1, 'paramater error token_type');
|
||||
return;
|
||||
}
|
||||
$tokenPos = array_search($tokenType, $arrTokenType);
|
||||
if (isnull($tokenPos) ||
|
||||
$tokenPos === false) {
|
||||
$this->_rspErr(1, 'paramater error token_pos');
|
||||
return;
|
||||
}
|
||||
$costItemId = mt\Shop::getCostItemIdByTokenType($tokenTtype);
|
||||
if ($costItemId <= 0) {
|
||||
$this->_rspErr(1, 'paramater error cost item id');
|
||||
return;
|
||||
}
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => $costItemId,
|
||||
'item_num' => $arrPrice[$tokenPos]
|
||||
)
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!myself()->_hasEnoughItems($costItems, $lackItem)) {
|
||||
myself()->_rspErr(2, myself()->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$gridInfo['count'] = 0;
|
||||
$this->save();
|
||||
|
||||
$AwardService = new AwardService();
|
||||
$propertyChgService = new PropertyChgService();
|
||||
$propertyChgService->addUserChg();
|
||||
|
||||
myself()->_decItems($costItems);
|
||||
myself()->_addItems(
|
||||
array(
|
||||
array(
|
||||
'item_id' => $goodsMeta['goods_id'],
|
||||
'item_num' => $goodsMeta['goods_num'],
|
||||
)
|
||||
),
|
||||
$awradService,
|
||||
$propertyChgService
|
||||
);
|
||||
|
||||
myself()->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto()
|
||||
));
|
||||
}
|
||||
|
||||
private function internalRefresh($manual)
|
||||
|
Loading…
x
Reference in New Issue
Block a user