This commit is contained in:
aozhiwei 2021-12-01 13:39:44 +08:00
parent a2aebe000f
commit c685808f5e
5 changed files with 76 additions and 13 deletions

View File

@ -101,7 +101,8 @@ class PropertyChg(object):
def __init__(self): def __init__(self):
self.fields = [ self.fields = [
['user_info', UserInfo(), '用户信息变更(用来更新本地客户端字段(有则更新无则不变))'] ['user_info', UserInfo(), '用户信息变更(用来更新本地客户端字段(有则更新无则不变))'],
['!container_chg', [''], '容器类数据变更(bag、hero、heroSkin、gunSkin)']
] ]
class CostInfoItem(object): class CostInfoItem(object):

View File

@ -7,6 +7,8 @@ require_once('models/GunSkin.php');
require_once('models/GunTalent.php'); require_once('models/GunTalent.php');
require_once('models/User.php'); require_once('models/User.php');
require_once('services/PropertyChgService.php');
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\GunSkin; use models\GunSkin;
use models\GunTalent; use models\GunTalent;
@ -84,10 +86,10 @@ class GunController extends BaseAuthedController {
} }
$this->_decItems($costList); $this->_decItems($costList);
GunTalent::upgradeLv($typeId, $talentId, $currLv + 1); GunTalent::upgradeLv($typeId, $talentId, $currLv + 1);
$propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg();
$this->_rspData(array( $this->_rspData(array(
'property_chg' => array( 'property_chg' => $propertyChgService->toDto()
'user_info' => User::info($this->_getOrmUserInfo())
)
)); ));
} }

View File

@ -14,6 +14,7 @@ require_once('models/GunSkin.php');
require_once('models/ShopBuyRecord.php'); require_once('models/ShopBuyRecord.php');
require_once('services/AwardService.php'); require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\User; use models\User;
@ -110,6 +111,7 @@ class ShopController extends BaseAuthedController {
return; return;
} }
$propertyChgService = new services\PropertyChgService();
$itemMeta = mt\Item::get($itemId); $itemMeta = mt\Item::get($itemId);
if (!$itemMeta) { if (!$itemMeta) {
$this->_rspErr(1, 'goods_id参数错误'); $this->_rspErr(1, 'goods_id参数错误');
@ -218,11 +220,10 @@ class ShopController extends BaseAuthedController {
$goodsDto['price_info'] = $priceInfo; $goodsDto['price_info'] = $priceInfo;
} }
} }
$propertyChgService->addUserChg();
$this->rspData(array( $this->rspData(array(
'award' => $awardService->toDto(), 'award' => $awardService->toDto(),
'property_chg' => array( 'property_chg' => $propertyChgService->toDto(),
'user_info' => User::info($this->_getOrmUserInfo())
),
'goods_chg' => $goodsDto 'goods_chg' => $goodsDto
)); ));
} }
@ -278,6 +279,7 @@ class ShopController extends BaseAuthedController {
private function outsideBuy($shopId, $itemId, $itemNum, $costItemId) private function outsideBuy($shopId, $itemId, $itemNum, $costItemId)
{ {
$propertyChgService = new services\PropertyChgService();
$itemMeta = mt\Item::get($itemId); $itemMeta = mt\Item::get($itemId);
if (!$itemMeta) { if (!$itemMeta) {
$this->_rspErr(1, 'item_id参数错误'); $this->_rspErr(1, 'item_id参数错误');
@ -347,11 +349,10 @@ class ShopController extends BaseAuthedController {
$goodsDto['price_info'] = $priceInfo; $goodsDto['price_info'] = $priceInfo;
} }
} }
$propertyChgService->addUserChg();
$this->_rspData(array( $this->_rspData(array(
'award' => $awardService->toDto(), 'award' => $awardService->toDto(),
'property_chg' => array( 'property_chg' => $propertyChgService->toDto(),
'user_info' => User::info($this->_getOrmUserInfo())
),
'goods_chg' => $goodsDto 'goods_chg' => $goodsDto
)); ));
} }

View File

@ -13,6 +13,8 @@ require_once('mt/Equip.php');
require_once('mt/Player.php'); require_once('mt/Player.php');
require_once('mt/Robot.php'); require_once('mt/Robot.php');
require_once('services/PropertyChgService.php');
use phpcommon\SqlHelper; use phpcommon\SqlHelper;
use models\User; use models\User;
use models\Hero; use models\Hero;
@ -138,10 +140,10 @@ class UserController extends BaseAuthedController {
if (count($fieldsKv) > 0) { if (count($fieldsKv) > 0) {
$this->_updateUserInfo($fieldsKv); $this->_updateUserInfo($fieldsKv);
} }
$propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg();
$this->_rspData(array( $this->_rspData(array(
'property_chg' => array( 'property_chg' => $propertyChgService->toDto()
'user_info' => User::info($this->_getOrmUserInfo())
)
)); ));
} }

View File

@ -0,0 +1,57 @@
<?php
namespace services;
require_once('models/User.php');
use models\User;
class PropertyChgService extends BaseService {
private $chgList = array();
private $userChg = false;
public function addUserChg()
{
$this->userChg = true;
}
public function addHeroChg()
{
$this->internalAddChg('hero');
}
public function addHeroSkinChg()
{
$this->internalAddChg('heroSkin');
}
public function addGunSkinChg()
{
$this->internalAddChg('gunSkin');
}
public function addBagChg()
{
$this->internalAddChg('bag');
}
public function toDto()
{
return array(
'user_info' => $this->userChg ? User::info(myself()->_getOrmUserInfo()) : array(),
'container_chg' => $this->chgList
);
}
private function internalAddChg($name)
{
foreach ($chgLlist as $item) {
if ($item == $name) {
return;
}
}
array_push($chgList, $name);
}
}