1
This commit is contained in:
parent
ec8231e4eb
commit
a2aebe000f
@ -7,13 +7,19 @@ require_once('mt/Item.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/Drop.php');
|
||||
|
||||
require_once('models/User.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/HeroSkin.php');
|
||||
require_once('models/GunSkin.php');
|
||||
require_once('models/ShopBuyRecord.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\User;
|
||||
use models\Hero;
|
||||
use models\HeroSkin;
|
||||
use models\GunSkin;
|
||||
use models\ShopBuyRecord;
|
||||
|
||||
class ShopController extends BaseAuthedController {
|
||||
@ -177,7 +183,7 @@ class ShopController extends BaseAuthedController {
|
||||
$this->_rspErr(2, '配置表错误');
|
||||
return;
|
||||
}
|
||||
$costItems = $this->getCostTimes($priceInfo, $costItemId);
|
||||
$costItems = $this->getCostItems($priceInfo, $costItemId);
|
||||
if (empty($costItems)) {
|
||||
$this->_rspErr(2, '配置表错误2');
|
||||
return;
|
||||
@ -283,7 +289,7 @@ class ShopController extends BaseAuthedController {
|
||||
}
|
||||
$costItemMeta = mt\Item::get($costItemId);
|
||||
if (!$costItemMeta) {
|
||||
$this->_rspErr(1, 'item_id参数错误');
|
||||
$this->_rspErr(1, 'cost_item_id参数错误');
|
||||
return;
|
||||
}
|
||||
$types = array(mt\Item::HERO_TYPE,
|
||||
@ -306,7 +312,7 @@ class ShopController extends BaseAuthedController {
|
||||
$this->_rspErr(2, '配置表错误');
|
||||
return;
|
||||
}
|
||||
$costItems = $this->getCostTimes($priceInfo, $costItemId);
|
||||
$costItems = $this->getCostItems($priceInfo, $costItemId);
|
||||
if (empty($costItems)) {
|
||||
$this->_rspErr(2, '配置表错误2');
|
||||
return;
|
||||
@ -341,7 +347,7 @@ class ShopController extends BaseAuthedController {
|
||||
$goodsDto['price_info'] = $priceInfo;
|
||||
}
|
||||
}
|
||||
$this->rspData(array(
|
||||
$this->_rspData(array(
|
||||
'award' => $awardService->toDto(),
|
||||
'property_chg' => array(
|
||||
'user_info' => User::info($this->_getOrmUserInfo())
|
||||
@ -394,7 +400,7 @@ class ShopController extends BaseAuthedController {
|
||||
private function getCostItems($priceInfo, $costItemId)
|
||||
{
|
||||
$costGroup = null;
|
||||
array_walk($priceInfo['cost_list'], function ($val) use(&$costGroup, $costItemId) {
|
||||
array_walk($priceInfo['price_info']['cost_list'], function ($val) use(&$costGroup, $costItemId) {
|
||||
if ($costGroup) {
|
||||
return;
|
||||
}
|
||||
@ -408,8 +414,7 @@ class ShopController extends BaseAuthedController {
|
||||
}
|
||||
$costItems = array();
|
||||
array_walk($costGroup, function ($val) use (&$costItems, $priceInfo) {
|
||||
if ($val['is_discount'] &&
|
||||
$priceInfo['discount'] > 0 &&
|
||||
if ($val['discount'] > 0 &&
|
||||
$this->_getNowTime() >= $priceInfo['discount_begin_time'] &&
|
||||
$this->_getNowTime() <= $priceInfo['discount_end_time']
|
||||
) {
|
||||
@ -460,7 +465,7 @@ class ShopController extends BaseAuthedController {
|
||||
case mt\Item::HERO_TYPE:
|
||||
{
|
||||
$heroDb = Hero::find($itemMeta['id']);
|
||||
if (!$heroDb) {
|
||||
if ($heroDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = '你已经拥有该英雄';
|
||||
return false;
|
||||
@ -470,7 +475,7 @@ class ShopController extends BaseAuthedController {
|
||||
case mt\Item::HERO_SKIN_TYPE:
|
||||
{
|
||||
$heroSkinDb = HeroSkin::find($itemMeta['id']);
|
||||
if (!$heroSkinDb) {
|
||||
if ($heroSkinDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = '你已经拥有该皮肤';
|
||||
return false;
|
||||
@ -480,7 +485,7 @@ class ShopController extends BaseAuthedController {
|
||||
case mt\Item::GUN_SKIN_TYPE:
|
||||
{
|
||||
$gunSkinDb = GunSkin::find($itemMeta['id']);
|
||||
if (!$gunSkinDb) {
|
||||
if ($gunSkinDb) {
|
||||
$errCode = 10;
|
||||
$errMsg = '你已经拥有该皮肤';
|
||||
return false;
|
||||
|
@ -34,14 +34,14 @@ class HeroSkin extends BaseModel {
|
||||
);
|
||||
}
|
||||
|
||||
public static function addSkin($skinId)
|
||||
public static function addSkin($itemMeta)
|
||||
{
|
||||
SqlHelper::upsert(
|
||||
myself()->_getSelfMysql(),
|
||||
't_hero_skin',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'skin_id' => $skinId
|
||||
'skin_id' => $itemMeta['id']
|
||||
),
|
||||
array(
|
||||
'skin_state' => 3,
|
||||
@ -49,7 +49,7 @@ class HeroSkin extends BaseModel {
|
||||
),
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId(),
|
||||
'skin_id' => $skinId,
|
||||
'skin_id' => $itemMeta['id'],
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
|
@ -94,18 +94,21 @@ class Item {
|
||||
$discount = splitStr1($meta['discount']);
|
||||
if ($meta['gold'] > 0) {
|
||||
array_push($info['price_info']['cost_list'],
|
||||
array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $meta['gold'],
|
||||
'discount' => count($discount) > 0 ? (int)$discount[0] : 0
|
||||
));
|
||||
)));
|
||||
}
|
||||
if ($meta['diamond_price'] > 0) {
|
||||
array_push($info['price_info']['cost_list'],
|
||||
array(
|
||||
array(
|
||||
'item_id' => V_ITEM_DIAMOND,
|
||||
'item_num' => $meta['diamond_price'],
|
||||
'discount' => count($discount) > 1 ? (int)$discount[1] : 0
|
||||
)
|
||||
));
|
||||
}
|
||||
return $info;
|
||||
|
@ -8,7 +8,7 @@ class AwardService extends BaseService {
|
||||
|
||||
public function addItem($itemId, $itemNum)
|
||||
{
|
||||
array_push($items, array(
|
||||
array_push($this->items, array(
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum
|
||||
));
|
||||
|
Loading…
x
Reference in New Issue
Block a user