Authored by LUOXC

fixbug

@@ -35,6 +35,7 @@ import java.util.stream.Collectors; @@ -35,6 +35,7 @@ import java.util.stream.Collectors;
35 35
36 import static com.yohoufo.common.utils.DateUtil.formatYYMMddHHmmssPoint; 36 import static com.yohoufo.common.utils.DateUtil.formatYYMMddHHmmssPoint;
37 import static com.yohoufo.dal.order.model.InviteSettlement.STATUS_WAIT_SETTLE; 37 import static com.yohoufo.dal.order.model.InviteSettlement.STATUS_WAIT_SETTLE;
  38 +import static com.yohoufo.order.utils.InviteSettlementUtils.RMB_FLAG;
38 import static com.yohoufo.order.utils.InviteSettlementUtils.formatAmount; 39 import static com.yohoufo.order.utils.InviteSettlementUtils.formatAmount;
39 import static com.yohoufo.order.utils.ServiceExceptions.throwServiceException; 40 import static com.yohoufo.order.utils.ServiceExceptions.throwServiceException;
40 41
@@ -113,9 +114,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService { @@ -113,9 +114,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService {
113 .pageSize(limit) 114 .pageSize(limit)
114 .pageTotal((totalElements % limit == 0) ? (totalElements / limit) : (totalElements / limit + 1)) 115 .pageTotal((totalElements % limit == 0) ? (totalElements / limit) : (totalElements / limit + 1))
115 .totalElements(totalElements) 116 .totalElements(totalElements)
116 - .totalSettleAmount(formatAmount("¥%s", totalSettleAmount))  
117 - .totalPaidAmount(formatAmount("¥%s", totalPaidAmount))  
118 - .totalWaitPayAmount(formatAmount("¥%s", totalWaitPayAmount)); 117 + .totalSettleAmount(formatAmount("%s%s", RMB_FLAG, totalSettleAmount))
  118 + .totalPaidAmount(formatAmount("%s%s", RMB_FLAG, totalPaidAmount))
  119 + .totalWaitPayAmount(formatAmount("%s%s", RMB_FLAG, totalWaitPayAmount));
119 if (totalElements == 0) { 120 if (totalElements == 0) {
120 return builder 121 return builder
121 .list(Lists.newArrayList()) 122 .list(Lists.newArrayList())
@@ -140,9 +141,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService { @@ -140,9 +141,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService {
140 .map(item -> new InviteSettlementItemListVO.InviteSettlementItemVO() 141 .map(item -> new InviteSettlementItemListVO.InviteSettlementItemVO()
141 .setBuyerOrderCode(item.getBuyerOrderCode().toString()) 142 .setBuyerOrderCode(item.getBuyerOrderCode().toString())
142 .setSellerName(sellerUidNickNameMap.get(item.getSellerUid())) 143 .setSellerName(sellerUidNickNameMap.get(item.getSellerUid()))
143 - .setOrderAmount(formatAmount("¥%s", item.getOrderAmount())) 144 + .setOrderAmount(formatAmount("%s%s", RMB_FLAG, item.getOrderAmount()))
144 .setOrderCreateTime(formatYYMMddHHmmssPoint(item.getOrderCreateTime())) 145 .setOrderCreateTime(formatYYMMddHHmmssPoint(item.getOrderCreateTime()))
145 - .setSettleAmount(formatAmount("¥%s", item.getSettleAmount())) 146 + .setSettleAmount(formatAmount("%s%s", RMB_FLAG, item.getSettleAmount()))
146 .setStatusDesc(itemHasPaid.test(item) ? "已付款" : "待付款")) 147 .setStatusDesc(itemHasPaid.test(item) ? "已付款" : "待付款"))
147 .collect(Collectors.toList())) 148 .collect(Collectors.toList()))
148 .build(); 149 .build();
@@ -16,15 +16,26 @@ import java.util.function.BiPredicate; @@ -16,15 +16,26 @@ import java.util.function.BiPredicate;
16 */ 16 */
17 public class InviteSettlementUtils { 17 public class InviteSettlementUtils {
18 18
  19 + public static String RMB_FLAG = "¥";
  20 +
19 public static String formatAmount(BigDecimal src) { 21 public static String formatAmount(BigDecimal src) {
20 return formatAmount("%s", src); 22 return formatAmount("%s", src);
21 } 23 }
22 24
23 - public static String formatAmount(String format, BigDecimal src) {  
24 - if (Objects.isNull(src)) { 25 + public static String formatAmount(String format, Object... args) {
  26 + if (Objects.isNull(args)) {
25 return null; 27 return null;
26 } else { 28 } else {
27 - return String.format(format, src.setScale(1, RoundingMode.FLOOR)); 29 + Object[] tmp = new Object[args.length];
  30 + for (int i = 0; i < args.length; i++) {
  31 + Object arg = args[i];
  32 + if (arg instanceof BigDecimal) {
  33 + tmp[i] = ((BigDecimal) arg).setScale(1, RoundingMode.FLOOR);
  34 + } else {
  35 + tmp[i] = arg;
  36 + }
  37 + }
  38 + return String.format(format, tmp);
28 } 39 }
29 } 40 }
30 41