|
@@ -24,6 +24,8 @@ import com.project.common.utils.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -340,13 +342,15 @@ public class PlatBasicsServiceImpl extends ServiceImpl<PlatBasicsMapper, PlatBas
|
|
|
if (StringUtils.isNull(platBasics)) {
|
|
|
StringUtils.getMapData("注册用户数", "registerNum", 0, tempMap);
|
|
|
StringUtils.getMapData("活跃人数", "orderNum", 0, tempMap);
|
|
|
- tempMap.put("onlineRate", "0.0");
|
|
|
+ tempMap.put("onlineRate", "0");
|
|
|
}else{
|
|
|
StringUtils.getMapData("注册用户数", "registerNum", platBasics.getRegisterNum(), tempMap);
|
|
|
StringUtils.getMapData("活跃人数", "orderNum", platBasics.getOrderNum(), tempMap);
|
|
|
- double result = (double) platBasics.getOrderNum() / platBasics.getRegisterNum();
|
|
|
- String formattedResult = String.format("%.1f", result * 100);
|
|
|
- tempMap.put("onlineRate", formattedResult);
|
|
|
+ BigDecimal a = new BigDecimal(platBasics.getOrderNum());
|
|
|
+ BigDecimal b = new BigDecimal(platBasics.getRegisterNum());
|
|
|
+ BigDecimal result = a.divide(b, 4, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal percentage = result.multiply(new BigDecimal("100")).stripTrailingZeros();
|
|
|
+ tempMap.put("onlineRate", percentage.toPlainString());
|
|
|
}
|
|
|
return tempMap;
|
|
|
}
|