Commit 0f8d1df6 authored by 332784038@qq.com's avatar 332784038@qq.com

Merge branch 'master-fix' into dev

parents dcf977b6 7c227ec3
......@@ -181,9 +181,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
// 没有则业绩属于公司客户,有则业绩归属于上个客户经理
CustomerOperateLogDO customerOperateLogDO =
customerOperateLogService.getOne(new LambdaQueryWrapper<CustomerOperateLogDO>()
.eq(CustomerOperateLogDO::getCustomerId, customerDO.getId())
.eq(CustomerOperateLogDO::getOperateType, 4) // TODO 暂定操作类型4为分配操作,有遗漏后面补充操作类型即可
.orderByDesc(CustomerOperateLogDO::getId).last("limit 1"));
.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();
}
......@@ -200,7 +200,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(order.getSalesmanId());
if (Objects.nonNull(adminUserRespDTO)) {
order.setDeptId(adminUserRespDTO.getDeptId());
}else {
} else {
order.setDeptId(0L);
}
} else if (CollectionUtil.isEmpty(orderExceptionDOList) &&
......@@ -1848,6 +1848,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
private void updateConsignorAndConsignee(OrderConsignorDO orderConsignorDO, OrderConsigneeDO
orderConsigneeDO, OrderDO orderDO, List<String> bugList) {
boolean flag = false;
CustomerDO consignorDO = null;
CustomerDO consigneeDO = null;
CustomerContactsDO consignorContactsDO = customerContactsService.getCustomerContacts(orderConsignorDO.getCustomerContactsId());
if (Objects.isNull(consignorContactsDO)) {
CustomerContactsDO newConsignorContactsDO = customerContactsService.getOne(new LambdaQueryWrapper<CustomerContactsDO>()
......@@ -1857,7 +1859,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
.orderByDesc(CustomerContactsDO::getId)
.last("limit 1"));
if (Objects.nonNull(newConsignorContactsDO)) {
CustomerDO consignorDO = customerService.getCustomer(newConsignorContactsDO.getCustomerId());
consignorDO = customerService.getCustomer(newConsignorContactsDO.getCustomerId());
log.info("订单【{}】,更新发货人联系人id-[{}]->[{}]和客户id-[{}]->[{}]",
orderDO.getOrderNo(), orderConsignorDO.getCustomerContactsId(), newConsignorContactsDO.getId(),
orderConsignorDO.getCustomerId(), newConsignorContactsDO.getCustomerId());
......@@ -1888,7 +1890,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
.orderByDesc(CustomerContactsDO::getId)
.last("limit 1"));
if (Objects.nonNull(newConsignorContactsDO)) {
CustomerDO consignorDO = customerService.getCustomer(newConsignorContactsDO.getCustomerId());
consignorDO = customerService.getCustomer(newConsignorContactsDO.getCustomerId());
log.info("订单【{}】,更新发货人联系人id-[{}]->[{}]和客户id-[{}]->[{}]",
orderDO.getOrderNo(), orderConsignorDO.getCustomerContactsId(), newConsignorContactsDO.getId(),
orderConsignorDO.getCustomerId(), newConsignorContactsDO.getCustomerId());
......@@ -1912,7 +1914,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
}
} else {
if (!Objects.equals(consignorContactsDO.getCustomerId(), orderConsignorDO.getCustomerId())) {
CustomerDO consignorDO = customerService.getCustomer(consignorContactsDO.getCustomerId());
consignorDO = customerService.getCustomer(consignorContactsDO.getCustomerId());
log.info("订单【{}】,更新发货人客户id-[{}]->[{}]",
orderDO.getOrderNo(), orderConsignorDO.getCustomerId(), consignorContactsDO.getCustomerId());
if (Objects.nonNull(consignorDO)) {
......@@ -1949,7 +1951,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
if (Objects.isNull(consigneeContactsDO)) {
CustomerContactsDO newConsigneeContactsDO = customerContactsService.getUniqueOneAndValidate(orderConsigneeDO.getCountryCode(), orderConsigneeDO.getPhone(), null);
if (Objects.nonNull(newConsigneeContactsDO)) {
CustomerDO consigneeDO = customerService.getCustomer(newConsigneeContactsDO.getCustomerId());
consigneeDO = customerService.getCustomer(newConsigneeContactsDO.getCustomerId());
log.info("订单【{}】,更新收货人联系人id-[{}]->[{}]和客户id-[{}]->[{}]",
orderDO.getOrderNo(), orderConsigneeDO.getCustomerContactsId(), newConsigneeContactsDO.getId(),
orderConsigneeDO.getCustomerId(), newConsigneeContactsDO.getCustomerId());
......@@ -1974,7 +1976,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
if (!StringUtils.equals(consigneeContactsDO.getPhoneNew(), orderConsigneeDO.getPhone())) {
CustomerContactsDO newConsigneeContactsDO = customerContactsService.getUniqueOneAndValidate(orderConsigneeDO.getCountryCode(), orderConsigneeDO.getPhone(), null);
if (Objects.nonNull(newConsigneeContactsDO)) {
CustomerDO consigneeDO = customerService.getCustomer(newConsigneeContactsDO.getCustomerId());
consigneeDO = customerService.getCustomer(newConsigneeContactsDO.getCustomerId());
log.info("订单【{}】,更新收货人联系人id-[{}]->[{}]和客户id-[{}]->[{}]",
orderDO.getOrderNo(), orderConsigneeDO.getCustomerContactsId(), newConsigneeContactsDO.getId(),
orderConsigneeDO.getCustomerId(), newConsigneeContactsDO.getCustomerId());
......@@ -1997,7 +1999,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
}
} else {
if (!Objects.equals(consigneeContactsDO.getCustomerId(), orderConsigneeDO.getCustomerId())) {
CustomerDO consigneeDO = customerService.getCustomer(consigneeContactsDO.getCustomerId());
consigneeDO = customerService.getCustomer(consigneeContactsDO.getCustomerId());
log.info("订单【{}】,更新收货人客户id-[{}]->[{}]",
orderDO.getOrderNo(), orderConsigneeDO.getCustomerId(), consigneeContactsDO.getCustomerId());
if (Objects.nonNull(consigneeDO)) {
......@@ -2019,9 +2021,10 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
orderDO.setCustomerId(orderConsignorDO.getCustomerId());
}
} else {
if (orderDO.getIsCargoControl()) {
if (consignorDO != null && !consignorDO.getNoConsignee() && !orderDO.getHasConsignee()) {
if (!Objects.equals(orderDO.getCustomerId(), orderConsignorDO.getCustomerId())) {
// 控货订单归属发货人
// 控货订单归属发货人->修改为发货人档案控货无收货人
orderDO.setCustomerId(orderConsignorDO.getCustomerId());
}
} else {
......@@ -2031,6 +2034,56 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
// 订单归属发货人
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())) {
// 控货订单归属收货人
......@@ -2040,17 +2093,24 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
}
}
}
if (Objects.nonNull(orderDO.getCustomerId()) && orderDO.getCustomerId() > 0) {
// 判断该订单、该客户是否有未分配客户异常,如果有,则这个订单不计算业绩
List<OrderExceptionDO> orderExceptionDOList =
orderExceptionService.getOrderExceptionByCustomerId(
orderDO.getCustomerId());
// 获取当前订单的异常
OrderExceptionDO currentOrderException = orderExceptionDOList.stream()
.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());
// 订单所属客户变更,则需要变更业绩归属
// 更新所属客户经理(业务员)
if (Objects.nonNull(customerDO) && Objects.nonNull(customerDO.getCustomerService()) && customerDO.getIsCustomerServiceConfirmed()) {
if (Objects.nonNull(customerDO) && Objects.nonNull(customerDO.getCustomerService()) && customerDO.getIsCustomerServiceConfirmed() && !customerDO.getIsInOpenSea()) {
log.info("订单【{}】,客户经理变动[{}]->[{}]", orderDO.getOrderNo(), orderDO.getSalesmanId(), customerDO.getCustomerService());
orderDO.setSalesmanId(customerDO.getCustomerService());
orderDO.setSalesmanId(customerDO.getIsInOpenSea() ? 0L : customerDO.getCustomerService());
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(customerDO.getCustomerService());
if (Objects.nonNull(adminUserRespDTO)) {
orderDO.setDeptId(adminUserRespDTO.getDeptId());
}else {
} else {
orderDO.setDeptId(0L);
}
} else {
......@@ -2667,8 +2727,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
List<OrderItemDO> listItem = orderItemMapper.selectList(q1);
if (CollectionUtil.isEmpty(listItem) == true) return;
for (OrderItemDO o:listItem
) {
for (OrderItemDO o : listItem
) {
}
......@@ -3436,9 +3496,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
//计价体积
param.setChargeVolume(
Objects.nonNull(orderItemDO.getWarehouseInInfoVO()) ?
orderItemDO.getChargeVolume() :
orderItemDO.getChargeVolume() :
(Objects.equals(orderDO.getStatus(), OrderStatusEnum.DRAFT.getValue()) ||
Objects.equals(orderDO.getStatus(),OrderStatusEnum.ORDER_PLACED.getValue()) ? orderItemDO.getVolume() : null)
Objects.equals(orderDO.getStatus(), OrderStatusEnum.ORDER_PLACED.getValue()) ? orderItemDO.getVolume() : null)
);
param.setChargeQuantity(Objects.nonNull(orderItemDO.getWarehouseInInfoVO()) ?
......
......@@ -668,93 +668,6 @@ 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 (Objects.nonNull(order.getType()) && order.getType().contains("2")) {
// // 海外仓归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
//
//
// // 补充业绩规则判断
// if(!consignorCustomerDO.getNoConsignee() && !order.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
// order.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else{
// if (order.getDrawee() == 1) {//发货人付款
// if (order.getDrawee() == 1 && createReqVO.getOfferId()!=null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService()!=null?consignorCustomerDO.getCustomerService():0);
// }else if(order.getDrawee() == 1 && consignorCustomerDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else{
// order.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }
// } else if (order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
// if(orderConsigneeDO!=null){
// order.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }else{
// 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.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else if(consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else if (consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
//
// }else {
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// }
//
//// if(!consignorCustomerDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
//// order.setCustomerId(orderConsigneeDO.getCustomerId());
//// if(orderConsignorDO!=null){
//// order.setCustomerId(orderConsigneeDO.getCustomerId());
////
//// }else{
////
//// order.setSalesmanId(0L);
//// }
////
////
//// }
//
// }
//
// } else {
// //业绩归属公司
// order.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }
// }
//
//
//
//
//
// }//end
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
......@@ -1023,7 +936,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {
// 海外仓归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
} else {
if (consignorDO != null && !consignorDO.getNoConsignee() &&
......@@ -1033,7 +946,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
}
} else {
......@@ -1049,19 +962,19 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 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.getCustomerService());
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(consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0);
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
}
} else if (order.getDrawee() == 2) {
//收货人付款 层级5 第一个
......@@ -1069,7 +982,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consigneeDO.getCustomerService());
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService()));
} else {
order.setCustomerId(0L);
order.setSalesmanId(0L);
......@@ -1090,45 +1003,31 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getCustomerService());
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.getCustomerService());
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.getCustomerService());
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.getCustomerService());
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(consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0);
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
}
// if(!consignorDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// if(consigneeDO!=null){
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// order.setSalesmanId(consigneeDO.getCustomerService());
// }else{
//
// order.setSalesmanId(0L);
// }
//
//
// }
}
} else {
......@@ -1136,7 +1035,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0);
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
}
}
......@@ -1157,14 +1056,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
//层级1
// 海外仓归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0);
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.getCustomerService() != null ? consignorDO.getCustomerService() : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
}
} else {
......@@ -1176,32 +1075,29 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 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.getCustomerService());
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(consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0);
// order.setCustomerId(0L);
// order.setSalesmanId(0L);
order.setSalesmanId(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(consigneeDO.getCustomerService());
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : consigneeDO.getCustomerService());
} else {
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
// order.setSalesmanId(0L);
}
} else if (order.getDrawee() == 3) {
//自定义付款
......@@ -1220,31 +1116,31 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getCustomerService());
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.getCustomerService());
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.getCustomerService());
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.getCustomerService());
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(consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0);
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
}
......@@ -1255,7 +1151,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0);
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
}
}
......@@ -1284,7 +1180,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
customerType = 1;
} else {
if (consignorDO != null && !consignorDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
......@@ -1292,7 +1188,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
customerType = 1;
}
......@@ -1305,37 +1201,34 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null ? consignorDO.getCustomerService() : 0));
customerType = 1;
} 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.getCustomerService());
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
customerType = 1;
} else {
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0);
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
customerType = 2;
// order.setCustomerId(0L);
// order.setSalesmanId(0L);
}
} 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(consigneeDO.getCustomerService());
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : consigneeDO.getCustomerService());
customerType = 1;
} else {
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
customerType = 0;
// order.setSalesmanId(0L);
}
} else if (order.getDrawee() == 3) { //自定义付款
......@@ -1352,27 +1245,27 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getCustomerService());
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
customerType = 1;
} 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.getCustomerService());
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
customerType = 1;
} 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.getCustomerService());
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
customerType = 1;
} 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.getCustomerService());
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : consignorDO.getCustomerService());
customerType = 1;
} else {
......@@ -1380,7 +1273,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0);
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
customerType = 2;
......@@ -1393,7 +1286,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0);
order.setSalesmanId(consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null ? consigneeDO.getCustomerService() : 0));
customerType = 2;
}
......@@ -1444,6 +1337,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
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()) ||
......@@ -1454,9 +1349,13 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
//if (order.getUserId() != null && order.getUserId() > 0 && customerType == 2) {
if (order.getUserId() != null && order.getUserId() > 0
&& order.getSalesmanId() != null && order.getSalesmanId() > 0) {
//order.setSalesmanId(0L);
addOrderSalesmanCustomerService(createReqVO, order);
order.setDeptId(0L);
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 {
// 只有客户的客户经理为空时
......@@ -3087,20 +2986,20 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
} else {
if (vo.getIsCargoControl()) {
if (!Objects.equals(vo.getCustomerId(),
orderConsignorBackVO.getCustomerId())) {
// 控货订单归属发货人
customerType = 1;
CustomerDO orgCustomerDO = customerService.getCustomer(vo.getCustomerId());
CustomerDO newCustomerDO = customerService.getCustomer(orderConsignorBackVO.getCustomerId());
infoVO = new ApplyInfoVO();
infoVO.setName("新规则,控货订单客户归属不变动/Change in customer ownership for orders");
// 出掉控货改变业绩归属的逻辑点
//infoVO.setOrgValue(Objects.nonNull(orgCustomerDO) ? ((StringUtils.isNotBlank(orgCustomerDO.getName()) ? orgCustomerDO.getName() : "无") + "/" + (StringUtils.isNotBlank(orgCustomerDO.getNameEn()) ? orgCustomerDO.getNameEn() : "empty")) : "无/not have");
//infoVO.setNewValue(Objects.nonNull(newCustomerDO) ? ((StringUtils.isNotBlank(newCustomerDO.getName()) ? newCustomerDO.getName() : "无") + "/" + (StringUtils.isNotBlank(newCustomerDO.getNameEn()) ? newCustomerDO.getNameEn() : "empty")) : "无/not have");
//vo.setCustomerId(orderConsignorBackVO.getCustomerId());
return;
}
// if (!Objects.equals(vo.getCustomerId(),
// orderConsignorBackVO.getCustomerId())) {
// // 控货订单归属发货人
// customerType = 1;
// CustomerDO orgCustomerDO = customerService.getCustomer(vo.getCustomerId());
// CustomerDO newCustomerDO = customerService.getCustomer(orderConsignorBackVO.getCustomerId());
// infoVO = new ApplyInfoVO();
// infoVO.setName("新规则,控货订单客户归属不变动/Change in customer ownership for orders");
// // 出掉控货改变业绩归属的逻辑点
// //infoVO.setOrgValue(Objects.nonNull(orgCustomerDO) ? ((StringUtils.isNotBlank(orgCustomerDO.getName()) ? orgCustomerDO.getName() : "无") + "/" + (StringUtils.isNotBlank(orgCustomerDO.getNameEn()) ? orgCustomerDO.getNameEn() : "empty")) : "无/not have");
// //infoVO.setNewValue(Objects.nonNull(newCustomerDO) ? ((StringUtils.isNotBlank(newCustomerDO.getName()) ? newCustomerDO.getName() : "无") + "/" + (StringUtils.isNotBlank(newCustomerDO.getNameEn()) ? newCustomerDO.getNameEn() : "empty")) : "无/not have");
// //vo.setCustomerId(orderConsignorBackVO.getCustomerId());
// return;
// }
} else {
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
if (vo.getDrawee() == 1) {
......
......@@ -171,6 +171,7 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
targetLogDO.setOrderId(orderId);
targetLogDO.setCustomerId(info.getCustomerId());
targetLogDO.setUserId(Objects.isNull(info.getSalesmanId()) ? 0L : info.getSalesmanId());
targetLogDO.setDeptId(Objects.isNull(info.getDeptId()) ? 0L : info.getDeptId());
targetLogDO.setAchievementTime(achievementTime);
if (info.getTransportId() == 3) {
targetLogDO.setLdBoxTime(achievementTime);
......
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