Authored by LUOXC

fixbug

... ... @@ -35,6 +35,7 @@ import java.util.stream.Collectors;
import static com.yohoufo.common.utils.DateUtil.formatYYMMddHHmmssPoint;
import static com.yohoufo.dal.order.model.InviteSettlement.STATUS_WAIT_SETTLE;
import static com.yohoufo.order.utils.InviteSettlementUtils.RMB_FLAG;
import static com.yohoufo.order.utils.InviteSettlementUtils.formatAmount;
import static com.yohoufo.order.utils.ServiceExceptions.throwServiceException;
... ... @@ -113,9 +114,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService {
.pageSize(limit)
.pageTotal((totalElements % limit == 0) ? (totalElements / limit) : (totalElements / limit + 1))
.totalElements(totalElements)
.totalSettleAmount(formatAmount("¥%s", totalSettleAmount))
.totalPaidAmount(formatAmount("¥%s", totalPaidAmount))
.totalWaitPayAmount(formatAmount("¥%s", totalWaitPayAmount));
.totalSettleAmount(formatAmount("%s%s", RMB_FLAG, totalSettleAmount))
.totalPaidAmount(formatAmount("%s%s", RMB_FLAG, totalPaidAmount))
.totalWaitPayAmount(formatAmount("%s%s", RMB_FLAG, totalWaitPayAmount));
if (totalElements == 0) {
return builder
.list(Lists.newArrayList())
... ... @@ -140,9 +141,9 @@ public class InviteSettlementServiceImpl implements IInviteSettlementService {
.map(item -> new InviteSettlementItemListVO.InviteSettlementItemVO()
.setBuyerOrderCode(item.getBuyerOrderCode().toString())
.setSellerName(sellerUidNickNameMap.get(item.getSellerUid()))
.setOrderAmount(formatAmount("¥%s", item.getOrderAmount()))
.setOrderAmount(formatAmount("%s%s", RMB_FLAG, item.getOrderAmount()))
.setOrderCreateTime(formatYYMMddHHmmssPoint(item.getOrderCreateTime()))
.setSettleAmount(formatAmount("¥%s", item.getSettleAmount()))
.setSettleAmount(formatAmount("%s%s", RMB_FLAG, item.getSettleAmount()))
.setStatusDesc(itemHasPaid.test(item) ? "已付款" : "待付款"))
.collect(Collectors.toList()))
.build();
... ...
... ... @@ -16,15 +16,26 @@ import java.util.function.BiPredicate;
*/
public class InviteSettlementUtils {
public static String RMB_FLAG = "¥";
public static String formatAmount(BigDecimal src) {
return formatAmount("%s", src);
}
public static String formatAmount(String format, BigDecimal src) {
if (Objects.isNull(src)) {
public static String formatAmount(String format, Object... args) {
if (Objects.isNull(args)) {
return null;
} else {
return String.format(format, src.setScale(1, RoundingMode.FLOOR));
Object[] tmp = new Object[args.length];
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
if (arg instanceof BigDecimal) {
tmp[i] = ((BigDecimal) arg).setScale(1, RoundingMode.FLOOR);
} else {
tmp[i] = arg;
}
}
return String.format(format, tmp);
}
}
... ...