no message
This commit is contained in:
parent
49394a5172
commit
a2a009a1e2
|
|
@ -987,6 +987,48 @@ public class OrderMasterController extends BaseController {
|
||||||
// orderMaster.setOrderStatuses();
|
// orderMaster.setOrderStatuses();
|
||||||
// }
|
// }
|
||||||
List<OrderMaster> list = orderMasterService.selectOrderMasterList(orderMaster);
|
List<OrderMaster> list = orderMasterService.selectOrderMasterList(orderMaster);
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return voDataTable(orderListResponses, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 优化1:收集所有需要查询的ID,避免重复查询
|
||||||
|
Set<Long> workerIds = new HashSet<>();
|
||||||
|
Set<Long> addressIds = new HashSet<>();
|
||||||
|
Set<Long> goodsIds = new HashSet<>();
|
||||||
|
|
||||||
|
list.forEach(master -> {
|
||||||
|
if (master.getWorkerId() != null) {
|
||||||
|
workerIds.add(master.getWorkerId());
|
||||||
|
}
|
||||||
|
if (master.getAddressId() != null) {
|
||||||
|
addressIds.add(master.getAddressId());
|
||||||
|
}
|
||||||
|
if (master.getGoodsId() != null) {
|
||||||
|
goodsIds.add(master.getGoodsId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 优化2:批量查询常用数据,避免循环中的重复查询
|
||||||
|
Map<Long, Worker> workerMap = new HashMap<>();
|
||||||
|
Map<Long, CustomerAddress> addressMap = new HashMap<>();
|
||||||
|
Map<Long, Goods> goodsMap = new HashMap<>();
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(workerIds)) {
|
||||||
|
List<Worker> workers = workerService.selectByIds(workerIds);
|
||||||
|
workers.forEach(worker -> workerMap.put(worker.getId(), worker));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(addressIds)) {
|
||||||
|
List<CustomerAddress> addresses = addressService.selectByCustomerAddressIds(addressIds);
|
||||||
|
addresses.forEach(address -> addressMap.put(address.getCustomerAddressId(), address));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(goodsIds)) {
|
||||||
|
List<Goods> goodsList = goodsService.selectByIds(goodsIds);
|
||||||
|
goodsList.forEach(goods -> goodsMap.put(goods.getGoodsId(), goods));
|
||||||
|
}
|
||||||
|
|
||||||
list.forEach(master -> {
|
list.forEach(master -> {
|
||||||
//子单
|
//子单
|
||||||
List<OrderDetail> detailList = orderDetailService.selectByOrderMasterId(master.getId());
|
List<OrderDetail> detailList = orderDetailService.selectByOrderMasterId(master.getId());
|
||||||
|
|
@ -995,19 +1037,26 @@ public class OrderMasterController extends BaseController {
|
||||||
OrderListResponse orderListResponse = new OrderListResponse();
|
OrderListResponse orderListResponse = new OrderListResponse();
|
||||||
List<OrderStandard> standardList = new ArrayList<>();
|
List<OrderStandard> standardList = new ArrayList<>();
|
||||||
|
|
||||||
// 师傅信息
|
// 优化3:使用预查询的师傅信息
|
||||||
Worker worker = master.getWorkerId() != null ? workerService.selectById(master.getWorkerId()) : null;
|
Worker worker = workerMap.get(master.getWorkerId());
|
||||||
|
|
||||||
// 消费者信息
|
// 消费者信息
|
||||||
// Customer customer = customerService.selectByCustomerId(master.getCustomerId());
|
// Customer customer = customerService.selectByCustomerId(master.getCustomerId());
|
||||||
|
|
||||||
// 商品规格及信息
|
// 商品规格及信息
|
||||||
List<OrderGoods> orderStandardList = orderGoodsService.selectByOrderMasterId(master.getId());
|
List<OrderGoods> orderStandardList = orderGoodsService.selectByOrderMasterId(master.getId());
|
||||||
|
Goods goods = new Goods();
|
||||||
|
if (orderStandardList.size() > 0) {
|
||||||
// 商品信息
|
// 商品信息
|
||||||
GoodsStandard goodsStandard = goodsStandardService.selectById(orderStandardList.get(0).getGoodsStandardId());
|
GoodsStandard goodsStandard = goodsStandardService.selectById(orderStandardList.get(0).getGoodsStandardId());
|
||||||
|
if (goodsStandard != null) {
|
||||||
|
goods = goodsService.selectById(goodsStandard.getGoodsId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 优化4:使用预查询的商品信息
|
||||||
|
goods = goodsMap.getOrDefault(master.getGoodsId(), new Goods());
|
||||||
|
}
|
||||||
|
|
||||||
Goods goods = goodsService.selectById(goodsStandard.getGoodsId());
|
|
||||||
// 填充商品三级类目
|
// 填充商品三级类目
|
||||||
if (goods.getDeptGoodsCategoryId() != null) {
|
if (goods.getDeptGoodsCategoryId() != null) {
|
||||||
Long categoryId = null;
|
Long categoryId = null;
|
||||||
|
|
@ -1053,7 +1102,6 @@ public class OrderMasterController extends BaseController {
|
||||||
.map(FinancialChangeRecord::getChangeMoney)
|
.map(FinancialChangeRecord::getChangeMoney)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
paymentMoney = paymentMoney.add(changePaymentMoney);
|
paymentMoney = paymentMoney.add(changePaymentMoney);
|
||||||
logger.info("加价费已支付{}加价列表{}主单id为{}",changePaymentMoney,financialChangeRecords,master.getId());
|
|
||||||
|
|
||||||
for (OrderDetail detail : detailList) {
|
for (OrderDetail detail : detailList) {
|
||||||
// 查询子单加价记录
|
// 查询子单加价记录
|
||||||
|
|
@ -1072,22 +1120,27 @@ public class OrderMasterController extends BaseController {
|
||||||
paymentMoney = paymentMoney.add(orderAttachmentRecord.getAttachMoney());
|
paymentMoney = paymentMoney.add(orderAttachmentRecord.getAttachMoney());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info("未支付的加价订单{}加价配件订单列表{}",record,orderAttachmentRecordList);
|
|
||||||
}
|
}
|
||||||
// 地址信息
|
// 优化5:使用预查询的地址信息
|
||||||
CustomerAddress customerAddress = addressService.selectByCustomerAddressId(master.getAddressId());
|
CustomerAddress customerAddress = addressMap.get(master.getAddressId());
|
||||||
|
if (customerAddress == null) {
|
||||||
|
customerAddress = new CustomerAddress();
|
||||||
|
}
|
||||||
SysArea sysArea;
|
SysArea sysArea;
|
||||||
if (customerAddress.getStreetId() != null) {
|
if (customerAddress.getStreetId() != null) {
|
||||||
sysArea = sysAreaService.selectById(customerAddress.getStreetId());
|
sysArea = sysAreaService.selectById(customerAddress.getStreetId());
|
||||||
} else {
|
} else {
|
||||||
sysArea = sysAreaService.selectById(customerAddress.getCountryId());
|
sysArea = sysAreaService.selectById(customerAddress.getCountryId());
|
||||||
}
|
}
|
||||||
String completeAddress = sysArea.getMergerName().replaceAll(",", "") + customerAddress.getAddress();
|
String completeAddress = "";
|
||||||
|
if (sysArea != null) {
|
||||||
|
completeAddress = sysArea.getMergerName().replaceAll(",", "") + customerAddress.getAddress();
|
||||||
|
}
|
||||||
|
|
||||||
// 查询售后记录
|
// 优化6:避免重复查询订单详情
|
||||||
List<AfterServiceRecord> afterServiceRecords = new ArrayList<>();
|
List<AfterServiceRecord> afterServiceRecords = new ArrayList<>();
|
||||||
List<OrderDetail> detailOrderList = orderDetailService.selectByOrderMasterId(master.getId());
|
// 直接使用已经查询的detailList,避免重复查询
|
||||||
detailOrderList.forEach(detail -> {
|
detailList.forEach(detail -> {
|
||||||
AfterServiceRecord afterServiceRecordQry = new AfterServiceRecord();
|
AfterServiceRecord afterServiceRecordQry = new AfterServiceRecord();
|
||||||
afterServiceRecordQry.setOrderDetailId(detail.getId());
|
afterServiceRecordQry.setOrderDetailId(detail.getId());
|
||||||
List<AfterServiceRecord> records = afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecordQry);
|
List<AfterServiceRecord> records = afterServiceRecordService.selectAfterServiceRecordList(afterServiceRecordQry);
|
||||||
|
|
@ -1156,13 +1209,21 @@ public class OrderMasterController extends BaseController {
|
||||||
orderListResponse.setAddress(master.getAddress());
|
orderListResponse.setAddress(master.getAddress());
|
||||||
} else {
|
} else {
|
||||||
if (!StringUtils.isEmpty(customerAddress.getStreetId() + "")) {
|
if (!StringUtils.isEmpty(customerAddress.getStreetId() + "")) {
|
||||||
String addressSysArea=sysArea.getMergerName();
|
String addressSysArea = sysArea != null ? sysArea.getMergerName() : "";
|
||||||
String[] array = addressSysArea.split(",");
|
String[] array = addressSysArea.split(",");
|
||||||
|
if (array.length > 0) {
|
||||||
orderListResponse.setProvinceName(array[0]);
|
orderListResponse.setProvinceName(array[0]);
|
||||||
|
}
|
||||||
|
if (array.length > 1) {
|
||||||
orderListResponse.setCityName(array[1]);
|
orderListResponse.setCityName(array[1]);
|
||||||
|
}
|
||||||
|
if (array.length == 3) {
|
||||||
orderListResponse.setCountryName(array[2]);
|
orderListResponse.setCountryName(array[2]);
|
||||||
|
}
|
||||||
|
if (array.length == 4) {
|
||||||
orderListResponse.setStreetName(array[3]);
|
orderListResponse.setStreetName(array[3]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
orderListResponse.setProvinceId(customerAddress.getProvinceId());
|
orderListResponse.setProvinceId(customerAddress.getProvinceId());
|
||||||
orderListResponse.setCityId(customerAddress.getCityId());
|
orderListResponse.setCityId(customerAddress.getCityId());
|
||||||
orderListResponse.setCountryId(customerAddress.getCountryId());
|
orderListResponse.setCountryId(customerAddress.getCountryId());
|
||||||
|
|
@ -1170,24 +1231,9 @@ public class OrderMasterController extends BaseController {
|
||||||
orderListResponse.setAddress(customerAddress.getAddress());
|
orderListResponse.setAddress(customerAddress.getAddress());
|
||||||
orderListResponse.setPhone(customerAddress.getPhone());
|
orderListResponse.setPhone(customerAddress.getPhone());
|
||||||
orderListResponse.setName(customerAddress.getName());
|
orderListResponse.setName(customerAddress.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
orderListResponses.add(orderListResponse);
|
orderListResponses.add(orderListResponse);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
||||||
// if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize()) {
|
|
||||||
// rspData.setRows(orderListResponses);
|
|
||||||
// rspData.setTotal(orderListResponses.size());
|
|
||||||
// return rspData;
|
|
||||||
// }
|
|
||||||
// Integer pageSize = pageDomain.getPageNum();
|
|
||||||
// if (pageSize > orderListResponses.size()) {
|
|
||||||
// pageSize = orderListResponses.size();
|
|
||||||
// }
|
|
||||||
// rspData.setRows(orderListResponses.subList(0, pageSize));
|
|
||||||
// rspData.setTotal(orderListResponses.size());
|
|
||||||
return voDataTable(orderListResponses, list);
|
return voDataTable(orderListResponses, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1661,9 +1707,14 @@ public class OrderMasterController extends BaseController {
|
||||||
String[] array = addressSysArea.split(",");
|
String[] array = addressSysArea.split(",");
|
||||||
orderListResponse.setProvinceName(array[0]);
|
orderListResponse.setProvinceName(array[0]);
|
||||||
orderListResponse.setCityName(array[1]);
|
orderListResponse.setCityName(array[1]);
|
||||||
|
if (array.length==3){
|
||||||
orderListResponse.setCountryName(array[2]);
|
orderListResponse.setCountryName(array[2]);
|
||||||
|
}
|
||||||
|
if (array.length==4){
|
||||||
orderListResponse.setStreetName(array[3]);
|
orderListResponse.setStreetName(array[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
orderListResponse.setProvinceId(customerAddress.getProvinceId());
|
orderListResponse.setProvinceId(customerAddress.getProvinceId());
|
||||||
orderListResponse.setCityId(customerAddress.getCityId());
|
orderListResponse.setCityId(customerAddress.getCityId());
|
||||||
orderListResponse.setCountryId(customerAddress.getCountryId());
|
orderListResponse.setCountryId(customerAddress.getCountryId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue