From c12a61e36253edcb0a0f9121d6c2b2882064210a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 22 Sep 2022 10:58:10 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 4 ++-- webapp/bootstrap/init.php | 10 ++++++++++ webapp/models/User.php | 12 ++++++------ webapp/services/FormulaService.php | 14 ++++---------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index b68e6e9f..b0f09760 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -40,8 +40,8 @@ CREATE TABLE `t_user` ( `history_best_rank` int(11) NOT NULL DEFAULT '0' COMMENT '历史最高段位', `score` int(11) NOT NULL DEFAULT '0' COMMENT '积分', `history_best_score` int(11) NOT NULL DEFAULT '0' COMMENT '历史最高积分', - `gold` bigint NOT NULL DEFAULT '0' COMMENT '金币', - `diamond` bigint NOT NULL DEFAULT '0' COMMENT '钻石', + `gold` double NOT NULL DEFAULT '0' COMMENT '金币', + `diamond` double NOT NULL DEFAULT '0' COMMENT '钻石', `hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '当前上阵英雄id', `first_fight` int(11) NOT NULL DEFAULT '0' COMMENT '是否首战', `last_season_id` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次赛季id', diff --git a/webapp/bootstrap/init.php b/webapp/bootstrap/init.php index d61feadc..5ebbe2d1 100644 --- a/webapp/bootstrap/init.php +++ b/webapp/bootstrap/init.php @@ -41,6 +41,16 @@ function isValidSex($sex) return in_array($sex, array(0, 1, 2)); } +function cegFormat($ceg) +{ + return floor($ceg * 100) / 100; +} + +function cecFormat($cec) +{ + return floor($cec * 100) / 100; +} + $_myself = null; function myself() diff --git a/webapp/models/User.php b/webapp/models/User.php index 424a3e6b..88d5fdfc 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -39,8 +39,8 @@ class User extends BaseModel { 'history_best_rank' => $row['history_best_rank'], 'score' => $row['score'], 'history_best_score' => $row['history_best_score'], - 'gold' => $row['gold'], - 'diamond' => $row['diamond'], + 'gold' => cegFormat($row['gold']), + 'diamond' => cecFormat($row['diamond']), 'hero_id' => $row['hero_id'], 'first_fight' => $row['first_fight'], 'already_guide' => $row['already_guide'], @@ -68,8 +68,8 @@ class User extends BaseModel { 'history_best_rank' => $row['history_best_rank'], 'score' => $row['score'], 'history_best_score' => $row['history_best_score'], - 'gold' => $row['gold'], - 'diamond' => $row['diamond'], + 'gold' => cegFormat($row['gold']), + 'diamond' => cecFormat($row['diamond']), 'hero_id' => $row['hero_id'], 'first_fight' => $row['first_fight'], 'already_guide' => $row['already_guide'], @@ -94,8 +94,8 @@ class User extends BaseModel { 'exp' => $row['exp'], 'rank' => $row['rank'], 'score' => $row['score'], - 'gold' => $row['gold'], - 'diamond' => $row['diamond'], + 'gold' => cegFormat($row['gold']), + 'diamond' => cecFormat($row['diamond']), 'hero_id' => $row['hero_id'], 'pve_instance_id' => $row['pve_instance_id'], 'like_count' => $row['like_count'], diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php index 54eb7ed9..c29c8dce 100644 --- a/webapp/services/FormulaService.php +++ b/webapp/services/FormulaService.php @@ -40,7 +40,7 @@ class FormulaService extends BaseService { (1 - ($ranked >= 30 ? 1 : 0)) * ($kills >= 1 ? 1 : 0) * ($aliveTime >= 30 ? 1 : 0); - return round($ceg); + return cegFormat(($ceg)); } public static function calcHeroPveCeg($heroDto, $instanceLevel, $instanceRank, $bossReward) @@ -53,13 +53,7 @@ class FormulaService extends BaseService { (0.8 - ($instanceRank - 1) * 0.25 + $bossReward * 0.2) * 1/10; - error_log(json_encode(array( - 'instanceLevel' => $instanceLevel, - 'instanceRank' => $instanceRank, - 'bossReward' => $bossReward, - 'ceg' => $ceg - ))); - return round($ceg); + return cegFormat($ceg); } public static function calcWeaponPvpCeg($weaponDto, $params) @@ -86,7 +80,7 @@ class FormulaService extends BaseService { (1 - ($ranked >= 30 ? 1 : 0)) * ($kills >= 1 ? 1 : 0) * ($aliveTime >= 30 ? 1 : 0); - return round($ceg); + return cegFormat($ceg); } public static function calcWeaponPveCeg($weaponDb, $instanceLevel, $instanceRank, $bossReward) @@ -99,7 +93,7 @@ class FormulaService extends BaseService { (0.8 - ($instanceRank - 1) * 0.25 + $bossReward * 0.2) * 1/10; - return round(ceg); + return cegFormat(ceg); } public static function calcHeroFragmentProbabilityPvp($params,