Browse Source

fix: 1.完善预存单 对账单 商家对账单 的查询功能

2.增加运单审核、预存单、对账单、结算单的仓库权限限制
3.修复到付运单审单后缺少目的仓的问题
visual
pref_mail@163.com 5 months ago
parent
commit
0207193f6a
  1. 8
      blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java
  2. 105
      blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/dto/MerchantStatisticsDTO.java
  3. 19
      blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/vo/WaybillDetailByWaybillNoVo.java
  4. 18
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataWarehouseClient.java
  5. 7
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml
  6. 4
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java
  7. 175
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/WaybillCheckListener.java
  8. 31
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsBalanceOrderInfoMapper.xml
  9. 4
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.java
  10. 48
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml
  11. 13
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsReconciliationOrderInfoMapper.xml
  12. 301
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsBalanceOrderInfoServiceImpl.java
  13. 53
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsOrderInfoServiceImpl.java
  14. 13
      blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/service/impl/StatisticsReconciliationOrderInfoServiceImpl.java
  15. 2
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml

8
blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataWarehouseClient.java

@ -113,8 +113,12 @@ public interface IBasicdataWarehouseClient {
BasicdataWarehouseVO getMyCurrentWarehouseAndConfig(); BasicdataWarehouseVO getMyCurrentWarehouseAndConfig();
/**
* 获取房前登录人能看的仓库ID集合
* @return
*/
@GetMapping(API_PREFIX + "/getWarehouseIds")
List<Long> getWarehouseIds();
/** /**
* 获取当前登录人的能查看的仓库 * 获取当前登录人的能查看的仓库

105
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 Integer listType;
private String consignee;
private String shipper; private String shipper;
private Long consigneeId; private Long consigneeId;
@ -33,17 +32,32 @@ public class MerchantStatisticsDTO implements Serializable {
private List<AftersalesOrderDTO> aftersalesOrderDTOS; private List<AftersalesOrderDTO> aftersalesOrderDTOS;
private Integer syncFeeSstatus;
private Integer signStatus;
private Integer isAftersales; private Integer isAftersales;
private Integer balanceStatus;
private Integer abnormalBalanceStatus; private Integer abnormalBalanceStatus;
private String balanceOrderNo; private String balanceOrderNo;
/**
* 运单号
*/
private String waybillNo; private String waybillNo;
/**
* 订单号
*/
private String orderCode; private String orderCode;
private String departureWarehouseName; private String departureWarehouseName;
/**
* 目的仓
*/
private String destinationWarehouseName; private String destinationWarehouseName;
/**
* 服务类型
*/
private String typeService; private String typeService;
private String shipperPerson; private String shipperPerson;
private String shipperMoblie; private String shipperMoblie;
@ -57,8 +71,91 @@ public class MerchantStatisticsDTO implements Serializable {
private String openTimeStartStr; private String openTimeStartStr;
private String openTimeEndStr; 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 openTimeStart;
/**
* 开单时间 结束
*/
private Date openTimeEnd; 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<Long> warehouseIds;
} }

19
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;
}

18
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(); return warehouseWarehouseService.getMyCurrentWarehouseAndConfig();
} }
@Override
public List<Long> getWarehouseIds() {
// 仓库ID集合
List<Long> watermarkIds = new ArrayList<>();
// 增加仓库权限的限制
BasicdataWarehouseEntity myCurrentWarehouse = this.getMyCurrentWarehouse();
if (Objects.isNull(myCurrentWarehouse)) {
List<BasicdataWarehouseEntity> myWarehouseList = this.getMyWarehouseList();
myWarehouseList.forEach(warehouse -> {
watermarkIds.add(warehouse.getId());
});
} else {
watermarkIds.add(myCurrentWarehouse.getId());
}
return watermarkIds;
}
@Override @Override
@GetMapping(API_PREFIX+"/getMyWatchWarehouse") @GetMapping(API_PREFIX+"/getMyWatchWarehouse")

7
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/mapper/BasicdataClientMapper.xml

@ -111,6 +111,7 @@
lbc. linkman, lbc. linkman,
lbc. phone, lbc. phone,
lbc. type_service, lbc. type_service,
lbc.clean_obj_type,
lbc. blade_region_province_id, lbc. blade_region_province_id,
lbc. blade_region_city_id, lbc. blade_region_city_id,
lbc. blade_region_area_id, lbc. blade_region_area_id,
@ -159,8 +160,12 @@
<if test="param.clientType != null and param.clientType != ''"> <if test="param.clientType != null and param.clientType != ''">
AND lbc.client_type = #{param.clientType} AND lbc.client_type = #{param.clientType}
</if> </if>
<if test="param.cleanObjType != null and param.cleanObjType != ''">
AND lbc.clean_obj_type = #{param.cleanObjType}
</if>
<if test="param.typeServiceName != null and param.typeServiceName != ''"> <if test="param.typeServiceName != null and param.typeServiceName != ''">
AND lbc.type_ervice = #{param.typeServiceName} AND lbc.type_service = #{param.typeServiceName}
</if> </if>
<if test="param.brandName != null and param.brandName != ''"> <if test="param.brandName != null and param.brandName != ''">
AND t.aaa LIKE CONCAT('%', #{param.brandName}, '%') AND t.aaa LIKE CONCAT('%', #{param.brandName}, '%')

4
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataClientServiceImpl.java

@ -421,7 +421,9 @@ public class BasicdataClientServiceImpl extends BaseServiceImpl<BasicdataClientM
basicdataClientLogEntity.setClientName(newClientEntity.getClientName()); basicdataClientLogEntity.setClientName(newClientEntity.getClientName());
basicdataClientLogEntity.setClientId(newClientEntity.getId()); basicdataClientLogEntity.setClientId(newClientEntity.getId());
basicdataClientLogEntity.setOperator(AuthUtil.getNickName()); basicdataClientLogEntity.setOperator(AuthUtil.getNickName());
basicdataClientLogEntity.setContent(content.deleteCharAt(content.lastIndexOf(",")).toString()); if(StringUtils.isNotBlank(content)){
basicdataClientLogEntity.setContent(content.deleteCharAt(content.lastIndexOf(",")).toString());
}
return basicdataClientLogService.save(basicdataClientLogEntity); return basicdataClientLogService.save(basicdataClientLogEntity);
} }

175
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/listener/mq/WaybillCheckListener.java

@ -56,42 +56,47 @@ public class WaybillCheckListener {
)) ))
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void checkWaybillIncomingData(String msg) { public void checkWaybillIncomingData(String msg) {
log.info("#########checkWaybillIncomingData: 运单审核处理收入结算数据 msg={}",msg); log.info("#########checkWaybillIncomingData: 运单审核处理收入结算数据 msg={}", msg);
JSONObject jsonObject = JSONUtil.parseObj(msg); JSONObject jsonObject = JSONUtil.parseObj(msg);
Long waybillId = jsonObject.getLong("waybillId"); Long waybillId = jsonObject.getLong("waybillId");
WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillId(waybillId); WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillId(waybillId);
if(Objects.isNull(waybillEntity)){ if (Objects.isNull(waybillEntity)) {
log.warn("###########checkWaybillIncomingData: 运单信息不存在 waybillId={}",waybillId); log.warn("###########checkWaybillIncomingData: 运单信息不存在 waybillId={}", waybillId);
throw new CustomerException(405, "运单信息不存在"); throw new CustomerException(405, "运单信息不存在");
} }
Integer waybillType = waybillEntity.getWaybillType(); Integer waybillType = waybillEntity.getWaybillType();
String payWay = waybillEntity.getPayWay(); String payWay = waybillEntity.getPayWay();
if(waybillType.equals(1)){ if (waybillType.equals(1)) {
//订制品(包含有数据库存品) //订制品(包含有数据库存品)
dealwithPackageOrder(waybillEntity); dealwithPackageOrder(waybillEntity);
}else if(waybillType.equals(2)){ } else if (waybillType.equals(2)) {
//零担 //零担
dealwithZeroOrder(waybillEntity); dealwithZeroOrder(waybillEntity);
}else{ } else {
log.warn("###############checkWaybillIncomingData: 运单类型不正确 waybillId={} waybillType={}",waybillId,waybillType); log.warn("###############checkWaybillIncomingData: 运单类型不正确 waybillId={} waybillType={}", waybillId, waybillType);
} }
if(payWay.equals("1")||payWay.equals("2")){ if (payWay.equals("1") || payWay.equals("2")) {
//如果是现付和到付需要直接生成结算单 //如果是现付和到付需要直接生成结算单
createBalanceOrder(waybillEntity); createBalanceOrder(waybillEntity);
} }
log.info("#########checkWaybillIncomingData: 运单审核处理收入结算数据 结束 waybillId={}",waybillId); log.info("#########checkWaybillIncomingData: 运单审核处理收入结算数据 结束 waybillId={}", waybillId);
} }
private void createBalanceOrder(WarehouseWaybillEntity waybillEntity) { private void createBalanceOrder(WarehouseWaybillEntity waybillEntity) {
String waybillNo = waybillEntity.getWaybillNo(); String waybillNo = waybillEntity.getWaybillNo();
log.info("####################createBalanceOrder: 创建现付到付的结算单 waybillNo={}",waybillNo); log.info("####################createBalanceOrder: 创建现付到付的结算单 waybillNo={}", waybillNo);
Long waybillId = waybillEntity.getId(); Long waybillId = waybillEntity.getId();
WarehouseWaybillEntity byWaybill = warehouseWaybillClient.findByWaybillId(waybillId);
if (Objects.isNull(byWaybill)) {
log.error("############createBalanceOrder: 运单不存在 waybillId={}", waybillId);
}
// List<WarehouseWayBillDetail> wayBillDetailList = warehouseWaybillDetailClient.findByWaybillId(waybillId); // List<WarehouseWayBillDetail> wayBillDetailList = warehouseWaybillDetailClient.findByWaybillId(waybillId);
//把wayBillDetailList中所有productName用逗号拼起来 //把wayBillDetailList中所有productName用逗号拼起来
// String productTypeNum = wayBillDetailList.stream().map(t->t.getProductName()+"("+t.getNum()+")").collect(Collectors.joining(",")); // 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); StatisticsPackageFeeInfoVO trunklinePackageFeeVO = statisticsOrderInfoService.findPackageListByOrderIds(orderInfoIdsList);
String balanceOrderCode = "JSD"+System.currentTimeMillis(); String balanceOrderCode = "JSD" + System.currentTimeMillis();
BigDecimal freightPrice = trunklinePackageFeeVO.getFreightPrice(); BigDecimal freightPrice = trunklinePackageFeeVO.getFreightPrice();
BigDecimal pickupPrice = trunklinePackageFeeVO.getPickupPrice(); BigDecimal pickupPrice = trunklinePackageFeeVO.getPickupPrice();
@ -154,8 +159,11 @@ public class WaybillCheckListener {
balanceOrderInfoEntity.setAbnormalBalanceStatus(0); balanceOrderInfoEntity.setAbnormalBalanceStatus(0);
balanceOrderInfoEntity.setAbnormalBalanceFee(BigDecimal.ZERO); balanceOrderInfoEntity.setAbnormalBalanceFee(BigDecimal.ZERO);
balanceOrderInfoEntity.setDestinationWarehouseId(byWaybill.getDestinationWarehouseId());
balanceOrderInfoEntity.setDestinationWarehouseName(byWaybill.getDestinationWarehouseName());
boolean saveFlag = balanceOrderInfoService.save(balanceOrderInfoEntity); boolean saveFlag = balanceOrderInfoService.save(balanceOrderInfoEntity);
if(saveFlag){ if (saveFlag) {
Long balanceOrderId = balanceOrderInfoEntity.getId(); Long balanceOrderId = balanceOrderInfoEntity.getId();
List<StatisticsOrderInfoEntity> updateOrderInfoList = new ArrayList<>(); List<StatisticsOrderInfoEntity> updateOrderInfoList = new ArrayList<>();
orderInfoEntityList.forEach(orderInfoEntity -> { orderInfoEntityList.forEach(orderInfoEntity -> {
@ -171,7 +179,7 @@ public class WaybillCheckListener {
updateEntity.setConfirmBalanceUserName(AuthUtil.getNickName()); updateEntity.setConfirmBalanceUserName(AuthUtil.getNickName());
updateOrderInfoList.add(updateEntity); updateOrderInfoList.add(updateEntity);
}); });
if(CollUtil.isNotEmpty(updateOrderInfoList)){ if (CollUtil.isNotEmpty(updateOrderInfoList)) {
statisticsOrderInfoService.updateBatchById(updateOrderInfoList); statisticsOrderInfoService.updateBatchById(updateOrderInfoList);
} }
} }
@ -179,7 +187,7 @@ public class WaybillCheckListener {
private void dealwithZeroOrder(WarehouseWaybillEntity waybillEntity) { private void dealwithZeroOrder(WarehouseWaybillEntity waybillEntity) {
String waybillNo = waybillEntity.getWaybillNo(); String waybillNo = waybillEntity.getWaybillNo();
log.info("############dealwithZeroOrder: 处理零担信息 waybillNo={}",waybillNo); log.info("############dealwithZeroOrder: 处理零担信息 waybillNo={}", waybillNo);
Long waybillId = waybillEntity.getId(); Long waybillId = waybillEntity.getId();
String brand = waybillEntity.getBrand(); String brand = waybillEntity.getBrand();
Long brandId = waybillEntity.getBrandId(); Long brandId = waybillEntity.getBrandId();
@ -193,12 +201,12 @@ public class WaybillCheckListener {
String destinationWarehouseName = waybillEntity.getDestinationWarehouseName(); String destinationWarehouseName = waybillEntity.getDestinationWarehouseName();
// BigDecimal pickupFee = Objects.isNull(waybillEntity.getPickupFee())?BigDecimal.ZERO:waybillEntity.getPickupFee(); // BigDecimal pickupFee = Objects.isNull(waybillEntity.getPickupFee())?BigDecimal.ZERO:waybillEntity.getPickupFee();
BigDecimal warehouseManagementFee = Objects.isNull(waybillEntity.getWarehouseManagementFee())?BigDecimal.ZERO:waybillEntity.getWarehouseManagementFee(); BigDecimal warehouseManagementFee = Objects.isNull(waybillEntity.getWarehouseManagementFee()) ? BigDecimal.ZERO : waybillEntity.getWarehouseManagementFee();
BigDecimal warehouseFee = Objects.isNull(waybillEntity.getStorageFee())?BigDecimal.ZERO:waybillEntity.getStorageFee(); BigDecimal warehouseFee = Objects.isNull(waybillEntity.getStorageFee()) ? BigDecimal.ZERO : waybillEntity.getStorageFee();
BigDecimal handlingFee = Objects.isNull(waybillEntity.getHandlingFee())?BigDecimal.ZERO:waybillEntity.getHandlingFee(); BigDecimal handlingFee = Objects.isNull(waybillEntity.getHandlingFee()) ? BigDecimal.ZERO : waybillEntity.getHandlingFee();
BigDecimal insuranceFee = Objects.isNull(waybillEntity.getInsuranceFee())?BigDecimal.ZERO:waybillEntity.getInsuranceFee(); BigDecimal insuranceFee = Objects.isNull(waybillEntity.getInsuranceFee()) ? BigDecimal.ZERO : waybillEntity.getInsuranceFee();
BigDecimal otherFee = Objects.isNull(waybillEntity.getOtherFee())?BigDecimal.ZERO:waybillEntity.getOtherFee(); BigDecimal otherFee = Objects.isNull(waybillEntity.getOtherFee()) ? BigDecimal.ZERO : waybillEntity.getOtherFee();
BigDecimal thirdOperationFee = Objects.isNull(waybillEntity.getThirdOperationFee())?BigDecimal.ZERO:waybillEntity.getThirdOperationFee(); BigDecimal thirdOperationFee = Objects.isNull(waybillEntity.getThirdOperationFee()) ? BigDecimal.ZERO : waybillEntity.getThirdOperationFee();
Integer totalCount = waybillEntity.getTotalCount(); Integer totalCount = waybillEntity.getTotalCount();
// BigDecimal pickupPrice = pickupFee.divide(new BigDecimal(totalCount), 2, BigDecimal.ROUND_HALF_UP); // BigDecimal pickupPrice = pickupFee.divide(new BigDecimal(totalCount), 2, BigDecimal.ROUND_HALF_UP);
@ -235,7 +243,7 @@ public class WaybillCheckListener {
orderInfoEntities.add(orderInfoEntity); orderInfoEntities.add(orderInfoEntity);
boolean b = statisticsOrderInfoService.saveBatch(orderInfoEntities); boolean b = statisticsOrderInfoService.saveBatch(orderInfoEntities);
if(b){ if (b) {
Long orderId = orderInfoEntity.getId(); Long orderId = orderInfoEntity.getId();
@ -244,7 +252,7 @@ public class WaybillCheckListener {
List<StatisticsDistributionPackageEntity> distributionPackageEntities = new ArrayList<>(); List<StatisticsDistributionPackageEntity> distributionPackageEntities = new ArrayList<>();
wayBillDetailList.forEach(wayBillDetail->{ wayBillDetailList.forEach(wayBillDetail -> {
Long productId = wayBillDetail.getProductId(); Long productId = wayBillDetail.getProductId();
String productName = wayBillDetail.getProductName(); String productName = wayBillDetail.getProductName();
Integer num = wayBillDetail.getNum(); Integer num = wayBillDetail.getNum();
@ -258,8 +266,8 @@ public class WaybillCheckListener {
trunklinePackageEntity.setWaybillNo(waybillNo); trunklinePackageEntity.setWaybillNo(waybillNo);
trunklinePackageEntity.setOrderCode(waybillNo); trunklinePackageEntity.setOrderCode(waybillNo);
trunklinePackageEntity.setNum(num); trunklinePackageEntity.setNum(num);
trunklinePackageEntity.setWeight(Objects.isNull(weight)?BigDecimal.ZERO:weight); trunklinePackageEntity.setWeight(Objects.isNull(weight) ? BigDecimal.ZERO : weight);
trunklinePackageEntity.setVolume(Objects.isNull(volume)?BigDecimal.ZERO:volume); trunklinePackageEntity.setVolume(Objects.isNull(volume) ? BigDecimal.ZERO : volume);
trunklinePackageEntity.setGoodsType(2); trunklinePackageEntity.setGoodsType(2);
trunklinePackageEntity.setOrderInfoId(orderId); trunklinePackageEntity.setOrderInfoId(orderId);
trunklinePackageEntity.setProductId(productId); trunklinePackageEntity.setProductId(productId);
@ -279,29 +287,29 @@ public class WaybillCheckListener {
Integer systemWarehouseChargeType = wayBillDetail.getSystemWarehouseChargeType(); Integer systemWarehouseChargeType = wayBillDetail.getSystemWarehouseChargeType();
Integer systemDeliveryChargeType = wayBillDetail.getSystemDeliveryChargeType(); Integer systemDeliveryChargeType = wayBillDetail.getSystemDeliveryChargeType();
if(systemChargeType == 1){ if (systemChargeType == 1) {
trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(new BigDecimal(num))); trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(new BigDecimal(num)));
}else if(systemChargeType == 2){ } else if (systemChargeType == 2) {
trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(trunklinePackageEntity.getWeight())); trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(trunklinePackageEntity.getWeight()));
}else if (systemChargeType == 3){ } else if (systemChargeType == 3) {
trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(trunklinePackageEntity.getVolume())); trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(trunklinePackageEntity.getVolume()));
} }
if(chargeType == 1){ if (chargeType == 1) {
trunklinePackageEntity.setFreightPrice(price.multiply(new BigDecimal(num))); trunklinePackageEntity.setFreightPrice(price.multiply(new BigDecimal(num)));
}else if(chargeType == 2){ } else if (chargeType == 2) {
trunklinePackageEntity.setFreightPrice(price.multiply(trunklinePackageEntity.getWeight())); trunklinePackageEntity.setFreightPrice(price.multiply(trunklinePackageEntity.getWeight()));
}else if (chargeType == 3){ } else if (chargeType == 3) {
trunklinePackageEntity.setFreightPrice(price.multiply(trunklinePackageEntity.getVolume())); trunklinePackageEntity.setFreightPrice(price.multiply(trunklinePackageEntity.getVolume()));
} }
if(systemPickupChargeType == 1){ if (systemPickupChargeType == 1) {
trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(new BigDecimal(num))); trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(new BigDecimal(num)));
trunklinePackageEntity.setPickupPrice(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.setSystemPickupPrice(systemPickupPrice.multiply(trunklinePackageEntity.getWeight()));
trunklinePackageEntity.setPickupPrice(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.setSystemPickupPrice(systemPickupPrice.multiply(trunklinePackageEntity.getVolume()));
trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(trunklinePackageEntity.getVolume())); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(trunklinePackageEntity.getVolume()));
} }
@ -367,8 +375,8 @@ public class WaybillCheckListener {
distributionPackageEntity.setWaybillNo(waybillNo); distributionPackageEntity.setWaybillNo(waybillNo);
distributionPackageEntity.setOrderCode(waybillNo); distributionPackageEntity.setOrderCode(waybillNo);
distributionPackageEntity.setNum(num); distributionPackageEntity.setNum(num);
distributionPackageEntity.setWeight(Objects.isNull(weight)?BigDecimal.ZERO:weight); distributionPackageEntity.setWeight(Objects.isNull(weight) ? BigDecimal.ZERO : weight);
distributionPackageEntity.setVolume(Objects.isNull(volume)?BigDecimal.ZERO:volume); distributionPackageEntity.setVolume(Objects.isNull(volume) ? BigDecimal.ZERO : volume);
distributionPackageEntity.setGoodsType(2); distributionPackageEntity.setGoodsType(2);
distributionPackageEntity.setOrderInfoId(orderId); distributionPackageEntity.setOrderInfoId(orderId);
distributionPackageEntity.setDeliveryLoadingFee(handlingPrice.multiply(new BigDecimal(num))); distributionPackageEntity.setDeliveryLoadingFee(handlingPrice.multiply(new BigDecimal(num)));
@ -384,11 +392,11 @@ public class WaybillCheckListener {
BigDecimal systemDeliveryPrice = wayBillDetail.getDeliveryPrice(); BigDecimal systemDeliveryPrice = wayBillDetail.getDeliveryPrice();
distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice); distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice);
if(systemDeliveryChargeType == 1){ if (systemDeliveryChargeType == 1) {
distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(new BigDecimal(num))); distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(new BigDecimal(num)));
}else if(systemDeliveryChargeType == 2){ } else if (systemDeliveryChargeType == 2) {
distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(weight)); distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(weight));
}else if (systemDeliveryChargeType == 3){ } else if (systemDeliveryChargeType == 3) {
distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(volume)); distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(volume));
} }
distributionPackageEntity.setDeliveryFee(BigDecimal.ZERO); distributionPackageEntity.setDeliveryFee(BigDecimal.ZERO);
@ -396,7 +404,7 @@ public class WaybillCheckListener {
BigDecimal systemDeliveryFeeTotal = distributionPackageEntity.getSystemDeliveryFee(); BigDecimal systemDeliveryFeeTotal = distributionPackageEntity.getSystemDeliveryFee();
if(payWay.equals("1") || payWay.equals("2")){ if (payWay.equals("1") || payWay.equals("2")) {
distributionPackageEntity.setDeliveryFee(systemDeliveryFeeTotal); distributionPackageEntity.setDeliveryFee(systemDeliveryFeeTotal);
} }
BigDecimal deliveryFeeTotal = distributionPackageEntity.getDeliveryFee(); BigDecimal deliveryFeeTotal = distributionPackageEntity.getDeliveryFee();
@ -412,24 +420,24 @@ public class WaybillCheckListener {
distributionPackageEntities.add(distributionPackageEntity); distributionPackageEntities.add(distributionPackageEntity);
}); });
if(CollUtil.isNotEmpty(trunklinePackageEntities)){ if (CollUtil.isNotEmpty(trunklinePackageEntities)) {
trunklinePackageService.saveBatch(trunklinePackageEntities); trunklinePackageService.saveBatch(trunklinePackageEntities);
} }
if(CollUtil.isNotEmpty(warehousePackageEntities)){ if (CollUtil.isNotEmpty(warehousePackageEntities)) {
warehousePackageService.saveBatch(warehousePackageEntities); warehousePackageService.saveBatch(warehousePackageEntities);
} }
if(CollUtil.isNotEmpty(distributionPackageEntities)){ if (CollUtil.isNotEmpty(distributionPackageEntities)) {
distributionPackageService.saveBatch(distributionPackageEntities); distributionPackageService.saveBatch(distributionPackageEntities);
} }
}else{ } else {
log.warn("#############dealwithPackageOrder: 保存订单数据失败 waybillNo={}",waybillNo); log.warn("#############dealwithPackageOrder: 保存订单数据失败 waybillNo={}", waybillNo);
} }
} }
private void dealwithPackageOrder(WarehouseWaybillEntity waybillEntity) { private void dealwithPackageOrder(WarehouseWaybillEntity waybillEntity) {
String waybillNo = waybillEntity.getWaybillNo(); String waybillNo = waybillEntity.getWaybillNo();
log.info("############dealwithPackageOrder: 处理订制品包件信息 waybillNo={}",waybillNo); log.info("############dealwithPackageOrder: 处理订制品包件信息 waybillNo={}", waybillNo);
Long waybillId = waybillEntity.getId(); Long waybillId = waybillEntity.getId();
String brand = waybillEntity.getBrand(); String brand = waybillEntity.getBrand();
Long brandId = waybillEntity.getBrandId(); Long brandId = waybillEntity.getBrandId();
@ -444,12 +452,12 @@ public class WaybillCheckListener {
//单价计算 //单价计算
// BigDecimal pickupFee = Objects.isNull(waybillEntity.getPickupFee())?BigDecimal.ZERO:waybillEntity.getPickupFee(); // BigDecimal pickupFee = Objects.isNull(waybillEntity.getPickupFee())?BigDecimal.ZERO:waybillEntity.getPickupFee();
BigDecimal warehouseManagementFee = Objects.isNull(waybillEntity.getWarehouseManagementFee())?BigDecimal.ZERO:waybillEntity.getWarehouseManagementFee(); BigDecimal warehouseManagementFee = Objects.isNull(waybillEntity.getWarehouseManagementFee()) ? BigDecimal.ZERO : waybillEntity.getWarehouseManagementFee();
BigDecimal warehouseFee = Objects.isNull(waybillEntity.getStorageFee())?BigDecimal.ZERO:waybillEntity.getStorageFee(); BigDecimal warehouseFee = Objects.isNull(waybillEntity.getStorageFee()) ? BigDecimal.ZERO : waybillEntity.getStorageFee();
BigDecimal handlingFee = Objects.isNull(waybillEntity.getHandlingFee())?BigDecimal.ZERO:waybillEntity.getHandlingFee(); BigDecimal handlingFee = Objects.isNull(waybillEntity.getHandlingFee()) ? BigDecimal.ZERO : waybillEntity.getHandlingFee();
BigDecimal insuranceFee = Objects.isNull(waybillEntity.getInsuranceFee())?BigDecimal.ZERO:waybillEntity.getInsuranceFee(); BigDecimal insuranceFee = Objects.isNull(waybillEntity.getInsuranceFee()) ? BigDecimal.ZERO : waybillEntity.getInsuranceFee();
BigDecimal otherFee = Objects.isNull(waybillEntity.getOtherFee())?BigDecimal.ZERO:waybillEntity.getOtherFee(); BigDecimal otherFee = Objects.isNull(waybillEntity.getOtherFee()) ? BigDecimal.ZERO : waybillEntity.getOtherFee();
BigDecimal thirdOperationFee = Objects.isNull(waybillEntity.getThirdOperationFee())?BigDecimal.ZERO:waybillEntity.getThirdOperationFee(); BigDecimal thirdOperationFee = Objects.isNull(waybillEntity.getThirdOperationFee()) ? BigDecimal.ZERO : waybillEntity.getThirdOperationFee();
Integer totalCount = waybillEntity.getTotalCount(); Integer totalCount = waybillEntity.getTotalCount();
// BigDecimal pickupPrice = pickupFee.divide(new BigDecimal(totalCount), 2, BigDecimal.ROUND_HALF_UP); // 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); BigDecimal thirdOperationPrice = thirdOperationFee.divide(new BigDecimal(totalCount), 2, BigDecimal.ROUND_HALF_UP);
//查询运单下所有的订单 //查询运单下所有的订单
List<TrunklineAdvanceEntity> advanceEntities =trunklineAdvanceClient.findListByWaybillNo(waybillNo); List<TrunklineAdvanceEntity> advanceEntities = trunklineAdvanceClient.findListByWaybillNo(waybillNo);
//查询包件信息 //查询包件信息
List<TrunklineAdvanceDetailEntity> advanceDetailEntities = trunklineAdvanceDetailClient.findListByWaybillId(waybillId); List<TrunklineAdvanceDetailEntity> advanceDetailEntities = trunklineAdvanceDetailClient.findListByWaybillId(waybillId);
//查询运单明细 //查询运单明细
@ -476,7 +483,7 @@ public class WaybillCheckListener {
//保存订单信息 //保存订单信息
List<StatisticsOrderInfoEntity> orderInfoEntities = new ArrayList<>(); List<StatisticsOrderInfoEntity> orderInfoEntities = new ArrayList<>();
advanceEntities.forEach(advanceEntity->{ advanceEntities.forEach(advanceEntity -> {
StatisticsOrderInfoEntity orderInfoEntity = new StatisticsOrderInfoEntity(); StatisticsOrderInfoEntity orderInfoEntity = new StatisticsOrderInfoEntity();
orderInfoEntity.setOrderCode(advanceEntity.getOrderCode()); orderInfoEntity.setOrderCode(advanceEntity.getOrderCode());
orderInfoEntity.setWaybillId(waybillId); orderInfoEntity.setWaybillId(waybillId);
@ -498,7 +505,7 @@ public class WaybillCheckListener {
}); });
boolean b = statisticsOrderInfoService.saveBatch(orderInfoEntities); boolean b = statisticsOrderInfoService.saveBatch(orderInfoEntities);
if(b){ if (b) {
Map<String, List<TrunklineAdvanceDetailEntity>> advanceDetailGroupByOrderCode = Map<String, List<TrunklineAdvanceDetailEntity>> advanceDetailGroupByOrderCode =
advanceDetailEntities.stream() advanceDetailEntities.stream()
.collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getOrderCode)); .collect(Collectors.groupingBy(TrunklineAdvanceDetailEntity::getOrderCode));
@ -506,11 +513,11 @@ public class WaybillCheckListener {
List<StatisticsTrunklinePackageEntity> trunklinePackageEntities = new ArrayList<>(); List<StatisticsTrunklinePackageEntity> trunklinePackageEntities = new ArrayList<>();
List<StatisticsWarehousePackageEntity> warehousePackageEntities = new ArrayList<>(); List<StatisticsWarehousePackageEntity> warehousePackageEntities = new ArrayList<>();
List<StatisticsDistributionPackageEntity> distributionPackageEntities = new ArrayList<>(); List<StatisticsDistributionPackageEntity> distributionPackageEntities = new ArrayList<>();
orderInfoEntities.forEach(orderInfoEntity->{ orderInfoEntities.forEach(orderInfoEntity -> {
Long orderId = orderInfoEntity.getId(); Long orderId = orderInfoEntity.getId();
String orderCode = orderInfoEntity.getOrderCode(); String orderCode = orderInfoEntity.getOrderCode();
List<TrunklineAdvanceDetailEntity> advanceDetailList = advanceDetailGroupByOrderCode.get(orderCode); List<TrunklineAdvanceDetailEntity> advanceDetailList = advanceDetailGroupByOrderCode.get(orderCode);
advanceDetailList.forEach(advanceDetailEntity->{ advanceDetailList.forEach(advanceDetailEntity -> {
Long incomeCategoryId = advanceDetailEntity.getIncomeCategoryId(); Long incomeCategoryId = advanceDetailEntity.getIncomeCategoryId();
String orderPackageCode = advanceDetailEntity.getOrderPackageCode(); String orderPackageCode = advanceDetailEntity.getOrderPackageCode();
Integer quantity = advanceDetailEntity.getQuantity(); Integer quantity = advanceDetailEntity.getQuantity();
@ -536,7 +543,7 @@ public class WaybillCheckListener {
trunklinePackageEntity.setOtherPrice(otherPrice.multiply(BigDecimal.ONE)); trunklinePackageEntity.setOtherPrice(otherPrice.multiply(BigDecimal.ONE));
trunklinePackageEntity.setThirdOperationPrice(thirdOperationPrice.multiply(BigDecimal.ONE)); trunklinePackageEntity.setThirdOperationPrice(thirdOperationPrice.multiply(BigDecimal.ONE));
if(!Objects.isNull(warehouseWayBillDetail)){ if (!Objects.isNull(warehouseWayBillDetail)) {
trunklinePackageEntity.setProductId(incomeCategoryId); trunklinePackageEntity.setProductId(incomeCategoryId);
trunklinePackageEntity.setProductName(warehouseWayBillDetail.getProductName()); trunklinePackageEntity.setProductName(warehouseWayBillDetail.getProductName());
@ -556,8 +563,8 @@ public class WaybillCheckListener {
BigDecimal packageWeight = productTotalWeight.divide(new BigDecimal(num), 2, BigDecimal.ROUND_HALF_UP);//平摊到包件的质量 BigDecimal packageWeight = productTotalWeight.divide(new BigDecimal(num), 2, BigDecimal.ROUND_HALF_UP);//平摊到包件的质量
BigDecimal packageVolume = productTotalVolume.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.setWeight(Objects.isNull(packageWeight) ? BigDecimal.ZERO : packageWeight);
trunklinePackageEntity.setVolume(Objects.isNull(packageVolume)?BigDecimal.ZERO:packageVolume); trunklinePackageEntity.setVolume(Objects.isNull(packageVolume) ? BigDecimal.ZERO : packageVolume);
BigDecimal systemFreightPrice = warehouseWayBillDetail.getFreightPrice();//系统运费单价 BigDecimal systemFreightPrice = warehouseWayBillDetail.getFreightPrice();//系统运费单价
BigDecimal price = warehouseWayBillDetail.getPrice();//实际运费单价 BigDecimal price = warehouseWayBillDetail.getPrice();//实际运费单价
@ -566,36 +573,36 @@ public class WaybillCheckListener {
//如果系统运费计算方式是按件,则用系统的运费单价乘以包件数量 //如果系统运费计算方式是按件,则用系统的运费单价乘以包件数量
//如果系统运费计算方式是按方,则用系统的运费单价乘以包件体积 //如果系统运费计算方式是按方,则用系统的运费单价乘以包件体积
//如果系统运费计算方式是按重量,则用系统的运费单价乘以包件重量 //如果系统运费计算方式是按重量,则用系统的运费单价乘以包件重量
if(systemChargeType == 1){ if (systemChargeType == 1) {
trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(BigDecimal.ONE)); trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(BigDecimal.ONE));
}else if(systemChargeType == 2){ } else if (systemChargeType == 2) {
trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(packageVolume)); trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(packageVolume));
}else if (systemChargeType == 3){ } else if (systemChargeType == 3) {
trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(packageWeight)); trunklinePackageEntity.setSystemFreightPrice(systemFreightPrice.multiply(packageWeight));
} }
//实际包件的运费 //实际包件的运费
if(chargeType == 1){ if (chargeType == 1) {
trunklinePackageEntity.setFreightPrice(price.multiply(BigDecimal.ONE)); trunklinePackageEntity.setFreightPrice(price.multiply(BigDecimal.ONE));
}else if(chargeType == 2){ } else if (chargeType == 2) {
trunklinePackageEntity.setFreightPrice(price.multiply(packageVolume)); trunklinePackageEntity.setFreightPrice(price.multiply(packageVolume));
}else if (chargeType == 3){ } else if (chargeType == 3) {
trunklinePackageEntity.setFreightPrice(price.multiply(packageWeight)); trunklinePackageEntity.setFreightPrice(price.multiply(packageWeight));
} }
//提货包件单价 //提货包件单价
if(systemPickupChargeType == 1){ if (systemPickupChargeType == 1) {
trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(BigDecimal.ONE)); trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(BigDecimal.ONE));
trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(BigDecimal.ONE)); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(BigDecimal.ONE));
}else if(systemPickupChargeType == 2){ } else if (systemPickupChargeType == 2) {
trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(packageVolume)); trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(packageVolume));
trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(packageVolume)); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(packageVolume));
}else if (systemPickupChargeType == 3){ } else if (systemPickupChargeType == 3) {
trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(packageWeight)); trunklinePackageEntity.setSystemPickupPrice(systemPickupPrice.multiply(packageWeight));
trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(packageWeight)); trunklinePackageEntity.setPickupPrice(systemPickupPrice.multiply(packageWeight));
} }
}else{ } else {
trunklinePackageEntity.setFreightChargeType(1); trunklinePackageEntity.setFreightChargeType(1);
@ -643,7 +650,7 @@ public class WaybillCheckListener {
warehousePackageEntity.setBrandId(brandId); warehousePackageEntity.setBrandId(brandId);
warehousePackageEntity.setConsigneeId(consigneeId); warehousePackageEntity.setConsigneeId(consigneeId);
warehousePackageEntity.setChargeType(1); warehousePackageEntity.setChargeType(1);
if(!Objects.isNull(warehouseWayBillDetail)){ if (!Objects.isNull(warehouseWayBillDetail)) {
Integer systemWarehouseChargeType = warehouseWayBillDetail.getSystemWarehouseChargeType(); Integer systemWarehouseChargeType = warehouseWayBillDetail.getSystemWarehouseChargeType();
warehousePackageEntity.setChargeType(systemWarehouseChargeType); warehousePackageEntity.setChargeType(systemWarehouseChargeType);
@ -678,8 +685,8 @@ public class WaybillCheckListener {
distributionPackageEntity.setOrderCode(orderCode); distributionPackageEntity.setOrderCode(orderCode);
distributionPackageEntity.setOrderPackageCode(orderPackageCode); distributionPackageEntity.setOrderPackageCode(orderPackageCode);
distributionPackageEntity.setNum(quantity); distributionPackageEntity.setNum(quantity);
distributionPackageEntity.setWeight(Objects.isNull(weight)?BigDecimal.ZERO:weight); distributionPackageEntity.setWeight(Objects.isNull(weight) ? BigDecimal.ZERO : weight);
distributionPackageEntity.setVolume(Objects.isNull(volume)?BigDecimal.ZERO:volume); distributionPackageEntity.setVolume(Objects.isNull(volume) ? BigDecimal.ZERO : volume);
distributionPackageEntity.setGoodsType(1); distributionPackageEntity.setGoodsType(1);
distributionPackageEntity.setOrderInfoId(orderId); distributionPackageEntity.setOrderInfoId(orderId);
distributionPackageEntity.setDeliveryLoadingFee(handlingPrice.multiply(BigDecimal.ONE)); distributionPackageEntity.setDeliveryLoadingFee(handlingPrice.multiply(BigDecimal.ONE));
@ -694,7 +701,7 @@ public class WaybillCheckListener {
distributionPackageEntity.setConsigneeId(consigneeId); distributionPackageEntity.setConsigneeId(consigneeId);
distributionPackageEntity.setDeliveryLoadingFee(handlingPrice.multiply(BigDecimal.ONE)); distributionPackageEntity.setDeliveryLoadingFee(handlingPrice.multiply(BigDecimal.ONE));
if(!Objects.isNull(warehouseWayBillDetail)){ if (!Objects.isNull(warehouseWayBillDetail)) {
Integer systemDeliveryChargeType = warehouseWayBillDetail.getSystemDeliveryChargeType(); Integer systemDeliveryChargeType = warehouseWayBillDetail.getSystemDeliveryChargeType();
BigDecimal productTotalWeight = warehouseWayBillDetail.getWeight(); BigDecimal productTotalWeight = warehouseWayBillDetail.getWeight();
@ -712,23 +719,23 @@ public class WaybillCheckListener {
BigDecimal systemDeliveryPrice = warehouseWayBillDetail.getDeliveryPrice(); BigDecimal systemDeliveryPrice = warehouseWayBillDetail.getDeliveryPrice();
if(systemDeliveryChargeType == 1){ if (systemDeliveryChargeType == 1) {
distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(BigDecimal.ONE)); distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(BigDecimal.ONE));
}else if(systemDeliveryChargeType == 2){ } else if (systemDeliveryChargeType == 2) {
distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(packageVolume)); distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(packageVolume));
}else if(systemDeliveryChargeType == 3){ } else if (systemDeliveryChargeType == 3) {
distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(packageWeight)); distributionPackageEntity.setSystemDeliveryFee(systemDeliveryPrice.multiply(packageWeight));
} }
distributionPackageEntity.setDeliveryFee(BigDecimal.ZERO); distributionPackageEntity.setDeliveryFee(BigDecimal.ZERO);
}else{ } else {
distributionPackageEntity.setSystemDeliveryChargeType(1); distributionPackageEntity.setSystemDeliveryChargeType(1);
distributionPackageEntity.setDeliveryChargeType(1); distributionPackageEntity.setDeliveryChargeType(1);
distributionPackageEntity.setSystemDeliveryFee(BigDecimal.ZERO); distributionPackageEntity.setSystemDeliveryFee(BigDecimal.ZERO);
distributionPackageEntity.setDeliveryFee(BigDecimal.ZERO); distributionPackageEntity.setDeliveryFee(BigDecimal.ZERO);
} }
if(payWay.equals("1") || payWay.equals("2")){ if (payWay.equals("1") || payWay.equals("2")) {
distributionPackageEntity.setDeliveryFee(distributionPackageEntity.getSystemDeliveryFee()); distributionPackageEntity.setDeliveryFee(distributionPackageEntity.getSystemDeliveryFee());
} }
BigDecimal deliveryFeeTotal = distributionPackageEntity.getDeliveryFee(); BigDecimal deliveryFeeTotal = distributionPackageEntity.getDeliveryFee();
@ -746,18 +753,18 @@ public class WaybillCheckListener {
distributionPackageEntities.add(distributionPackageEntity); distributionPackageEntities.add(distributionPackageEntity);
}); });
}); });
if(CollUtil.isNotEmpty(trunklinePackageEntities)){ if (CollUtil.isNotEmpty(trunklinePackageEntities)) {
trunklinePackageService.saveBatch(trunklinePackageEntities); trunklinePackageService.saveBatch(trunklinePackageEntities);
} }
if(CollUtil.isNotEmpty(warehousePackageEntities)){ if (CollUtil.isNotEmpty(warehousePackageEntities)) {
warehousePackageService.saveBatch(warehousePackageEntities); warehousePackageService.saveBatch(warehousePackageEntities);
} }
if(CollUtil.isNotEmpty(distributionPackageEntities)){ if (CollUtil.isNotEmpty(distributionPackageEntities)) {
distributionPackageService.saveBatch(distributionPackageEntities); distributionPackageService.saveBatch(distributionPackageEntities);
} }
}else{ } else {
log.warn("#############dealwithPackageOrder: 保存订单数据失败 waybillNo={}",waybillNo); log.warn("#############dealwithPackageOrder: 保存订单数据失败 waybillNo={}", waybillNo);
} }
} }
} }

31
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsBalanceOrderInfoMapper.xml

@ -21,6 +21,37 @@
<if test="param.abnormalBalanceStatus != null "> <if test="param.abnormalBalanceStatus != null ">
and abnormal_balance_status = #{param.abnormalBalanceStatus} and abnormal_balance_status = #{param.abnormalBalanceStatus}
</if> </if>
<if test="param.consignee != null ">
and consignee = #{param.consignee}
</if>
<if test="param.consignee != null ">
and consignee = #{param.consignee}
</if>
<if test="param.createTimeStart != null">
and create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
and create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.abnormalTimeStart != null">
and abnormal_time &gt;= #{param.abnormalTimeStart}
</if>
<if test="param.abnormalTimeEnd != null">
and abnormal_time &lt;= #{param.abnormalTimeEnd}
</if>
<if test="param.balanceTimeStart != null">
and balance_time &gt;= #{param.balanceTimeStart}
</if>
<if test="param.balanceTimeEnd != null">
and balance_time &lt;= #{param.balanceTimeEnd}
</if>
<if test="param.destinationWarehouseName != null">
and destination_warehouse_name = #{param.destinationWarehouseName}
</if>
and destination_warehouse_id in
<foreach collection="param.warehouseIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select> </select>

4
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.StatisticsOrderInfoExportVO;
import com.logpm.statistics.vo.StatisticsOrderInfoVO; import com.logpm.statistics.vo.StatisticsOrderInfoVO;
import com.logpm.statistics.vo.StatisticsPackageFeeInfoVO; import com.logpm.statistics.vo.StatisticsPackageFeeInfoVO;
import com.logpm.statistics.vo.WaybillDetailByWaybillNoVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
@Mapper @Mapper
public interface StatisticsOrderInfoMapper extends BaseMapper<StatisticsOrderInfoEntity> { public interface StatisticsOrderInfoMapper extends BaseMapper<StatisticsOrderInfoEntity> {
@ -35,4 +37,6 @@ public interface StatisticsOrderInfoMapper extends BaseMapper<StatisticsOrderInf
void clearReconcilitionOrderInfoByOrderInfoIds(@Param("orderInfoIds") List<Long> orderInfoIds, @Param("nickName") String nickName, @Param("date") Date date); void clearReconcilitionOrderInfoByOrderInfoIds(@Param("orderInfoIds") List<Long> orderInfoIds, @Param("nickName") String nickName, @Param("date") Date date);
List<StatisticsOrderInfoExportVO> orderInfoListExport(@Param("param") MerchantStatisticsDTO merchantStatisticsDTO); List<StatisticsOrderInfoExportVO> orderInfoListExport(@Param("param") MerchantStatisticsDTO merchantStatisticsDTO);
List<WaybillDetailByWaybillNoVo> findWaybillDetailByWaybillId(@Param("warehouseIdSet") Set<Long> warehouseIdSet);
} }

48
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsOrderInfoMapper.xml

@ -18,6 +18,7 @@
lww.consignee_name consigneePerson, lww.consignee_name consigneePerson,
lww.consignee_mobile consigneeMobile, lww.consignee_mobile consigneeMobile,
lww.consignee_address consigneeAddress, lww.consignee_address consigneeAddress,
concat(GROUP_CONCAT(lwwd.product_name)) as goodsName,
lsoi.sign_status signStatus, lsoi.sign_status signStatus,
lsoi.sign_date signDate, lsoi.sign_date signDate,
lww.create_time openTime, lww.create_time openTime,
@ -42,6 +43,7 @@
from logpm_statistics_order_info lsoi from logpm_statistics_order_info lsoi
left join logpm_basicdata_client lbc on lbc.id = lsoi.consignee_id 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 lww on lww.id = lsoi.waybill_id
LEFT JOIN logpm_warehouse_waybill_detail lwwd on lwwd.waybill_id=lww.id
where 1=1 where 1=1
and lsoi.create_reconciliation_order_status = 0 and lsoi.create_reconciliation_order_status = 0
<if test="param.listType == 1"> <if test="param.listType == 1">
@ -66,7 +68,7 @@
and Locate(#{param.waybillNo},lww.waybill_no) > 0 and Locate(#{param.waybillNo},lww.waybill_no) > 0
</if> </if>
<if test="param.orderCode != null and param.orderCode != '' "> <if test="param.orderCode != null and param.orderCode != '' ">
and Locate(#{param.orderCode},lww.order_code) > 0 and Locate(#{param.orderCode},lww.order_no) > 0
</if> </if>
<if test="param.shipper != null and param.shipper != '' "> <if test="param.shipper != null and param.shipper != '' ">
and Locate(#{param.shipper},lww.shipper) > 0 and Locate(#{param.shipper},lww.shipper) > 0
@ -86,6 +88,18 @@
<if test="param.openTimeEnd != null"> <if test="param.openTimeEnd != null">
and lww.create_time &lt;= #{param.openTimeEnd} and lww.create_time &lt;= #{param.openTimeEnd}
</if> </if>
<if test="param.signTimeStart != null">
and lsoi.sign_date &gt;= #{param.signTimeStart}
</if>
<if test="param.signTimeEnd != null">
and lsoi.sign_date &lt;= #{param.signTimeEnd}
</if>
<if test="param.syncFeeDateStart != null">
and lsoi.sync_fee_date &gt;= #{param.syncFeeDateStart}
</if>
<if test="param.syncFeeDateEnd != null">
and lsoi.sync_fee_date &lt;= #{param.syncFeeDateEnd}
</if>
<if test="param.shipperPerson != null and param.shipperPerson != '' "> <if test="param.shipperPerson != null and param.shipperPerson != '' ">
and Locate(#{param.shipperPerson},lww.shipper_person) > 0 and Locate(#{param.shipperPerson},lww.shipper_person) > 0
</if> </if>
@ -102,12 +116,15 @@
and lbc.clean_obj_type = #{param.cleanObjType} and lbc.clean_obj_type = #{param.cleanObjType}
</if> </if>
<if test="param.payType != null and param.payType != '' "> <if test="param.payType != null and param.payType != '' ">
and lbc.pay_type = #{param.payType} and lww.pay_type = #{param.payType}
</if> </if>
<if test="param.payWay != null and param.payWay != '' "> <if test="param.payWay != null and param.payWay != '' ">
and lbc.pay_way = #{param.payWay} and lww.pay_way = #{param.payWay}
</if> </if>
and lsoi.destination_warehouse_id in
<foreach collection="param.warehouseIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
group by lsoi.id group by lsoi.id
</select> </select>
@ -487,6 +504,29 @@
where 1=1 where 1=1
and lsoi.waybill_id = #{waybillId} and lsoi.waybill_id = #{waybillId}
</select> </select>
<select id="findWaybillDetailByWaybillId" resultType="com.logpm.statistics.vo.WaybillDetailByWaybillNoVo">
SELECT
waybill_id,
GROUP_CONCAT( t.b ) AS goodsName
FROM
(
SELECT
waybill_id,
concat( product_name, '(', sum( num ), ')' ) AS b
FROM
logpm_warehouse_waybill_detail
WHERE
waybill_id IN
<foreach collection="warehouseIdSet" item="item" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY
waybill_id,
product_name
) t
GROUP BY
t.waybill_id
</select>
<delete id="deleteListByOrderInfoIds" > <delete id="deleteListByOrderInfoIds" >
delete from logpm_statistics_order_info delete from logpm_statistics_order_info

13
blade-service/logpm-statisticsdata/src/main/java/com/logpm/statistics/mapper/StatisticsReconciliationOrderInfoMapper.xml

@ -26,14 +26,13 @@
<if test="param.openTimeEnd != null"> <if test="param.openTimeEnd != null">
and create_time &lt;= #{param.openTimeEnd} and create_time &lt;= #{param.openTimeEnd}
</if> </if>
<if test="param.consignee != null"> <if test="param.destinationWarehouseName != null">
and consignee &lt;= #{param.consignee} and destination_warehouse_name = #{param.destinationWarehouseName}
</if> </if>
and destination_warehouse_id in
<if test="param.isAftersales != null"> <foreach collection="param.warehouseIds" item="item" open="(" separator="," close=")">
and is_aftersale &lt;= #{param.isAftersales} #{item}
</if> </foreach>
</select> </select>

301
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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.MerchantStatisticsDTO;
import com.logpm.statistics.dto.StatisticsBalanceAbnormalDTO; import com.logpm.statistics.dto.StatisticsBalanceAbnormalDTO;
import com.logpm.statistics.dto.StatisticsBalanceRecordDTO; import com.logpm.statistics.dto.StatisticsBalanceRecordDTO;
@ -39,6 +41,7 @@ public class StatisticsBalanceOrderInfoServiceImpl extends BaseServiceImpl<Stati
private final IStatisticsBalanceAbnormalPhotoService balanceAbnormalPhotoService; private final IStatisticsBalanceAbnormalPhotoService balanceAbnormalPhotoService;
private final IStatisticsBalanceRecordService balanceRecordService; private final IStatisticsBalanceRecordService balanceRecordService;
private final IStatisticsBalanceRecordPhotoService balanceRecordPhotoService; private final IStatisticsBalanceRecordPhotoService balanceRecordPhotoService;
private final IBasicdataWarehouseClient warehouseClient;
@Override @Override
public IPage<StatisticsBalanceOrderInfoVO> pageList(MerchantStatisticsDTO merchantStatisticsDTO) { public IPage<StatisticsBalanceOrderInfoVO> pageList(MerchantStatisticsDTO merchantStatisticsDTO) {
@ -47,196 +50,202 @@ public class StatisticsBalanceOrderInfoServiceImpl extends BaseServiceImpl<Stati
page.setCurrent(merchantStatisticsDTO.getPageNum()); page.setCurrent(merchantStatisticsDTO.getPageNum());
page.setSize(merchantStatisticsDTO.getPageSize()); page.setSize(merchantStatisticsDTO.getPageSize());
List<Long> warehouseIds = warehouseClient.getWarehouseIds();
if(!warehouseIds.isEmpty()){
merchantStatisticsDTO.setWarehouseIds(warehouseIds);
}
return baseMapper.pageList(page,merchantStatisticsDTO); return baseMapper.pageList(page,merchantStatisticsDTO);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public R addAbnormal(StatisticsBalanceAbnormalDTO balanceAbnormalDTO) { public R addAbnormal(StatisticsBalanceAbnormalDTO balanceAbnormalDTO) {
StatisticsBalanceAbnormalEntity balanceAbnormalEntity = new StatisticsBalanceAbnormalEntity(); StatisticsBalanceAbnormalEntity balanceAbnormalEntity = new StatisticsBalanceAbnormalEntity();
BeanUtil.copy(balanceAbnormalDTO,balanceAbnormalEntity); BeanUtil.copy(balanceAbnormalDTO, balanceAbnormalEntity);
balanceAbnormalEntity.setAbnormalUserName(AuthUtil.getNickName()); balanceAbnormalEntity.setAbnormalUserName(AuthUtil.getNickName());
balanceAbnormalService.save(balanceAbnormalEntity); balanceAbnormalService.save(balanceAbnormalEntity);
Long balanceAbnormalId = balanceAbnormalEntity.getId(); Long balanceAbnormalId = balanceAbnormalEntity.getId();
List<StatisticsBalanceAbnormalPhotoEntity> abnormalPhotoEntityList = balanceAbnormalDTO.getAbnormalPhotoEntityList(); List<StatisticsBalanceAbnormalPhotoEntity> abnormalPhotoEntityList = balanceAbnormalDTO.getAbnormalPhotoEntityList();
abnormalPhotoEntityList.forEach(abnormalPhotoEntity -> { abnormalPhotoEntityList.forEach(abnormalPhotoEntity -> {
abnormalPhotoEntity.setAbnormalId(balanceAbnormalId); abnormalPhotoEntity.setAbnormalId(balanceAbnormalId);
}); });
balanceAbnormalPhotoService.saveBatch(abnormalPhotoEntityList); balanceAbnormalPhotoService.saveBatch(abnormalPhotoEntityList);
Long balanceOrderInfoId = balanceAbnormalEntity.getBalanceOrderInfoId(); Long balanceOrderInfoId = balanceAbnormalEntity.getBalanceOrderInfoId();
StatisticsBalanceOrderInfoEntity balanceOrderInfoEntity = baseMapper.selectById(balanceOrderInfoId); StatisticsBalanceOrderInfoEntity balanceOrderInfoEntity = baseMapper.selectById(balanceOrderInfoId);
if(Objects.isNull(balanceOrderInfoEntity)){ if (Objects.isNull(balanceOrderInfoEntity)) {
log.warn("###########addAbnormal: 结算单信息不存在 balanceOrderInfoEntity={}",balanceOrderInfoEntity); log.warn("###########addAbnormal: 结算单信息不存在 balanceOrderInfoEntity={}", balanceOrderInfoEntity);
throw new CustomerException(405,"结算单信息不存在"); throw new CustomerException(405, "结算单信息不存在");
} }
BigDecimal totalBalanceFee = balanceOrderInfoEntity.getTotalBalanceFee(); BigDecimal totalBalanceFee = balanceOrderInfoEntity.getTotalBalanceFee();
BigDecimal hasBalanceFee = balanceOrderInfoEntity.getHasBalanceFee(); BigDecimal hasBalanceFee = balanceOrderInfoEntity.getHasBalanceFee();
BigDecimal abnormalFee = balanceAbnormalEntity.getAbnormalFee(); BigDecimal abnormalFee = balanceAbnormalEntity.getAbnormalFee();
BigDecimal total = totalBalanceFee.add(abnormalFee); BigDecimal total = totalBalanceFee.add(abnormalFee);
balanceOrderInfoEntity.setAbnormalBalanceStatus(1); balanceOrderInfoEntity.setAbnormalBalanceStatus(1);
balanceOrderInfoEntity.setAbnormalBalanceFee(balanceOrderInfoEntity.getAbnormalBalanceFee().add(abnormalFee)); balanceOrderInfoEntity.setAbnormalBalanceFee(balanceOrderInfoEntity.getAbnormalBalanceFee().add(abnormalFee));
balanceOrderInfoEntity.setAbnormalTime(balanceAbnormalEntity.getCreateTime()); balanceOrderInfoEntity.setAbnormalTime(balanceAbnormalEntity.getCreateTime());
balanceOrderInfoEntity.setAbnormalUserName(balanceAbnormalEntity.getAbnormalUserName()); balanceOrderInfoEntity.setAbnormalUserName(balanceAbnormalEntity.getAbnormalUserName());
balanceOrderInfoEntity.setAbnormalRemark(balanceAbnormalEntity.getAbnormalRemark()); balanceOrderInfoEntity.setAbnormalRemark(balanceAbnormalEntity.getAbnormalRemark());
if(hasBalanceFee.compareTo(total) >= 0){ if (hasBalanceFee.compareTo(total) >= 0) {
balanceOrderInfoEntity.setBalanceStatus(2); balanceOrderInfoEntity.setBalanceStatus(2);
}else{ } else {
if(hasBalanceFee.compareTo(BigDecimal.ZERO) == 0){ if (hasBalanceFee.compareTo(BigDecimal.ZERO) == 0) {
balanceOrderInfoEntity.setBalanceStatus(0); balanceOrderInfoEntity.setBalanceStatus(0);
}else{ } else {
balanceOrderInfoEntity.setBalanceStatus(1); balanceOrderInfoEntity.setBalanceStatus(1);
}
} }
updateById(balanceOrderInfoEntity);
return R.success("添加成功");
} }
updateById(balanceOrderInfoEntity);
@Override return R.success("添加成功");
public R findAbnormalList(StatisticsBalanceAbnormalDTO balanceAbnormalDTO) { }
Long balanceOrderInfoId = balanceAbnormalDTO.getBalanceOrderInfoId();
QueryWrapper<StatisticsBalanceAbnormalEntity> balanceAbnormalEntityQueryWrapper = new QueryWrapper<>(); @Override
balanceAbnormalEntityQueryWrapper.eq("balance_order_info_id",balanceOrderInfoId); public R findAbnormalList(StatisticsBalanceAbnormalDTO balanceAbnormalDTO) {
Long balanceOrderInfoId = balanceAbnormalDTO.getBalanceOrderInfoId();
List<StatisticsBalanceAbnormalEntity> list = balanceAbnormalService.list(balanceAbnormalEntityQueryWrapper); QueryWrapper<StatisticsBalanceAbnormalEntity> balanceAbnormalEntityQueryWrapper = new QueryWrapper<>();
balanceAbnormalEntityQueryWrapper.eq("balance_order_info_id", balanceOrderInfoId);
if(list.isEmpty()){ List<StatisticsBalanceAbnormalEntity> list = balanceAbnormalService.list(balanceAbnormalEntityQueryWrapper);
return R.data(CollUtil.newArrayList());
}
//把list中所有元素的id放到一个List集合中 if (list.isEmpty()) {
List<Long> idList= list.stream() return R.data(CollUtil.newArrayList());
.map(StatisticsBalanceAbnormalEntity::getId) }
.collect(Collectors.toList());
QueryWrapper<StatisticsBalanceAbnormalPhotoEntity> balanceAbnormalPhotoEntityQueryWrapper = new QueryWrapper<>(); //把list中所有元素的id放到一个List集合中
balanceAbnormalPhotoEntityQueryWrapper.in("abnormal_id",idList); List<Long> idList = list.stream()
.map(StatisticsBalanceAbnormalEntity::getId)
.collect(Collectors.toList());
List<StatisticsBalanceAbnormalPhotoEntity> abnormalPhotoEntityList = balanceAbnormalPhotoService.list(balanceAbnormalPhotoEntityQueryWrapper); QueryWrapper<StatisticsBalanceAbnormalPhotoEntity> balanceAbnormalPhotoEntityQueryWrapper = new QueryWrapper<>();
//把abnormalPhotoEntityList中所有元素按照abnormalId进行分组 balanceAbnormalPhotoEntityQueryWrapper.in("abnormal_id", idList);
Map<Long, List<StatisticsBalanceAbnormalPhotoEntity>> groupedPhotos = abnormalPhotoEntityList.stream()
.collect(Collectors.groupingBy(StatisticsBalanceAbnormalPhotoEntity::getAbnormalId));
List<StatisticsBalanceAbnormalVO> abnormalVOList = new ArrayList<>(); List<StatisticsBalanceAbnormalPhotoEntity> abnormalPhotoEntityList = balanceAbnormalPhotoService.list(balanceAbnormalPhotoEntityQueryWrapper);
list.forEach(balanceAbnormalEntity -> { //把abnormalPhotoEntityList中所有元素按照abnormalId进行分组
StatisticsBalanceAbnormalVO balanceAbnormalVO = new StatisticsBalanceAbnormalVO(); Map<Long, List<StatisticsBalanceAbnormalPhotoEntity>> groupedPhotos = abnormalPhotoEntityList.stream()
BeanUtil.copy(balanceAbnormalEntity,balanceAbnormalVO); .collect(Collectors.groupingBy(StatisticsBalanceAbnormalPhotoEntity::getAbnormalId));
balanceAbnormalVO.setAbnormalPhotoEntityList(groupedPhotos.get(balanceAbnormalEntity.getId()));
abnormalVOList.add(balanceAbnormalVO);
});
return R.data(abnormalVOList); List<StatisticsBalanceAbnormalVO> 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) return R.data(abnormalVOList);
@Override }
public R addBalanceRecord(StatisticsBalanceRecordDTO balanceRecordDTO) {
StatisticsBalanceRecordEntity balanceRecordEntity = new StatisticsBalanceRecordEntity();
BeanUtil.copy(balanceRecordDTO,balanceRecordEntity);
balanceRecordEntity.setBalanceUserName(AuthUtil.getNickName());
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<StatisticsBalanceRecordPhotoEntity> recordPhotoEntityList = balanceRecordDTO.getRecordPhotoEntityList(); balanceRecordService.save(balanceRecordEntity);
recordPhotoEntityList.forEach(recordPhotoEntity -> { List<StatisticsBalanceRecordPhotoEntity> recordPhotoEntityList = balanceRecordDTO.getRecordPhotoEntityList();
recordPhotoEntity.setRecordId(balanceRecordEntity.getId());
});
balanceRecordPhotoService.saveBatch(recordPhotoEntityList); recordPhotoEntityList.forEach(recordPhotoEntity -> {
recordPhotoEntity.setRecordId(balanceRecordEntity.getId());
});
Long balanceOrderInfoId = balanceRecordDTO.getBalanceOrderInfoId(); balanceRecordPhotoService.saveBatch(recordPhotoEntityList);
StatisticsBalanceOrderInfoEntity balanceOrderInfoEntity = baseMapper.selectById(balanceOrderInfoId); Long balanceOrderInfoId = balanceRecordDTO.getBalanceOrderInfoId();
if(Objects.isNull(balanceOrderInfoEntity)){
log.warn("###########addBalanceRecord: 结算单信息不存在 balanceOrderInfoEntity={}",balanceOrderInfoEntity);
return R.fail(405,"结算单信息不存在");
}
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 balanceFee = balanceRecordEntity.getBalanceFee();
BigDecimal abnormalBalanceFee = balanceOrderInfoEntity.getAbnormalBalanceFee();
BigDecimal total = totalBalanceFee.add(abnormalBalanceFee); BigDecimal totalBalanceFee = balanceOrderInfoEntity.getTotalBalanceFee();
BigDecimal hasBalanceFee = balanceOrderInfoEntity.getHasBalanceFee(); BigDecimal abnormalBalanceFee = balanceOrderInfoEntity.getAbnormalBalanceFee();
BigDecimal newHasBalanceFee = hasBalanceFee.add(balanceFee); BigDecimal total = totalBalanceFee.add(abnormalBalanceFee);
BigDecimal hasBalanceFee = balanceOrderInfoEntity.getHasBalanceFee();
if(newHasBalanceFee.compareTo(total) >= 0){ BigDecimal newHasBalanceFee = hasBalanceFee.add(balanceFee);
balanceOrderInfoEntity.setBalanceStatus(2);
balanceOrderInfoEntity.setNoBalanceFee(BigDecimal.ZERO);
}else{
balanceOrderInfoEntity.setBalanceStatus(1);
balanceOrderInfoEntity.setNoBalanceFee(total.subtract(newHasBalanceFee));
}
balanceOrderInfoEntity.setHasBalanceFee(newHasBalanceFee); if (newHasBalanceFee.compareTo(total) >= 0) {
balanceOrderInfoEntity.setBalanceTime(balanceRecordEntity.getCreateTime()); balanceOrderInfoEntity.setBalanceStatus(2);
balanceOrderInfoEntity.setBalanceUserName(balanceRecordEntity.getBalanceUserName()); balanceOrderInfoEntity.setNoBalanceFee(BigDecimal.ZERO);
balanceOrderInfoEntity.setBalanceRemark(balanceRecordEntity.getBalanceRemark()); } 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 return R.success("添加成功");
public R findRecordList(StatisticsBalanceRecordDTO balanceRecordDTO) { }
Long balanceOrderInfoId = balanceRecordDTO.getBalanceOrderInfoId(); @Override
public R findRecordList(StatisticsBalanceRecordDTO balanceRecordDTO) {
QueryWrapper<StatisticsBalanceRecordEntity> balanceAbnormalEntityQueryWrapper = new QueryWrapper<>(); Long balanceOrderInfoId = balanceRecordDTO.getBalanceOrderInfoId();
balanceAbnormalEntityQueryWrapper.eq("balance_order_info_id",balanceOrderInfoId);
List<StatisticsBalanceRecordEntity> list = balanceRecordService.list(balanceAbnormalEntityQueryWrapper); QueryWrapper<StatisticsBalanceRecordEntity> balanceAbnormalEntityQueryWrapper = new QueryWrapper<>();
balanceAbnormalEntityQueryWrapper.eq("balance_order_info_id", balanceOrderInfoId);
if(list.isEmpty()){ List<StatisticsBalanceRecordEntity> list = balanceRecordService.list(balanceAbnormalEntityQueryWrapper);
return R.data(CollUtil.newArrayList());
}
//把list中所有元素的id放到一个List集合中 if (list.isEmpty()) {
List<Long> idList= list.stream() return R.data(CollUtil.newArrayList());
.map(StatisticsBalanceRecordEntity::getId)
.collect(Collectors.toList());
QueryWrapper<StatisticsBalanceRecordPhotoEntity> balanceRecordPhotoEntityQueryWrapper = new QueryWrapper<>();
balanceRecordPhotoEntityQueryWrapper.in("record_id",idList);
List<StatisticsBalanceRecordPhotoEntity> recordPhotoEntityList = balanceRecordPhotoService.list(balanceRecordPhotoEntityQueryWrapper);
//把abnormalPhotoEntityList中所有元素按照abnormalId进行分组
Map<Long, List<StatisticsBalanceRecordPhotoEntity>> groupedPhotos = recordPhotoEntityList.stream()
.collect(Collectors.groupingBy(StatisticsBalanceRecordPhotoEntity::getRecordId));
List<StatisticsBalanceRecordVO> 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);
} }
@Override //把list中所有元素的id放到一个List集合中
public R findBalanceDetail(Long balanceOrderId) { List<Long> idList = list.stream()
.map(StatisticsBalanceRecordEntity::getId)
.collect(Collectors.toList());
QueryWrapper<StatisticsBalanceRecordPhotoEntity> balanceRecordPhotoEntityQueryWrapper = new QueryWrapper<>();
balanceRecordPhotoEntityQueryWrapper.in("record_id", idList);
List<StatisticsBalanceRecordPhotoEntity> recordPhotoEntityList = balanceRecordPhotoService.list(balanceRecordPhotoEntityQueryWrapper);
//把abnormalPhotoEntityList中所有元素按照abnormalId进行分组
Map<Long, List<StatisticsBalanceRecordPhotoEntity>> groupedPhotos = recordPhotoEntityList.stream()
.collect(Collectors.groupingBy(StatisticsBalanceRecordPhotoEntity::getRecordId));
List<StatisticsBalanceRecordVO> 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);
}
} }

53
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.entity.BasicdataPriceTemplateEntity;
import com.logpm.basicdata.feign.IBasicdataCodeClient; import com.logpm.basicdata.feign.IBasicdataCodeClient;
import com.logpm.basicdata.feign.IBasicdataPriceClient; import com.logpm.basicdata.feign.IBasicdataPriceClient;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.basicdata.vo.*; import com.logpm.basicdata.vo.*;
import com.logpm.statistics.dto.AftersalesOrderDTO; import com.logpm.statistics.dto.AftersalesOrderDTO;
import com.logpm.statistics.dto.ChangesRecordDTO; import com.logpm.statistics.dto.ChangesRecordDTO;
@ -45,13 +46,13 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl<StatisticsOr
private final IStatisticsChangesRecordService changesRecordService; private final IStatisticsChangesRecordService changesRecordService;
private final IStatisticsChangesPhotoService changesPhotoService; private final IStatisticsChangesPhotoService changesPhotoService;
private final IBasicdataCodeClient basicdataCodeClient;
private final IStatisticsBalanceOrderInfoService balanceOrderInfoService; private final IStatisticsBalanceOrderInfoService balanceOrderInfoService;
private final IBasicdataPriceClient priceClient; private final IBasicdataPriceClient priceClient;
private final IStatisticsDistributionPackageService distributionPackageService; private final IStatisticsDistributionPackageService distributionPackageService;
private final IStatisticsWarehousePackageService warehousePackageService; private final IStatisticsWarehousePackageService warehousePackageService;
private final IStatisticsReconciliationOrderInfoService reconciliationOrderInfoService; private final IStatisticsReconciliationOrderInfoService reconciliationOrderInfoService;
private final IStatisticsAftersalesOrderRecordService aftersalesOrderRecordService; private final IStatisticsAftersalesOrderRecordService aftersalesOrderRecordService;
private final IBasicdataWarehouseClient warehouseClient;
@Override @Override
public List<StatisticsOrderInfoEntity> findListByWaybillId(Long waybillId) { public List<StatisticsOrderInfoEntity> findListByWaybillId(Long waybillId) {
@ -75,22 +76,58 @@ public class StatisticsOrderInfoServiceImpl extends BaseServiceImpl<StatisticsOr
page.setCurrent(merchantStatisticsDTO.getPageNum()); page.setCurrent(merchantStatisticsDTO.getPageNum());
page.setSize(merchantStatisticsDTO.getPageSize()); page.setSize(merchantStatisticsDTO.getPageSize());
List<Long> warehouseIds = warehouseClient.getWarehouseIds();
if(!warehouseIds.isEmpty()){
merchantStatisticsDTO.setWarehouseIds(warehouseIds);
}
IPage<StatisticsOrderInfoVO> statisticsOrderInfoVOIPage = baseMapper.pageList(page, merchantStatisticsDTO); IPage<StatisticsOrderInfoVO> statisticsOrderInfoVOIPage = baseMapper.pageList(page, merchantStatisticsDTO);
List<StatisticsOrderInfoVO> records = statisticsOrderInfoVOIPage.getRecords(); List<StatisticsOrderInfoVO> records = statisticsOrderInfoVOIPage.getRecords();
//把records中所有的orderInfoId放入一个集合 //把records中所有的orderInfoId放入一个集合
List<Long> orderInfoIdList = records.stream().map(StatisticsOrderInfoVO::getOrderInfoId).collect(Collectors.toList()); List<Long> orderInfoIdList = records.stream().map(StatisticsOrderInfoVO::getOrderInfoId).collect(Collectors.toList());
// 运单ID集合
Set<Long> warehouseIdSet = records.stream().map(StatisticsOrderInfoVO::getWaybillId).collect(Collectors.toSet());
List<WaybillDetailByWaybillNoVo> waybillDetailByWaybillNoVoList;
Map<Long, StatisticsPackageFeeInfoVO> orderPackageInfoMap;
if(CollUtil.isNotEmpty(orderInfoIdList)){ if(CollUtil.isNotEmpty(orderInfoIdList)){
List<StatisticsPackageFeeInfoVO> orderPackageInfoList = baseMapper.findPackageListByOrderIdsGroupById(orderInfoIdList); List<StatisticsPackageFeeInfoVO> orderPackageInfoList = baseMapper.findPackageListByOrderIdsGroupById(orderInfoIdList);
//把orderPackageInfoList转化成以orderInfoId为key的Map //把orderPackageInfoList转化成以orderInfoId为key的Map
Map<Long, StatisticsPackageFeeInfoVO> orderPackageInfoMap = orderPackageInfoList.stream() if(CollUtil.isNotEmpty(orderPackageInfoList)){
.collect(Collectors.toMap(StatisticsPackageFeeInfoVO::getOrderInfoId, statisticsPackageFeeInfoVO -> statisticsPackageFeeInfoVO)); 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); 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); statisticsOrderInfoVOIPage.setRecords(records);
return statisticsOrderInfoVOIPage; return statisticsOrderInfoVOIPage;

13
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.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.statistics.dto.MerchantStatisticsDTO; import com.logpm.statistics.dto.MerchantStatisticsDTO;
import com.logpm.statistics.entity.StatisticsReconciliationOrderInfoEntity; import com.logpm.statistics.entity.StatisticsReconciliationOrderInfoEntity;
import com.logpm.statistics.mapper.StatisticsReconciliationOrderInfoMapper; import com.logpm.statistics.mapper.StatisticsReconciliationOrderInfoMapper;
import com.logpm.statistics.service.IStatisticsReconciliationOrderInfoService; import com.logpm.statistics.service.IStatisticsReconciliationOrderInfoService;
import com.logpm.statistics.vo.StatisticsReconciliationInfoExportVO; import com.logpm.statistics.vo.StatisticsReconciliationInfoExportVO;
import com.logpm.warehouse.feign.IWarehouseWaybillClient;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.common.utils.CommonUtil; import org.springblade.common.utils.CommonUtil;
@ -21,6 +23,10 @@ import java.util.List;
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor
public class StatisticsReconciliationOrderInfoServiceImpl extends BaseServiceImpl<StatisticsReconciliationOrderInfoMapper,StatisticsReconciliationOrderInfoEntity> implements IStatisticsReconciliationOrderInfoService { public class StatisticsReconciliationOrderInfoServiceImpl extends BaseServiceImpl<StatisticsReconciliationOrderInfoMapper,StatisticsReconciliationOrderInfoEntity> implements IStatisticsReconciliationOrderInfoService {
private IBasicdataWarehouseClient warehouseClient;
@Override @Override
public IPage<StatisticsReconciliationOrderInfoEntity> pageReconciliationList(MerchantStatisticsDTO merchantStatisticsDTO) { public IPage<StatisticsReconciliationOrderInfoEntity> pageReconciliationList(MerchantStatisticsDTO merchantStatisticsDTO) {
@ -31,6 +37,13 @@ public class StatisticsReconciliationOrderInfoServiceImpl extends BaseServiceImp
merchantStatisticsDTO.setOpenTimeStart(CommonUtil.getStartByDateStr(merchantStatisticsDTO.getOpenTimeStartStr())); merchantStatisticsDTO.setOpenTimeStart(CommonUtil.getStartByDateStr(merchantStatisticsDTO.getOpenTimeStartStr()));
merchantStatisticsDTO.setOpenTimeEnd(CommonUtil.getEndByDateStr(merchantStatisticsDTO.getOpenTimeEndStr())); merchantStatisticsDTO.setOpenTimeEnd(CommonUtil.getEndByDateStr(merchantStatisticsDTO.getOpenTimeEndStr()));
List<Long> warehouseIds = warehouseClient.getWarehouseIds();
if(!warehouseIds.isEmpty()){
merchantStatisticsDTO.setWarehouseIds(warehouseIds);
}
return baseMapper.pageReconciliationList(page, merchantStatisticsDTO); return baseMapper.pageReconciliationList(page, merchantStatisticsDTO);
} }

2
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseWaybillMapper.xml

@ -505,7 +505,7 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="param.warehouseId != null"> <if test="param.destinationWarehouseIds != null">
and lww.destination_warehouse_id in and lww.destination_warehouse_id in
<foreach collection="param.destinationWarehouseIds" item="item" open="(" separator="," close=")"> <foreach collection="param.destinationWarehouseIds" item="item" open="(" separator="," close=")">
#{item} #{item}

Loading…
Cancel
Save