add awardService
This commit is contained in:
parent
9425c26c37
commit
46028a3aaa
@ -96,5 +96,5 @@ class Award(object):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.fields = [
|
self.fields = [
|
||||||
['!item_list', [AwardItem()], '奖励物品列表']
|
['!items', [AwardItem()], '奖励物品列表']
|
||||||
]
|
]
|
||||||
|
@ -4,6 +4,7 @@ ini_set('date.timezone','Asia/Shanghai');
|
|||||||
require 'phpcommon/common.php';
|
require 'phpcommon/common.php';
|
||||||
require_once('phpcommon/sqlhelper.php');
|
require_once('phpcommon/sqlhelper.php');
|
||||||
require_once('models/BaseModel.php');
|
require_once('models/BaseModel.php');
|
||||||
|
require_once('services/BaseService.php');
|
||||||
|
|
||||||
define('TEAMID_KEY', 'team_uuid:');
|
define('TEAMID_KEY', 'team_uuid:');
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ require_once('mt/Item.php');
|
|||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/Drop.php');
|
require_once('mt/Drop.php');
|
||||||
|
|
||||||
|
require_once('services/AwardService.php');
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
class ShopController extends BaseAuthedController {
|
class ShopController extends BaseAuthedController {
|
||||||
@ -37,6 +39,10 @@ class ShopController extends BaseAuthedController {
|
|||||||
$this->_rspErr(2, '配置表错误');
|
$this->_rspErr(2, '配置表错误');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (Hero::find($heroId)) {
|
||||||
|
$this->_rspErr(3, '你已经有该英雄');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$costItems = array(
|
$costItems = array(
|
||||||
'item_id' => $goodsInfo['costItemId'],
|
'item_id' => $goodsInfo['costItemId'],
|
||||||
'item_num' => $goodsInfo['costItemNum'],
|
'item_num' => $goodsInfo['costItemNum'],
|
||||||
@ -48,6 +54,14 @@ class ShopController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
$this->_decItems($costItems);
|
$this->_decItems($costItems);
|
||||||
Hero::addHero($heroMeta);
|
Hero::addHero($heroMeta);
|
||||||
|
$awardService = new services\AwardService();
|
||||||
|
$heroDb = Hero::find($heroId);
|
||||||
|
if ($heroDb) {
|
||||||
|
$awardService->addHero(Hero::toDto($heroDb));
|
||||||
|
}
|
||||||
|
$this->rspData(array(
|
||||||
|
'award' => $awardService->toData()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buyHeroSkin()
|
public function buyHeroSkin()
|
||||||
|
49
webapp/services/AwardService.php
Normal file
49
webapp/services/AwardService.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class AwardService extends BaseService {
|
||||||
|
|
||||||
|
const ITEM_TYPE = 1;
|
||||||
|
const HERO_TYPE = 2;
|
||||||
|
const HEROSKIN_TYPE = 3;
|
||||||
|
const GUNSKIN_TYPE = 4;
|
||||||
|
|
||||||
|
private $items = array();
|
||||||
|
|
||||||
|
public function addItem($itemDto)
|
||||||
|
{
|
||||||
|
$this->internalAdd(self::ITEM_TYPE, $itemDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addHero($heroDto)
|
||||||
|
{
|
||||||
|
$this->internalAdd(self::HERO_TYPE, $heroDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addHeroSkin($heroSkinDto)
|
||||||
|
{
|
||||||
|
$this->internalAdd(self::HEROSKIN_TYPE, $heroSkinDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addGunSkin($gunSkinDto)
|
||||||
|
{
|
||||||
|
$this->internalAdd(self::GUNSKIN_TYPE, $gunSkinDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toDto()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'items' => $this->items
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function internalAdd($type, $dto)
|
||||||
|
{
|
||||||
|
array_push($items, array(
|
||||||
|
'type' => $type,
|
||||||
|
"union_${type}" => $dto
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class BaseService {
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user