Commit 3481b43f authored by 332784038@qq.com's avatar 332784038@qq.com

Merge branch 'master-fix' into dev

parents 9a97bd5a 4e51ba9a
......@@ -2016,85 +2016,6 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
applicationContext.publishEvent(event);
checkOrderSalesman(orderDO, event.getOfferId(), 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());
// }
// }
// }
// }
// }
// 判断该订单、该客户是否有未分配客户异常,如果有,则这个订单不计算业绩
List<OrderExceptionDO> orderExceptionDOList =
orderExceptionService.getOrderExceptionByCustomerId(
......@@ -2104,6 +2025,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
.filter(orderExceptionDO -> Objects.equals(orderExceptionDO.getOrderId(), orderDO.getOrderId())).findFirst().orElse(null);
if (Objects.isNull(currentOrderException) && Objects.nonNull(orderDO.getCustomerId()) && orderDO.getCustomerId() > 0) {
CustomerDO customerDO = customerService.getById(orderDO.getCustomerId());
orderDO.setIsInOpenSea(customerDO.getIsInOpenSea());
orderDO.setYejiType(customerDO.getIsNew() ? 1 : 0);
// 订单所属客户变更,则需要变更业绩归属
// 更新所属客户经理(业务员)
if (Objects.nonNull(customerDO) && Objects.nonNull(customerDO.getCustomerService()) && customerDO.getIsCustomerServiceConfirmed() && !customerDO.getIsInOpenSea()) {
......@@ -2141,48 +2064,30 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
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);
order.setDeptId(0L);
customerType = 0;
}
} else if (order.getDrawee() == 3) { //自定义付款
......@@ -2195,40 +2100,22 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
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;
}
}
......
......@@ -5,7 +5,6 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.dto.OrderDto;
import cn.iocoder.yudao.framework.apollo.core.event.*;
import cn.iocoder.yudao.framework.apollo.core.event.Order.CalculateOrderVValueEvent;
import cn.iocoder.yudao.framework.apollo.core.event.Order.CalculateOrderYeJiTypeEvent;
import cn.iocoder.yudao.framework.common.util.spring.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.util.bigDecimal.BigDecimalUtils;
......@@ -119,7 +118,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.math.RoundingMode;
......@@ -669,12 +667,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (!Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
//customerType 发货人-1 收货人 2
int customerType = this.checkOrderSalesman(order, createReqVO.getOfferId(), null, null, orderConsignorDO, orderConsigneeDO);
// 更新所属客户经理(业务员)
// if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getIsChargeCustomer()) && order.getIsChargeCustomer()) {
//addOrderCustomerService(order, customerType);
addOrderCustomerServiceAndCustomer(createReqVO, order, customerType);
addOrderCustomerService(order, customerType);
}
}
......@@ -913,256 +908,13 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO,
orderConsigneeDO);
// 更新所属客户经理(业务员)
// if (Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getIsChargeCustomer()) && order.getIsChargeCustomer()) {
//addOrderCustomerService(order, customerType);
addOrderCustomerServiceAndCustomer(createReqVO, order, customerType);
}
}
}
private void addOrderSalesmanCustomerService(OrderDO order) {
OrderConsigneeDO orderConsigneeDO =
orderConsigneeService.getOne(
new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, order.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
OrderConsignorDO orderConsignorDO =
orderConsignorService.getOne(
new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, order.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
CustomerDO consignorDO =
customerService.getCustomer(orderConsignorDO.getCustomerId());
CustomerDO consigneeDO =
customerService.getCustomer(orderConsigneeDO.getCustomerId());
//收货人
if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {
// 海外仓归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
} else {
if (consignorDO != null && !consignorDO.getNoConsignee() &&
!order.getHasConsignee()) {
//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if (consignorDO != null) {
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
}
} else {
List<TargetOfferBackVO> offerBackVOList =
targetLogMapper.getTargetOfferBackByOrerId(order.getOrderId());
if (order.getDrawee() == 1) {
//发货人付款
if (order.getDrawee() == 1 &&
CollectionUtil.isNotEmpty(offerBackVOList)) {
//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? 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()));
} 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.getCustomerService() : 0));
}
} 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.getCustomerService() : 0));
} else {
order.setCustomerId(0L);
order.setSalesmanId(0L);
}
} 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 (CollectionUtil.isNotEmpty(offerBackVOList) && (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()));
} else if (CollectionUtil.isNotEmpty(offerBackVOList) && (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()));
} 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()));
} 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()));
} 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.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.getCustomerService() : 0));
}
}
}
}
//新增判断客户归属
private void addOrderSalesmanCustomerService(OrderCreateReqVO createReqVO, OrderDO order) {
OrderConsigneeDO orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, order.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
OrderConsignorDO orderConsignorDO = orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, order.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
CustomerDO consignorDO = customerService.getCustomer(orderConsignorDO.getCustomerId());
CustomerDO consigneeDO = customerService.getCustomer(orderConsigneeDO.getCustomerId());//收货人
if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {
//层级1
// 海外仓归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
} else {
if (consignorDO != null && !consignorDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if (consignorDO != null) {
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
}
} else {
if (order.getDrawee() == 1) {
//发货人付款
if (order.getDrawee() == 1 && createReqVO.getOfferId() != 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.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());
} 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.getCustomerService() : 0));
}
} 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.getCustomerService() : 0));
} else {
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
}
} 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 (createReqVO.getOfferId() != 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());
} else if (createReqVO.getOfferId() != 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());
} 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());
} 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());
} 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.getCustomerService() : 0));
addOrderCustomerService(order, customerType);
}
}
} 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.getCustomerService() : 0));
}
}
}
}
public int checkOrderSalesman(OrderDO order, Long offerId, CustomerDO consignorDO, CustomerDO consigneeDO, OrderConsignorDO orderConsignorDO, OrderConsigneeDO orderConsigneeDO) {
int customerType = 1; //1-业绩归属发货人,2-业绩归属收货人
if (Objects.isNull(orderConsigneeDO)) {//订单收货人
......@@ -1185,95 +937,63 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
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 {
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));
customerType = 2;
} else {
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
order.setDeptId(0L);
customerType = 0;
}
}
} 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));
customerType = 2;
} else {
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
order.setDeptId(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 ,以上不符合的都归收货人
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));
customerType = 2;
} else {
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
order.setDeptId(0L);
customerType = 0;
}
}
......@@ -1282,14 +1002,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
//业绩归收货人
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));
customerType = 2;
} else {
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
order.setDeptId(0L);
customerType = 0;
}
}
......@@ -1300,92 +1018,6 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
return customerType;
}
private void addOrderCustomerServiceAndCustomer(OrderCreateReqVO createReqVO, OrderDO order, int customerType) {
if (Objects.nonNull(order.getParentOrderId()) && order.getParentOrderId() > 0 && !order.getSplitSeparateOrder()) {
// 拆单子订单,并且未标记为独立订单,则不执行客户经理分配规则,以原单为主
return;
}
// 判断该订单、该客户是否有未分配客户异常,如果有,则这个订单不计算业绩
List<OrderExceptionDO> orderExceptionDOList =
orderExceptionService.getOrderExceptionByCustomerId(
order.getCustomerId());
// 获取当前订单的异常
OrderExceptionDO currentOrderException = orderExceptionDOList.stream()
.filter(orderExceptionDO -> Objects.equals(orderExceptionDO.getOrderId(), order.getOrderId())).findFirst().orElse(null);
CustomerDO customerDO = customerService.getById(order.getCustomerId());
Long oldCustomerService = null; // 老客户经理默认为null
if (Objects.nonNull(customerDO) && Objects.nonNull(customerDO.getCustomerService()) && customerDO.getCustomerService() != 0L && Objects.nonNull(customerDO.getCustomerServiceAssignedTime())
&& !customerDO.getIsCustomerServiceConfirmed() && !customerDO.getIsInOpenSea()) {
// 如果客户存在,客户经理已分配,有分配时间,但是待确认接收,也不是公海捞取,那么需要判断该客户之前是否有客户经理,没有则业绩属于公司客户,有则业绩归属于上个客户经理
CustomerOperateLogDO customerOperateLogDO = customerOperateLogService.getOne(new LambdaQueryWrapper<CustomerOperateLogDO>()
.eq(CustomerOperateLogDO::getCustomerId, customerDO.getId())
.eq(CustomerOperateLogDO::getOperateType, 4) // TODO 暂定操作类型4为分配操作,有遗漏后面补充操作类型即可
.orderByDesc(CustomerOperateLogDO::getId).last("limit 1"));
if (Objects.nonNull(customerOperateLogDO) && Objects.nonNull(customerOperateLogDO.getOldCustomerService()) && customerOperateLogDO.getOldCustomerService() != 0L) {
oldCustomerService = customerOperateLogDO.getOldCustomerService();
}
}
// 没有该订单,该客户的未分配客户经理异常
if (Objects.isNull(currentOrderException) && Objects.nonNull(customerDO) && Objects.nonNull(customerDO.getCustomerService()) && customerDO.getCustomerService() != 0L
&& (customerDO.getIsCustomerServiceConfirmed() || (!customerDO.getIsCustomerServiceConfirmed() && Objects.nonNull(oldCustomerService)))) {
if (Objects.nonNull(oldCustomerService)) {
// 如果这里的旧客户经理id不为null,说明此客户属于移交新客户经理,但是新客户经理还未接收,业绩算老客户经理的
order.setSalesmanId(oldCustomerService);
} else if ((customerDO.getIsInOpenSea() && Objects.nonNull(customerDO.getEnterOpenSeaTime())) || !customerDO.getIsCustomerServiceConfirmed()) { //客户还在公海上,和待接收的,不做业绩归属分配,归公司
order.setSalesmanId(0L);
order.setCustomerId(0L);
} else {
addOrderSalesmanCustomerService(createReqVO, order);
}
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(order.getSalesmanId());
if (Objects.nonNull(adminUserRespDTO)) {
order.setDeptId(adminUserRespDTO.getDeptId());
} else {
order.setDeptId(0L);
}
} else if (CollectionUtil.isEmpty(orderExceptionDOList) && Objects.nonNull(customerDO)
&& (Objects.isNull(customerDO.getCustomerService()) ||
(!customerDO.getIsCustomerServiceConfirmed() && Objects.isNull(oldCustomerService)))) {
// 如果客户正在移交新客户经理,但是未接收,并且老客户经理不为null,则不创建客户经理未分配异常
//web下单,业绩为收货人,不产生未分配客户经理异常
//if (order.getUserId() != null && order.getUserId() > 0 && customerType == 2) {
if (order.getUserId() != null && order.getUserId() > 0
&& order.getSalesmanId() != null && order.getSalesmanId() > 0) {
addOrderSalesmanCustomerService(createReqVO, order);
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(order.getSalesmanId());
if (Objects.nonNull(adminUserRespDTO)) {
order.setDeptId(adminUserRespDTO.getDeptId());
} else {
order.setDeptId(0L);
}
log.info("web下单,业绩为收货人,不产生未分配客户经理异常 orderNo={}", order.getOrderNo());
} else {
// 只有客户的客户经理为空时
String descZh = "归属客户:%s 客户编号:%s";
String descEn = "Customer: %s Customer No.: %s";
// 该客户没有客户经理, 需要生成异常,判断当前客户是发货人还是收货人
if (customerType == 1) {
// 发货人
descZh = String.format(descZh, "发货人", customerDO.getNumber());
descEn = String.format(descEn, "consignor", customerDO.getNumber());
} else {
// 收货人
descZh = String.format(descZh, "收货人", customerDO.getNumber());
descEn = String.format(descEn, "consignee", customerDO.getNumber());
}
OrderExceptionCreateReqVO orderExceptionCreateReqVO = this.genOrderException(order.getOrderId(), order, null, order.getCustomerId(), OrderExceptionEnum.NOT_CUSTOMER_SERVICE_EXCEPTION,
descZh, descEn);
orderExceptionService.createOrderException(orderExceptionCreateReqVO);
}
} else {
// 该订单存在该客户未分配客户经理异常,
// 或者该客户的客户经理待接收,则不再生成未分配客户经理异常,且该订单不产生业绩归属
order.setSalesmanId(0L);
order.setDeptId(0L);
}
}
private void addOrderCustomerService(OrderDO order,
int customerType) {
......@@ -1408,6 +1040,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.getOrderId())).findFirst().orElse(null);
CustomerDO customerDO = customerService.getById(order.getCustomerId());
order.setIsInOpenSea(customerDO.getIsInOpenSea());
order.setYejiType(customerDO.getIsNew() ? 1 : 0);
Long oldCustomerService = null;
// 老客户经理默认为null
if (Objects.nonNull(customerDO) &&
......@@ -1445,8 +1079,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 但是新客户经理还未接收,业绩算老客户经理的
order.setSalesmanId(oldCustomerService);
} else {
//order.setSalesmanId(customerDO.getCustomerService());
addOrderSalesmanCustomerService(order);
order.setSalesmanId(customerDO.getCustomerService());
}
AdminUserRespDTO adminUserRespDTO =
adminUserApi.getUser(order.getSalesmanId());
......@@ -1464,8 +1097,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
//web下单,业绩为收货人,不产生未分配客户经理异常
if (order.getUserId() != null && order.getUserId() > 0 &&
customerType == 2) {
//order.setSalesmanId(0L);
addOrderSalesmanCustomerService(order);
order.setSalesmanId(0L);
order.setDeptId(0L);
log.info("web下单,业绩为收货人,不产生未分配客户经理异常 orderNo={}", order.getOrderNo());
} else {
......@@ -1508,9 +1140,10 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
OrderExceptionDO currentOrderException = orderExceptionDOList.stream()
.filter(orderExceptionDO -> Objects.equals(orderExceptionDO.getOrderId(), vo.getOrderId())).findFirst().orElse(null);
CustomerDO customerDO = customerService.getById(vo.getCustomerId());
vo.setIsInOpenSea(Objects.isNull(customerDO) || Objects.isNull(customerDO.getIsInOpenSea()) ? false : customerDO.getIsInOpenSea());
vo.setYejiType(customerDO.getIsNew() ? 1 : 0);
// 没有该订单,该客户的未分配客户经理异常
ApplyInfoVO infoVO = null;
if (Objects.isNull(currentOrderException) && Objects.nonNull(customerDO) && Objects.nonNull(customerDO.getCustomerService()) && customerDO.getIsCustomerServiceConfirmed()) {
// 只有客户的客户经理被接收了才算有效
AdminUserRespDTO orgAdminUserRespDTO = adminUserApi.getUser(vo.getSalesmanId());
......@@ -2856,47 +2489,31 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (!Objects.equals(vo.getCustomerId(), orderConsignorBackVO.getCustomerId())) {
// 海外仓归属发货人
customerType = 1;
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
}
} else {
if (consignorDO != null && !consignorDO.getNoConsignee() && !vo.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(Objects.isNull(consignorDO) || Objects.isNull(consignorDO.getIsInOpenSea()) ? false : consignorDO.getIsInOpenSea());
vo.setYejiType(consignorDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else {
OrderAssociationOfferInfoEvent event = new OrderAssociationOfferInfoEvent(vo.getOrderId(), null);
applicationContext.publishEvent(event);
if (vo.getDrawee() == 1) {//发货人付款
if (vo.getDrawee() == 1 && event.getOfferId() != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(Objects.isNull(consignorDO) || Objects.isNull(consignorDO.getIsInOpenSea()) ? false : consignorDO.getIsInOpenSea());
vo.setYejiType(consignorDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (vo.getDrawee() == 1 && consignorDO.getDefaultPay()) {// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(Objects.isNull(consignorDO) || Objects.isNull(consignorDO.getIsInOpenSea()) ? false : consignorDO.getIsInOpenSea());
vo.setYejiType(consignorDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else {
vo.setCustomerId(orderConsigneeBackVO.getCustomerId() != null ? orderConsigneeBackVO.getCustomerId() : 0);
vo.setIsInOpenSea(Objects.isNull(consigneeDO) || Objects.isNull(consigneeDO.getIsInOpenSea()) ? false : consigneeDO.getIsInOpenSea());
vo.setYejiType(Objects.isNull(consigneeDO) || Objects.isNull(consigneeDO.getIsNew()) ? 1 : (consigneeDO.getIsNew() ? 1 : 0));
vo.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
customerType = 2;
}
} else if (vo.getDrawee() == 2) {//收货人付款 层级5 第一个
if (consigneeDO != null) {
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(Objects.isNull(consigneeDO.getIsInOpenSea()) ? false : consigneeDO.getIsInOpenSea());
vo.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
} else {
//没有收货人
vo.setCustomerId(0L);
vo.setSalesmanId(0L);
vo.setDeptId(0L);
customerType = 0;
}
} else if (vo.getDrawee() == 3) { //自定义付款
......@@ -2909,39 +2526,22 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
int clearanceFee = clearanceFeeList.get(0).getValue();//清关费
if (event.getOfferId() != null && (vo.getDrawee() == 3 && freight == 1)) {//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(Objects.isNull(consignorDO) || Objects.isNull(consignorDO.getIsInOpenSea()) ? false : consignorDO.getIsInOpenSea());
vo.setYejiType(consignorDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (event.getOfferId() != null && (vo.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(Objects.isNull(consignorDO) || Objects.isNull(consignorDO.getIsInOpenSea()) ? false : consignorDO.getIsInOpenSea());
vo.setYejiType(consignorDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (consignorDO.getDefaultPay() && (vo.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(Objects.isNull(consignorDO) || Objects.isNull(consignorDO.getIsInOpenSea()) ? false : consignorDO.getIsInOpenSea());
vo.setYejiType(consignorDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (consignorDO.getDefaultPay() && (vo.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(Objects.isNull(consignorDO) || Objects.isNull(consignorDO.getIsInOpenSea()) ? false : consignorDO.getIsInOpenSea());
vo.setYejiType(consignorDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else {
//去掉层级5、6 ,以上不符合的都归收货人
vo.setCustomerId(orderConsigneeBackVO.getCustomerId() != null ? orderConsigneeBackVO.getCustomerId() : 0);
vo.setIsInOpenSea(Objects.isNull(consigneeDO) || Objects.isNull(consigneeDO.getIsInOpenSea()) ? false : consigneeDO.getIsInOpenSea());
vo.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
customerType = 2;
}
}
} else {
//业绩归收货人
vo.setCustomerId(orderConsigneeBackVO.getCustomerId() != null ? orderConsigneeBackVO.getCustomerId() : 0);
vo.setIsInOpenSea(Objects.isNull(consigneeDO) || Objects.isNull(consigneeDO.getIsInOpenSea()) ? false : consigneeDO.getIsInOpenSea());
vo.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
vo.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
customerType = 2;
}
}
......@@ -3682,7 +3282,6 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus())
&& Objects.nonNull(updateObj.getIsChargeCustomer()) && updateObj.getIsChargeCustomer()) {
addOrderCustomerService(updateObj, customerType);
//setUpdateOrderCustomerServiceCustomerId(updateReqVO, updateObj,consignorDO,consigneeDO,orderConsignorDO,orderConsigneeDO);
}
}
}
......
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