This commit is contained in:
aozhiwei 2021-12-03 11:21:59 +08:00
parent 76c1fad1cb
commit d3d9561ca9
6 changed files with 122 additions and 2 deletions

View File

@ -182,7 +182,16 @@ class SeassonCardLvUnlockReward(object):
self.fields = [
['card_lv', 0, '手册等级'],
['state', 0, '0:不可领取 1:可领取 2:已领取'],
['item', AwardItem(), '奖品'],
['items', [AwardItem()], '奖品'],
]
class SeasonCardGiftPackage(object):
def __init__(self):
self.fields = [
['package_id', 0, '礼包id'],
['state', 0, '0:未购买 1:已购买'],
['price_info', PriceInfo(), '价格信息'],
]
class SeasonCard(object):
@ -192,7 +201,7 @@ class SeasonCard(object):
['season_id', 0, '赛季id(客户端显示为Sxxx)'],
['card_lv', 0, '手册等级'],
['card_exp', 0, '手册经验'],
['!purchased_gift_packages', [0], '已购买的礼包列表'],
['!gift_packages', [SeasonCardGiftPackage()], '礼包列表'],
['!unlock_rewards', [SeassonCardLvUnlockReward()], '等级解锁的奖励领取列表'],
]

View File

@ -235,6 +235,8 @@ CREATE TABLE `t_season` (
`win_times` int(11) NOT NULL DEFAULT '0' COMMENT '赛季胜利场次',
`total_score` int(11) NOT NULL DEFAULT '0' COMMENT '赛季积分',
`max_score` int(11) NOT NULL DEFAULT '0' COMMENT '赛季最高积分',
`gift_state1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买状态 0:未购 1:已购',
`gift_state2` int(11) NOT NULL DEFAULT '0' COMMENT '豪华礼包购买状态 0:未购 1:已购',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),

View File

@ -45,6 +45,16 @@ function myself()
return $_myself;
}
function array_find($arr, $cb)
{
foreach ($arr as $val) {
if ($cb($val)) {
return $val;
}
}
return null;
}
require 'config_loader.php';
function new_sendError($errcode, $errmsg_tid, $errmsg)

View File

@ -48,6 +48,8 @@ class SeasonCardController extends BaseAuthedController {
'season_id' => $this->currSeasonMeta['id'],
'card_lv' => $this->seasonDb ? $this->seasonDb['card_lv'] : 1,
'card_exp' => $this->seasonDb ? $this->seasonDb['card_exp'] : 0,
'gift_packages' => $this->getGiftPackages(),
'unlock_rewards' => $this->getUnlockRewards()
)
)
));
@ -63,6 +65,37 @@ class SeasonCardController extends BaseAuthedController {
public function buyGiftPackage()
{
$packageId = getReqVal('package_id', 0);
$giftPackage = array_find($this->getGiftPackages(), function ($val) use($packageId) {
if ($val['package_id'] == $packageId) {
return true;
}
return false;
});
if (!$giftPackage) {
$this->_rspErr(1, 'pacakge_id参数错误');
return;
}
if ($giftPackage['state'] == 1) {
$this->_rspErr(2, '不能重复购买');
return;
}
}
private function getGiftPackages()
{
$giftPackages = array(
);
return $giftPackages;
}
private function getUnlockRewards()
{
$rewards = array(
);
return $rewards;
}
}

33
webapp/models/Season.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace models;
require_once('mt/Item.php');
use mt;
use phpcommon\SqlHelper;
class Season extends BaseModel {
public static function find($itemId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_bag',
array(
'account_id' => myself()->_getAccountId(),
'item_id' => $itemId,
)
);
return $row;
}
public static function toDto($row)
{
return array(
'item_id' => $row['item_id'],
'item_num' => $row['item_num'],
);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace models;
require_once('mt/Item.php');
use mt;
use phpcommon\SqlHelper;
class SeasonCard extends BaseModel {
public static function find($itemId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_bag',
array(
'account_id' => myself()->_getAccountId(),
'item_id' => $itemId,
)
);
return $row;
}
public static function toDto($row)
{
return array(
'item_id' => $row['item_id'],
'item_num' => $row['item_num'],
);
}
}