From ad004bb04318090669da0a8218c39d6282ec1745 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Fri, 23 Sep 2022 18:07:25 +0800 Subject: [PATCH] 1 --- webapp/controller/ChipController.class.php | 38 +++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index e3de1f16..1c8dd32d 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -350,16 +350,36 @@ class ChipController extends BaseAuthedController $cumulative_cost += \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']); // Chip::deleteChip(['token_id'=>$val]); } - $this->_rspData([ - 'state' => 0, - 'data' => [ - 'main'=>$token_id_main, - 'param'=>$token_id_param, - 'main_cost'=>$upgrade_cost, - 'param_cost'=>$cumulative_cost, - ], - ]);return; + $num = round(round(($cumulative_cost/$upgrade_cost),5)*10000); + $a = rand(1,10000); + if ($num<$a){ + $this->_rspData([ + 'state' => 0, + 'data' => [ + 'main'=>$token_id_main, + 'param'=>$token_id_param, + 'main_cost'=>$upgrade_cost, + 'param_cost'=>$cumulative_cost, + 'num'=>$num, + 'rand'=>$a + ], + ]); + return; + }else{ + $this->_rspData([ + 'state' => 1, + 'data' => [ + 'main'=>$token_id_main, + 'param'=>$token_id_param, + 'main_cost'=>$upgrade_cost, + 'param_cost'=>$cumulative_cost, + 'num'=>$num, + 'rand'=>$a + ], + ]); + return; + } $propertyChgService = new services\PropertyChgService(); $propertyChgService->addChip(); if ($num