fix: 多条退款detail合并为单条
This commit is contained in:
@@ -271,6 +271,18 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
HashMap<String, TbOrderDetail> detailHashMap = new HashMap<>();
|
||||||
|
list.forEach(item -> {
|
||||||
|
TbOrderDetail orderDetail = detailHashMap.get(item.getCartId().toString());
|
||||||
|
if (orderDetail == null) {
|
||||||
|
detailHashMap.put(item.getCartId().toString(), item);
|
||||||
|
}else {
|
||||||
|
orderDetail.setNum(orderDetail.getNum() + item.getNum());
|
||||||
|
orderDetail.setPriceAmount(orderDetail.getPriceAmount().add(item.getPriceAmount()));
|
||||||
|
orderDetail.setPackAmount(orderDetail.getPackAmount().add(item.getPackAmount()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 根据placeNum进行分组
|
// 根据placeNum进行分组
|
||||||
Map<Integer, List<TbOrderDetail>> groupedByPlaceNum = list.stream()
|
Map<Integer, List<TbOrderDetail>> groupedByPlaceNum = list.stream()
|
||||||
.collect(Collectors.groupingBy(TbOrderDetail::getPlaceNum));
|
.collect(Collectors.groupingBy(TbOrderDetail::getPlaceNum));
|
||||||
@@ -296,7 +308,7 @@ public class OrderService {
|
|||||||
orderVo.setStatus(orderInfo.getStatus());
|
orderVo.setStatus(orderInfo.getStatus());
|
||||||
//TODO 增加商家二维码
|
//TODO 增加商家二维码
|
||||||
orderVo.setShopQrcode(shopInfo.getShopQrcode());
|
orderVo.setShopQrcode(shopInfo.getShopQrcode());
|
||||||
orderVo.setDetails(list);
|
orderVo.setDetails((List<TbOrderDetail>) detailHashMap.values());
|
||||||
orderVo.setOrderNo(orderInfo.getOrderNo());
|
orderVo.setOrderNo(orderInfo.getOrderNo());
|
||||||
orderVo.setTime(orderInfo.getCreatedAt());
|
orderVo.setTime(orderInfo.getCreatedAt());
|
||||||
if (orderInfo.getStatus().equals("paying") || orderInfo.getStatus().equals("unpaid")) {
|
if (orderInfo.getStatus().equals("paying") || orderInfo.getStatus().equals("unpaid")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user