diff --git a/doc/_common.py b/doc/_common.py index 9a2ca92..4b8649d 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -101,7 +101,8 @@ class PropertyChg(object): def __init__(self): self.fields = [ - ['user_info', UserInfo(), '用户信息变更(用来更新本地客户端字段(有则更新无则不变))'] + ['user_info', UserInfo(), '用户信息变更(用来更新本地客户端字段(有则更新无则不变))'], + ['!container_chg', [''], '容器类数据变更(bag、hero、heroSkin、gunSkin)'] ] class CostInfoItem(object): diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index 966c7e9..dd99fea 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -7,6 +7,8 @@ require_once('models/GunSkin.php'); require_once('models/GunTalent.php'); require_once('models/User.php'); +require_once('services/PropertyChgService.php'); + use phpcommon\SqlHelper; use models\GunSkin; use models\GunTalent; @@ -84,10 +86,10 @@ class GunController extends BaseAuthedController { } $this->_decItems($costList); GunTalent::upgradeLv($typeId, $talentId, $currLv + 1); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); $this->_rspData(array( - 'property_chg' => array( - 'user_info' => User::info($this->_getOrmUserInfo()) - ) + 'property_chg' => $propertyChgService->toDto() )); } diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 8fa8540..0c521ee 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -14,6 +14,7 @@ require_once('models/GunSkin.php'); require_once('models/ShopBuyRecord.php'); require_once('services/AwardService.php'); +require_once('services/PropertyChgService.php'); use phpcommon\SqlHelper; use models\User; @@ -110,6 +111,7 @@ class ShopController extends BaseAuthedController { return; } + $propertyChgService = new services\PropertyChgService(); $itemMeta = mt\Item::get($itemId); if (!$itemMeta) { $this->_rspErr(1, 'goods_id参数错误'); @@ -218,11 +220,10 @@ class ShopController extends BaseAuthedController { $goodsDto['price_info'] = $priceInfo; } } + $propertyChgService->addUserChg(); $this->rspData(array( 'award' => $awardService->toDto(), - 'property_chg' => array( - 'user_info' => User::info($this->_getOrmUserInfo()) - ), + 'property_chg' => $propertyChgService->toDto(), 'goods_chg' => $goodsDto )); } @@ -278,6 +279,7 @@ class ShopController extends BaseAuthedController { private function outsideBuy($shopId, $itemId, $itemNum, $costItemId) { + $propertyChgService = new services\PropertyChgService(); $itemMeta = mt\Item::get($itemId); if (!$itemMeta) { $this->_rspErr(1, 'item_id参数错误'); @@ -347,11 +349,10 @@ class ShopController extends BaseAuthedController { $goodsDto['price_info'] = $priceInfo; } } + $propertyChgService->addUserChg(); $this->_rspData(array( 'award' => $awardService->toDto(), - 'property_chg' => array( - 'user_info' => User::info($this->_getOrmUserInfo()) - ), + 'property_chg' => $propertyChgService->toDto(), 'goods_chg' => $goodsDto )); } diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index d54ef6d..ec07bf8 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -13,6 +13,8 @@ require_once('mt/Equip.php'); require_once('mt/Player.php'); require_once('mt/Robot.php'); +require_once('services/PropertyChgService.php'); + use phpcommon\SqlHelper; use models\User; use models\Hero; @@ -138,10 +140,10 @@ class UserController extends BaseAuthedController { if (count($fieldsKv) > 0) { $this->_updateUserInfo($fieldsKv); } + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); $this->_rspData(array( - 'property_chg' => array( - 'user_info' => User::info($this->_getOrmUserInfo()) - ) + 'property_chg' => $propertyChgService->toDto() )); } diff --git a/webapp/services/PropertyChgService.php b/webapp/services/PropertyChgService.php new file mode 100644 index 0000000..d737fcd --- /dev/null +++ b/webapp/services/PropertyChgService.php @@ -0,0 +1,57 @@ +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); + } + +}