Commit 961528a4 authored by 332784038@qq.com's avatar 332784038@qq.com

Merge branch 'master-fix' into dev

parents 702497cf c8c60dc2
......@@ -2012,87 +2012,87 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
}
}
checkOrderSalesman(orderDO,null,consignorDO,consigneeDO,orderConsignorDO,orderConsigneeDO);
if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (StringUtils.isNotBlank(orderDO.getType()) && orderDO.getType().contains("2")) {
if (!Objects.equals(orderDO.getCustomerId(), orderConsignorDO.getCustomerId())) {
// 海外仓归属发货人
orderDO.setCustomerId(orderConsignorDO.getCustomerId());
}
} else {
if (consignorDO != null && !consignorDO.getNoConsignee() && !orderDO.getHasConsignee()) {
if (!Objects.equals(orderDO.getCustomerId(), orderConsignorDO.getCustomerId())) {
// 控货订单归属发货人->修改为发货人档案控货无收货人
orderDO.setCustomerId(orderConsignorDO.getCustomerId());
}
} else {
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
if (orderDO.getDrawee() == 1) {
if (!Objects.equals(orderDO.getCustomerId(), orderConsignorDO.getCustomerId())) {
// 订单归属发货人
orderDO.setCustomerId(orderConsignorDO.getCustomerId());
}
} else if (orderDO.getDrawee() == 3) {
//自定义付款
List<CustomDraweeVO> list =
JSONObject.parseArray(orderDO.getCustomDrawee(), CustomDraweeVO.class);
if (CollectionUtil.isNotEmpty(list)) {
List<CustomDraweeVO> freightList = list.stream().filter(s -> s.getName().equals("freight")).collect(Collectors.toList());
List<CustomDraweeVO> clearanceFeeList = list.stream().filter(s -> s.getName().equals("clearanceFee")).collect(Collectors.toList());
int freight = freightList.get(0).getValue();//运费
int clearanceFee = clearanceFeeList.get(0).getValue();//清关费
// 检查订单是否有关联报价单
OrderAssociationOfferCostEvent offerCostEvent =
new OrderAssociationOfferCostEvent(orderDO.getOrderId(),
BigDecimal.ZERO, 0, BigDecimal.ZERO,
0, false);
applicationContext.publishEvent(offerCostEvent);
if (offerCostEvent.isAssociationOffer() && (orderDO.getDrawee() == 3 && freight == 1)) {//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
orderDO.setCustomerId(orderConsignorDO.getCustomerId());
orderDO.setIsInOpenSea(consignorDO.getIsInOpenSea());
orderDO.setYejiType(consignorDO.getIsNew() ? 1 : 0);
orderDO.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
} else if (offerCostEvent.isAssociationOffer() && (orderDO.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
orderDO.setCustomerId(orderConsignorDO.getCustomerId());
orderDO.setIsInOpenSea(consignorDO.getIsInOpenSea());
orderDO.setYejiType(consignorDO.getIsNew() ? 1 : 0);
orderDO.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
} else if (consignorDO.getDefaultPay() && (orderDO.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
orderDO.setCustomerId(orderConsignorDO.getCustomerId());
orderDO.setIsInOpenSea(consignorDO.getIsInOpenSea());
orderDO.setYejiType(consignorDO.getIsNew() ? 1 : 0);
orderDO.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
} else if (consignorDO.getDefaultPay() && (orderDO.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
orderDO.setCustomerId(orderConsignorDO.getCustomerId());
orderDO.setIsInOpenSea(consignorDO.getIsInOpenSea());
orderDO.setYejiType(consignorDO.getIsNew() ? 1 : 0);
orderDO.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
} else {
//去掉层级5、6 ,以上不符合的都归收货人
orderDO.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
orderDO.setIsInOpenSea(consigneeDO.getIsInOpenSea());
orderDO.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
orderDO.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
}
}
} else {
if (!Objects.equals(orderDO.getCustomerId(), orderConsigneeDO.getCustomerId())) {
// 控货订单归属收货人
orderDO.setCustomerId(orderConsigneeDO.getCustomerId());
}
}
}
}
}
// if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
// if (StringUtils.isNotBlank(orderDO.getType()) && orderDO.getType().contains("2")) {
// if (!Objects.equals(orderDO.getCustomerId(), orderConsignorDO.getCustomerId())) {
// // 海外仓归属发货人
// orderDO.setCustomerId(orderConsignorDO.getCustomerId());
// }
// } else {
//
// if (consignorDO != null && !consignorDO.getNoConsignee() && !orderDO.getHasConsignee()) {
// if (!Objects.equals(orderDO.getCustomerId(), orderConsignorDO.getCustomerId())) {
// // 控货订单归属发货人->修改为发货人档案控货无收货人
// orderDO.setCustomerId(orderConsignorDO.getCustomerId());
// }
// } else {
// // 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
// if (orderDO.getDrawee() == 1) {
// if (!Objects.equals(orderDO.getCustomerId(), orderConsignorDO.getCustomerId())) {
// // 订单归属发货人
// orderDO.setCustomerId(orderConsignorDO.getCustomerId());
// }
// } else if (orderDO.getDrawee() == 3) {
// //自定义付款
//
// List<CustomDraweeVO> list =
// JSONObject.parseArray(orderDO.getCustomDrawee(), CustomDraweeVO.class);
// if (CollectionUtil.isNotEmpty(list)) {
//
// List<CustomDraweeVO> freightList = list.stream().filter(s -> s.getName().equals("freight")).collect(Collectors.toList());
// List<CustomDraweeVO> clearanceFeeList = list.stream().filter(s -> s.getName().equals("clearanceFee")).collect(Collectors.toList());
// int freight = freightList.get(0).getValue();//运费
// int clearanceFee = clearanceFeeList.get(0).getValue();//清关费
// // 检查订单是否有关联报价单
// OrderAssociationOfferCostEvent offerCostEvent =
// new OrderAssociationOfferCostEvent(orderDO.getOrderId(),
// BigDecimal.ZERO, 0, BigDecimal.ZERO,
// 0, false);
// applicationContext.publishEvent(offerCostEvent);
// if (offerCostEvent.isAssociationOffer() && (orderDO.getDrawee() == 3 && freight == 1)) {//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
//
// orderDO.setCustomerId(orderConsignorDO.getCustomerId());
// orderDO.setIsInOpenSea(consignorDO.getIsInOpenSea());
// orderDO.setYejiType(consignorDO.getIsNew() ? 1 : 0);
// orderDO.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
// } else if (offerCostEvent.isAssociationOffer() && (orderDO.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
//
// orderDO.setCustomerId(orderConsignorDO.getCustomerId());
// orderDO.setIsInOpenSea(consignorDO.getIsInOpenSea());
// orderDO.setYejiType(consignorDO.getIsNew() ? 1 : 0);
// orderDO.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
// } else if (consignorDO.getDefaultPay() && (orderDO.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
//
// orderDO.setCustomerId(orderConsignorDO.getCustomerId());
// orderDO.setIsInOpenSea(consignorDO.getIsInOpenSea());
// orderDO.setYejiType(consignorDO.getIsNew() ? 1 : 0);
// orderDO.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
// } else if (consignorDO.getDefaultPay() && (orderDO.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
// orderDO.setCustomerId(orderConsignorDO.getCustomerId());
// orderDO.setIsInOpenSea(consignorDO.getIsInOpenSea());
// orderDO.setYejiType(consignorDO.getIsNew() ? 1 : 0);
// orderDO.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
//
// } else {
// //去掉层级5、6 ,以上不符合的都归收货人
// orderDO.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
// orderDO.setIsInOpenSea(consigneeDO.getIsInOpenSea());
// orderDO.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
// orderDO.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
//
// }
// }
// } else {
// if (!Objects.equals(orderDO.getCustomerId(), orderConsigneeDO.getCustomerId())) {
// // 控货订单归属收货人
// orderDO.setCustomerId(orderConsigneeDO.getCustomerId());
// }
// }
// }
// }
// }
// 判断该订单、该客户是否有未分配客户异常,如果有,则这个订单不计算业绩
List<OrderExceptionDO> orderExceptionDOList =
orderExceptionService.getOrderExceptionByCustomerId(
......@@ -2120,7 +2120,120 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
}
orderMapper.updateById(orderDO);
}
public int checkOrderSalesman(OrderDO order, Long offerId, CustomerDO consignorDO, CustomerDO consigneeDO, OrderConsignorDO orderConsignorDO, OrderConsigneeDO orderConsigneeDO) {
int customerType = 1; //1-业绩归属发货人,2-业绩归属收货人
if (Objects.isNull(orderConsigneeDO)) {//订单收货人
orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, order.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
}
if (Objects.isNull(orderConsignorDO)) {//订单发货人
orderConsignorDO = orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, order.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
}
if (Objects.isNull(consignorDO)) {//发货人客户
consignorDO = customerService.getCustomer(orderConsignorDO.getCustomerId());
}
if (Objects.isNull(consigneeDO)) {
consigneeDO = customerService.getCustomer(orderConsigneeDO.getCustomerId());//收货人客户
}
// 原客户经理
Long orgCustomerId = Objects.isNull(order.getCustomerId()) ? 0L : order.getCustomerId();
if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {//层级1
// 海外仓归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0));
} else {
if (consignorDO != null && !consignorDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0));
} else {
if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && offerId != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0));
} else if (order.getDrawee() == 1 && consignorDO.getDefaultPay()) {// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0));
} else {
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0));
customerType = 2;
}
} else if (order.getDrawee() == 2) {//收货人付款 层级5 第一个
if (consigneeDO != null) {
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0));
} else {
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
customerType = 0;
}
} else if (order.getDrawee() == 3) { //自定义付款
List<CustomDraweeVO> list = JSONObject.parseArray(order.getCustomDrawee(), CustomDraweeVO.class);
if (CollectionUtil.isNotEmpty(list)) {
List<CustomDraweeVO> freightList = list.stream().filter(s -> s.getName().equals("freight")).collect(Collectors.toList());
List<CustomDraweeVO> clearanceFeeList = list.stream().filter(s -> s.getName().equals("clearanceFee")).collect(Collectors.toList());
int freight = freightList.get(0).getValue();//运费
int clearanceFee = clearanceFeeList.get(0).getValue();//清关费
if (offerId != null && (order.getDrawee() == 3 && freight == 1)) {//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0));
} else if (offerId != null && (order.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0));
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0));
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0));
} else {
//去掉层级5、6 ,以上不符合的都归收货人
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0));
customerType = 2;
}
}
} else {
//业绩归收货人
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0));
customerType = 2;
}
}
}
// 订单修改是否变动了归属客户,此字段用来判定订单是否需要重置归属客户经理,下单后归属客户的客户经理是固定的,除非订单归属客户变动,才需要重置客户经理
order.setIsChargeCustomer(!Objects.equals(order.getCustomerId(), orgCustomerId));
return customerType;
}
@Override
public void updateOrderOrgWeightUnitAndOrgVolumeUnit(List<String> orderNumbers) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment