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,41 +1037,48 @@ 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());
|
||||||
|
if (goodsStandard != null) {
|
||||||
|
goods = goodsService.selectById(goodsStandard.getGoodsId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 优化4:使用预查询的商品信息
|
||||||
|
goods = goodsMap.getOrDefault(master.getGoodsId(), new Goods());
|
||||||
|
}
|
||||||
|
|
||||||
// 商品信息
|
|
||||||
GoodsStandard goodsStandard = goodsStandardService.selectById(orderStandardList.get(0).getGoodsStandardId());
|
|
||||||
|
|
||||||
Goods goods = goodsService.selectById(goodsStandard.getGoodsId());
|
|
||||||
// 填充商品三级类目
|
// 填充商品三级类目
|
||||||
if(goods.getDeptGoodsCategoryId() != null){
|
if (goods.getDeptGoodsCategoryId() != null) {
|
||||||
Long categoryId = null;
|
Long categoryId = null;
|
||||||
// 前端发单和后台派单
|
// 前端发单和后台派单
|
||||||
if(com.ghy.common.utils.StringUtils.isEmpty(master.getOrderMode())){
|
if (com.ghy.common.utils.StringUtils.isEmpty(master.getOrderMode())) {
|
||||||
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.selectOneByGoodsCategoryId(goods.getDeptGoodsCategoryId());
|
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.selectOneByGoodsCategoryId(goods.getDeptGoodsCategoryId());
|
||||||
if(deptGoodsCategory != null){
|
if (deptGoodsCategory != null) {
|
||||||
categoryId = deptGoodsCategory.getGoodsCategoryId();
|
categoryId = deptGoodsCategory.getGoodsCategoryId();
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.get(goods.getDeptGoodsCategoryId());
|
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.get(goods.getDeptGoodsCategoryId());
|
||||||
if(deptGoodsCategory != null){
|
if (deptGoodsCategory != null) {
|
||||||
categoryId = deptGoodsCategory.getGoodsCategoryId();
|
categoryId = deptGoodsCategory.getGoodsCategoryId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(categoryId != null){
|
if (categoryId != null) {
|
||||||
GoodsCategory one = goodsCategoryService.selectById(categoryId);
|
GoodsCategory one = goodsCategoryService.selectById(categoryId);
|
||||||
if(one != null && one.getParentCategoryId() != null){
|
if (one != null && one.getParentCategoryId() != null) {
|
||||||
GoodsCategory two = goodsCategoryService.selectById(one.getParentCategoryId());
|
GoodsCategory two = goodsCategoryService.selectById(one.getParentCategoryId());
|
||||||
if(two != null && two.getParentCategoryId() != null){
|
if (two != null && two.getParentCategoryId() != null) {
|
||||||
GoodsCategory three = goodsCategoryService.selectById(two.getParentCategoryId());
|
GoodsCategory three = goodsCategoryService.selectById(two.getParentCategoryId());
|
||||||
if(three != null){
|
if (three != null) {
|
||||||
master.setConsoleGoodsName(three.getGoodsCategoryName()
|
master.setConsoleGoodsName(three.getGoodsCategoryName()
|
||||||
+ "-" + two.getGoodsCategoryName()
|
+ "-" + two.getGoodsCategoryName()
|
||||||
+ "-" + one.getGoodsCategoryName());
|
+ "-" + one.getGoodsCategoryName());
|
||||||
|
|
@ -1044,16 +1093,15 @@ public class OrderMasterController extends BaseController {
|
||||||
BigDecimal totalPayMoney = financialMaster.getPayMoney();
|
BigDecimal totalPayMoney = financialMaster.getPayMoney();
|
||||||
BigDecimal totalChangeMoney = new BigDecimal(0);
|
BigDecimal totalChangeMoney = new BigDecimal(0);
|
||||||
BigDecimal paymentMoney = BigDecimal.ZERO;
|
BigDecimal paymentMoney = BigDecimal.ZERO;
|
||||||
if (financialMaster.getPayStatus()==1){
|
if (financialMaster.getPayStatus() == 1) {
|
||||||
paymentMoney=paymentMoney.add(financialMaster.getTotalMoney());
|
paymentMoney = paymentMoney.add(financialMaster.getTotalMoney());
|
||||||
}
|
}
|
||||||
List<FinancialChangeRecord> financialChangeRecords=financialChangeRecordService.selectByMasterId(master.getId());
|
List<FinancialChangeRecord> financialChangeRecords = financialChangeRecordService.selectByMasterId(master.getId());
|
||||||
BigDecimal changePaymentMoney =financialChangeRecords.stream()
|
BigDecimal changePaymentMoney = financialChangeRecords.stream()
|
||||||
.filter(record->record.getPayStatus()==1)
|
.filter(record -> record.getPayStatus() == 1)
|
||||||
.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) {
|
||||||
// 查询子单加价记录
|
// 查询子单加价记录
|
||||||
|
|
@ -1065,29 +1113,34 @@ public class OrderMasterController extends BaseController {
|
||||||
OrderAttachmentRecord param = new OrderAttachmentRecord();
|
OrderAttachmentRecord param = new OrderAttachmentRecord();
|
||||||
param.setOrderDetailId(detail.getId());
|
param.setOrderDetailId(detail.getId());
|
||||||
List<OrderAttachmentRecord> orderAttachmentRecordList = orderAttachmentRecordService.selectOrderAttachmentRecordList(param);
|
List<OrderAttachmentRecord> orderAttachmentRecordList = orderAttachmentRecordService.selectOrderAttachmentRecordList(param);
|
||||||
for (OrderAttachmentRecord orderAttachmentRecord:orderAttachmentRecordList){
|
for (OrderAttachmentRecord orderAttachmentRecord : orderAttachmentRecordList) {
|
||||||
if (record!=null&&record.getPayStatus()==0){
|
if (record != null && record.getPayStatus() == 0) {
|
||||||
totalChangeMoney = totalChangeMoney.add(orderAttachmentRecord.getAttachMoney());
|
totalChangeMoney = totalChangeMoney.add(orderAttachmentRecord.getAttachMoney());
|
||||||
}else{
|
} else {
|
||||||
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);
|
||||||
|
|
@ -1122,8 +1175,8 @@ public class OrderMasterController extends BaseController {
|
||||||
orderListResponse.setChangeMoney(totalChangeMoney);
|
orderListResponse.setChangeMoney(totalChangeMoney);
|
||||||
orderListResponse.setWorkerName(worker == null ? "" : worker.getName());
|
orderListResponse.setWorkerName(worker == null ? "" : worker.getName());
|
||||||
orderListResponse.setWorkerPhone(worker == null ? "" : worker.getPhone());
|
orderListResponse.setWorkerPhone(worker == null ? "" : worker.getPhone());
|
||||||
orderListResponse.setCustomerName(org.apache.commons.lang3.StringUtils.isNotEmpty(master.getName())?master.getName():customerAddress.getName());
|
orderListResponse.setCustomerName(org.apache.commons.lang3.StringUtils.isNotEmpty(master.getName()) ? master.getName() : customerAddress.getName());
|
||||||
orderListResponse.setCustomerPhone(org.apache.commons.lang3.StringUtils.isNotEmpty(master.getPhone())?master.getPhone():customerAddress.getPhone());
|
orderListResponse.setCustomerPhone(org.apache.commons.lang3.StringUtils.isNotEmpty(master.getPhone()) ? master.getPhone() : customerAddress.getPhone());
|
||||||
orderListResponse.setServerTime(master.getRevTime());
|
orderListResponse.setServerTime(master.getRevTime());
|
||||||
orderListResponse.setExpectTimeStart(master.getExpectTimeStart());
|
orderListResponse.setExpectTimeStart(master.getExpectTimeStart());
|
||||||
orderListResponse.setExpectTimeEnd(master.getExpectTimeEnd());
|
orderListResponse.setExpectTimeEnd(master.getExpectTimeEnd());
|
||||||
|
|
@ -1142,7 +1195,7 @@ public class OrderMasterController extends BaseController {
|
||||||
orderListResponse.setAfterServiceRecordList(afterServiceRecords);
|
orderListResponse.setAfterServiceRecordList(afterServiceRecords);
|
||||||
orderListResponse.setServerMoney(master.getServerMoney());
|
orderListResponse.setServerMoney(master.getServerMoney());
|
||||||
orderListResponse.setIsCall(master.getIsCall());
|
orderListResponse.setIsCall(master.getIsCall());
|
||||||
if (StringUtils.isNotEmpty(master.getProvinceName())){
|
if (StringUtils.isNotEmpty(master.getProvinceName())) {
|
||||||
orderListResponse.setProvinceId(master.getProvinceId());
|
orderListResponse.setProvinceId(master.getProvinceId());
|
||||||
orderListResponse.setCityId(master.getCityId());
|
orderListResponse.setCityId(master.getCityId());
|
||||||
orderListResponse.setCountryId(master.getCountryId());
|
orderListResponse.setCountryId(master.getCountryId());
|
||||||
|
|
@ -1154,14 +1207,22 @@ public class OrderMasterController extends BaseController {
|
||||||
orderListResponse.setStreetId(master.getStreetId());
|
orderListResponse.setStreetId(master.getStreetId());
|
||||||
orderListResponse.setStreetName(master.getStreetName());
|
orderListResponse.setStreetName(master.getStreetName());
|
||||||
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(",");
|
||||||
orderListResponse.setProvinceName(array[0]);
|
if (array.length > 0) {
|
||||||
orderListResponse.setCityName(array[1]);
|
orderListResponse.setProvinceName(array[0]);
|
||||||
orderListResponse.setCountryName(array[2]);
|
}
|
||||||
orderListResponse.setStreetName(array[3]);
|
if (array.length > 1) {
|
||||||
|
orderListResponse.setCityName(array[1]);
|
||||||
|
}
|
||||||
|
if (array.length == 3) {
|
||||||
|
orderListResponse.setCountryName(array[2]);
|
||||||
|
}
|
||||||
|
if (array.length == 4) {
|
||||||
|
orderListResponse.setStreetName(array[3]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
orderListResponse.setProvinceId(customerAddress.getProvinceId());
|
orderListResponse.setProvinceId(customerAddress.getProvinceId());
|
||||||
orderListResponse.setCityId(customerAddress.getCityId());
|
orderListResponse.setCityId(customerAddress.getCityId());
|
||||||
|
|
@ -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,8 +1707,13 @@ 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]);
|
||||||
orderListResponse.setCountryName(array[2]);
|
if (array.length==3){
|
||||||
orderListResponse.setStreetName(array[3]);
|
orderListResponse.setCountryName(array[2]);
|
||||||
|
}
|
||||||
|
if (array.length==4){
|
||||||
|
orderListResponse.setStreetName(array[3]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
orderListResponse.setProvinceId(customerAddress.getProvinceId());
|
orderListResponse.setProvinceId(customerAddress.getProvinceId());
|
||||||
orderListResponse.setCityId(customerAddress.getCityId());
|
orderListResponse.setCityId(customerAddress.getCityId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue