|
|
@@ -1514,6 +1514,9 @@ public class LawyerUserViolationServiceImpl extends ServiceImpl<LawyerUserViolat
|
|
|
detailVO.setReportingUserName(reportingUserName);
|
|
|
}
|
|
|
|
|
|
+ // 设置订单价格字符串
|
|
|
+ setOrderPriceStr(detailVO);
|
|
|
+
|
|
|
log.info("根据订单ID查询举报详情成功,orderId={}, violationId={}", orderId, detailVO.getViolationId());
|
|
|
return detailVO;
|
|
|
|
|
|
@@ -1524,6 +1527,69 @@ public class LawyerUserViolationServiceImpl extends ServiceImpl<LawyerUserViolat
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 金额单位转换:分转元
|
|
|
+ */
|
|
|
+ private static final int FEN_TO_YUAN = 100;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置订单价格字符串
|
|
|
+ * <p>
|
|
|
+ * 根据charge_minute、minute_num、charge_time、time_num字段设置orderPriceStr
|
|
|
+ * 优先级:charge_minute和minute_num > charge_time和time_num
|
|
|
+ * chargeMinute和chargeTime单位都是分,需要转换为元并保留两位小数,去掉尾随的0
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param detailVO 举报详情VO对象
|
|
|
+ */
|
|
|
+ private void setOrderPriceStr(LawyerViolationDetailVO detailVO) {
|
|
|
+ if (detailVO == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当charge_minute和minute_num不为空时,返回"¥charge_minute/minute_num分钟"
|
|
|
+ // chargeMinute单位是分,需要转换为元并保留两位小数,去掉尾随的0
|
|
|
+ if (detailVO.getChargeMinute() != null && detailVO.getMinuteNum() != null) {
|
|
|
+ BigDecimal chargeMinuteYuan = BigDecimal.valueOf(detailVO.getChargeMinute())
|
|
|
+ .divide(BigDecimal.valueOf(FEN_TO_YUAN), 2, RoundingMode.HALF_UP);
|
|
|
+ String priceStr = formatPrice(chargeMinuteYuan);
|
|
|
+ String orderPriceStr = String.format("¥%s/%d分钟", priceStr, detailVO.getMinuteNum());
|
|
|
+ detailVO.setOrderPriceStr(orderPriceStr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当charge_time和time_num不为空时,返回"¥charge_time/time_num次"
|
|
|
+ // chargeTime单位是分,需要转换为元并保留两位小数,去掉尾随的0
|
|
|
+ if (detailVO.getChargeTime() != null && detailVO.getTimeNum() != null) {
|
|
|
+ BigDecimal chargeTimeYuan = BigDecimal.valueOf(detailVO.getChargeTime())
|
|
|
+ .divide(BigDecimal.valueOf(FEN_TO_YUAN), 2, RoundingMode.HALF_UP);
|
|
|
+ String priceStr = formatPrice(chargeTimeYuan);
|
|
|
+ String orderPriceStr = String.format("¥%s/%d次", priceStr, detailVO.getTimeNum());
|
|
|
+ detailVO.setOrderPriceStr(orderPriceStr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当都为空则返回空
|
|
|
+ detailVO.setOrderPriceStr("");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 格式化价格,去掉尾随的0
|
|
|
+ * <p>
|
|
|
+ * 例如:1.00 -> 1, 1.50 -> 1.5, 1.25 -> 1.25
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @param price 价格(BigDecimal)
|
|
|
+ * @return 格式化后的价格字符串
|
|
|
+ */
|
|
|
+ private String formatPrice(BigDecimal price) {
|
|
|
+ if (price == null) {
|
|
|
+ return "0";
|
|
|
+ }
|
|
|
+ // 去掉尾随的0
|
|
|
+ return price.stripTrailingZeros().toPlainString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 根据用户ID获取举报人姓名
|
|
|
*
|
|
|
* @param userId 用户ID
|