@ -286,6 +286,12 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl<StatisticsOr
statisticsBalanceOrderInfoEntity . setInstallFee ( BigDecimal . ZERO ) ;
statisticsBalanceOrderInfoEntity . setIsAftersale ( isAftersales ) ;
statisticsBalanceOrderInfoEntity . setAftersalesFee ( aftersalesFee ) ;
statisticsBalanceOrderInfoEntity . setAbnormalBalanceStatus ( 0 ) ;
statisticsBalanceOrderInfoEntity . setAbnormalBalanceFee ( BigDecimal . ZERO ) ;
statisticsBalanceOrderInfoEntity . setBalanceStatus ( 0 ) ;
statisticsBalanceOrderInfoEntity . setHasBalanceFee ( BigDecimal . ZERO ) ;
statisticsBalanceOrderInfoEntity . setNoBalanceFee ( totalFeeAddAfter ) ;
balanceOrderInfoService . save ( statisticsBalanceOrderInfoEntity ) ;
Long balanceOrderId = statisticsBalanceOrderInfoEntity . getId ( ) ;
@ -331,16 +337,19 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl<StatisticsOr
//把records中所有的orderInfoId放入一个集合
List < Long > orderInfoIdList = records . stream ( ) . map ( StatisticsOrderInfoVO : : getOrderInfoId ) . collect ( Collectors . toList ( ) ) ;
List < StatisticsPackageFeeInfoVO > orderPackageInfoList = baseMapper . findPackageListByOrderIdsGroupById ( orderInfoIdList ) ;
//把orderPackageInfoList转化成以orderInfoId为key的Map
Map < Long , StatisticsPackageFeeInfoVO > orderPackageInfoMap = orderPackageInfoList . stream ( )
. collect ( Collectors . toMap ( StatisticsPackageFeeInfoVO : : getOrderInfoId , statisticsPackageFeeInfoVO - > statisticsPackageFeeInfoVO ) ) ;
if ( CollUtil . isNotEmpty ( orderInfoIdList ) ) {
List < StatisticsPackageFeeInfoVO > orderPackageInfoList = baseMapper . findPackageListByOrderIdsGroupById ( orderInfoIdList ) ;
//把orderPackageInfoList转化成以orderInfoId为key的Map
Map < Long , StatisticsPackageFeeInfoVO > orderPackageInfoMap = orderPackageInfoList . stream ( )
. collect ( Collectors . toMap ( StatisticsPackageFeeInfoVO : : getOrderInfoId , statisticsPackageFeeInfoVO - > statisticsPackageFeeInfoVO ) ) ;
records . forEach ( statisticsOrderInfoVO - > {
Long orderInfoId = statisticsOrderInfoVO . getOrderInfoId ( ) ;
StatisticsPackageFeeInfoVO statisticsPackageFeeInfoVO = orderPackageInfoMap . get ( orderInfoId ) ;
BeanUtil . copy ( statisticsPackageFeeInfoVO , statisticsOrderInfoVO ) ;
} ) ;
}
records . forEach ( statisticsOrderInfoVO - > {
Long orderInfoId = statisticsOrderInfoVO . getOrderInfoId ( ) ;
StatisticsPackageFeeInfoVO statisticsPackageFeeInfoVO = orderPackageInfoMap . get ( orderInfoId ) ;
BeanUtil . copy ( statisticsPackageFeeInfoVO , statisticsOrderInfoVO ) ;
} ) ;
return records ;
}
@ -511,6 +520,8 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl<StatisticsOr
reconciliationOrder . setIsChanges ( 0 ) ;
reconciliationOrder . setChangesFee ( BigDecimal . ZERO ) ;
reconciliationOrder . setCheckStatus ( 0 ) ;
boolean saveFlag = reconciliationOrderInfoService . save ( reconciliationOrder ) ;
if ( saveFlag ) {
Long reconciliationOrderId = reconciliationOrder . getId ( ) ;
@ -656,85 +667,91 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl<StatisticsOr
List < Long > orderInfoIds = baseMapper . findOrderInfoIdListByReconciliationOrderIds ( reconciliationOrderIdList ) ;
List < StatisticsOrderInfoEntity > orderInfoEntities = baseMapper . selectBatchIds ( orderInfoIds ) ;
if ( CollUtil . isEmpty ( orderInfoEntities ) ) {
log . warn ( "############calculateReconcilitionOrder: 未找到对应订单信息" ) ;
throw new CustomerException ( 405 , "未找到对应订单信息" ) ;
}
if ( CollUtil . isNotEmpty ( orderInfoIds ) ) {
List < StatisticsOrderInfoEntity > orderInfoEntities = baseMapper . selectBatchIds ( orderInfoIds ) ;
if ( CollUtil . isEmpty ( orderInfoEntities ) ) {
log . warn ( "############calculateReconcilitionOrder: 未找到对应订单信息" ) ;
throw new CustomerException ( 405 , "未找到对应订单信息" ) ;
}
for ( StatisticsOrderInfoEntity orderInfoEntity : orderInfoEntities ) {
Integer syncFeeStatus = orderInfoEntity . getSyncFeeStatus ( ) ;
Long orderId = orderInfoEntity . getId ( ) ;
String orderCode = orderInfoEntity . getOrderCode ( ) ;
if ( syncFeeStatus = = 0 ) {
log . warn ( "############calculateReconcilitionOrder: 订单还未同步数据 orderId={}" , orderId ) ;
throw new CustomerException ( 405 , "订单[" + orderCode + "]还未同步数据" ) ;
for ( StatisticsOrderInfoEntity orderInfoEntity : orderInfoEntities ) {
Integer syncFeeStatus = orderInfoEntity . getSyncFeeStatus ( ) ;
Long orderId = orderInfoEntity . getId ( ) ;
String orderCode = orderInfoEntity . getOrderCode ( ) ;
if ( syncFeeStatus = = 0 ) {
log . warn ( "############calculateReconcilitionOrder: 订单还未同步数据 orderId={}" , orderId ) ;
throw new CustomerException ( 405 , "订单[" + orderCode + "]还未同步数据" ) ;
}
}
}
//判断orderInfoEntities中所有元素通过consigneeId进行分组
Map < Long , List < StatisticsOrderInfoEntity > > groupByConsigneeId = orderInfoEntities . stream ( ) . collect ( Collectors . groupingBy ( StatisticsOrderInfoEntity : : getConsigneeId ) ) ;
int consigneeSize = groupByConsigneeId . keySet ( ) . size ( ) ;
if ( consigneeSize > 1 ) {
log . warn ( "############calculateReconcilitionOrder: 订单不属于同一个商家" ) ;
throw new CustomerException ( 405 , "订单不属于同一个商家" ) ;
}
Map < Long , List < StatisticsOrderInfoEntity > > groupByDestinationWarehouseId = orderInfoEntities . stream ( ) . collect ( Collectors . groupingBy ( StatisticsOrderInfoEntity : : getDestinationWarehouseId ) ) ;
int destinationWarehouseIdSize = groupByDestinationWarehouseId . keySet ( ) . size ( ) ;
if ( destinationWarehouseIdSize > 1 ) {
log . warn ( "############calculateReconcilitionOrder: 订单不属于同一个目的仓" ) ;
throw new CustomerException ( 405 , "订单不属于同一个目的仓" ) ;
//判断orderInfoEntities中所有元素通过consigneeId进行分组
Map < Long , List < StatisticsOrderInfoEntity > > groupByConsigneeId = orderInfoEntities . stream ( ) . collect ( Collectors . groupingBy ( StatisticsOrderInfoEntity : : getConsigneeId ) ) ;
int consigneeSize = groupByConsigneeId . keySet ( ) . size ( ) ;
if ( consigneeSize > 1 ) {
log . warn ( "############calculateReconcilitionOrder: 订单不属于同一个商家" ) ;
throw new CustomerException ( 405 , "订单不属于同一个商家" ) ;
}
Map < Long , List < StatisticsOrderInfoEntity > > groupByDestinationWarehouseId = orderInfoEntities . stream ( ) . collect ( Collectors . groupingBy ( StatisticsOrderInfoEntity : : getDestinationWarehouseId ) ) ;
int destinationWarehouseIdSize = groupByDestinationWarehouseId . keySet ( ) . size ( ) ;
if ( destinationWarehouseIdSize > 1 ) {
log . warn ( "############calculateReconcilitionOrder: 订单不属于同一个目的仓" ) ;
throw new CustomerException ( 405 , "订单不属于同一个目的仓" ) ;
}
StatisticsPackageFeeInfoVO orderPackageTotalVO = baseMapper . findPackageListByOrderIds ( orderInfoIds ) ;
BigDecimal freightPrice = orderPackageTotalVO . getFreightPrice ( ) ;
BigDecimal pickupPrice = orderPackageTotalVO . getPickupPrice ( ) ;
BigDecimal warehouseServiceFee = orderPackageTotalVO . getWarehouseServiceFee ( ) ;
BigDecimal deliveryServiceFee = orderPackageTotalVO . getDeliveryServiceFee ( ) ;
BigDecimal totalFee = freightPrice . add ( pickupPrice ) . add ( warehouseServiceFee ) . add ( deliveryServiceFee ) . add ( changesFee ) . add ( aftersalesFee ) ;
StatisticsOrderInfoEntity statisticsOrderInfoEntity = orderInfoEntities . get ( 0 ) ;
Long consigneeId = statisticsOrderInfoEntity . getConsigneeId ( ) ;
String consignee = statisticsOrderInfoEntity . getConsignee ( ) ;
Long destinationWarehouseId = statisticsOrderInfoEntity . getDestinationWarehouseId ( ) ;
String destinationWarehouseName = statisticsOrderInfoEntity . getDestinationWarehouseName ( ) ;
//把orderInfoEntities中所有waybillNo去重拼接起来
reconciliationOrderInfo . setWaybillNo ( orderInfoEntities . stream ( ) . map ( StatisticsOrderInfoEntity : : getWaybillNo ) . distinct ( ) . collect ( Collectors . joining ( "," ) ) ) ;
reconciliationOrderInfo . setOrderCode ( orderInfoEntities . stream ( ) . map ( StatisticsOrderInfoEntity : : getOrderCode ) . distinct ( ) . collect ( Collectors . joining ( "," ) ) ) ;
reconciliationOrderInfo . setBrand ( orderInfoEntities . stream ( ) . map ( StatisticsOrderInfoEntity : : getBrand ) . distinct ( ) . collect ( Collectors . joining ( "," ) ) ) ;
reconciliationOrderInfo . setConsigneeId ( consigneeId ) ;
reconciliationOrderInfo . setConsignee ( consignee ) ;
reconciliationOrderInfo . setDestinationWarehouseName ( destinationWarehouseName ) ;
reconciliationOrderInfo . setDestinationWarehouseId ( destinationWarehouseId ) ;
reconciliationOrderInfo . setTotalNum ( orderPackageTotalVO . getTotalNum ( ) ) ;
reconciliationOrderInfo . setTotalWeight ( orderPackageTotalVO . getTotalWeight ( ) ) ;
reconciliationOrderInfo . setTotalVolume ( orderPackageTotalVO . getTotalVolume ( ) ) ;
reconciliationOrderInfo . setRealTotalFee ( totalFee ) ;
reconciliationOrderInfo . setPickupFee ( pickupPrice ) ;
reconciliationOrderInfo . setFreightFee ( freightPrice ) ;
reconciliationOrderInfo . setWarehouseServiceFee ( warehouseServiceFee ) ;
reconciliationOrderInfo . setWarehouseFee ( orderPackageTotalVO . getWarehouseFee ( ) ) ;
reconciliationOrderInfo . setWarehouseManageFee ( orderPackageTotalVO . getWarehouseManageFee ( ) ) ;
reconciliationOrderInfo . setWarehouseSortingFee ( orderPackageTotalVO . getWarehouseSortingFee ( ) ) ;
reconciliationOrderInfo . setWarehouseOperatingFee ( orderPackageTotalVO . getWarehouseOperatingFee ( ) ) ;
reconciliationOrderInfo . setDeliveryFee ( orderPackageTotalVO . getDeliveryFee ( ) ) ;
reconciliationOrderInfo . setDeliveryServiceFee ( deliveryServiceFee ) ;
reconciliationOrderInfo . setDeliveryLoadingFee ( orderPackageTotalVO . getDeliveryLoadingFee ( ) ) ;
reconciliationOrderInfo . setDeliverySortingFee ( orderPackageTotalVO . getDeliverySortingFee ( ) ) ;
reconciliationOrderInfo . setDeliveryUpfloorFee ( orderPackageTotalVO . getDeliveryUpfloorFee ( ) ) ;
reconciliationOrderInfo . setDeliveryMoveFee ( orderPackageTotalVO . getDeliveryMoveFee ( ) ) ;
reconciliationOrderInfo . setDeliveryOtherFee ( orderPackageTotalVO . getDeliveryOtherFee ( ) ) ;
reconciliationOrderInfo . setDeliveryCrossingFee ( orderPackageTotalVO . getDeliveryCrossingFee ( ) ) ;
reconciliationOrderInfo . setInstallFee ( BigDecimal . ZERO ) ;
reconciliationOrderInfo . setOtherFee ( BigDecimal . ZERO ) ;
reconciliationOrderInfo . setAftersalesFee ( aftersalesFee ) ;
reconciliationOrderInfo . setChangesFee ( changesFee ) ;
reconciliationOrderInfoService . updateById ( reconciliationOrderInfo ) ;
} else {
reconciliationOrderInfoService . removeById ( reconciliationOrderId ) ;
}
StatisticsPackageFeeInfoVO orderPackageTotalVO = baseMapper . findPackageListByOrderIds ( orderInfoIds ) ;
BigDecimal freightPrice = orderPackageTotalVO . getFreightPrice ( ) ;
BigDecimal pickupPrice = orderPackageTotalVO . getPickupPrice ( ) ;
BigDecimal warehouseServiceFee = orderPackageTotalVO . getWarehouseServiceFee ( ) ;
BigDecimal deliveryServiceFee = orderPackageTotalVO . getDeliveryServiceFee ( ) ;
BigDecimal totalFee = freightPrice . add ( pickupPrice ) . add ( warehouseServiceFee ) . add ( deliveryServiceFee ) . add ( changesFee ) . add ( aftersalesFee ) ;
StatisticsOrderInfoEntity statisticsOrderInfoEntity = orderInfoEntities . get ( 0 ) ;
Long consigneeId = statisticsOrderInfoEntity . getConsigneeId ( ) ;
String consignee = statisticsOrderInfoEntity . getConsignee ( ) ;
Long destinationWarehouseId = statisticsOrderInfoEntity . getDestinationWarehouseId ( ) ;
String destinationWarehouseName = statisticsOrderInfoEntity . getDestinationWarehouseName ( ) ;
//把orderInfoEntities中所有waybillNo去重拼接起来
reconciliationOrderInfo . setWaybillNo ( orderInfoEntities . stream ( ) . map ( StatisticsOrderInfoEntity : : getWaybillNo ) . distinct ( ) . collect ( Collectors . joining ( "," ) ) ) ;
reconciliationOrderInfo . setOrderCode ( orderInfoEntities . stream ( ) . map ( StatisticsOrderInfoEntity : : getOrderCode ) . distinct ( ) . collect ( Collectors . joining ( "," ) ) ) ;
reconciliationOrderInfo . setBrand ( orderInfoEntities . stream ( ) . map ( StatisticsOrderInfoEntity : : getBrand ) . distinct ( ) . collect ( Collectors . joining ( "," ) ) ) ;
reconciliationOrderInfo . setConsigneeId ( consigneeId ) ;
reconciliationOrderInfo . setConsignee ( consignee ) ;
reconciliationOrderInfo . setDestinationWarehouseName ( destinationWarehouseName ) ;
reconciliationOrderInfo . setDestinationWarehouseId ( destinationWarehouseId ) ;
reconciliationOrderInfo . setTotalNum ( orderPackageTotalVO . getTotalNum ( ) ) ;
reconciliationOrderInfo . setTotalWeight ( orderPackageTotalVO . getTotalWeight ( ) ) ;
reconciliationOrderInfo . setTotalVolume ( orderPackageTotalVO . getTotalVolume ( ) ) ;
reconciliationOrderInfo . setRealTotalFee ( totalFee ) ;
reconciliationOrderInfo . setPickupFee ( pickupPrice ) ;
reconciliationOrderInfo . setFreightFee ( freightPrice ) ;
reconciliationOrderInfo . setWarehouseServiceFee ( warehouseServiceFee ) ;
reconciliationOrderInfo . setWarehouseFee ( orderPackageTotalVO . getWarehouseFee ( ) ) ;
reconciliationOrderInfo . setWarehouseManageFee ( orderPackageTotalVO . getWarehouseManageFee ( ) ) ;
reconciliationOrderInfo . setWarehouseSortingFee ( orderPackageTotalVO . getWarehouseSortingFee ( ) ) ;
reconciliationOrderInfo . setWarehouseOperatingFee ( orderPackageTotalVO . getWarehouseOperatingFee ( ) ) ;
reconciliationOrderInfo . setDeliveryFee ( orderPackageTotalVO . getDeliveryFee ( ) ) ;
reconciliationOrderInfo . setDeliveryServiceFee ( deliveryServiceFee ) ;
reconciliationOrderInfo . setDeliveryLoadingFee ( orderPackageTotalVO . getDeliveryLoadingFee ( ) ) ;
reconciliationOrderInfo . setDeliverySortingFee ( orderPackageTotalVO . getDeliverySortingFee ( ) ) ;
reconciliationOrderInfo . setDeliveryUpfloorFee ( orderPackageTotalVO . getDeliveryUpfloorFee ( ) ) ;
reconciliationOrderInfo . setDeliveryMoveFee ( orderPackageTotalVO . getDeliveryMoveFee ( ) ) ;
reconciliationOrderInfo . setDeliveryOtherFee ( orderPackageTotalVO . getDeliveryOtherFee ( ) ) ;
reconciliationOrderInfo . setDeliveryCrossingFee ( orderPackageTotalVO . getDeliveryCrossingFee ( ) ) ;
reconciliationOrderInfo . setInstallFee ( BigDecimal . ZERO ) ;
reconciliationOrderInfo . setOtherFee ( BigDecimal . ZERO ) ;
reconciliationOrderInfo . setAftersalesFee ( aftersalesFee ) ;
reconciliationOrderInfo . setChangesFee ( changesFee ) ;
reconciliationOrderInfoService . updateById ( reconciliationOrderInfo ) ;
}