Merge branch 'james_bc' into hjb
This commit is contained in:
commit
680ee162d4
@ -47,7 +47,7 @@ class Battle(object):
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['info', [], '战绩详情'],
|
||||
['info', _common.BattleSettlement(), '战绩详情'],
|
||||
]
|
||||
},
|
||||
]
|
||||
|
@ -394,7 +394,8 @@ class NewGoods(object):
|
||||
['limit_num', 0, '限购数量'],
|
||||
['buy_cond', '', '购买条件'],
|
||||
['buy_gift', '', '购买次数赠品'],
|
||||
['normal_gift', '', '普通狗赠品']
|
||||
['normal_gift', '', '普通狗赠品'],
|
||||
['bought_times', 0, '已购买次数']
|
||||
]
|
||||
|
||||
class ShopName(object):
|
||||
@ -882,10 +883,11 @@ class BattleCegReward(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['uuid', '', '唯一id'],
|
||||
['curr_ceg', 0, '当前ceg数量'],
|
||||
['obtain_ceg', 0, '实际获得ceg数量'],
|
||||
['ceg_uplimit', 0, 'ceg数量上限'],
|
||||
['hero_uniid', '', '唯一id'],
|
||||
['id', '', 'id'],
|
||||
['gold_uplimit', 0, '当前ceg数量'],
|
||||
['obtain_gold', 0, '实际获得ceg数量'],
|
||||
['curr_gold', 0, 'ceg数量上限'],
|
||||
]
|
||||
|
||||
class BattleItemReward(object):
|
||||
@ -896,16 +898,6 @@ class BattleItemReward(object):
|
||||
['item_num', 0, '道具数量'],
|
||||
]
|
||||
|
||||
class BattleReward(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['hero', BattleCegReward(), '英雄奖励'],
|
||||
['weapon1', BattleCegReward(), '武器1奖励'],
|
||||
['weapon2', BattleCegReward(), '武器2奖励'],
|
||||
['!items', [BattleItemReward()], '碎片奖励'],
|
||||
['lvInfo', [['oldLv',0,'老等级'],['newLv',0,'新等级']], '等级信息'],
|
||||
]
|
||||
|
||||
class BattleRankScore(object):
|
||||
|
||||
@ -1098,3 +1090,76 @@ class TeamReportTeam(object):
|
||||
['team_id', 0, '队伍id'],
|
||||
['!members', [['account_id', '', '账号id']], '枪械属性'],
|
||||
]
|
||||
|
||||
class BattleSettlement(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['version', 0, '版本'],
|
||||
['battle_uuid', 0, '本次战斗唯一id'],
|
||||
['team_id', 0, '队伍id'],
|
||||
['room_uuid', 0, '房间唯一id'],
|
||||
['room_mode', 0, '0:pvp 1: pve'],
|
||||
['team_mode', 0, '0:个人 1:组队(保留)'],
|
||||
['game_over', 0, '游戏是否结束'],
|
||||
['victory', 0, '是否胜利(pvp:吃鸡 pve:是否通关)'],
|
||||
['watchable', 0, '是否可观战,小胡那的接口写死0(看历史不可观战)'],
|
||||
['map_id', 0, '地图id'],
|
||||
['settlement_status', 0, '0: 结算中(读取个人结算数据) 1:已结算(请求小胡接口)'],
|
||||
['pvp_settlement_type', 0, '結算類型0:個人 1:組隊(保留)'],
|
||||
['pvp_settlement_color', 0, '0:灰 1:黃'],
|
||||
['pvp_team_rank', 0, '队伍排名'],
|
||||
['pvp_total_human_num', 0, '房间总人数'],
|
||||
['pvp_alive_human_num', 0, '房间剩余存活人数'],
|
||||
['pvp_total_team_num', 0, '本次战斗队伍总数'],
|
||||
['pvp_match_mode', 0, '比赛模式 0: pvp 1:排位赛'],
|
||||
['pve_settlement_color', 0, '0:灰 1:黃'],
|
||||
['pve_wave', 0, 'pve波次'],
|
||||
['pve_max_wave', 0, 'pve总波次'],
|
||||
['pve_instance_id', 0, 'pve副本id'],
|
||||
['!members', [BattleSettlementMembersInfo()], '队伍成员信息'],
|
||||
]
|
||||
|
||||
class BattleSettlementMembersInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['account_id', 0, '账号id(真人才有account_id)'],
|
||||
['name', '', '玩家名字'],
|
||||
['head', 0, '头像id'],
|
||||
['head_frame', 0, '头像框'],
|
||||
['sex', 0, '性别'],
|
||||
['hero_uniid', 0, '英雄uniid'],
|
||||
['hero_id', 0, '英雄itemId'],
|
||||
['dead', 0, '是否已死亡'],
|
||||
['is_mvp', 0, '是否mvp'],
|
||||
['old_rank', 0, '老段位'],
|
||||
['new_rank', 0, '新段位'],
|
||||
['old_score', 0, '老段位积分'],
|
||||
['new_score', 0, '新段位积分'],
|
||||
['pvp_kill', 0, 'pvp击杀敌人数'],
|
||||
['pvp_damage', 0, 'pvp伤害总量'],
|
||||
['pvp_assist', 0, 'pvp助攻'],
|
||||
['pvp_survia_time', 0, 'pvp存活时间(毫秒)'],
|
||||
['pvp_recover', 0, 'pvp治疗总量'],
|
||||
['pvp_rescue', 0, 'pvp救援'],
|
||||
['pvp_personal_rank', 0, '个人排名'],
|
||||
['pve_order', 0, 'pve波次'],
|
||||
['pve_score', 0, 'pve分数'],
|
||||
['pve_star', 0, 'pve星'],
|
||||
['pve_damage', 0, 'pve伤害总量'],
|
||||
['pve_revive', 0, 'pve复活次数'],
|
||||
['pve_survia_time', 0, 'pvp存活时间(毫秒)'],
|
||||
['pve_wave', 0, 'pve波次'],
|
||||
['pve_max_wave', 0, 'pve总波次'],
|
||||
['pve_boss_killed', 0, 'pve副本boos是否被击杀'],
|
||||
['reward', BattleReward(), 'reward'],
|
||||
]
|
||||
|
||||
class BattleReward(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['hero', BattleCegReward(), '英雄奖励'],
|
||||
['!items', [BattleItemReward()], '碎片奖励'],
|
||||
]
|
@ -699,6 +699,25 @@ CREATE TABLE `t_battle_settlement_team` (
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_battle_settlement_team`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_battle_input`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_battle_input` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`battle_uuid` varchar(60) NOT NULL DEFAULT '' COMMENT '战斗记录唯一id',
|
||||
`room_uuid` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'room_id',
|
||||
`input` mediumblob COMMENT 'input',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `battle_room_uuid` (`battle_uuid`, `room_uuid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_battle_history`
|
||||
--
|
||||
|
@ -472,6 +472,11 @@ class BaseAuthedController extends BaseController {
|
||||
$propertyService->addChip();
|
||||
}
|
||||
break;
|
||||
case mt\Item::RANDOM_BOX_TYPE:
|
||||
{
|
||||
$this->_openRandomBox($itemMeta,$awardService,$propertyService);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
$this->_addLog('additems', 'invalid_item', array(
|
||||
@ -498,6 +503,21 @@ class BaseAuthedController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public function _openRandomBox($itemMeta,$awardService,$propertyService){
|
||||
if ($itemMeta['include_item_id']) {
|
||||
$includeItemIds = explode('|', $itemMeta['include_item_id']);
|
||||
$key = array_rand($includeItemIds,1);
|
||||
|
||||
$items = array(
|
||||
array(
|
||||
'item_id' => $includeItemIds[$key] ,
|
||||
'item_num' => 1
|
||||
)
|
||||
);
|
||||
$this->_addItems($items,$awardService,$propertyService);
|
||||
}
|
||||
}
|
||||
|
||||
public function _addTryUsingItems($items)
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
|
@ -129,6 +129,24 @@ class BattleController extends BaseAuthedController {
|
||||
$this->_rspErr(1, 'Repeated request');
|
||||
return;
|
||||
}
|
||||
SqlHelper::upsert
|
||||
(myself()->_getSelfMysql(),
|
||||
't_battle_input',
|
||||
array(
|
||||
'battle_uuid' => $battle_uuid,
|
||||
'room_uuid' => $room_uuid,
|
||||
),
|
||||
array(
|
||||
'input' => json_encode($data)
|
||||
),
|
||||
array(
|
||||
'battle_uuid' => $battle_uuid,
|
||||
'room_uuid' => $room_uuid,
|
||||
'input' => json_encode($data),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
$teamList = array();
|
||||
if ($data) {
|
||||
$teamList = $data['team_list'];
|
||||
@ -168,19 +186,7 @@ class BattleController extends BaseAuthedController {
|
||||
// $this->_rspData($data);
|
||||
$this->_rspOk();
|
||||
}
|
||||
|
||||
public function test(){
|
||||
// echo "当前时间=>" . time() . '|' . date('Y-m-d H:i:s',time()) ;
|
||||
// echo "当天时间=>" . $this->_getDaySeconds(time()) . '|' . date('Y-m-d H:i:s',$this->_getDaySeconds(time()));
|
||||
// echo "下一天时间=>" . ($this->_getDaySeconds(time())+3600*24) . '|' . date('Y-m-d H:i:s',$this->_getDaySeconds(time())+3600*24);
|
||||
// echo "当周时间=>" . $this->_getMondaySeconds() . '|' . date('Y-m-d H:i:s',$this->_getMondaySeconds());
|
||||
// echo "下周时间=>" . ($this->_getMondaySeconds() + 7*24*3600) . '|' . date('Y-m-d H:i:s',$this->_getMondaySeconds() + 7*24*3600);
|
||||
// $this->switchAccount('james');
|
||||
// $user = $this->_getOrmUserInfo();
|
||||
// print_r($user);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
http post
|
||||
php://input
|
||||
|
@ -39,24 +39,13 @@ class FragmentController extends BaseAuthedController
|
||||
switch ($type) {
|
||||
case 1:
|
||||
{
|
||||
// $itemMetaList = mt\Item::getMetaListByType(mt\Item::HERO_TYPE);
|
||||
// $hero = array();
|
||||
// foreach ($itemMetaList as $meta){
|
||||
// array_push($hero,$meta['id']);
|
||||
// }
|
||||
$itemMetaList = mt\Item::getMetaListByType(mt\Item::HERO_TYPE);
|
||||
$hero = array();
|
||||
foreach ($itemMetaList as $meta){
|
||||
array_push($hero,$meta['id']);
|
||||
}
|
||||
$meta = mt\Parameter::getByName('jigsaw_merge_h_price');
|
||||
$mint = $meta ? $meta['param_value'] : 100;
|
||||
$hero = array(
|
||||
30100,
|
||||
30500,
|
||||
30600,
|
||||
30700,
|
||||
30900,
|
||||
31000,
|
||||
30200,
|
||||
30300,
|
||||
30400,
|
||||
);
|
||||
$this->_rspData(array(
|
||||
'list' => $hero,
|
||||
'mint' => $mint
|
||||
@ -70,7 +59,6 @@ class FragmentController extends BaseAuthedController
|
||||
foreach ($itemMetaList as $meta){
|
||||
array_push($gun,$meta['id']);
|
||||
}
|
||||
// $mint = strval(\services\FormulaService::Weapon_Parts_Synthetic_Cost());
|
||||
$meta = mt\Parameter::getByName('jigsaw_merge_w_price');
|
||||
$mint = $meta ? $meta['param_value'] : 20;
|
||||
$this->_rspData(array(
|
||||
|
@ -159,10 +159,10 @@ class GunController extends BaseAuthedController {
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $nextLevelMeta['gold']
|
||||
),
|
||||
array(
|
||||
'item_id' => V_ITEM_DIAMOND,
|
||||
'item_num' => $nextLevelMeta['diamond']
|
||||
),
|
||||
// array(
|
||||
// 'item_id' => V_ITEM_DIAMOND,
|
||||
// 'item_num' => $nextLevelMeta['diamond']
|
||||
// ),
|
||||
);
|
||||
|
||||
$newGunDb = $gunDb;
|
||||
@ -220,10 +220,10 @@ class GunController extends BaseAuthedController {
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $nextLevelMeta['gold']
|
||||
),
|
||||
array(
|
||||
'item_id' => V_ITEM_DIAMOND,
|
||||
'item_num' => $nextLevelMeta['diamond']
|
||||
),
|
||||
// array(
|
||||
// 'item_id' => V_ITEM_DIAMOND,
|
||||
// 'item_num' => $nextLevelMeta['diamond']
|
||||
// ),
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
|
@ -131,10 +131,10 @@ class HeroController extends BaseAuthedController {
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $nextLevelMeta['gold']
|
||||
),
|
||||
array(
|
||||
'item_id' => V_ITEM_DIAMOND,
|
||||
'item_num' => $nextLevelMeta['diamond']
|
||||
)
|
||||
// array(
|
||||
// 'item_id' => V_ITEM_DIAMOND,
|
||||
// 'item_num' => $nextLevelMeta['diamond']
|
||||
// )
|
||||
);
|
||||
|
||||
$heroDto = Hero::toDto($heroDb);
|
||||
@ -222,10 +222,10 @@ class HeroController extends BaseAuthedController {
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $nextLevelMeta['gold']
|
||||
),
|
||||
array(
|
||||
'item_id' => V_ITEM_DIAMOND,
|
||||
'item_num' => $nextLevelMeta['diamond']
|
||||
)
|
||||
// array(
|
||||
// 'item_id' => V_ITEM_DIAMOND,
|
||||
// 'item_num' => $nextLevelMeta['diamond']
|
||||
// )
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
|
@ -14,6 +14,7 @@ require_once('models/HeroSkin.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/GunSkin.php');
|
||||
require_once('models/ShopBuyRecord.php');
|
||||
require_once('models/Chip.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
@ -26,8 +27,10 @@ use models\HeroSkin;
|
||||
use models\Gun;
|
||||
use models\GunSkin;
|
||||
use models\ShopBuyRecord;
|
||||
use models\Chip;
|
||||
|
||||
class ShopController extends BaseAuthedController {
|
||||
class ShopController extends BaseAuthedController
|
||||
{
|
||||
|
||||
const TOKEN_TYPE_CEG = '1';
|
||||
const TOKEN_TYPE_CEC = '2';
|
||||
@ -48,27 +51,57 @@ class ShopController extends BaseAuthedController {
|
||||
public function getGoodsList()
|
||||
{
|
||||
$goodsList = mt\ShopGoods::all();
|
||||
|
||||
$this->_rspData(array(
|
||||
'goods_list' => $goodsList ? $goodsList : array(),
|
||||
));
|
||||
$goodsList = $goodsList ? $goodsList : array();
|
||||
$buyRecordHash = ShopBuyRecord::allToHash();
|
||||
|
||||
foreach ($goodsList as &$goods) {
|
||||
$goods['bought_times'] = 0;
|
||||
switch ($goods['limit_type']) {
|
||||
case mt\Item::DAILY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $goods['id']);
|
||||
$goods['bought_times'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
case mt\Item::WEEKLY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $goods['id']);
|
||||
$goods['bought_times'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
case mt\Item::TOTAL_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $goods['id']);
|
||||
$goods['bought_times'] = $buyRecord ? $buyRecord['total_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_rspData(
|
||||
array(
|
||||
'goods_list' => $goodsList,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getShopNames()
|
||||
{
|
||||
$shopList = mt\Shop::all();
|
||||
|
||||
$this->_rspData(array(
|
||||
'shop_name_list' => $shopList ? $shopList : array(),
|
||||
));
|
||||
$this->_rspData(
|
||||
array(
|
||||
'shop_name_list' => $shopList ? $shopList : array(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function buyGoodsNew()
|
||||
{
|
||||
$id = getReqVal('id', 0);
|
||||
$token_type = getReqVal('token_type', '');
|
||||
$goods_num = getReqVal('goods_num', 0);
|
||||
|
||||
|
||||
$row = mt\ShopGoods::get($id);
|
||||
|
||||
$desired_token_type = $row['token_type'];
|
||||
@ -79,7 +112,7 @@ class ShopController extends BaseAuthedController {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($goods_num>$row['max_amount']) {
|
||||
if ($goods_num > $row['max_amount']) {
|
||||
$this->_rspErr(1, "goods_num parameter error, max_amount: {$row['max_amount']}");
|
||||
return;
|
||||
}
|
||||
@ -87,84 +120,80 @@ class ShopController extends BaseAuthedController {
|
||||
$buyRecordHash = ShopBuyRecord::allToHash();
|
||||
$boughtTimes = 1;
|
||||
switch ($row['limit_type']) {
|
||||
case ShopController::DAILY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1: 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $row['limit_num']) {
|
||||
$this->_rspErr(2, 'Has reached the maximum number of purchase restrictions today');
|
||||
return;
|
||||
}
|
||||
if ($row['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ShopController::WEEKLY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1: 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $row['limit_num']) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions this week has been reached');
|
||||
return;
|
||||
}
|
||||
if ($row['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ShopController::TOTAL_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1: 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $row['limit_num']) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
if ($row['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'he maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case ShopController::DAILY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $row['limit_num']) {
|
||||
$this->_rspErr(2, 'Has reached the maximum number of purchase restrictions today');
|
||||
return;
|
||||
}
|
||||
if ($row['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ShopController::WEEKLY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $row['limit_num']) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions this week has been reached');
|
||||
return;
|
||||
}
|
||||
if ($row['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ShopController::TOTAL_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $id);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $row['limit_num']) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
if ($row['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'he maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$price_array = splitStr1($row['price']);
|
||||
$discount_array = splitStr1($row['discount']);
|
||||
|
||||
|
||||
$need_price = $price_array[$token_pos];
|
||||
$discount = $discount_array[$token_pos];
|
||||
|
||||
$discount_begin = strtotime($row['discount_begin'].' UTC');
|
||||
$discount_end = strtotime($row['discount_end'].' UTC');
|
||||
$discount_begin = strtotime($row['discount_begin'] . ' UTC');
|
||||
$discount_end = strtotime($row['discount_end'] . ' UTC');
|
||||
$nowTime = $this->_getNowTime();
|
||||
|
||||
if ($nowTime>=$discount_begin && $nowTime<$discount_end) {
|
||||
|
||||
|
||||
if ($nowTime >= $discount_begin && $nowTime < $discount_end) {
|
||||
|
||||
$need_price = ceil($need_price * ($discount / 100.0));
|
||||
}
|
||||
|
||||
$costItemId = $this->getCostItemIdByTokenType($token_type);
|
||||
|
||||
switch($token_type) {
|
||||
|
||||
switch ($token_type) {
|
||||
case ShopController::TOKEN_TYPE_CEG:
|
||||
case ShopController::TOKEN_TYPE_CEC:
|
||||
$costItems = $this->makeCostItems($costItemId, $goods_num*$need_price);
|
||||
$costItems = $this->makeCostItems($costItemId, $goods_num * $need_price);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(2, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$itemMeta = mt\Item::get($row['goods_id']);
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
for ($i = 0; $i<$goods_num; $i++) {
|
||||
for ($i = 0; $i < $goods_num; $i++) {
|
||||
$this->internalAddItem($propertyChgService, $itemMeta);
|
||||
}
|
||||
$awardService = new services\AwardService();
|
||||
@ -184,19 +213,20 @@ class ShopController extends BaseAuthedController {
|
||||
'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' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
'goods_chg' => $goodsDto
|
||||
));
|
||||
$this->_rspData(
|
||||
array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
'goods_chg' => $goodsDto
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case ShopController::TOKEN_TYPE_BCEG:
|
||||
@ -208,13 +238,13 @@ class ShopController extends BaseAuthedController {
|
||||
case ShopController::TOKEN_TYPE_MATIC:
|
||||
case ShopController::TOKEN_TYPE_BNB:
|
||||
default:
|
||||
$this->_rspErr(1, "token_type is unsupport, {$token_type}");
|
||||
$this->_rspErr(1, "token_type is unsupport, {$token_type}");
|
||||
}
|
||||
}
|
||||
|
||||
private function getCostItemIdByTokenType($token_type)
|
||||
{
|
||||
switch($token_type) {
|
||||
switch ($token_type) {
|
||||
case ShopController::TOKEN_TYPE_CEG:
|
||||
return V_ITEM_GOLD;
|
||||
break;
|
||||
@ -254,13 +284,15 @@ class ShopController extends BaseAuthedController {
|
||||
}
|
||||
$goodsList = mt\ShopGoods::getGoodsList($shopId);
|
||||
if (!$goodsList) {
|
||||
$this->_rspData(array(
|
||||
'info' => array(
|
||||
'shop_id' => $shopId,
|
||||
'goods_list1' => array(),
|
||||
'goods_list2' => array(),
|
||||
$this->_rspData(
|
||||
array(
|
||||
'info' => array(
|
||||
'shop_id' => $shopId,
|
||||
'goods_list1' => array(),
|
||||
'goods_list2' => array(),
|
||||
)
|
||||
)
|
||||
));
|
||||
);
|
||||
return;
|
||||
}
|
||||
$buyRecordHash = ShopBuyRecord::allToHash();
|
||||
@ -279,28 +311,24 @@ class ShopController extends BaseAuthedController {
|
||||
'total_buy_times' => $itemMeta['limit_num'],
|
||||
);
|
||||
switch ($itemMeta['limit_type']) {
|
||||
case mt\Item::DAILY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
case mt\Item::WEEKLY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
case mt\Item::TOTAL_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['total_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case mt\Item::DAILY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_day_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
case mt\Item::WEEKLY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['this_week_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
case mt\Item::TOTAL_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$goodsDto['bought_times'] = $buyRecord ? $buyRecord['total_buy_times'] : 0;
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
break;
|
||||
}
|
||||
$priceInfo = mt\Item::getPriceInfo($itemMeta);
|
||||
if (!empty($priceInfo)) {
|
||||
@ -309,13 +337,15 @@ class ShopController extends BaseAuthedController {
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'info' => array(
|
||||
'shop_id' => $shopId,
|
||||
'goods_list1' => $goodsDtoList1,
|
||||
'goods_list2' => $goodsDtoList2,
|
||||
$this->_rspData(
|
||||
array(
|
||||
'info' => array(
|
||||
'shop_id' => $shopId,
|
||||
'goods_list1' => $goodsDtoList1,
|
||||
'goods_list2' => $goodsDtoList2,
|
||||
)
|
||||
)
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
public function buyGoods()
|
||||
@ -345,54 +375,49 @@ class ShopController extends BaseAuthedController {
|
||||
$buyRecordHash = ShopBuyRecord::allToHash();
|
||||
$boughtTimes = 1;
|
||||
switch ($itemMeta['limit_type']) {
|
||||
case mt\Item::DAILY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1: 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'Has reached the maximum number of purchase restrictions today');
|
||||
return;
|
||||
}
|
||||
if ($itemMeta['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Item::WEEKLY_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1: 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions this week has been reached');
|
||||
return;
|
||||
}
|
||||
if ($itemMeta['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Item::TOTAL_BUY_LIMIT:
|
||||
{
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1: 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
if ($itemMeta['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'he maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
{
|
||||
case mt\Item::DAILY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_day_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_day_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'Has reached the maximum number of purchase restrictions today');
|
||||
return;
|
||||
}
|
||||
if ($itemMeta['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Item::WEEKLY_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['this_week_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'this_week_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions this week has been reached');
|
||||
return;
|
||||
}
|
||||
if ($itemMeta['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Item::TOTAL_BUY_LIMIT: {
|
||||
$buyRecord = getXVal($buyRecordHash, $itemMeta['id']);
|
||||
$boughtTimes = $buyRecord ? $buyRecord['total_buy_times'] + 1 : 1;
|
||||
if ($buyRecord && getXVal($buyRecord, 'total_buy_times', 0) >= $itemMeta['limit_num']) {
|
||||
$this->_rspErr(2, 'The maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
if ($itemMeta['limit_num'] <= 0) {
|
||||
$this->_rspErr(2, 'he maximum number of purchase restrictions has been reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
break;
|
||||
} {
|
||||
$errCode = 0;
|
||||
$errMsg = '';
|
||||
if (!$this->canBuy($itemMeta, $errCode, $errMsg)) {
|
||||
@ -433,29 +458,31 @@ class ShopController extends BaseAuthedController {
|
||||
'limit_type' => $itemMeta['limit_type'],
|
||||
'bought_times' => $boughtTimes,
|
||||
'total_buy_times' => $itemMeta['limit_num'],
|
||||
);
|
||||
{
|
||||
); {
|
||||
$priceInfo = mt\Item::getPriceInfo($itemMeta);
|
||||
if (!empty($priceInfo)) {
|
||||
$goodsDto['price_info'] = $priceInfo['price_info'];
|
||||
}
|
||||
}
|
||||
$propertyChgService->addUserChg();
|
||||
$this->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
'goods_chg' => $goodsDto
|
||||
));
|
||||
$this->_rspData(
|
||||
array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
'goods_chg' => $goodsDto
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getDiscountList()
|
||||
{
|
||||
$items = array();
|
||||
{
|
||||
$types = array(mt\Item::HERO_TYPE,
|
||||
mt\Item::HERO_SKIN_TYPE,
|
||||
mt\Item::GUN_SKIN_TYPE);
|
||||
mt\Item::filter(function ($meta) use(&$items, &$types) {
|
||||
$items = array(); {
|
||||
$types = array(
|
||||
mt\Item::HERO_TYPE,
|
||||
mt\Item::HERO_SKIN_TYPE,
|
||||
mt\Item::GUN_SKIN_TYPE
|
||||
);
|
||||
mt\Item::filter(function ($meta) use (&$items, &$types) {
|
||||
if (mt\Item::inTypes($meta, $types)) {
|
||||
array_push($items, $meta);
|
||||
}
|
||||
@ -463,7 +490,7 @@ class ShopController extends BaseAuthedController {
|
||||
});
|
||||
}
|
||||
$goodsDtoList = array();
|
||||
array_walk($items, function ($val) use(&$priceList, &$goodsDtoList) {
|
||||
array_walk($items, function ($val) use (&$priceList, &$goodsDtoList) {
|
||||
$goodsDto = array(
|
||||
'item_id' => $val['id'],
|
||||
'gold_discount' => 0,
|
||||
@ -475,16 +502,14 @@ class ShopController extends BaseAuthedController {
|
||||
foreach ($costGroup as $cost) {
|
||||
if ($cost['discount'] > 0) {
|
||||
switch ($cost['item_id']) {
|
||||
case V_ITEM_GOLD:
|
||||
{
|
||||
$goodsDto['gold_discount'] = $cost['discount'];
|
||||
}
|
||||
break;
|
||||
case V_ITEM_DIAMOND:
|
||||
{
|
||||
$goodsDto['diamond_discount'] = $cost['discount'];
|
||||
}
|
||||
break;
|
||||
case V_ITEM_GOLD: {
|
||||
$goodsDto['gold_discount'] = $cost['discount'];
|
||||
}
|
||||
break;
|
||||
case V_ITEM_DIAMOND: {
|
||||
$goodsDto['diamond_discount'] = $cost['discount'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -492,11 +517,13 @@ class ShopController extends BaseAuthedController {
|
||||
if ($goodsDto['gold_discount'] > 0 || $goodsDto['diamond_discount'] > 0) {
|
||||
array_push($goodsDtoList, $goodsDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$this->_rspData(array(
|
||||
'goods_list' => $goodsDtoList,
|
||||
));
|
||||
$this->_rspData(
|
||||
array(
|
||||
'goods_list' => $goodsDtoList,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function outsideBuy($shopId, $itemId, $itemNum, $costItemId)
|
||||
@ -516,14 +543,15 @@ class ShopController extends BaseAuthedController {
|
||||
$this->_rspErr(1, 'cost_item_id parameter error');
|
||||
return;
|
||||
}
|
||||
$types = array(mt\Item::HERO_TYPE,
|
||||
mt\Item::HERO_SKIN_TYPE,
|
||||
mt\Item::GUN_SKIN_TYPE);
|
||||
$types = array(
|
||||
mt\Item::HERO_TYPE,
|
||||
mt\Item::HERO_SKIN_TYPE,
|
||||
mt\Item::GUN_SKIN_TYPE
|
||||
);
|
||||
if (!mt\Item::inTypes($itemMeta, $types)) {
|
||||
$this->_rspErr(1, 'item_id parameter error');
|
||||
return;
|
||||
}
|
||||
{
|
||||
} {
|
||||
$errCode = 0;
|
||||
$errMsg = '';
|
||||
if (!$this->canBuy($itemMeta, $errCode, $errMsg)) {
|
||||
@ -564,29 +592,31 @@ class ShopController extends BaseAuthedController {
|
||||
'limit_type' => $itemMeta['limit_type'],
|
||||
'bought_times' => 0,
|
||||
'total_buy_times' => $itemMeta['limit_num'],
|
||||
);
|
||||
{
|
||||
); {
|
||||
$priceInfo = mt\Item::getPriceInfo($itemMeta);
|
||||
if (!empty($priceInfo)) {
|
||||
$goodsDto['price_info'] = $priceInfo;
|
||||
}
|
||||
}
|
||||
$propertyChgService->addUserChg();
|
||||
$this->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
'goods_chg' => $goodsDto
|
||||
));
|
||||
$this->_rspData(
|
||||
array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => $propertyChgService->toDto(),
|
||||
'goods_chg' => $goodsDto
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function getOutsideShopInfo()
|
||||
{
|
||||
$items = array();
|
||||
{
|
||||
$types = array(mt\Item::HERO_TYPE,
|
||||
mt\Item::HERO_SKIN_TYPE,
|
||||
mt\Item::GUN_SKIN_TYPE);
|
||||
mt\Item::filter(function ($meta) use(&$items, &$types) {
|
||||
$items = array(); {
|
||||
$types = array(
|
||||
mt\Item::HERO_TYPE,
|
||||
mt\Item::HERO_SKIN_TYPE,
|
||||
mt\Item::GUN_SKIN_TYPE
|
||||
);
|
||||
mt\Item::filter(function ($meta) use (&$items, &$types) {
|
||||
if (mt\Item::inTypes($meta, $types)) {
|
||||
array_push($items, $meta);
|
||||
}
|
||||
@ -595,7 +625,7 @@ class ShopController extends BaseAuthedController {
|
||||
}
|
||||
$goodsDtoList1 = array();
|
||||
$goodsDtoList2 = array();
|
||||
array_walk($items, function ($val) use(&$priceList, &$goodsDtoList1, &$goodsDtoList2) {
|
||||
array_walk($items, function ($val) use (&$priceList, &$goodsDtoList1, &$goodsDtoList2) {
|
||||
$goodsDto = array(
|
||||
'goods_id' => $val['id'],
|
||||
'item_id' => $val['id'],
|
||||
@ -611,19 +641,21 @@ class ShopController extends BaseAuthedController {
|
||||
array_push($goodsDtoList1, $goodsDto);
|
||||
}
|
||||
});
|
||||
$this->_rspData(array(
|
||||
'info' => array(
|
||||
'shop_id' => mt\Shop::OUTSIDE_SHOP,
|
||||
'goods_list1' => $goodsDtoList1,
|
||||
'goods_list2' => $goodsDtoList2,
|
||||
$this->_rspData(
|
||||
array(
|
||||
'info' => array(
|
||||
'shop_id' => mt\Shop::OUTSIDE_SHOP,
|
||||
'goods_list1' => $goodsDtoList1,
|
||||
'goods_list2' => $goodsDtoList2,
|
||||
)
|
||||
)
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
private function getCostItems($priceInfo, $costItemId)
|
||||
{
|
||||
$costGroup = null;
|
||||
array_walk($priceInfo['price_info']['cost_list'], function ($val) use(&$costGroup, $costItemId) {
|
||||
array_walk($priceInfo['price_info']['cost_list'], function ($val) use (&$costGroup, $costItemId) {
|
||||
if ($costGroup) {
|
||||
return;
|
||||
}
|
||||
@ -637,19 +669,22 @@ class ShopController extends BaseAuthedController {
|
||||
}
|
||||
$costItems = array();
|
||||
array_walk($costGroup, function ($val) use (&$costItems, $priceInfo) {
|
||||
if ($val['discount'] > 0 &&
|
||||
if (
|
||||
$val['discount'] > 0 &&
|
||||
$this->_getNowTime() >= $priceInfo['discount_begin_time'] &&
|
||||
$this->_getNowTime() <= $priceInfo['discount_end_time']
|
||||
) {
|
||||
array_push($costItems, array(
|
||||
'item_id' => $val['item_id'],
|
||||
'item_num' => (int)($val['item_num'] * ($priceInfo['discount'] / 100)),
|
||||
));
|
||||
'item_num' => (int) ($val['item_num'] * ($priceInfo['discount'] / 100)),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
array_push($costItems, array(
|
||||
'item_id' => $val['item_id'],
|
||||
'item_num' => $val['item_num'],
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
return $costItems;
|
||||
@ -658,37 +693,37 @@ class ShopController extends BaseAuthedController {
|
||||
private function internalAddItem($propertyChgService, $itemMeta)
|
||||
{
|
||||
switch ($itemMeta['type']) {
|
||||
case mt\Item::HERO_TYPE:
|
||||
{
|
||||
Hero::addHero($itemMeta);
|
||||
$propertyChgService->addHeroChg();
|
||||
$propertyChgService->addUserChg();
|
||||
}
|
||||
break;
|
||||
case mt\Item::HERO_SKIN_TYPE:
|
||||
{
|
||||
HeroSkin::addSkin($itemMeta);
|
||||
$propertyChgService->addHeroSkinChg();
|
||||
}
|
||||
break;
|
||||
case mt\Item::GUN_TYPE:
|
||||
{
|
||||
Gun::addGun($itemMeta);
|
||||
$propertyChgService->addGunChg();
|
||||
}
|
||||
break;
|
||||
case mt\Item::GUN_SKIN_TYPE:
|
||||
{
|
||||
GunSkin::addSkin($itemMeta);
|
||||
$propertyChgService->addGunSkinChg();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
Bag::addItem($itemMeta['id'], 1);
|
||||
$propertyChgService->addBagChg();
|
||||
}
|
||||
break;
|
||||
case mt\Item::HERO_TYPE: {
|
||||
Hero::addHero($itemMeta);
|
||||
$propertyChgService->addHeroChg();
|
||||
$propertyChgService->addUserChg();
|
||||
}
|
||||
break;
|
||||
case mt\Item::HERO_SKIN_TYPE: {
|
||||
HeroSkin::addSkin($itemMeta);
|
||||
$propertyChgService->addHeroSkinChg();
|
||||
}
|
||||
break;
|
||||
case mt\Item::GUN_TYPE: {
|
||||
Gun::addGun($itemMeta);
|
||||
$propertyChgService->addGunChg();
|
||||
}
|
||||
break;
|
||||
case mt\Item::GUN_SKIN_TYPE: {
|
||||
GunSkin::addSkin($itemMeta);
|
||||
$propertyChgService->addGunSkinChg();
|
||||
}
|
||||
break;
|
||||
case mt\Item::CHIP_TYPE: {
|
||||
Chip::addChip($itemMeta);
|
||||
$propertyChgService->addChip();
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
Bag::addItem($itemMeta['id'], 1);
|
||||
$propertyChgService->addBagChg();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -697,43 +732,39 @@ class ShopController extends BaseAuthedController {
|
||||
$errCode = 0;
|
||||
$errMsg = '';
|
||||
switch ($itemMeta['type']) {
|
||||
case mt\Item::HERO_TYPE:
|
||||
{
|
||||
$heroDb = Hero::find($itemMeta['id']);
|
||||
if ($heroDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = 'You already have the hero';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Item::HERO_SKIN_TYPE:
|
||||
{
|
||||
$heroSkinDb = HeroSkin::find($itemMeta['id']);
|
||||
if ($heroSkinDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = 'You already have the skin';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Item::GUN_SKIN_TYPE:
|
||||
{
|
||||
$gunSkinDb = GunSkin::find($itemMeta['id']);
|
||||
if ($gunSkinDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = 'You already have the skin';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case mt\Item::HERO_TYPE: {
|
||||
$heroDb = Hero::find($itemMeta['id']);
|
||||
if ($heroDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = 'You already have the hero';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Item::HERO_SKIN_TYPE: {
|
||||
$heroSkinDb = HeroSkin::find($itemMeta['id']);
|
||||
if ($heroSkinDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = 'You already have the skin';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Item::GUN_SKIN_TYPE: {
|
||||
$gunSkinDb = GunSkin::find($itemMeta['id']);
|
||||
if ($gunSkinDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = 'You already have the skin';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -49,7 +49,7 @@ class UserController extends BaseAuthedController {
|
||||
$userInfo = $this->_safeGetOrmUserInfo();
|
||||
if (!$userInfo) {
|
||||
$this->createNewUserV2($userName);
|
||||
$this->_addFreeItem2(); //送 50 Test_CEG
|
||||
$this->_addFreeItem(); //送 50 Test_CEG
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
$this->_setV(TN_RANK_STATUS, 0, 1);
|
||||
}
|
||||
@ -130,17 +130,6 @@ class UserController extends BaseAuthedController {
|
||||
}
|
||||
|
||||
private function _addFreeItem(){
|
||||
$chipMeta = \mt\Item::getMetaListByType(\mt\Item::CHIP_TYPE);
|
||||
foreach ($chipMeta as $row){
|
||||
Chip::addChip($row);
|
||||
}
|
||||
|
||||
foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) {
|
||||
$heroMeta = mt\Item::get($heroId);
|
||||
if ($heroMeta) {
|
||||
Hero::addHero($heroMeta);
|
||||
}
|
||||
}
|
||||
$addItems =array();
|
||||
foreach (mt\Parameter::getListValue('creator_present_items') as $itemsStr) {
|
||||
list($itemId, $itemNum) = explode(':', $itemsStr);
|
||||
@ -152,12 +141,6 @@ class UserController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
}
|
||||
array_push($addItems,
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => 50
|
||||
));
|
||||
|
||||
$awardService = new services\AwardService();
|
||||
$propertyChgService = new services\PropertyChgService();
|
||||
$this->_addItems($addItems, $awardService, $propertyChgService);
|
||||
|
@ -94,6 +94,8 @@ class Item {
|
||||
const PARACHUTE_TYPE = 16;
|
||||
const CHIP_BOX_TYPE = 17;
|
||||
const RING_TYPE = 19;
|
||||
const EMOJI_TYPE = 20;
|
||||
const RANDOM_BOX_TYPE = 21;
|
||||
|
||||
const FUNC_RENAME_CARD_SUBTYPE = 1;
|
||||
const MATERIAL_CHIP_SUBTYPE = 3;
|
||||
|
@ -6,7 +6,7 @@ use phpcommon;
|
||||
|
||||
class Skill {
|
||||
|
||||
const DEFAULT_SKILL = 10101;
|
||||
const DEFAULT_SKILL = 10401;
|
||||
public static function get($id)
|
||||
{
|
||||
return getXVal(self::getMetaList(), $id);
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace services;
|
||||
|
||||
use mt\Item;
|
||||
|
||||
class AwardService extends BaseService {
|
||||
|
||||
private $items = array();
|
||||
@ -14,10 +16,17 @@ class AwardService extends BaseService {
|
||||
return;
|
||||
}
|
||||
}
|
||||
array_push($this->items, array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum
|
||||
));
|
||||
$itemMeta = Item::get($itemId);
|
||||
if (!in_array(
|
||||
$itemMeta['type'],array(
|
||||
Item::RANDOM_BOX_TYPE,
|
||||
))){
|
||||
array_push($this->items, array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function toDto()
|
||||
|
@ -129,6 +129,7 @@ class TameBattleDataService extends BaseService {
|
||||
case self::MATCH_MODE_RANK:
|
||||
{
|
||||
//排位赛
|
||||
$this->updatePvpData();
|
||||
$this->updateRankData();
|
||||
$this->updateScore();
|
||||
$this->settlementReward();
|
||||
|
Loading…
x
Reference in New Issue
Block a user