fix: 多条退款detail合并为单条
This commit is contained in:
@@ -22,10 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -178,9 +175,9 @@ public class OrderService {
|
||||
orderVo.setTime(orderInfo.getCreatedAt());
|
||||
if (orderInfo.getStatus().equals("paying") || orderInfo.getStatus().equals("unpaid")) {
|
||||
Long totalSeconds = orderInfo.getCreatedAt() + 15 * 60 * 1000l - System.currentTimeMillis();
|
||||
if(totalSeconds>0){
|
||||
orderVo.setExpiredMinutes(totalSeconds/1000 / 60);
|
||||
orderVo.setExpiredSeconds(totalSeconds/1000 % 60);
|
||||
if (totalSeconds > 0) {
|
||||
orderVo.setExpiredMinutes(totalSeconds / 1000 / 60);
|
||||
orderVo.setExpiredSeconds(totalSeconds / 1000 % 60);
|
||||
}
|
||||
}
|
||||
orderVo.setPayAmount(orderInfo.getOrderAmount());
|
||||
@@ -224,21 +221,28 @@ public class OrderService {
|
||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||
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);
|
||||
String key;
|
||||
if (item.getCartId() == null) {
|
||||
key = item.getProductId().toString() + item.getProductSkuId() + item.getPlaceNum();
|
||||
}else {
|
||||
key = item.getCartId().toString();
|
||||
}
|
||||
TbOrderDetail orderDetail = detailHashMap.get(key);
|
||||
if (orderDetail == null) {
|
||||
detailHashMap.put(key, item);
|
||||
} else {
|
||||
orderDetail.setNum(orderDetail.getNum() + item.getNum());
|
||||
orderDetail.setPriceAmount(orderDetail.getPriceAmount().add(item.getPriceAmount()));
|
||||
orderDetail.setPackAmount(orderDetail.getPackAmount().add(item.getPackAmount()));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
for (TbOrderDetail orderDetail : detailHashMap.values()) {
|
||||
num = num + orderDetail.getNum();
|
||||
}
|
||||
orderInfo.setDetailList(new ArrayList<>(detailHashMap.values()));
|
||||
}else {
|
||||
} else {
|
||||
orderInfo.setDetailList(list);
|
||||
}
|
||||
|
||||
@@ -292,10 +296,16 @@ 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);
|
||||
String key;
|
||||
if (item.getCartId() == null) {
|
||||
key = item.getProductId().toString() + item.getProductSkuId() + item.getPlaceNum();
|
||||
}else {
|
||||
key = item.getCartId().toString();
|
||||
}
|
||||
TbOrderDetail orderDetail = detailHashMap.get(key);
|
||||
if (orderDetail == null) {
|
||||
detailHashMap.put(key, item);
|
||||
} else {
|
||||
orderDetail.setNum(orderDetail.getNum() + item.getNum());
|
||||
orderDetail.setPriceAmount(orderDetail.getPriceAmount().add(item.getPriceAmount()));
|
||||
orderDetail.setPackAmount(orderDetail.getPackAmount().add(item.getPackAmount()));
|
||||
@@ -332,9 +342,9 @@ public class OrderService {
|
||||
orderVo.setTime(orderInfo.getCreatedAt());
|
||||
if (orderInfo.getStatus().equals("paying") || orderInfo.getStatus().equals("unpaid")) {
|
||||
long totalSeconds = orderInfo.getCreatedAt() + 15 * 60 * 1000l - System.currentTimeMillis();
|
||||
if(totalSeconds>0){
|
||||
orderVo.setExpiredMinutes(totalSeconds/1000 / 60);
|
||||
orderVo.setExpiredSeconds(totalSeconds/1000 % 60);
|
||||
if (totalSeconds > 0) {
|
||||
orderVo.setExpiredMinutes(totalSeconds / 1000 / 60);
|
||||
orderVo.setExpiredSeconds(totalSeconds / 1000 % 60);
|
||||
}
|
||||
}
|
||||
orderVo.setPayAmount(orderInfo.getOrderAmount());
|
||||
|
||||
Reference in New Issue
Block a user