|
@@ -217,11 +217,11 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
|
Set<String> permissionList = sysRoleService.selectRolePermissionByUserId(SecurityUtils.getUserId());
|
|
|
DynamicDataSourceContextHolder.poll();
|
|
|
if (ObjectUtil.isNotEmpty(permissionList)) {
|
|
|
- //if当前用户的角色 in [运营专员, 运营助理] 页面仅展示产品.管理部门 == 当前用户所在部门的相关数据
|
|
|
+ //if当前用户的角色 in [运营专员, 运营助理] 页面仅展示产品.管理部门 == 当前用户所在部门或下级部门的相关数据
|
|
|
if (permissionList.contains("E-commerce operation") || permissionList.contains("Operation assistant")) {
|
|
|
- Long userDeptId = SecurityUtils.getDeptId();
|
|
|
- String userDeptIdStr = ObjectUtil.isNotEmpty(userDeptId) ? userDeptId.toString() : "";
|
|
|
- wrapper.eq("json_unquote( pi.victoriatourist_json -> '$.deptId' )", userDeptIdStr);
|
|
|
+ wrapper.and(q -> q.eq("de.dept_id", SecurityUtils.getDeptId())
|
|
|
+ .or()
|
|
|
+ .like("de.ancestors", SecurityUtils.getDeptId()));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -232,43 +232,68 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- List<Long> supplyIds = list.stream().map(PurchaseVo::getSupplyId).collect(Collectors.toList());
|
|
|
- List<SupplierInfo> supplierInfoList = supplierInfoService.list(Wrappers.<SupplierInfo>query().lambda().in(SupplierInfo::getId, supplyIds));
|
|
|
- Map<Long, List<SupplierInfo>> supplyMap = supplierInfoList.stream().distinct().collect(Collectors.groupingBy(SupplierInfo::getId));
|
|
|
- if (MapUtils.isNotEmpty(supplyMap)) {
|
|
|
- for (PurchaseVo p : list) {
|
|
|
- List<SupplierInfo> supplys = supplyMap.getOrDefault(p.getSupplyId(), null);
|
|
|
- p.setSupplyName(supplys == null ? null : supplys.get(0).getName());
|
|
|
- }
|
|
|
+ List<Long> supplyIds = list.stream().map(PurchaseVo::getSupplyId).collect(Collectors.toList());
|
|
|
+ List<SupplierInfo> supplierInfoList = supplierInfoService.list(Wrappers.<SupplierInfo>query().lambda().in(SupplierInfo::getId, supplyIds));
|
|
|
+ Map<Long, List<SupplierInfo>> supplyMap = supplierInfoList.stream().distinct().collect(Collectors.groupingBy(SupplierInfo::getId));
|
|
|
+ if (MapUtils.isNotEmpty(supplyMap)) {
|
|
|
+ for (PurchaseVo p : list) {
|
|
|
+ List<SupplierInfo> supplys = supplyMap.getOrDefault(p.getSupplyId(), null);
|
|
|
+ p.setSupplyName(supplys == null ? null : supplys.get(0).getName());
|
|
|
}
|
|
|
}
|
|
|
- //-------------------------------------------------
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- //维多利亚 赋值收货仓库名称
|
|
|
- List<Long> wids = new ArrayList<>();
|
|
|
- for (PurchaseVo purchaseVo : list) {
|
|
|
- String victoriatouristJson = purchaseVo.getVictoriatouristJson();
|
|
|
- if (ObjectUtils.isNotEmpty(victoriatouristJson)) {
|
|
|
- JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
- wids.add(json.getLong("receiptWarehouseId"));
|
|
|
- }
|
|
|
+
|
|
|
+ //维多利亚 赋值收货仓库名称
|
|
|
+ List<Long> wids = new ArrayList<>();
|
|
|
+ for (PurchaseVo purchaseVo : list) {
|
|
|
+ String victoriatouristJson = purchaseVo.getVictoriatouristJson();
|
|
|
+ if (ObjectUtils.isNotEmpty(victoriatouristJson)) {
|
|
|
+ JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
+ wids.add(json.getLong("receiptWarehouseId"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Warehouse> warehouses = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(wids)) {
|
|
|
+ warehouses = warehouseService.listByIds(wids);
|
|
|
+ }
|
|
|
+ Map<Long, String> warehousesMap = warehouses.stream().collect(Collectors.toMap(Warehouse::getId, Warehouse::getName));
|
|
|
+
|
|
|
+ //赋值已付款金额
|
|
|
+ List<Long> purchaseIds = list.stream().map(PurchaseVo::getId).collect(Collectors.toList());
|
|
|
+ Map<Long, List<PurchasePayRecordDetail>> PayRecordMap = purchasePayRecordDetailService.mapKGroup(PurchasePayRecordDetail::getPurchaseId,
|
|
|
+ q -> q.in(PurchasePayRecordDetail::getPurchaseId, purchaseIds));
|
|
|
+
|
|
|
+ //赋值退款金额
|
|
|
+ Map<Long, List<PurchaseRefundRecord>> refundRecordMap = purchaseRefundRecordService.mapKGroup(PurchaseRefundRecord::getPurchaseId,
|
|
|
+ q -> q.in(PurchaseRefundRecord::getPurchaseId, purchaseIds));
|
|
|
+
|
|
|
+ for (PurchaseVo purchaseVo : list) {
|
|
|
+ String victoriatouristJson = purchaseVo.getVictoriatouristJson();
|
|
|
+ if (ObjectUtils.isNotEmpty(victoriatouristJson)) {
|
|
|
+ JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
+ String warehouseName = warehousesMap.get(json.getLong("receiptWarehouseId"));
|
|
|
+ json.put("receiptWarehouseName", warehouseName);
|
|
|
+ purchaseVo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
|
}
|
|
|
- if (ObjectUtils.isEmpty(wids)) {
|
|
|
- return page;
|
|
|
+
|
|
|
+ //赋值已付款金额
|
|
|
+ List<PurchasePayRecordDetail> purchasePayRecords = PayRecordMap.get(purchaseVo.getId());
|
|
|
+ purchaseVo.setPaidAmount(BigDecimal.ZERO);
|
|
|
+ if (ObjectUtils.isNotEmpty(purchasePayRecords)) {
|
|
|
+ //求和已付款
|
|
|
+ BigDecimal paidAmount = purchasePayRecords.stream().map(PurchasePayRecordDetail::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ purchaseVo.setPaidAmount(paidAmount);
|
|
|
}
|
|
|
- List<Warehouse> warehouses = warehouseService.listByIds(wids);
|
|
|
- Map<Long, String> warehousesMap = warehouses.stream().collect(Collectors.toMap(Warehouse::getId, Warehouse::getName));
|
|
|
- for (PurchaseVo purchaseVo : list) {
|
|
|
- String victoriatouristJson = purchaseVo.getVictoriatouristJson();
|
|
|
- if (ObjectUtils.isNotEmpty(victoriatouristJson)) {
|
|
|
- JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
- String warehouseName = warehousesMap.get(json.getLong("receiptWarehouseId"));
|
|
|
- json.put("receiptWarehouseName", warehouseName);
|
|
|
- purchaseVo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
|
- }
|
|
|
+
|
|
|
+ //赋值退款金额
|
|
|
+ List<PurchaseRefundRecord> purchaseRefundRecords = refundRecordMap.get(purchaseVo.getId());
|
|
|
+ purchaseVo.setRefundAmount(BigDecimal.ZERO);
|
|
|
+ if (ObjectUtils.isNotEmpty(purchaseRefundRecords)) {
|
|
|
+ //求和已退款
|
|
|
+ BigDecimal refundAmount = purchaseRefundRecords.stream().map(PurchaseRefundRecord::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ purchaseVo.setRefundAmount(refundAmount);
|
|
|
}
|
|
|
- //赋值到货状态
|
|
|
+ }
|
|
|
+ //赋值到货状态
|
|
|
// List<Long> pids = list.stream().map(PurchaseVo::getId).collect(Collectors.toList());
|
|
|
// List<Arrival> arrivalList = arrivalService.list(q -> q.in(Arrival::getPurchaseId, pids));
|
|
|
// Map<Long, List<Arrival>> arrivalMap = arrivalList.stream().collect(Collectors.groupingBy(Arrival::getPurchaseId));
|
|
@@ -290,34 +315,6 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
|
|
|
// purchaseVo.setArrivalStatus(2);
|
|
|
// }
|
|
|
// }
|
|
|
- }
|
|
|
- //赋值已付款金额
|
|
|
- List<Long> purchaseIds = list.stream().map(PurchaseVo::getId).collect(Collectors.toList());
|
|
|
- Map<Long, List<PurchasePayRecordDetail>> PayRecordMap = purchasePayRecordDetailService.mapKGroup(PurchasePayRecordDetail::getPurchaseId,
|
|
|
- q -> q.in(PurchasePayRecordDetail::getPurchaseId, purchaseIds));
|
|
|
- for (PurchaseVo purchaseVo : list) {
|
|
|
- List<PurchasePayRecordDetail> purchasePayRecords = PayRecordMap.get(purchaseVo.getId());
|
|
|
- if (ObjectUtils.isEmpty(purchasePayRecords)) {
|
|
|
- purchaseVo.setPaidAmount(BigDecimal.ZERO);
|
|
|
- continue;
|
|
|
- }
|
|
|
- //求和已付款
|
|
|
- BigDecimal paidAmount = purchasePayRecords.stream().map(PurchasePayRecordDetail::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- purchaseVo.setPaidAmount(paidAmount);
|
|
|
- }
|
|
|
- //赋值退款金额
|
|
|
- Map<Long, List<PurchaseRefundRecord>> refundRecordMap = purchaseRefundRecordService.mapKGroup(PurchaseRefundRecord::getPurchaseId,
|
|
|
- q -> q.in(PurchaseRefundRecord::getPurchaseId, purchaseIds));
|
|
|
- for (PurchaseVo purchaseVo : list) {
|
|
|
- List<PurchaseRefundRecord> purchaseRefundRecords = refundRecordMap.get(purchaseVo.getId());
|
|
|
- if (ObjectUtils.isEmpty(purchaseRefundRecords)) {
|
|
|
- purchaseVo.setRefundAmount(BigDecimal.ZERO);
|
|
|
- continue;
|
|
|
- }
|
|
|
- //求和已退款
|
|
|
- BigDecimal refundAmount = purchaseRefundRecords.stream().map(PurchaseRefundRecord::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- purchaseVo.setRefundAmount(refundAmount);
|
|
|
- }
|
|
|
|
|
|
return page;
|
|
|
}
|