From 0207193f6a1ae2afa468b1f490300a90c18f4b13 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Tue, 29 Oct 2024 00:54:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E5=AE=8C=E5=96=84=E9=A2=84=E5=AD=98?= =?UTF-8?q?=E5=8D=95=20=E5=AF=B9=E8=B4=A6=E5=8D=95=20=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E5=8D=95=20=E7=9A=84=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=202.=E5=A2=9E=E5=8A=A0=E8=BF=90=E5=8D=95?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E3=80=81=E9=A2=84=E5=AD=98=E5=8D=95=E3=80=81?= =?UTF-8?q?=E5=AF=B9=E8=B4=A6=E5=8D=95=E3=80=81=E7=BB=93=E7=AE=97=E5=8D=95?= =?UTF-8?q?=E7=9A=84=E4=BB=93=E5=BA=93=E6=9D=83=E9=99=90=E9=99=90=E5=88=B6?= =?UTF-8?q?=203.=E4=BF=AE=E5=A4=8D=E5=88=B0=E4=BB=98=E8=BF=90=E5=8D=95?= =?UTF-8?q?=E5=AE=A1=E5=8D=95=E5=90=8E=E7=BC=BA=E5=B0=91=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E4=BB=93=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/IBasicdataWarehouseClient.java | 8 +- .../statistics/dto/MerchantStatisticsDTO.java | 105 +++++- .../vo/WaybillDetailByWaybillNoVo.java | 19 ++ .../feign/BasicdataWarehouseClient.java | 18 ++ .../mapper/BasicdataClientMapper.xml | 7 +- .../impl/BasicdataClientServiceImpl.java | 4 +- .../listener/mq/WaybillCheckListener.java | 175 +++++----- .../StatisticsBalanceOrderInfoMapper.xml | 31 ++ .../mapper/StatisticsOrderInfoMapper.java | 4 + .../mapper/StatisticsOrderInfoMapper.xml | 48 ++- ...tatisticsReconciliationOrderInfoMapper.xml | 13 +- ...StatisticsBalanceOrderInfoServiceImpl.java | 301 +++++++++--------- .../impl/StatisticsOrderInfoServiceImpl.java | 53 ++- ...icsReconciliationOrderInfoServiceImpl.java | 13 + .../mapper/WarehouseWaybillMapper.xml | 2 +- 15 files changed, 543 insertions(+), 258 deletions(-) create mode 100644 blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/vo/WaybillDetailByWaybillNoVo.java diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java index efb42184a..26a727b98 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java @@ -113,8 +113,12 @@ public interface IBasicdataWarehouseClient { BasicdataWarehouseVO getMyCurrentWarehouseAndConfig(); - - + /** + * 获取房前登录人能看的仓库ID集合 + * @return + */ + @GetMapping(API_PREFIX + "/getWarehouseIds") + List getWarehouseIds(); /** * 获取当前登录人的能查看的仓库 diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/dto/MerchantStatisticsDTO.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/dto/MerchantStatisticsDTO.java index 9b009bd14..70a0a2e50 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/dto/MerchantStatisticsDTO.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/dto/MerchantStatisticsDTO.java @@ -18,7 +18,6 @@ public class MerchantStatisticsDTO implements Serializable { private Integer listType; - private String consignee; private String shipper; private Long consigneeId; @@ -33,17 +32,32 @@ public class MerchantStatisticsDTO implements Serializable { private List aftersalesOrderDTOS; - private Integer syncFeeSstatus; - private Integer signStatus; + + + private Integer isAftersales; - private Integer balanceStatus; + private Integer abnormalBalanceStatus; private String balanceOrderNo; + /** + * 运单号 + */ private String waybillNo; + /** + * 订单号 + */ private String orderCode; + private String departureWarehouseName; + /** + * 目的仓 + */ private String destinationWarehouseName; + + /** + * 服务类型 + */ private String typeService; private String shipperPerson; private String shipperMoblie; @@ -57,8 +71,91 @@ public class MerchantStatisticsDTO implements Serializable { private String openTimeStartStr; private String openTimeEndStr; + /** + * 收货单位 + */ + private String consignee; + + /** + * 计算金额状态 0否 1是 + */ + private Integer syncFeeSstatus; + /** + * + * 签收状态:0-未签收,1-部分签收,2-已签收 + */ + private Integer signStatus; + /** + * 计算价格开始时间 + */ + private Date syncFeeDateStart; + + /** + * 计算价格结束时间 + */ + private Date syncFeeDateEnd; + + + /** + * 签收开始时间 + */ + private Date signTimeStart; + + /** + * 签收开始时间 + */ + private Date signTimeEnd; + /** + * 开单时间 开始 + */ private Date openTimeStart; + + /** + * 开单时间 结束 + */ + private Date openTimeEnd; + /** + * 结算状态0未结算 1部分结算 2已结算 + */ + private Integer balanceStatus; + + /** + * 结算开始时间 + */ + private Date balanceTimeStart; + + /** + * 结算结束时间 + */ + private Date balanceTimeEnd; + + /** + * 异常开始时间 + */ + private Date abnormalTimeStart; + + /** + * 异常结束时间 + */ + private Date abnormalTimeEnd; + + + /** + * 单据创建开始时间 + */ + private Date createTimeStart; + + /** + * 单据单据创建结束时间 + */ + private Date createTimeEnd; + + /** + * 能查看的仓库列表 + */ + private List warehouseIds; + } diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/vo/WaybillDetailByWaybillNoVo.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/vo/WaybillDetailByWaybillNoVo.java new file mode 100644 index 000000000..cbf3eec2f --- /dev/null +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/vo/WaybillDetailByWaybillNoVo.java @@ -0,0 +1,19 @@ +package com.logpm.statistics.vo; + +import lombok.Data; + +@Data +public class WaybillDetailByWaybillNoVo { + + /** + * 运单ID + */ + private Long waybillId; + + /** + * 凭借的产品数量 + * @Detail 木门(3),木门配件(17) + */ + private String goodsName; + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java index c34d86f6c..ffeb0a645 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java @@ -166,6 +166,24 @@ public class BasicdataWarehouseClient implements IBasicdataWarehouseClient { return warehouseWarehouseService.getMyCurrentWarehouseAndConfig(); } + @Override + public List getWarehouseIds() { + + + // 仓库ID集合 + List watermarkIds = new ArrayList<>(); + // 增加仓库权限的限制 + BasicdataWarehouseEntity myCurrentWarehouse = this.getMyCurrentWarehouse(); + if (Objects.isNull(myCurrentWarehouse)) { + List myWarehouseList = this.getMyWarehouseList(); + myWarehouseList.forEach(warehouse -> { + watermarkIds.add(warehouse.getId()); + }); + } else { + watermarkIds.add(myCurrentWarehouse.getId()); + } + return watermarkIds; + } @Override @GetMapping(API_PREFIX+"/getMyWatchWarehouse") diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml index 98a9cb5f4..38124ac04 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml @@ -111,6 +111,7 @@ lbc. linkman, lbc. phone, lbc. type_service, + lbc.clean_obj_type, lbc. blade_region_province_id, lbc. blade_region_city_id, lbc. blade_region_area_id, @@ -159,8 +160,12 @@ AND lbc.client_type = #{param.clientType} + + AND lbc.clean_obj_type = #{param.cleanObjType} + + - AND lbc.type_ervice = #{param.typeServiceName} + AND lbc.type_service = #{param.typeServiceName} AND t.aaa LIKE CONCAT('%', #{param.brandName}, '%') diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java index c50f72669..e4eae1a39 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java @@ -421,7 +421,9 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl wayBillDetailList = warehouseWaybillDetailClient.findByWaybillId(waybillId); //把wayBillDetailList中所有productName用逗号拼起来 // String productTypeNum = wayBillDetailList.stream().map(t->t.getProductName()+"("+t.getNum()+")").collect(Collectors.joining(",")); @@ -103,7 +108,7 @@ public class WaybillCheckListener { StatisticsPackageFeeInfoVO trunklinePackageFeeVO = statisticsOrderInfoService.findPackageListByOrderIds(orderInfoIdsList); - String balanceOrderCode = "JSD"+System.currentTimeMillis(); + String balanceOrderCode = "JSD" + System.currentTimeMillis(); BigDecimal freightPrice = trunklinePackageFeeVO.getFreightPrice(); BigDecimal pickupPrice = trunklinePackageFeeVO.getPickupPrice(); @@ -154,8 +159,11 @@ public class WaybillCheckListener { balanceOrderInfoEntity.setAbnormalBalanceStatus(0); balanceOrderInfoEntity.setAbnormalBalanceFee(BigDecimal.ZERO); + balanceOrderInfoEntity.setDestinationWarehouseId(byWaybill.getDestinationWarehouseId()); + balanceOrderInfoEntity.setDestinationWarehouseName(byWaybill.getDestinationWarehouseName()); + boolean saveFlag = balanceOrderInfoService.save(balanceOrderInfoEntity); - if(saveFlag){ + if (saveFlag) { Long balanceOrderId = balanceOrderInfoEntity.getId(); List updateOrderInfoList = new ArrayList<>(); orderInfoEntityList.forEach(orderInfoEntity -> { @@ -171,7 +179,7 @@ public class WaybillCheckListener { updateEntity.setConfirmBalanceUserName(AuthUtil.getNickName()); updateOrderInfoList.add(updateEntity); }); - if(CollUtil.isNotEmpty(updateOrderInfoList)){ + if (CollUtil.isNotEmpty(updateOrderInfoList)) { statisticsOrderInfoService.updateBatchById(updateOrderInfoList); } } @@ -179,7 +187,7 @@ public class WaybillCheckListener { private void dealwithZeroOrder(WarehouseWaybillEntity waybillEntity) { String waybillNo = waybillEntity.getWaybillNo(); - log.info("############dealwithZeroOrder: 处理零担信息 waybillNo={}",waybillNo); + log.info("############dealwithZeroOrder: 处理零担信息 waybillNo={}", waybillNo); Long waybillId = waybillEntity.getId(); String brand = waybillEntity.getBrand(); Long brandId = waybillEntity.getBrandId(); @@ -193,12 +201,12 @@ public class WaybillCheckListener { String destinationWarehouseName = waybillEntity.getDestinationWarehouseName(); // BigDecimal pickupFee = Objects.isNull(waybillEntity.getPickupFee())?BigDecimal.ZERO:waybillEntity.getPickupFee(); - BigDecimal warehouseManagementFee = Objects.isNull(waybillEntity.getWarehouseManagementFee())?BigDecimal.ZERO:waybillEntity.getWarehouseManagementFee(); - BigDecimal warehouseFee = Objects.isNull(waybillEntity.getStorageFee())?BigDecimal.ZERO:waybillEntity.getStorageFee(); - BigDecimal handlingFee = Objects.isNull(waybillEntity.getHandlingFee())?BigDecimal.ZERO:waybillEntity.getHandlingFee(); - BigDecimal insuranceFee = Objects.isNull(waybillEntity.getInsuranceFee())?BigDecimal.ZERO:waybillEntity.getInsuranceFee(); - BigDecimal otherFee = Objects.isNull(waybillEntity.getOtherFee())?BigDecimal.ZERO:waybillEntity.getOtherFee(); - BigDecimal thirdOperationFee = Objects.isNull(waybillEntity.getThirdOperationFee())?BigDecimal.ZERO:waybillEntity.getThirdOperationFee(); + BigDecimal warehouseManagementFee = Objects.isNull(waybillEntity.getWarehouseManagementFee()) ? BigDecimal.ZERO : waybillEntity.getWarehouseManagementFee(); + BigDecimal warehouseFee = Objects.isNull(waybillEntity.getStorageFee()) ? BigDecimal.ZERO : waybillEntity.getStorageFee(); + BigDecimal handlingFee = Objects.isNull(waybillEntity.getHandlingFee()) ? BigDecimal.ZERO : waybillEntity.getHandlingFee(); + BigDecimal insuranceFee = Objects.isNull(waybillEntity.getInsuranceFee()) ? BigDecimal.ZERO : waybillEntity.getInsuranceFee(); + BigDecimal otherFee = Objects.isNull(waybillEntity.getOtherFee()) ? BigDecimal.ZERO : waybillEntity.getOtherFee(); + BigDecimal thirdOperationFee = Objects.isNull(waybillEntity.getThirdOperationFee()) ? BigDecimal.ZERO : waybillEntity.getThirdOperationFee(); Integer totalCount = waybillEntity.getTotalCount(); // BigDecimal pickupPrice = pickupFee.divide(new BigDecimal(totalCount), 2, BigDecimal.ROUND_HALF_UP); @@ -235,7 +243,7 @@ public class WaybillCheckListener { orderInfoEntities.add(orderInfoEntity); boolean b = statisticsOrderInfoService.saveBatch(orderInfoEntities); - if(b){ + if (b) { Long orderId = orderInfoEntity.getId(); @@ -244,7 +252,7 @@ public class WaybillCheckListener { List distributionPackageEntities = new ArrayList<>(); - wayBillDetailList.forEach(wayBillDetail->{ + wayBillDetailList.forEach(wayBillDetail -> { Long productId = wayBillDetail.getProductId(); String productName = wayBillDetail.getProductName(); Integer num = wayBillDetail.getNum(); @@ -258,8 +266,8 @@ public class WaybillCheckListener { trunklinePackageEntity.setWaybillNo(waybillNo); trunklinePackageEntity.setOrderCode(waybillNo); trunklinePackageEntity.setNum(num); - trunklinePackageEntity.setWeight(Objects.isNull(weight)?BigDecimal.ZERO:weight); - trunklinePackageEntity.setVolume(Objects.isNull(volume)?BigDecimal.ZERO:volume); + trunklinePackageEntity.setWeight(Objects.isNull(weight) ? BigDecimal.ZERO : weight); + trunklinePackageEntity.setVolume(Objects.isNull(volume) ? BigDecimal.ZERO : volume); trunklinePackageEntity.setGoodsType(2); trunklinePackageEntity.setOrderInfoId(orderId); trunklinePackageEntity.setProductId(productId); @@ -279,29 +287,29 @@ public class WaybillCheckListener { Integer systemWarehouseChargeType = wayBillDetail.getSystemWarehouseChargeType(); Integer systemDeliveryChargeType = wayBillDetail.getSystemDeliveryChargeType(); - if(systemChargeType == 1){ + if (systemChargeType == 1) { trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(new BigDecimal(num))); - }else if(systemChargeType == 2){ + } else if (systemChargeType == 2) { trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(trunklinePackageEntity.getWeight())); - }else if (systemChargeType == 3){ + } else if (systemChargeType == 3) { trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(trunklinePackageEntity.getVolume())); } - if(chargeType == 1){ + if (chargeType == 1) { trunklinePackageEntity.setFreightPrice(price.multiply(new BigDecimal(num))); - }else if(chargeType == 2){ + } else if (chargeType == 2) { trunklinePackageEntity.setFreightPrice(price.multiply(trunklinePackageEntity.getWeight())); - }else if (chargeType == 3){ + } else if (chargeType == 3) { trunklinePackageEntity.setFreightPrice(price.multiply(trunklinePackageEntity.getVolume())); } - if(systemPickupChargeType == 1){ + if (systemPickupChargeType == 1) { trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(new BigDecimal(num))); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(new BigDecimal(num))); - }else if(systemPickupChargeType == 2){ + } else if (systemPickupChargeType == 2) { trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(trunklinePackageEntity.getWeight())); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(trunklinePackageEntity.getWeight())); - }else if (systemPickupChargeType == 3){ + } else if (systemPickupChargeType == 3) { trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(trunklinePackageEntity.getVolume())); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(trunklinePackageEntity.getVolume())); } @@ -367,8 +375,8 @@ public class WaybillCheckListener { distributionPackageEntity.setWaybillNo(waybillNo); distributionPackageEntity.setOrderCode(waybillNo); distributionPackageEntity.setNum(num); - distributionPackageEntity.setWeight(Objects.isNull(weight)?BigDecimal.ZERO:weight); - distributionPackageEntity.setVolume(Objects.isNull(volume)?BigDecimal.ZERO:volume); + distributionPackageEntity.setWeight(Objects.isNull(weight) ? BigDecimal.ZERO : weight); + distributionPackageEntity.setVolume(Objects.isNull(volume) ? BigDecimal.ZERO : volume); distributionPackageEntity.setGoodsType(2); distributionPackageEntity.setOrderInfoId(orderId); distributionPackageEntity.setDeliveryLoadingFee(handlingPrice.multiply(new BigDecimal(num))); @@ -384,11 +392,11 @@ public class WaybillCheckListener { BigDecimal systemDeliveryPrice = wayBillDetail.getDeliveryPrice(); distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice); - if(systemDeliveryChargeType == 1){ + if (systemDeliveryChargeType == 1) { distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(new BigDecimal(num))); - }else if(systemDeliveryChargeType == 2){ + } else if (systemDeliveryChargeType == 2) { distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(weight)); - }else if (systemDeliveryChargeType == 3){ + } else if (systemDeliveryChargeType == 3) { distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(volume)); } distributionPackageEntity.setDeliveryFee(BigDecimal.ZERO); @@ -396,7 +404,7 @@ public class WaybillCheckListener { BigDecimal systemDeliveryFeeTotal = distributionPackageEntity.getSystemDeliveryFee(); - if(payWay.equals("1") || payWay.equals("2")){ + if (payWay.equals("1") || payWay.equals("2")) { distributionPackageEntity.setDeliveryFee(systemDeliveryFeeTotal); } BigDecimal deliveryFeeTotal = distributionPackageEntity.getDeliveryFee(); @@ -412,24 +420,24 @@ public class WaybillCheckListener { distributionPackageEntities.add(distributionPackageEntity); }); - if(CollUtil.isNotEmpty(trunklinePackageEntities)){ + if (CollUtil.isNotEmpty(trunklinePackageEntities)) { trunklinePackageService.saveBatch(trunklinePackageEntities); } - if(CollUtil.isNotEmpty(warehousePackageEntities)){ + if (CollUtil.isNotEmpty(warehousePackageEntities)) { warehousePackageService.saveBatch(warehousePackageEntities); } - if(CollUtil.isNotEmpty(distributionPackageEntities)){ + if (CollUtil.isNotEmpty(distributionPackageEntities)) { distributionPackageService.saveBatch(distributionPackageEntities); } - }else{ - log.warn("#############dealwithPackageOrder: 保存订单数据失败 waybillNo={}",waybillNo); + } else { + log.warn("#############dealwithPackageOrder: 保存订单数据失败 waybillNo={}", waybillNo); } } private void dealwithPackageOrder(WarehouseWaybillEntity waybillEntity) { String waybillNo = waybillEntity.getWaybillNo(); - log.info("############dealwithPackageOrder: 处理订制品包件信息 waybillNo={}",waybillNo); + log.info("############dealwithPackageOrder: 处理订制品包件信息 waybillNo={}", waybillNo); Long waybillId = waybillEntity.getId(); String brand = waybillEntity.getBrand(); Long brandId = waybillEntity.getBrandId(); @@ -444,12 +452,12 @@ public class WaybillCheckListener { //单价计算 // BigDecimal pickupFee = Objects.isNull(waybillEntity.getPickupFee())?BigDecimal.ZERO:waybillEntity.getPickupFee(); - BigDecimal warehouseManagementFee = Objects.isNull(waybillEntity.getWarehouseManagementFee())?BigDecimal.ZERO:waybillEntity.getWarehouseManagementFee(); - BigDecimal warehouseFee = Objects.isNull(waybillEntity.getStorageFee())?BigDecimal.ZERO:waybillEntity.getStorageFee(); - BigDecimal handlingFee = Objects.isNull(waybillEntity.getHandlingFee())?BigDecimal.ZERO:waybillEntity.getHandlingFee(); - BigDecimal insuranceFee = Objects.isNull(waybillEntity.getInsuranceFee())?BigDecimal.ZERO:waybillEntity.getInsuranceFee(); - BigDecimal otherFee = Objects.isNull(waybillEntity.getOtherFee())?BigDecimal.ZERO:waybillEntity.getOtherFee(); - BigDecimal thirdOperationFee = Objects.isNull(waybillEntity.getThirdOperationFee())?BigDecimal.ZERO:waybillEntity.getThirdOperationFee(); + BigDecimal warehouseManagementFee = Objects.isNull(waybillEntity.getWarehouseManagementFee()) ? BigDecimal.ZERO : waybillEntity.getWarehouseManagementFee(); + BigDecimal warehouseFee = Objects.isNull(waybillEntity.getStorageFee()) ? BigDecimal.ZERO : waybillEntity.getStorageFee(); + BigDecimal handlingFee = Objects.isNull(waybillEntity.getHandlingFee()) ? BigDecimal.ZERO : waybillEntity.getHandlingFee(); + BigDecimal insuranceFee = Objects.isNull(waybillEntity.getInsuranceFee()) ? BigDecimal.ZERO : waybillEntity.getInsuranceFee(); + BigDecimal otherFee = Objects.isNull(waybillEntity.getOtherFee()) ? BigDecimal.ZERO : waybillEntity.getOtherFee(); + BigDecimal thirdOperationFee = Objects.isNull(waybillEntity.getThirdOperationFee()) ? BigDecimal.ZERO : waybillEntity.getThirdOperationFee(); Integer totalCount = waybillEntity.getTotalCount(); // BigDecimal pickupPrice = pickupFee.divide(new BigDecimal(totalCount), 2, BigDecimal.ROUND_HALF_UP); @@ -461,9 +469,8 @@ public class WaybillCheckListener { BigDecimal thirdOperationPrice = thirdOperationFee.divide(new BigDecimal(totalCount), 2, BigDecimal.ROUND_HALF_UP); - //查询运单下所有的订单 - List advanceEntities =trunklineAdvanceClient.findListByWaybillNo(waybillNo); + List advanceEntities = trunklineAdvanceClient.findListByWaybillNo(waybillNo); //查询包件信息 List advanceDetailEntities = trunklineAdvanceDetailClient.findListByWaybillId(waybillId); //查询运单明细 @@ -476,7 +483,7 @@ public class WaybillCheckListener { //保存订单信息 List orderInfoEntities = new ArrayList<>(); - advanceEntities.forEach(advanceEntity->{ + advanceEntities.forEach(advanceEntity -> { StatisticsOrderInfoEntity orderInfoEntity = new StatisticsOrderInfoEntity(); orderInfoEntity.setOrderCode(advanceEntity.getOrderCode()); orderInfoEntity.setWaybillId(waybillId); @@ -498,7 +505,7 @@ public class WaybillCheckListener { }); boolean b = statisticsOrderInfoService.saveBatch(orderInfoEntities); - if(b){ + if (b) { Map> advanceDetailGroupByOrderCode = advanceDetailEntities.stream() .collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getOrderCode)); @@ -506,11 +513,11 @@ public class WaybillCheckListener { List trunklinePackageEntities = new ArrayList<>(); List warehousePackageEntities = new ArrayList<>(); List distributionPackageEntities = new ArrayList<>(); - orderInfoEntities.forEach(orderInfoEntity->{ + orderInfoEntities.forEach(orderInfoEntity -> { Long orderId = orderInfoEntity.getId(); String orderCode = orderInfoEntity.getOrderCode(); List advanceDetailList = advanceDetailGroupByOrderCode.get(orderCode); - advanceDetailList.forEach(advanceDetailEntity->{ + advanceDetailList.forEach(advanceDetailEntity -> { Long incomeCategoryId = advanceDetailEntity.getIncomeCategoryId(); String orderPackageCode = advanceDetailEntity.getOrderPackageCode(); Integer quantity = advanceDetailEntity.getQuantity(); @@ -536,7 +543,7 @@ public class WaybillCheckListener { trunklinePackageEntity.setOtherPrice(otherPrice.multiply(BigDecimal.ONE)); trunklinePackageEntity.setThirdOperationPrice(thirdOperationPrice.multiply(BigDecimal.ONE)); - if(!Objects.isNull(warehouseWayBillDetail)){ + if (!Objects.isNull(warehouseWayBillDetail)) { trunklinePackageEntity.setProductId(incomeCategoryId); trunklinePackageEntity.setProductName(warehouseWayBillDetail.getProductName()); @@ -556,8 +563,8 @@ public class WaybillCheckListener { BigDecimal packageWeight = productTotalWeight.divide(new BigDecimal(num), 2, BigDecimal.ROUND_HALF_UP);//平摊到包件的质量 BigDecimal packageVolume = productTotalVolume.divide(new BigDecimal(num), 2, BigDecimal.ROUND_HALF_UP);//平摊到包件的体积 - trunklinePackageEntity.setWeight(Objects.isNull(packageWeight)?BigDecimal.ZERO:packageWeight); - trunklinePackageEntity.setVolume(Objects.isNull(packageVolume)?BigDecimal.ZERO:packageVolume); + trunklinePackageEntity.setWeight(Objects.isNull(packageWeight) ? BigDecimal.ZERO : packageWeight); + trunklinePackageEntity.setVolume(Objects.isNull(packageVolume) ? BigDecimal.ZERO : packageVolume); BigDecimal systemFreightPrice = warehouseWayBillDetail.getFreightPrice();//系统运费单价 BigDecimal price = warehouseWayBillDetail.getPrice();//实际运费单价 @@ -566,36 +573,36 @@ public class WaybillCheckListener { //如果系统运费计算方式是按件,则用系统的运费单价乘以包件数量 //如果系统运费计算方式是按方,则用系统的运费单价乘以包件体积 //如果系统运费计算方式是按重量,则用系统的运费单价乘以包件重量 - if(systemChargeType == 1){ + if (systemChargeType == 1) { trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(BigDecimal.ONE)); - }else if(systemChargeType == 2){ + } else if (systemChargeType == 2) { trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(packageVolume)); - }else if (systemChargeType == 3){ + } else if (systemChargeType == 3) { trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(packageWeight)); } //实际包件的运费 - if(chargeType == 1){ + if (chargeType == 1) { trunklinePackageEntity.setFreightPrice(price.multiply(BigDecimal.ONE)); - }else if(chargeType == 2){ + } else if (chargeType == 2) { trunklinePackageEntity.setFreightPrice(price.multiply(packageVolume)); - }else if (chargeType == 3){ + } else if (chargeType == 3) { trunklinePackageEntity.setFreightPrice(price.multiply(packageWeight)); } //提货包件单价 - if(systemPickupChargeType == 1){ + if (systemPickupChargeType == 1) { trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(BigDecimal.ONE)); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(BigDecimal.ONE)); - }else if(systemPickupChargeType == 2){ + } else if (systemPickupChargeType == 2) { trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(packageVolume)); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(packageVolume)); - }else if (systemPickupChargeType == 3){ + } else if (systemPickupChargeType == 3) { trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(packageWeight)); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(packageWeight)); } - }else{ + } else { trunklinePackageEntity.setFreightChargeType(1); @@ -643,7 +650,7 @@ public class WaybillCheckListener { warehousePackageEntity.setBrandId(brandId); warehousePackageEntity.setConsigneeId(consigneeId); warehousePackageEntity.setChargeType(1); - if(!Objects.isNull(warehouseWayBillDetail)){ + if (!Objects.isNull(warehouseWayBillDetail)) { Integer systemWarehouseChargeType = warehouseWayBillDetail.getSystemWarehouseChargeType(); warehousePackageEntity.setChargeType(systemWarehouseChargeType); @@ -678,8 +685,8 @@ public class WaybillCheckListener { distributionPackageEntity.setOrderCode(orderCode); distributionPackageEntity.setOrderPackageCode(orderPackageCode); distributionPackageEntity.setNum(quantity); - distributionPackageEntity.setWeight(Objects.isNull(weight)?BigDecimal.ZERO:weight); - distributionPackageEntity.setVolume(Objects.isNull(volume)?BigDecimal.ZERO:volume); + distributionPackageEntity.setWeight(Objects.isNull(weight) ? BigDecimal.ZERO : weight); + distributionPackageEntity.setVolume(Objects.isNull(volume) ? BigDecimal.ZERO : volume); distributionPackageEntity.setGoodsType(1); distributionPackageEntity.setOrderInfoId(orderId); distributionPackageEntity.setDeliveryLoadingFee(handlingPrice.multiply(BigDecimal.ONE)); @@ -694,7 +701,7 @@ public class WaybillCheckListener { distributionPackageEntity.setConsigneeId(consigneeId); distributionPackageEntity.setDeliveryLoadingFee(handlingPrice.multiply(BigDecimal.ONE)); - if(!Objects.isNull(warehouseWayBillDetail)){ + if (!Objects.isNull(warehouseWayBillDetail)) { Integer systemDeliveryChargeType = warehouseWayBillDetail.getSystemDeliveryChargeType(); BigDecimal productTotalWeight = warehouseWayBillDetail.getWeight(); @@ -712,23 +719,23 @@ public class WaybillCheckListener { BigDecimal systemDeliveryPrice = warehouseWayBillDetail.getDeliveryPrice(); - if(systemDeliveryChargeType == 1){ + if (systemDeliveryChargeType == 1) { distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(BigDecimal.ONE)); - }else if(systemDeliveryChargeType == 2){ + } else if (systemDeliveryChargeType == 2) { distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(packageVolume)); - }else if(systemDeliveryChargeType == 3){ + } else if (systemDeliveryChargeType == 3) { distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(packageWeight)); } distributionPackageEntity.setDeliveryFee(BigDecimal.ZERO); - }else{ + } else { distributionPackageEntity.setSystemDeliveryChargeType(1); distributionPackageEntity.setDeliveryChargeType(1); distributionPackageEntity.setSystemDeliveryFee(BigDecimal.ZERO); distributionPackageEntity.setDeliveryFee(BigDecimal.ZERO); } - if(payWay.equals("1") || payWay.equals("2")){ + if (payWay.equals("1") || payWay.equals("2")) { distributionPackageEntity.setDeliveryFee(distributionPackageEntity.getSystemDeliveryFee()); } BigDecimal deliveryFeeTotal = distributionPackageEntity.getDeliveryFee(); @@ -746,18 +753,18 @@ public class WaybillCheckListener { distributionPackageEntities.add(distributionPackageEntity); }); }); - if(CollUtil.isNotEmpty(trunklinePackageEntities)){ + if (CollUtil.isNotEmpty(trunklinePackageEntities)) { trunklinePackageService.saveBatch(trunklinePackageEntities); } - if(CollUtil.isNotEmpty(warehousePackageEntities)){ + if (CollUtil.isNotEmpty(warehousePackageEntities)) { warehousePackageService.saveBatch(warehousePackageEntities); } - if(CollUtil.isNotEmpty(distributionPackageEntities)){ + if (CollUtil.isNotEmpty(distributionPackageEntities)) { distributionPackageService.saveBatch(distributionPackageEntities); } - }else{ - log.warn("#############dealwithPackageOrder: 保存订单数据失败 waybillNo={}",waybillNo); + } else { + log.warn("#############dealwithPackageOrder: 保存订单数据失败 waybillNo={}", waybillNo); } } } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsBalanceOrderInfoMapper.xml b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsBalanceOrderInfoMapper.xml index a447a6ce3..18a9b30ad 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsBalanceOrderInfoMapper.xml +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsBalanceOrderInfoMapper.xml @@ -21,6 +21,37 @@ and abnormal_balance_status = #{param.abnormalBalanceStatus} + + and consignee = #{param.consignee} + + + and consignee = #{param.consignee} + + + and create_time >= #{param.createTimeStart} + + + and create_time <= #{param.createTimeEnd} + + + and abnormal_time >= #{param.abnormalTimeStart} + + + and abnormal_time <= #{param.abnormalTimeEnd} + + + and balance_time >= #{param.balanceTimeStart} + + + and balance_time <= #{param.balanceTimeEnd} + + + and destination_warehouse_name = #{param.destinationWarehouseName} + + and destination_warehouse_id in + + #{item} + diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.java index f5fab987a..33cd84b94 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.java @@ -7,11 +7,13 @@ import com.logpm.statistics.entity.StatisticsOrderInfoEntity; import com.logpm.statistics.vo.StatisticsOrderInfoExportVO; import com.logpm.statistics.vo.StatisticsOrderInfoVO; import com.logpm.statistics.vo.StatisticsPackageFeeInfoVO; +import com.logpm.statistics.vo.WaybillDetailByWaybillNoVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.Date; import java.util.List; +import java.util.Set; @Mapper public interface StatisticsOrderInfoMapper extends BaseMapper { @@ -35,4 +37,6 @@ public interface StatisticsOrderInfoMapper extends BaseMapper orderInfoIds, @Param("nickName") String nickName, @Param("date") Date date); List orderInfoListExport(@Param("param") MerchantStatisticsDTO merchantStatisticsDTO); + + List findWaybillDetailByWaybillId(@Param("warehouseIdSet") Set warehouseIdSet); } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml index 15ee38b14..7c1d9a242 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml @@ -18,6 +18,7 @@ lww.consignee_name consigneePerson, lww.consignee_mobile consigneeMobile, lww.consignee_address consigneeAddress, + concat(GROUP_CONCAT(lwwd.product_name)) as goodsName, lsoi.sign_status signStatus, lsoi.sign_date signDate, lww.create_time openTime, @@ -42,6 +43,7 @@ from logpm_statistics_order_info lsoi left join logpm_basicdata_client lbc on lbc.id = lsoi.consignee_id left join logpm_warehouse_waybill lww on lww.id = lsoi.waybill_id + LEFT JOIN logpm_warehouse_waybill_detail lwwd on lwwd.waybill_id=lww.id where 1=1 and lsoi.create_reconciliation_order_status = 0 @@ -66,7 +68,7 @@ and Locate(#{param.waybillNo},lww.waybill_no) > 0 - and Locate(#{param.orderCode},lww.order_code) > 0 + and Locate(#{param.orderCode},lww.order_no) > 0 and Locate(#{param.shipper},lww.shipper) > 0 @@ -86,6 +88,18 @@ and lww.create_time <= #{param.openTimeEnd} + + and lsoi.sign_date >= #{param.signTimeStart} + + + and lsoi.sign_date <= #{param.signTimeEnd} + + + and lsoi.sync_fee_date >= #{param.syncFeeDateStart} + + + and lsoi.sync_fee_date <= #{param.syncFeeDateEnd} + and Locate(#{param.shipperPerson},lww.shipper_person) > 0 @@ -102,12 +116,15 @@ and lbc.clean_obj_type = #{param.cleanObjType} - and lbc.pay_type = #{param.payType} + and lww.pay_type = #{param.payType} - and lbc.pay_way = #{param.payWay} + and lww.pay_way = #{param.payWay} - + and lsoi.destination_warehouse_id in + + #{item} + group by lsoi.id @@ -487,6 +504,29 @@ where 1=1 and lsoi.waybill_id = #{waybillId} + delete from logpm_statistics_order_info diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsReconciliationOrderInfoMapper.xml b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsReconciliationOrderInfoMapper.xml index a28e7653b..b4589bb58 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsReconciliationOrderInfoMapper.xml +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsReconciliationOrderInfoMapper.xml @@ -26,14 +26,13 @@ and create_time <= #{param.openTimeEnd} - - and consignee <= #{param.consignee} + + and destination_warehouse_name = #{param.destinationWarehouseName} - - - and is_aftersale <= #{param.isAftersales} - - + and destination_warehouse_id in + + #{item} + diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsBalanceOrderInfoServiceImpl.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsBalanceOrderInfoServiceImpl.java index eb2201bd1..d240ae87a 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsBalanceOrderInfoServiceImpl.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsBalanceOrderInfoServiceImpl.java @@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.statistics.dto.MerchantStatisticsDTO; import com.logpm.statistics.dto.StatisticsBalanceAbnormalDTO; import com.logpm.statistics.dto.StatisticsBalanceRecordDTO; @@ -39,6 +41,7 @@ public class StatisticsBalanceOrderInfoServiceImpl extends BaseServiceImpl pageList(MerchantStatisticsDTO merchantStatisticsDTO) { @@ -47,196 +50,202 @@ public class StatisticsBalanceOrderInfoServiceImpl extends BaseServiceImpl warehouseIds = warehouseClient.getWarehouseIds(); + if(!warehouseIds.isEmpty()){ + merchantStatisticsDTO.setWarehouseIds(warehouseIds); + } + + return baseMapper.pageList(page,merchantStatisticsDTO); - } +} - @Transactional(rollbackFor = Exception.class) - @Override - public R addAbnormal(StatisticsBalanceAbnormalDTO balanceAbnormalDTO) { - StatisticsBalanceAbnormalEntity balanceAbnormalEntity = new StatisticsBalanceAbnormalEntity(); - BeanUtil.copy(balanceAbnormalDTO,balanceAbnormalEntity); - balanceAbnormalEntity.setAbnormalUserName(AuthUtil.getNickName()); +@Transactional(rollbackFor = Exception.class) +@Override +public R addAbnormal(StatisticsBalanceAbnormalDTO balanceAbnormalDTO) { + StatisticsBalanceAbnormalEntity balanceAbnormalEntity = new StatisticsBalanceAbnormalEntity(); + BeanUtil.copy(balanceAbnormalDTO, balanceAbnormalEntity); + balanceAbnormalEntity.setAbnormalUserName(AuthUtil.getNickName()); - balanceAbnormalService.save(balanceAbnormalEntity); - Long balanceAbnormalId = balanceAbnormalEntity.getId(); + balanceAbnormalService.save(balanceAbnormalEntity); + Long balanceAbnormalId = balanceAbnormalEntity.getId(); - List abnormalPhotoEntityList = balanceAbnormalDTO.getAbnormalPhotoEntityList(); + List abnormalPhotoEntityList = balanceAbnormalDTO.getAbnormalPhotoEntityList(); - abnormalPhotoEntityList.forEach(abnormalPhotoEntity -> { - abnormalPhotoEntity.setAbnormalId(balanceAbnormalId); - }); + abnormalPhotoEntityList.forEach(abnormalPhotoEntity -> { + abnormalPhotoEntity.setAbnormalId(balanceAbnormalId); + }); - balanceAbnormalPhotoService.saveBatch(abnormalPhotoEntityList); + balanceAbnormalPhotoService.saveBatch(abnormalPhotoEntityList); - Long balanceOrderInfoId = balanceAbnormalEntity.getBalanceOrderInfoId(); + Long balanceOrderInfoId = balanceAbnormalEntity.getBalanceOrderInfoId(); - StatisticsBalanceOrderInfoEntity balanceOrderInfoEntity = baseMapper.selectById(balanceOrderInfoId); - if(Objects.isNull(balanceOrderInfoEntity)){ - log.warn("###########addAbnormal: 结算单信息不存在 balanceOrderInfoEntity={}",balanceOrderInfoEntity); - throw new CustomerException(405,"结算单信息不存在"); - } - BigDecimal totalBalanceFee = balanceOrderInfoEntity.getTotalBalanceFee(); - BigDecimal hasBalanceFee = balanceOrderInfoEntity.getHasBalanceFee(); - BigDecimal abnormalFee = balanceAbnormalEntity.getAbnormalFee(); - - BigDecimal total = totalBalanceFee.add(abnormalFee); - - balanceOrderInfoEntity.setAbnormalBalanceStatus(1); - balanceOrderInfoEntity.setAbnormalBalanceFee(balanceOrderInfoEntity.getAbnormalBalanceFee().add(abnormalFee)); - balanceOrderInfoEntity.setAbnormalTime(balanceAbnormalEntity.getCreateTime()); - balanceOrderInfoEntity.setAbnormalUserName(balanceAbnormalEntity.getAbnormalUserName()); - balanceOrderInfoEntity.setAbnormalRemark(balanceAbnormalEntity.getAbnormalRemark()); - if(hasBalanceFee.compareTo(total) >= 0){ - balanceOrderInfoEntity.setBalanceStatus(2); - }else{ - if(hasBalanceFee.compareTo(BigDecimal.ZERO) == 0){ - balanceOrderInfoEntity.setBalanceStatus(0); - }else{ - balanceOrderInfoEntity.setBalanceStatus(1); - } + StatisticsBalanceOrderInfoEntity balanceOrderInfoEntity = baseMapper.selectById(balanceOrderInfoId); + if (Objects.isNull(balanceOrderInfoEntity)) { + log.warn("###########addAbnormal: 结算单信息不存在 balanceOrderInfoEntity={}", balanceOrderInfoEntity); + throw new CustomerException(405, "结算单信息不存在"); + } + BigDecimal totalBalanceFee = balanceOrderInfoEntity.getTotalBalanceFee(); + BigDecimal hasBalanceFee = balanceOrderInfoEntity.getHasBalanceFee(); + BigDecimal abnormalFee = balanceAbnormalEntity.getAbnormalFee(); + + BigDecimal total = totalBalanceFee.add(abnormalFee); + + balanceOrderInfoEntity.setAbnormalBalanceStatus(1); + balanceOrderInfoEntity.setAbnormalBalanceFee(balanceOrderInfoEntity.getAbnormalBalanceFee().add(abnormalFee)); + balanceOrderInfoEntity.setAbnormalTime(balanceAbnormalEntity.getCreateTime()); + balanceOrderInfoEntity.setAbnormalUserName(balanceAbnormalEntity.getAbnormalUserName()); + balanceOrderInfoEntity.setAbnormalRemark(balanceAbnormalEntity.getAbnormalRemark()); + if (hasBalanceFee.compareTo(total) >= 0) { + balanceOrderInfoEntity.setBalanceStatus(2); + } else { + if (hasBalanceFee.compareTo(BigDecimal.ZERO) == 0) { + balanceOrderInfoEntity.setBalanceStatus(0); + } else { + balanceOrderInfoEntity.setBalanceStatus(1); } - updateById(balanceOrderInfoEntity); - - return R.success("添加成功"); } + updateById(balanceOrderInfoEntity); - @Override - public R findAbnormalList(StatisticsBalanceAbnormalDTO balanceAbnormalDTO) { - Long balanceOrderInfoId = balanceAbnormalDTO.getBalanceOrderInfoId(); + return R.success("添加成功"); +} - QueryWrapper balanceAbnormalEntityQueryWrapper = new QueryWrapper<>(); - balanceAbnormalEntityQueryWrapper.eq("balance_order_info_id",balanceOrderInfoId); +@Override +public R findAbnormalList(StatisticsBalanceAbnormalDTO balanceAbnormalDTO) { + Long balanceOrderInfoId = balanceAbnormalDTO.getBalanceOrderInfoId(); - List list = balanceAbnormalService.list(balanceAbnormalEntityQueryWrapper); + QueryWrapper balanceAbnormalEntityQueryWrapper = new QueryWrapper<>(); + balanceAbnormalEntityQueryWrapper.eq("balance_order_info_id", balanceOrderInfoId); - if(list.isEmpty()){ - return R.data(CollUtil.newArrayList()); - } + List list = balanceAbnormalService.list(balanceAbnormalEntityQueryWrapper); - //把list中所有元素的id放到一个List集合中 - List idList= list.stream() - .map(StatisticsBalanceAbnormalEntity::getId) - .collect(Collectors.toList()); + if (list.isEmpty()) { + return R.data(CollUtil.newArrayList()); + } - QueryWrapper balanceAbnormalPhotoEntityQueryWrapper = new QueryWrapper<>(); - balanceAbnormalPhotoEntityQueryWrapper.in("abnormal_id",idList); + //把list中所有元素的id放到一个List集合中 + List idList = list.stream() + .map(StatisticsBalanceAbnormalEntity::getId) + .collect(Collectors.toList()); - List abnormalPhotoEntityList = balanceAbnormalPhotoService.list(balanceAbnormalPhotoEntityQueryWrapper); - //把abnormalPhotoEntityList中所有元素按照abnormalId进行分组 - Map> groupedPhotos = abnormalPhotoEntityList.stream() - .collect(Collectors.groupingBy(StatisticsBalanceAbnormalPhotoEntity::getAbnormalId)); + QueryWrapper balanceAbnormalPhotoEntityQueryWrapper = new QueryWrapper<>(); + balanceAbnormalPhotoEntityQueryWrapper.in("abnormal_id", idList); - List abnormalVOList = new ArrayList<>(); - list.forEach(balanceAbnormalEntity -> { - StatisticsBalanceAbnormalVO balanceAbnormalVO = new StatisticsBalanceAbnormalVO(); - BeanUtil.copy(balanceAbnormalEntity,balanceAbnormalVO); - balanceAbnormalVO.setAbnormalPhotoEntityList(groupedPhotos.get(balanceAbnormalEntity.getId())); - abnormalVOList.add(balanceAbnormalVO); - }); + List abnormalPhotoEntityList = balanceAbnormalPhotoService.list(balanceAbnormalPhotoEntityQueryWrapper); + //把abnormalPhotoEntityList中所有元素按照abnormalId进行分组 + Map> groupedPhotos = abnormalPhotoEntityList.stream() + .collect(Collectors.groupingBy(StatisticsBalanceAbnormalPhotoEntity::getAbnormalId)); - return R.data(abnormalVOList); - } + List abnormalVOList = new ArrayList<>(); + list.forEach(balanceAbnormalEntity -> { + StatisticsBalanceAbnormalVO balanceAbnormalVO = new StatisticsBalanceAbnormalVO(); + BeanUtil.copy(balanceAbnormalEntity, balanceAbnormalVO); + balanceAbnormalVO.setAbnormalPhotoEntityList(groupedPhotos.get(balanceAbnormalEntity.getId())); + abnormalVOList.add(balanceAbnormalVO); + }); - @Transactional(rollbackFor = Exception.class) - @Override - public R addBalanceRecord(StatisticsBalanceRecordDTO balanceRecordDTO) { - StatisticsBalanceRecordEntity balanceRecordEntity = new StatisticsBalanceRecordEntity(); - BeanUtil.copy(balanceRecordDTO,balanceRecordEntity); - balanceRecordEntity.setBalanceUserName(AuthUtil.getNickName()); + return R.data(abnormalVOList); +} - balanceRecordService.save(balanceRecordEntity); +@Transactional(rollbackFor = Exception.class) +@Override +public R addBalanceRecord(StatisticsBalanceRecordDTO balanceRecordDTO) { + StatisticsBalanceRecordEntity balanceRecordEntity = new StatisticsBalanceRecordEntity(); + BeanUtil.copy(balanceRecordDTO, balanceRecordEntity); + balanceRecordEntity.setBalanceUserName(AuthUtil.getNickName()); - List recordPhotoEntityList = balanceRecordDTO.getRecordPhotoEntityList(); + balanceRecordService.save(balanceRecordEntity); - recordPhotoEntityList.forEach(recordPhotoEntity -> { - recordPhotoEntity.setRecordId(balanceRecordEntity.getId()); - }); + List recordPhotoEntityList = balanceRecordDTO.getRecordPhotoEntityList(); - balanceRecordPhotoService.saveBatch(recordPhotoEntityList); + recordPhotoEntityList.forEach(recordPhotoEntity -> { + recordPhotoEntity.setRecordId(balanceRecordEntity.getId()); + }); - Long balanceOrderInfoId = balanceRecordDTO.getBalanceOrderInfoId(); + balanceRecordPhotoService.saveBatch(recordPhotoEntityList); - StatisticsBalanceOrderInfoEntity balanceOrderInfoEntity = baseMapper.selectById(balanceOrderInfoId); - if(Objects.isNull(balanceOrderInfoEntity)){ - log.warn("###########addBalanceRecord: 结算单信息不存在 balanceOrderInfoEntity={}",balanceOrderInfoEntity); - return R.fail(405,"结算单信息不存在"); - } + Long balanceOrderInfoId = balanceRecordDTO.getBalanceOrderInfoId(); - BigDecimal balanceFee = balanceRecordEntity.getBalanceFee(); + StatisticsBalanceOrderInfoEntity balanceOrderInfoEntity = baseMapper.selectById(balanceOrderInfoId); + if (Objects.isNull(balanceOrderInfoEntity)) { + log.warn("###########addBalanceRecord: 结算单信息不存在 balanceOrderInfoEntity={}", balanceOrderInfoEntity); + return R.fail(405, "结算单信息不存在"); + } - BigDecimal totalBalanceFee = balanceOrderInfoEntity.getTotalBalanceFee(); - BigDecimal abnormalBalanceFee = balanceOrderInfoEntity.getAbnormalBalanceFee(); + BigDecimal balanceFee = balanceRecordEntity.getBalanceFee(); - BigDecimal total = totalBalanceFee.add(abnormalBalanceFee); - BigDecimal hasBalanceFee = balanceOrderInfoEntity.getHasBalanceFee(); + BigDecimal totalBalanceFee = balanceOrderInfoEntity.getTotalBalanceFee(); + BigDecimal abnormalBalanceFee = balanceOrderInfoEntity.getAbnormalBalanceFee(); - BigDecimal newHasBalanceFee = hasBalanceFee.add(balanceFee); + BigDecimal total = totalBalanceFee.add(abnormalBalanceFee); + BigDecimal hasBalanceFee = balanceOrderInfoEntity.getHasBalanceFee(); - if(newHasBalanceFee.compareTo(total) >= 0){ - balanceOrderInfoEntity.setBalanceStatus(2); - balanceOrderInfoEntity.setNoBalanceFee(BigDecimal.ZERO); - }else{ - balanceOrderInfoEntity.setBalanceStatus(1); - balanceOrderInfoEntity.setNoBalanceFee(total.subtract(newHasBalanceFee)); - } + BigDecimal newHasBalanceFee = hasBalanceFee.add(balanceFee); - balanceOrderInfoEntity.setHasBalanceFee(newHasBalanceFee); - balanceOrderInfoEntity.setBalanceTime(balanceRecordEntity.getCreateTime()); - balanceOrderInfoEntity.setBalanceUserName(balanceRecordEntity.getBalanceUserName()); - balanceOrderInfoEntity.setBalanceRemark(balanceRecordEntity.getBalanceRemark()); + if (newHasBalanceFee.compareTo(total) >= 0) { + balanceOrderInfoEntity.setBalanceStatus(2); + balanceOrderInfoEntity.setNoBalanceFee(BigDecimal.ZERO); + } else { + balanceOrderInfoEntity.setBalanceStatus(1); + balanceOrderInfoEntity.setNoBalanceFee(total.subtract(newHasBalanceFee)); + } - updateById(balanceOrderInfoEntity); + balanceOrderInfoEntity.setHasBalanceFee(newHasBalanceFee); + balanceOrderInfoEntity.setBalanceTime(balanceRecordEntity.getCreateTime()); + balanceOrderInfoEntity.setBalanceUserName(balanceRecordEntity.getBalanceUserName()); + balanceOrderInfoEntity.setBalanceRemark(balanceRecordEntity.getBalanceRemark()); - return R.success("添加成功"); - } + updateById(balanceOrderInfoEntity); - @Override - public R findRecordList(StatisticsBalanceRecordDTO balanceRecordDTO) { + return R.success("添加成功"); +} - Long balanceOrderInfoId = balanceRecordDTO.getBalanceOrderInfoId(); +@Override +public R findRecordList(StatisticsBalanceRecordDTO balanceRecordDTO) { - QueryWrapper balanceAbnormalEntityQueryWrapper = new QueryWrapper<>(); - balanceAbnormalEntityQueryWrapper.eq("balance_order_info_id",balanceOrderInfoId); + Long balanceOrderInfoId = balanceRecordDTO.getBalanceOrderInfoId(); - List list = balanceRecordService.list(balanceAbnormalEntityQueryWrapper); + QueryWrapper balanceAbnormalEntityQueryWrapper = new QueryWrapper<>(); + balanceAbnormalEntityQueryWrapper.eq("balance_order_info_id", balanceOrderInfoId); - if(list.isEmpty()){ - return R.data(CollUtil.newArrayList()); - } + List list = balanceRecordService.list(balanceAbnormalEntityQueryWrapper); - //把list中所有元素的id放到一个List集合中 - List idList= list.stream() - .map(StatisticsBalanceRecordEntity::getId) - .collect(Collectors.toList()); - - QueryWrapper balanceRecordPhotoEntityQueryWrapper = new QueryWrapper<>(); - balanceRecordPhotoEntityQueryWrapper.in("record_id",idList); - - List recordPhotoEntityList = balanceRecordPhotoService.list(balanceRecordPhotoEntityQueryWrapper); - //把abnormalPhotoEntityList中所有元素按照abnormalId进行分组 - Map> groupedPhotos = recordPhotoEntityList.stream() - .collect(Collectors.groupingBy(StatisticsBalanceRecordPhotoEntity::getRecordId)); - - List balanceRecordVOS = new ArrayList<>(); - list.forEach(balanceRecordEntity -> { - StatisticsBalanceRecordVO balanceRecordVO = new StatisticsBalanceRecordVO(); - BeanUtil.copy(balanceRecordEntity,balanceRecordVO); - balanceRecordVO.setRecordPhotoEntityList(groupedPhotos.get(balanceRecordEntity.getId())); - balanceRecordVO.setBalanceUserName(balanceRecordEntity.getBalanceUserName()); - balanceRecordVO.setBalanceRemark(balanceRecordEntity.getBalanceRemark()); - balanceRecordVOS.add(balanceRecordVO); - }); - - return R.data(balanceRecordVOS); + if (list.isEmpty()) { + return R.data(CollUtil.newArrayList()); } - @Override - public R findBalanceDetail(Long balanceOrderId) { + //把list中所有元素的id放到一个List集合中 + List idList = list.stream() + .map(StatisticsBalanceRecordEntity::getId) + .collect(Collectors.toList()); + + QueryWrapper balanceRecordPhotoEntityQueryWrapper = new QueryWrapper<>(); + balanceRecordPhotoEntityQueryWrapper.in("record_id", idList); + + List recordPhotoEntityList = balanceRecordPhotoService.list(balanceRecordPhotoEntityQueryWrapper); + //把abnormalPhotoEntityList中所有元素按照abnormalId进行分组 + Map> groupedPhotos = recordPhotoEntityList.stream() + .collect(Collectors.groupingBy(StatisticsBalanceRecordPhotoEntity::getRecordId)); + + List balanceRecordVOS = new ArrayList<>(); + list.forEach(balanceRecordEntity -> { + StatisticsBalanceRecordVO balanceRecordVO = new StatisticsBalanceRecordVO(); + BeanUtil.copy(balanceRecordEntity, balanceRecordVO); + balanceRecordVO.setRecordPhotoEntityList(groupedPhotos.get(balanceRecordEntity.getId())); + balanceRecordVO.setBalanceUserName(balanceRecordEntity.getBalanceUserName()); + balanceRecordVO.setBalanceRemark(balanceRecordEntity.getBalanceRemark()); + balanceRecordVOS.add(balanceRecordVO); + }); + + return R.data(balanceRecordVOS); +} - StatisticsBalanceOrderInfoEntity statisticsBalanceOrderInfoEntity = baseMapper.selectById(balanceOrderId); +@Override +public R findBalanceDetail(Long balanceOrderId) { - return R.data(statisticsBalanceOrderInfoEntity); - } + StatisticsBalanceOrderInfoEntity statisticsBalanceOrderInfoEntity = baseMapper.selectById(balanceOrderId); + + return R.data(statisticsBalanceOrderInfoEntity); +} } diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java index 32f056d1e..307202291 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java @@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.logpm.basicdata.entity.BasicdataPriceTemplateEntity; import com.logpm.basicdata.feign.IBasicdataCodeClient; import com.logpm.basicdata.feign.IBasicdataPriceClient; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.basicdata.vo.*; import com.logpm.statistics.dto.AftersalesOrderDTO; import com.logpm.statistics.dto.ChangesRecordDTO; @@ -45,13 +46,13 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl findListByWaybillId(Long waybillId) { @@ -75,22 +76,58 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl warehouseIds = warehouseClient.getWarehouseIds(); + if(!warehouseIds.isEmpty()){ + merchantStatisticsDTO.setWarehouseIds(warehouseIds); + } + + IPage statisticsOrderInfoVOIPage = baseMapper.pageList(page, merchantStatisticsDTO); List records = statisticsOrderInfoVOIPage.getRecords(); //把records中所有的orderInfoId放入一个集合 List orderInfoIdList = records.stream().map(StatisticsOrderInfoVO::getOrderInfoId).collect(Collectors.toList()); + // 运单ID集合 + Set warehouseIdSet = records.stream().map(StatisticsOrderInfoVO::getWaybillId).collect(Collectors.toSet()); + List waybillDetailByWaybillNoVoList; + Map orderPackageInfoMap; if(CollUtil.isNotEmpty(orderInfoIdList)){ List orderPackageInfoList = baseMapper.findPackageListByOrderIdsGroupById(orderInfoIdList); //把orderPackageInfoList转化成以orderInfoId为key的Map - Map orderPackageInfoMap = orderPackageInfoList.stream() - .collect(Collectors.toMap(StatisticsPackageFeeInfoVO::getOrderInfoId, statisticsPackageFeeInfoVO -> statisticsPackageFeeInfoVO)); + if(CollUtil.isNotEmpty(orderPackageInfoList)){ + orderPackageInfoMap = orderPackageInfoList.stream() + .collect(Collectors.toMap(StatisticsPackageFeeInfoVO::getOrderInfoId, statisticsPackageFeeInfoVO -> statisticsPackageFeeInfoVO)); + } else { + orderPackageInfoMap = null; + } + } else { + orderPackageInfoMap = null; + } + if(CollUtil.isNotEmpty(warehouseIdSet)){ + waybillDetailByWaybillNoVoList = baseMapper.findWaybillDetailByWaybillId(warehouseIdSet); + } else { + waybillDetailByWaybillNoVoList = null; + } + + records.forEach(statisticsOrderInfoVO -> { + Long waybillId = statisticsOrderInfoVO.getWaybillId(); + WaybillDetailByWaybillNoVo waybillDetailByWaybillNoVo1 = null; - records.forEach(statisticsOrderInfoVO -> { - Long orderInfoId = statisticsOrderInfoVO.getOrderInfoId(); + Long orderInfoId = statisticsOrderInfoVO.getOrderInfoId(); + if(orderPackageInfoMap!=null){ StatisticsPackageFeeInfoVO statisticsPackageFeeInfoVO = orderPackageInfoMap.get(orderInfoId); - BeanUtil.copy(statisticsPackageFeeInfoVO, statisticsOrderInfoVO); - }); - } + if(statisticsPackageFeeInfoVO!=null){ + BeanUtil.copy(statisticsPackageFeeInfoVO, statisticsOrderInfoVO); + } + } + + if(waybillDetailByWaybillNoVoList!=null){ + waybillDetailByWaybillNoVo1 = waybillDetailByWaybillNoVoList.stream().filter(waybillDetailByWaybillNoVo -> Objects.equals(waybillDetailByWaybillNoVo.getWaybillId(), waybillId)).findFirst().orElse(null); + } + if(waybillDetailByWaybillNoVo1!=null){ + statisticsOrderInfoVO.setGoodsName(waybillDetailByWaybillNoVo1.getGoodsName()); + } + }); statisticsOrderInfoVOIPage.setRecords(records); return statisticsOrderInfoVOIPage; diff --git a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsReconciliationOrderInfoServiceImpl.java b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsReconciliationOrderInfoServiceImpl.java index 7d8bfb9f8..76fe2f7df 100644 --- a/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsReconciliationOrderInfoServiceImpl.java +++ b/blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsReconciliationOrderInfoServiceImpl.java @@ -2,11 +2,13 @@ package com.logpm.statistics.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.statistics.dto.MerchantStatisticsDTO; import com.logpm.statistics.entity.StatisticsReconciliationOrderInfoEntity; import com.logpm.statistics.mapper.StatisticsReconciliationOrderInfoMapper; import com.logpm.statistics.service.IStatisticsReconciliationOrderInfoService; import com.logpm.statistics.vo.StatisticsReconciliationInfoExportVO; +import com.logpm.warehouse.feign.IWarehouseWaybillClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.utils.CommonUtil; @@ -21,6 +23,10 @@ import java.util.List; @Slf4j @AllArgsConstructor public class StatisticsReconciliationOrderInfoServiceImpl extends BaseServiceImpl implements IStatisticsReconciliationOrderInfoService { + + + private IBasicdataWarehouseClient warehouseClient; + @Override public IPage pageReconciliationList(MerchantStatisticsDTO merchantStatisticsDTO) { @@ -31,6 +37,13 @@ public class StatisticsReconciliationOrderInfoServiceImpl extends BaseServiceImp merchantStatisticsDTO.setOpenTimeStart(CommonUtil.getStartByDateStr(merchantStatisticsDTO.getOpenTimeStartStr())); merchantStatisticsDTO.setOpenTimeEnd(CommonUtil.getEndByDateStr(merchantStatisticsDTO.getOpenTimeEndStr())); + + List warehouseIds = warehouseClient.getWarehouseIds(); + if(!warehouseIds.isEmpty()){ + merchantStatisticsDTO.setWarehouseIds(warehouseIds); + } + + return baseMapper.pageReconciliationList(page, merchantStatisticsDTO); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml index 3b1f3d51a..6c5934277 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml @@ -505,7 +505,7 @@ #{item} - + and lww.destination_warehouse_id in #{item}