|
@@ -320,9 +320,12 @@ public class TOrderController {
|
|
|
|
|
|
// 设置设备信息到订单中
|
|
|
for (TOrder order : orderList) {
|
|
|
- String name = equipmentMap.get(order.getClientId());
|
|
|
+ String orderClientId = order.getClientId();
|
|
|
+ String name = equipmentMap.get(orderClientId);
|
|
|
if (StringUtils.isNotEmpty(name)) {
|
|
|
order.setEs(name);
|
|
|
+ } else {
|
|
|
+ order.setEs(orderClientId.substring(orderClientId.length() - 6));
|
|
|
}
|
|
|
OrderDetailsVo orderDetailsVo = new OrderDetailsVo();
|
|
|
BeanUtil.copyProperties(order, orderDetailsVo);
|
|
@@ -403,17 +406,19 @@ public class TOrderController {
|
|
|
//商家 子账户
|
|
|
//登录账户为子账户 不查下级 只查对应机器的订单
|
|
|
TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(adminId)));
|
|
|
- if (adminEquipment.getType().equals("0")) {
|
|
|
- //全部机器
|
|
|
- TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
- query.eq(TCoinOrder::getAdminId, upAdmin.getId());
|
|
|
- } else {
|
|
|
- String equipmentIds = adminEquipment.getEquipmentIds();
|
|
|
+ if (adminEquipment != null) {
|
|
|
+ if (adminEquipment.getType().equals("0")) {
|
|
|
+ //全部机器
|
|
|
+ TAdmin upAdmin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(admin.getParentId())));
|
|
|
+ query.eq(TCoinOrder::getAdminId, upAdmin.getId());
|
|
|
+ } else {
|
|
|
+ String equipmentIds = adminEquipment.getEquipmentIds();
|
|
|
// List<String> equipmentIdList = JSON.parseArray(equipmentIds, String.class);
|
|
|
- List<String> equipmentIdList = Arrays.asList(equipmentIds.split(","));
|
|
|
- query.in(TCoinOrder::getEquipmentId, equipmentIdList);
|
|
|
+ List<String> equipmentIdList = Arrays.asList(equipmentIds.split(","));
|
|
|
+ query.in(TCoinOrder::getEquipmentId, equipmentIdList);
|
|
|
+ }
|
|
|
+ query.eq(TCoinOrder::getAdminId, admin.getParentId());
|
|
|
}
|
|
|
- query.eq(TCoinOrder::getAdminId, admin.getParentId());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -505,27 +510,49 @@ public class TOrderController {
|
|
|
Page<TCoinOrder> page = new Page<>(current, size, true);
|
|
|
IPage<TCoinOrder> iPage = coinOrderService.page(page, query);
|
|
|
//显示订单所属机器的设备名称
|
|
|
- if (admin.getType() != null && admin.getType() < 2) {
|
|
|
- //公司人员
|
|
|
- List<TCoinOrder> orderList = iPage.getRecords();
|
|
|
- if (orderList.size() > 0) {
|
|
|
- for (TCoinOrder order : orderList) {
|
|
|
- TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
- order.setEs(equipment.getName());
|
|
|
- }
|
|
|
- iPage.setRecords(orderList);
|
|
|
+// if (admin.getType() != null && admin.getType() < 2) {
|
|
|
+// //公司人员
|
|
|
+// List<TCoinOrder> orderList = iPage.getRecords();
|
|
|
+// if (orderList.size() > 0) {
|
|
|
+// for (TCoinOrder order : orderList) {
|
|
|
+// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
+// order.setEs(equipment.getName());
|
|
|
+// }
|
|
|
+// iPage.setRecords(orderList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ List<TCoinOrder> coinOrderList = iPage.getRecords();
|
|
|
+ if (coinOrderList.size() > 0) {
|
|
|
+ // 设备编号集合
|
|
|
+ List<String> clientIds = new ArrayList<>();
|
|
|
+ for (TCoinOrder coinOrder : coinOrderList) {
|
|
|
+ clientIds.add(coinOrder.getClientId());
|
|
|
}
|
|
|
- }
|
|
|
- if (admin.getType() != null && admin.getType() > 1) {
|
|
|
- //商家
|
|
|
- List<TCoinOrder> orderList = iPage.getRecords();
|
|
|
- if (orderList.size() > 0) {
|
|
|
- TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(orderList.get(0).getClientId()));
|
|
|
- for (TCoinOrder order : orderList) {
|
|
|
- order.setEs(equipment.getName());
|
|
|
+ // 设备编号名称集合
|
|
|
+ Map<String, String> equipmentMap = new HashMap<>();
|
|
|
+ // 设备编号名称集合
|
|
|
+ List<TEquipment> equipmentList = R.getDataIfSuccess(szwlFeign.findEquipmentByClientIds(clientIds));
|
|
|
+ for (TEquipment equipment : equipmentList) {
|
|
|
+ equipmentMap.put(equipment.getClientId(), equipment.getName());
|
|
|
+ }
|
|
|
+// List<TCoinOrder> orderList = iPage.getRecords();
|
|
|
+// if (orderList.size() > 0) {
|
|
|
+//// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(orderList.get(0).getClientId()));
|
|
|
+// for (TCoinOrder order : orderList) {
|
|
|
+// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(orderList.get(0).getClientId()));
|
|
|
+// order.setEs(equipment.getName());
|
|
|
+// }
|
|
|
+// }
|
|
|
+ for (TCoinOrder coinOrder : coinOrderList) {
|
|
|
+ String coinOrderClientId = coinOrder.getClientId();
|
|
|
+ String name = equipmentMap.get(coinOrderClientId);
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ coinOrder.setEs(name);
|
|
|
+ } else {
|
|
|
+ coinOrder.setEs(coinOrderClientId.substring(coinOrderClientId.length() - 6));
|
|
|
}
|
|
|
}
|
|
|
- iPage.setRecords(orderList);
|
|
|
+ iPage.setRecords(coinOrderList);
|
|
|
}
|
|
|
return R.ok(iPage);
|
|
|
}
|
|
@@ -561,7 +588,7 @@ public class TOrderController {
|
|
|
TOrder tOrder = list.get(0);
|
|
|
String s = tOrder.getId().toString();
|
|
|
if (s.length() > 6) {
|
|
|
- s = s.substring(s.length() - 6, s.length());
|
|
|
+ s = s.substring(s.length() - 6);
|
|
|
}
|
|
|
return R.ok(s, "成功");
|
|
|
}
|