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