1
This commit is contained in:
parent
a8e2217c2b
commit
2830888059
@ -313,13 +313,14 @@ CREATE TABLE `t_season_card` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`season_id` int(11) NOT NULL DEFAULT '0' COMMENT '赛季id',
|
||||
`type` int(11) NOT NULL DEFAULT '0' COMMENT '手册类型 1:普通 2:精英',
|
||||
`card_lv` int(11) NOT NULL DEFAULT '0' COMMENT '赛季手册等级',
|
||||
`reward_received` int(11) NOT NULL DEFAULT '0' COMMENT '赛季手册等级奖励是否已领取',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `account_id_season_id` (`account_id`, `season_id`),
|
||||
UNIQUE KEY `account_id_season_id_card_lv` (`account_id`, `season_id`, `card_lv`)
|
||||
UNIQUE KEY `account_id_season_id_type_card_lv` (`account_id`, `season_id`, `type`, `card_lv`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
@ -10,6 +10,7 @@ require_once('mt/Drop.php');
|
||||
require_once('mt/Season.php');
|
||||
require_once('mt/SeasonCard.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/SeasonService.php');
|
||||
|
||||
@ -22,6 +23,7 @@ use models\SeasonCard;
|
||||
class SeasonCardController extends BaseAuthedController {
|
||||
|
||||
private $propertyChgService = null;
|
||||
private $awardService = null;
|
||||
private $userInfo = null;
|
||||
private $seasonService = null;
|
||||
private $currSeasonMeta = null;
|
||||
@ -37,6 +39,7 @@ class SeasonCardController extends BaseAuthedController {
|
||||
die();
|
||||
}
|
||||
$this->propertyChgService = new services\PropertyChgService();
|
||||
$this->awardService = new services\AwardChgService();
|
||||
$this->userInfo = $this->_safeGetOrmUserInfo();
|
||||
$this->seasonService = new services\SeasonService();
|
||||
if (!$this->seasonService->checkSeason($this->userInfo)) {
|
||||
@ -52,7 +55,12 @@ class SeasonCardController extends BaseAuthedController {
|
||||
$this->_rspErr(10, '服务器内部错误');
|
||||
die();
|
||||
}
|
||||
$this->seasonCardDb = SeasonCard::allHash($this->currSeasonMeta['id']);
|
||||
$this->seasonCardDb = array(
|
||||
SeasonCard::NORMAL_PACKAGE_ID => SeasonCard::allHash($this->currSeasonMeta['id'],
|
||||
SeasonCard::NORMAL_PACKAGE_ID),
|
||||
SeasonCard::VIP_PACKAGE_ID => SeasonCard::allHash($this->currSeasonMeta['id'],
|
||||
SeasonCard::VIP_PACKAGE_ID),
|
||||
);
|
||||
}
|
||||
|
||||
public function info()
|
||||
@ -60,10 +68,14 @@ class SeasonCardController extends BaseAuthedController {
|
||||
$this->_rspData(array(
|
||||
'info' => array(
|
||||
'season_id' => $this->currSeasonMeta['id'],
|
||||
'season_begin_time' => strtotime($this->currSeasonMeta['begin_time']),
|
||||
'season_begin_end' => strtotime($this->currSeasonMeta['end_time']),
|
||||
'card_lv' => $this->seasonDb ? $this->seasonDb['card_lv'] : 1,
|
||||
'card_exp' => $this->seasonDb ? $this->seasonDb['card_exp'] : 0,
|
||||
'card_max_exp' => $this->seasonDb ? $this->seasonDb['card_exp'] : 0,
|
||||
'gift_packages' => $this->getGiftPackages(),
|
||||
'received_level_rewards' => $this->getReceivedLevelRewards()
|
||||
'received_level_rewards1' => $this->getReceivedLevelRewards(SeasonCard::NORMAL_PACKAGE_ID),
|
||||
'received_level_rewards2' => $this->getReceivedLevelRewards(SeasonCard::VIP_PACKAGE_ID),
|
||||
)
|
||||
));
|
||||
}
|
||||
@ -123,6 +135,7 @@ class SeasonCardController extends BaseAuthedController {
|
||||
public function buyGiftPackage()
|
||||
{
|
||||
$packageId = getReqVal('package_id', 0);
|
||||
$costItemId = getReqVal('cost_item_id', 0);
|
||||
$giftPackage = array_find($this->getGiftPackages(), function ($val) use($packageId) {
|
||||
if ($val['package_id'] == $packageId) {
|
||||
return true;
|
||||
@ -137,22 +150,60 @@ class SeasonCardController extends BaseAuthedController {
|
||||
$this->_rspErr(2, '不能重复购买');
|
||||
return;
|
||||
}
|
||||
$priceInfo = $giftPackage['priceInfo'];
|
||||
if (empty($priceInfo)) {
|
||||
$this->_rspErr(3, '配置表错误');
|
||||
return;
|
||||
}
|
||||
$itemMeta = mt\Item::get($priceInfo['item_id']);
|
||||
if (empty($itemMeta)) {
|
||||
$this->_rspErr(3, '配置表错误1');
|
||||
return;
|
||||
}
|
||||
$dropMeta = mt\Drop::get($itemMeta['drop']);
|
||||
if (empty($dropMeta)) {
|
||||
$this->_rspErr(3, '配置表错误3');
|
||||
return;
|
||||
}
|
||||
$costItems = $this->getCostItems($priceInfo, $costItemId);
|
||||
if (empty($costItems)) {
|
||||
$this->_rspErr(3, '配置表错误2');
|
||||
return;
|
||||
}
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(4, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
Season::updateGiftPackageState($this->currSeasonMeta['id'], $packageId);
|
||||
$this->_decItems($costItems);
|
||||
$this->_scatterDrop('season:gift_package:' . $packageId,
|
||||
$dropMeta,
|
||||
$this->awardService,
|
||||
$this->propertyChgService);
|
||||
$this->_rspData(array(
|
||||
'award' => $this->awardService->toDto(),
|
||||
'property_chg' => $this->propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
private function getGiftPackages()
|
||||
{
|
||||
$itemMeta = mt\Item::get(SeasonCard::VIP_PACKAGE_ITEM_ID);
|
||||
$priceInfo = $itemMeta ? mt\Item::getPriceInfo($itemMeta) : null;
|
||||
$giftPackages = array(
|
||||
|
||||
'package_id' => SeasonCard::VIP_PACKAGE_ID,
|
||||
'state' => $this->seasonDb['gift_state2'],
|
||||
'price_info' => $priceInfo
|
||||
);
|
||||
return $giftPackages;
|
||||
}
|
||||
|
||||
private function getReceivedLevelRewards()
|
||||
private function getReceivedLevelRewards($type)
|
||||
{
|
||||
return array_map(function ($val) {
|
||||
return $val['card_lv'];
|
||||
}, $this->seasonCardDb);
|
||||
}, getXVal($this->seasonCardDb, $type, array()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,12 @@ use phpcommon\SqlHelper;
|
||||
|
||||
class SeasonCard extends BaseModel {
|
||||
|
||||
public static function find($seasonId, $cardLv)
|
||||
const NORMAL_PACKAGE_ID = 1;
|
||||
const VIP_PACKAGE_ID = 2;
|
||||
|
||||
const VIP_PACKAGE_ITEM_ID = 20005;
|
||||
|
||||
public static function find($seasonId, $type, $cardLv)
|
||||
{
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
@ -17,6 +22,7 @@ class SeasonCard extends BaseModel {
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'season_id' => $seasonId,
|
||||
'type' => $type,
|
||||
'card_lv' => $cardLv,
|
||||
)
|
||||
);
|
||||
@ -46,16 +52,18 @@ class SeasonCard extends BaseModel {
|
||||
}, $rows);
|
||||
}
|
||||
|
||||
public static function allHash($seasonId)
|
||||
public static function allHash($seasonId, $type)
|
||||
{
|
||||
$cardHash = array();
|
||||
foreach (self::all($seasonId) as $row) {
|
||||
if ($row['type'] == $type) {
|
||||
$cardHash[$row['card_lv']] = $row;
|
||||
}
|
||||
}
|
||||
return $cardHash;
|
||||
}
|
||||
|
||||
public function add($seasonId, $cardLv)
|
||||
public function add($seasonId, $type, $cardLv)
|
||||
{
|
||||
$initSeasonCard = mt\SeasonCard::getInitCard();
|
||||
SqlHelper::upsert(
|
||||
@ -64,6 +72,7 @@ class SeasonCard extends BaseModel {
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'season_id' => $seasonId,
|
||||
'type' => $type,
|
||||
'card_lv' => $cardLv,
|
||||
),
|
||||
array(
|
||||
@ -71,6 +80,7 @@ class SeasonCard extends BaseModel {
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'season_id' => $seasonId,
|
||||
'type' => $type,
|
||||
'card_lv' => $cardLv,
|
||||
'reward_received' => 1,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user