diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index be917c15..25769447 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -5,37 +5,17 @@ 需要对web3service回调的做签名校验!!! */ -class CallbackController extends BaseController { +require_once('services/CallBack.php'); - private $handlers = array( - 'mintNftHero' => 'MintNftHero' , - 'gameItemMallBuyOk' => 'GameItemMallBuyOk', - 'gameItemMarketBuyOk' => 'GameItemMarketBuyOk', - 'MarketSellOrderOk' => 'MarketSellOrderOk', - 'MarketBuyOrderOk' => 'MarketBuyOrderOk', - 'MarketCancelOrderOk' => 'MarketCancelOrderOk', - 'MarketPriceUpdateOrderOk' => 'MarketPriceUpdateOrderOk', - 'inappPurchase' => 'InAppPurchase', - 'outappPurchase' => 'OutAppPurchase', - ); +use services\CallBackService; + +class CallbackController extends BaseController { public function dispatch() { - error_log("CallbackController Begin"); + $cbService = new CallBackService(); $action = getReqVal('action', ''); - if (key_exists($action, $this->handlers)) { - error_log("Callback:dispatch____". json_encode($_REQUEST)); - $this->internalDispatch($this->handlers[$action]); - } else { - $this->_rspErr(500, 'not found'); - } - } - - private function internalDispatch($className) - { - require_once ('services/callback/' . $className . '.php'); - $obj = eval("return new services\\" . $className . "();"); - $obj->process(); + $cbService->dispatch($action); } } diff --git a/webapp/services/CallBack.php b/webapp/services/CallBack.php new file mode 100644 index 00000000..f0d2bd98 --- /dev/null +++ b/webapp/services/CallBack.php @@ -0,0 +1,39 @@ + 'MintNftHero' , + 'gameItemMallBuyOk' => 'GameItemMallBuyOk', + 'gameItemMarketBuyOk' => 'GameItemMarketBuyOk', + 'MarketSellOrderOk' => 'MarketSellOrderOk', + 'MarketBuyOrderOk' => 'MarketBuyOrderOk', + 'MarketCancelOrderOk' => 'MarketCancelOrderOk', + 'MarketPriceUpdateOrderOk' => 'MarketPriceUpdateOrderOk', + 'inappPurchase' => 'InAppPurchase', + 'outappPurchase' => 'OutAppPurchase', + ); + + public function dispatch($action) + { + error_log("CallbackController Begin"); + if (key_exists($action, $this->handlers)) { + error_log("Callback:dispatch____". json_encode($_REQUEST)); + $this->internalDispatch($this->handlers[$action]); + } else { + myself()->_rspErr(500, 'not found'); + die(); + } + } + + private function internalDispatch($className) + { + require_once ('services/callback/' . $className . '.php'); + $obj = eval("return new services\\" . $className . "();"); + $obj->process(); + die(); + } + +}