Commit 77a01927 authored by 332784038@qq.com's avatar 332784038@qq.com

Merge branch 'master-fix' into dev

parents e52ba1b6 b5583399
package cn.iocoder.yudao.framework.apollo.core.event;
import cn.iocoder.yudao.framework.common.validation.Marks;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
@AllArgsConstructor
public class OrderAssociationOfferInfoEvent {
/**
* 订单ID
*/
private Long orderId;
@ApiModelProperty(value = "主键ID", required = true)
private Long offerId;
}
...@@ -2012,7 +2012,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2012,7 +2012,9 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
} }
} }
checkOrderSalesman(orderDO,null,consignorDO,consigneeDO,orderConsignorDO,orderConsigneeDO); OrderAssociationOfferInfoEvent event = new OrderAssociationOfferInfoEvent(orderDO.getOrderId(), null);
applicationContext.publishEvent(event);
checkOrderSalesman(orderDO, event.getOfferId(), consignorDO, consigneeDO, orderConsignorDO, orderConsigneeDO);
// if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.DRAFT.getValue())) { // if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
// if (StringUtils.isNotBlank(orderDO.getType()) && orderDO.getType().contains("2")) { // if (StringUtils.isNotBlank(orderDO.getType()) && orderDO.getType().contains("2")) {
...@@ -2120,6 +2122,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2120,6 +2122,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
} }
orderMapper.updateById(orderDO); orderMapper.updateById(orderDO);
} }
public int checkOrderSalesman(OrderDO order, Long offerId, CustomerDO consignorDO, CustomerDO consigneeDO, OrderConsignorDO orderConsignorDO, OrderConsigneeDO orderConsigneeDO) { public int checkOrderSalesman(OrderDO order, Long offerId, CustomerDO consignorDO, CustomerDO consigneeDO, OrderConsignorDO orderConsignorDO, OrderConsigneeDO orderConsigneeDO) {
int customerType = 1; //1-业绩归属发货人,2-业绩归属收货人 int customerType = 1; //1-业绩归属发货人,2-业绩归属收货人
if (Objects.isNull(orderConsigneeDO)) {//订单收货人 if (Objects.isNull(orderConsigneeDO)) {//订单收货人
...@@ -2144,30 +2147,30 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2144,30 +2147,30 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else { } else {
if (consignorDO != null && !consignorDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2 if (consignorDO != null && !consignorDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else { } else {
if (order.getDrawee() == 1) {//发货人付款 if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && offerId != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个 if (order.getDrawee() == 1 && offerId != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (order.getDrawee() == 1 && consignorDO.getDefaultPay()) {// 如果是发货人付款且档案设置默认付运费 --层级4 第一个 } else if (order.getDrawee() == 1 && consignorDO.getDefaultPay()) {// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else { } else {
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0); order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea()); order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0); order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0)); order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
customerType = 2; customerType = 2;
} }
} else if (order.getDrawee() == 2) {//收货人付款 层级5 第一个 } else if (order.getDrawee() == 2) {//收货人付款 层级5 第一个
...@@ -2175,7 +2178,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2175,7 +2178,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
order.setCustomerId(orderConsigneeDO.getCustomerId()); order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setIsInOpenSea(consigneeDO.getIsInOpenSea()); order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0); order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0)); order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
} else { } else {
//没有收货人 //没有收货人
order.setCustomerId(0L); order.setCustomerId(0L);
...@@ -2194,29 +2197,29 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2194,29 +2197,29 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (offerId != null && (order.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费 } else if (offerId != null && (order.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人 } else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人 } else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else { } else {
//去掉层级5、6 ,以上不符合的都归收货人 //去掉层级5、6 ,以上不符合的都归收货人
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0); order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea()); order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0); order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0)); order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
customerType = 2; customerType = 2;
} }
} }
...@@ -2225,7 +2228,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order ...@@ -2225,7 +2228,7 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0); order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea()); order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0); order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0)); order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
customerType = 2; customerType = 2;
} }
} }
......
...@@ -1186,30 +1186,30 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -1186,30 +1186,30 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else { } else {
if (consignorDO != null && !consignorDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2 if (consignorDO != null && !consignorDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else { } else {
if (order.getDrawee() == 1) {//发货人付款 if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && offerId != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个 if (order.getDrawee() == 1 && offerId != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (order.getDrawee() == 1 && consignorDO.getDefaultPay()) {// 如果是发货人付款且档案设置默认付运费 --层级4 第一个 } else if (order.getDrawee() == 1 && consignorDO.getDefaultPay()) {// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else { } else {
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0); order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea()); order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0); order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0)); order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
customerType = 2; customerType = 2;
} }
} else if (order.getDrawee() == 2) {//收货人付款 层级5 第一个 } else if (order.getDrawee() == 2) {//收货人付款 层级5 第一个
...@@ -1217,7 +1217,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -1217,7 +1217,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsigneeDO.getCustomerId()); order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setIsInOpenSea(consigneeDO.getIsInOpenSea()); order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0); order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0)); order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
} else { } else {
//没有收货人 //没有收货人
order.setCustomerId(0L); order.setCustomerId(0L);
...@@ -1236,29 +1236,29 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -1236,29 +1236,29 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (offerId != null && (order.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费 } else if (offerId != null && (order.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人 } else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人 } else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId()); order.setCustomerId(orderConsignorDO.getCustomerId());
order.setIsInOpenSea(consignorDO.getIsInOpenSea()); order.setIsInOpenSea(consignorDO.getIsInOpenSea());
order.setYejiType(consignorDO.getIsNew() ? 1 : 0); order.setYejiType(consignorDO.getIsNew() ? 1 : 0);
order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed()? consignorDO.getCustomerService() : 0)); order.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
} else { } else {
//去掉层级5、6 ,以上不符合的都归收货人 //去掉层级5、6 ,以上不符合的都归收货人
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0); order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea()); order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0); order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0)); order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
customerType = 2; customerType = 2;
} }
} }
...@@ -1267,7 +1267,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -1267,7 +1267,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0); order.setCustomerId(orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() : 0);
order.setIsInOpenSea(consigneeDO.getIsInOpenSea()); order.setIsInOpenSea(consigneeDO.getIsInOpenSea());
order.setYejiType(consigneeDO.getIsNew() ? 1 : 0); order.setYejiType(consigneeDO.getIsNew() ? 1 : 0);
order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed()? consigneeDO.getCustomerService() : 0)); order.setSalesmanId(Objects.nonNull(consigneeDO.getIsInOpenSea()) && consigneeDO.getIsInOpenSea() ? 0L : (consigneeDO.getCustomerService() != null && consigneeDO.getIsCustomerServiceConfirmed() ? consigneeDO.getCustomerService() : 0));
customerType = 2; customerType = 2;
} }
} }
...@@ -2146,27 +2146,30 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -2146,27 +2146,30 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 比较发货人信息 // 比较发货人信息
CustomerContactsDO consignorContactsDO = customerContactsService.getCustomerContacts(updateReqVO.getConsignorContactsId()); CustomerContactsDO consignorContactsDO = customerContactsService.getCustomerContacts(updateReqVO.getConsignorContactsId());
OrderConsignorBackVO orderConsignorBackVO = vo.getConsignorVO(); OrderConsignorBackVO orderConsignorBackVO = vo.getConsignorVO();
CustomerDO consignorDO = null;
if (Objects.nonNull(consignorContactsDO)) { if (Objects.nonNull(consignorContactsDO)) {
consignorDO = customerService.getById(updateReqVO.getConsignorId());
this.compareConsignorInfo(updateReqVO, consignorContactsDO, orderConsignorBackVO, applyInfoList, vo); this.compareConsignorInfo(updateReqVO, consignorContactsDO, orderConsignorBackVO, applyInfoList, vo);
} }
vo.setConsignorVO(orderConsignorBackVO); vo.setConsignorVO(orderConsignorBackVO);
// 比较收货人信息 // 比较收货人信息
CustomerContactsDO consigneeContactsDO = customerContactsService.getCustomerContacts(updateReqVO.getConsigneeContactsId()); CustomerContactsDO consigneeContactsDO = customerContactsService.getCustomerContacts(updateReqVO.getConsigneeContactsId());
OrderConsigneeBackVO orderConsigneeBackVO = vo.getConsigneeVO(); OrderConsigneeBackVO orderConsigneeBackVO = vo.getConsigneeVO();
CustomerDO consigneeDO = null;
if (Objects.isNull(consigneeContactsDO)) { if (Objects.isNull(consigneeContactsDO)) {
//todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码 //todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码
CustomerDO consignorCustomerDO = customerService.getById(updateReqVO.getConsignorId()); consigneeDO = customerService.getById(updateReqVO.getConsignorId());
// 客户不存在,新增客户联系人信息 orderConsigneeDO中有值 // 客户不存在,新增客户联系人信息 orderConsigneeDO中有值
// 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。 // 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。
// 有客户经理,则暂时不生成客户档案。(放在入仓时处理) // 有客户经理,则暂时不生成客户档案。(放在入仓时处理)
if (consignorCustomerDO == null || consignorCustomerDO.getCustomerService() == null || consignorCustomerDO.getCustomerService() == 0) { if (consigneeDO == null || consigneeDO.getCustomerService() == null || consigneeDO.getCustomerService() == 0) {
consigneeContactsDO = customerService.createConsigeeCustomer( consigneeContactsDO = customerService.createConsigeeCustomer(
orderConsigneeBackVO.getName(), orderConsigneeBackVO.getName(),
orderConsigneeBackVO.getCountryCode(), orderConsigneeBackVO.getCountryCode(),
orderConsigneeBackVO.getPhone(), orderConsigneeBackVO.getPhone(),
orderConsigneeBackVO.getCompany(), orderConsigneeBackVO.getCompany(),
orderConsigneeBackVO.getEmail(), orderConsigneeBackVO.getEmail(),
consignorCustomerDO, vo.getOrderNo()); consigneeDO, vo.getOrderNo());
} }
} }
if (Objects.nonNull(consigneeContactsDO)) { if (Objects.nonNull(consigneeContactsDO)) {
...@@ -2185,7 +2188,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -2185,7 +2188,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
} }
Date expireTime = DateUtil.offsetDay(warehouseInDO.getInTime(), 3); Date expireTime = DateUtil.offsetDay(warehouseInDO.getInTime(), 3);
if (expireTime.compareTo(new Date()) >= 0) { if (expireTime.compareTo(new Date()) >= 0) {
this.comparePerformanceAttribution(vo, applyInfoList, orderConsignorBackVO, orderConsigneeBackVO); this.comparePerformanceAttribution(vo, applyInfoList, orderConsignorBackVO, orderConsigneeBackVO, consignorDO, consigneeDO);
} else { } else {
ApplyInfoVO infoVO = new ApplyInfoVO(); ApplyInfoVO infoVO = new ApplyInfoVO();
infoVO.setName("入仓时间超过三天,订单的业绩归属客户不再变动/If the warehouse entry time exceeds three days, the performance of the order will no longer be attributed to the customer"); infoVO.setName("入仓时间超过三天,订单的业绩归属客户不再变动/If the warehouse entry time exceeds three days, the performance of the order will no longer be attributed to the customer");
...@@ -2809,8 +2812,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -2809,8 +2812,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
private void comparePerformanceAttribution(OrderBackVO vo, private void comparePerformanceAttribution(OrderBackVO vo,
List<ApplyInfoVO> applyInfoList, List<ApplyInfoVO> applyInfoList,
OrderConsignorBackVO orderConsignorBackVO, OrderConsignorBackVO orderConsignorBackVO,
OrderConsigneeBackVO orderConsigneeBackVO) { OrderConsigneeBackVO orderConsigneeBackVO,
CustomerDO consignorDO,
CustomerDO consigneeDO) {
// 原客户经理
Long orgCustomerId = Objects.isNull(vo.getCustomerId()) ? 0L : vo.getCustomerId(); Long orgCustomerId = Objects.isNull(vo.getCustomerId()) ? 0L : vo.getCustomerId();
CustomerDO orgCustomerDO = customerService.getCustomer(vo.getCustomerId());
// TODO 客户归属变动时记录日志 // TODO 客户归属变动时记录日志
if (!Objects.equals(vo.getStatus(), OrderStatusEnum.DRAFT.getValue())) { if (!Objects.equals(vo.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
ApplyInfoVO infoVO = null; ApplyInfoVO infoVO = null;
...@@ -2819,63 +2828,98 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -2819,63 +2828,98 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (!Objects.equals(vo.getCustomerId(), orderConsignorBackVO.getCustomerId())) { if (!Objects.equals(vo.getCustomerId(), orderConsignorBackVO.getCustomerId())) {
// 海外仓归属发货人 // 海外仓归属发货人
customerType = 1; 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()); vo.setCustomerId(orderConsignorBackVO.getCustomerId());
} }
} else { } else {
if (vo.getIsCargoControl()) { if (consignorDO != null && !consignorDO.getNoConsignee() && !vo.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
// if (!Objects.equals(vo.getCustomerId(), vo.setCustomerId(orderConsignorBackVO.getCustomerId());
// orderConsignorBackVO.getCustomerId())) { vo.setIsInOpenSea(consignorDO.getIsInOpenSea());
// // 控货订单归属发货人 vo.setYejiType(consignorDO.getIsNew() ? 1 : 0);
// customerType = 1; vo.setSalesmanId(consignorDO.getIsInOpenSea() ? 0L : (consignorDO.getCustomerService() != null && consignorDO.getIsCustomerServiceConfirmed() ? consignorDO.getCustomerService() : 0));
// 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 { } else {
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人 OrderAssociationOfferInfoEvent event = new OrderAssociationOfferInfoEvent(vo.getOrderId(), null);
if (vo.getDrawee() == 1) { applicationContext.publishEvent(event);
if (!Objects.equals(vo.getCustomerId(), orderConsignorBackVO.getCustomerId())) { if (vo.getDrawee() == 1) {//发货人付款
// 订单归属发货人 if (vo.getDrawee() == 1 && event.getOfferId() != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
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()); vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(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(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(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 if (vo.getDrawee() == 2) {//收货人付款 层级5 第一个
if (consigneeDO != null) {
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(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 { } else {
if (!Objects.equals(vo.getCustomerId(), orderConsigneeBackVO.getCustomerId())) { //没有收货人
// 控货订单归属收货人 vo.setCustomerId(0L);
vo.setSalesmanId(0L);
customerType = 0;
}
} else if (vo.getDrawee() == 3) { //自定义付款
List<CustomDraweeVO> list = JSONObject.parseArray(vo.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 (event.getOfferId() != null && (vo.getDrawee() == 3 && freight == 1)) {//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
vo.setCustomerId(orderConsignorBackVO.getCustomerId());
vo.setIsInOpenSea(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(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(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(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(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; customerType = 2;
CustomerDO orgCustomerDO = customerService.getCustomer(vo.getCustomerId());
CustomerDO newCustomerDO = customerService.getCustomer(orderConsigneeBackVO.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(orderConsigneeBackVO.getCustomerId());
} }
} }
} else {
//业绩归收货人
vo.setCustomerId(orderConsigneeBackVO.getCustomerId() != null ? orderConsigneeBackVO.getCustomerId() : 0);
vo.setIsInOpenSea(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;
} }
} }
vo.setCustomerType(customerType);
if (infoVO != null) {
applyInfoList.add(infoVO);
} }
vo.setCustomerType(customerType);
// 订单所属客户变更,则需要变更业绩归属 // 订单所属客户变更,则需要变更业绩归属
// 更新所属客户经理(业务员) // 更新所属客户经理(业务员)
// if ((Objects.nonNull(vo.getCustomerId()) && vo.getCustomerId() > 0L) || // if ((Objects.nonNull(vo.getCustomerId()) && vo.getCustomerId() > 0L) ||
...@@ -2883,6 +2927,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -2883,6 +2927,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 订单修改是否变动了归属客户,此字段用来判定订单是否需要重置归属客户经理,下单后归属客户的客户经理是固定的,除非订单归属客户变动,才需要重置客户经理 // 订单修改是否变动了归属客户,此字段用来判定订单是否需要重置归属客户经理,下单后归属客户的客户经理是固定的,除非订单归属客户变动,才需要重置客户经理
vo.setIsChargeCustomer(!Objects.equals(vo.getCustomerId(), orgCustomerId)); vo.setIsChargeCustomer(!Objects.equals(vo.getCustomerId(), orgCustomerId));
if (!Objects.equals(vo.getCustomerId(), orgCustomerId)) { if (!Objects.equals(vo.getCustomerId(), orgCustomerId)) {
CustomerDO newCustomerDO = customerService.getCustomer(vo.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");
applyInfoList.add(infoVO);
compareOrderCustomerService(vo, applyInfoList, customerType); compareOrderCustomerService(vo, applyInfoList, customerType);
} }
} }
...@@ -3363,86 +3413,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -3363,86 +3413,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
null, null,
orderConsignorDO, orderConsignorDO,
orderConsigneeDO); orderConsigneeDO);
// if (Objects.nonNull(updateObj.getType()) && updateObj.getType().contains("2")) {
// // 海外仓归属发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
//// if (updateObj.getIsCargoControl()) {
//// // 控货订单归属发货人
//// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
//// } else {
// // 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
//// if (updateObj.getDrawee() == 1) {
//// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
//// } else {
//// customerType = 2;
//// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
//// }
//
// // 补充业绩规则判断
// if(!consignorCustomerDO.getNoConsignee() && !updateObj.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else{
// // 补充业绩规则判断
// if (updateObj.getDrawee() == 1) {//发货人付款
// if (updateObj.getDrawee() == 1 && updateReqVO.getOfferId() != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else if(updateObj.getDrawee() == 1 && consignorCustomerDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else{
// //不符合的,业绩归属收货人
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0) ;
//
// }
// } else if (updateObj.getDrawee() == 2) {//收货人付款 层级5 第一个
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId()) ;
// } else if (updateObj.getDrawee() == 3) { //自定义付款
//
// List<CustomDraweeVO> list = JSONObject.parseArray(updateObj.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(updateReqVO.getOfferId()!=null && ( updateObj.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else if(updateReqVO.getOfferId()!=null && ( updateObj.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else if(consignorCustomerDO.getDefaultPay() && ( updateObj.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else if (consignorCustomerDO.getDefaultPay() && ( updateObj.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else {
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
// }
// //去掉层级5、6 ,其他情况的都归收货人
//// if(!consignorDO.getDefaultPay() && (updateObj.getDrawee()==3 && freight==2 ) || (updateObj.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
//// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
//// }
//
// }
//
// } else {
// //业绩归属收获人
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }
// }
//
//
//
//
//
//
//
// }
// 更新所属客户经理(业务员) // 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus()) if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus())
&& Objects.nonNull(updateObj.getCustomerId()) && && Objects.nonNull(updateObj.getIsChargeCustomer()) && updateObj.getIsChargeCustomer()) {
updateObj.getCustomerId() > 0) {
addOrderCustomerService(updateObj, customerType); addOrderCustomerService(updateObj, customerType);
} }
} }
......
...@@ -592,6 +592,23 @@ public class OrderBackVO { ...@@ -592,6 +592,23 @@ public class OrderBackVO {
private Boolean isChargeCustomer; private Boolean isChargeCustomer;
@ApiModelProperty(value = "客户业绩类型:1 新客户业绩 0老客户业绩")
private Integer yejiType;
/*
业绩产生时间
*/
private Date yejiCreateDate;
/*
海运根据体积计算出的V值,空运根据重量计算出的V值
*/
private BigDecimal calVValue;
@ApiModelProperty(value = "是否有收货人,1-是,0-否")
private Boolean hasConsignee = true;
public void setExternalWarehouseJson(String externalWarehouseJson) { public void setExternalWarehouseJson(String externalWarehouseJson) {
this.externalWarehouseJson = externalWarehouseJson; this.externalWarehouseJson = externalWarehouseJson;
if (StringUtils.isNotBlank(externalWarehouseJson)) { if (StringUtils.isNotBlank(externalWarehouseJson)) {
......
...@@ -3,11 +3,14 @@ package cn.iocoder.yudao.module.sale.listener; ...@@ -3,11 +3,14 @@ package cn.iocoder.yudao.module.sale.listener;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.apollo.core.event.OrderAssociationOfferCostEvent; import cn.iocoder.yudao.framework.apollo.core.event.OrderAssociationOfferCostEvent;
import cn.iocoder.yudao.framework.apollo.core.event.OrderAssociationOfferInfoEvent;
import cn.iocoder.yudao.module.product.dto.FeeDto; import cn.iocoder.yudao.module.product.dto.FeeDto;
import cn.iocoder.yudao.module.product.enums.FeeTypeEnum; import cn.iocoder.yudao.module.product.enums.FeeTypeEnum;
import cn.iocoder.yudao.module.sale.service.offer.OfferService; import cn.iocoder.yudao.module.sale.service.offer.OfferService;
import cn.iocoder.yudao.module.sale.vo.offer.EstCostVO; import cn.iocoder.yudao.module.sale.vo.offer.EstCostVO;
import cn.iocoder.yudao.module.sale.vo.offer.OfferRespVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -53,4 +56,17 @@ public class OrderAssociationOfferListener { ...@@ -53,4 +56,17 @@ public class OrderAssociationOfferListener {
} }
} }
} }
/**
* 根据订单id查询关联报价单信息
*
* @param event 参数与返回值
*/
@EventListener(OrderAssociationOfferInfoEvent.class)
public void selectOfferInfoByOrderId(OrderAssociationOfferInfoEvent event) {
OfferRespVO offerRespVO = offerService.getOfferByOrderId(event.getOrderId());
if (Objects.nonNull(offerRespVO)) {
event.setOfferId(offerRespVO.getOfferId());
}
}
} }
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