Commit 675de447 authored by liuzeheng's avatar liuzeheng

Merge branch 'master' into dev

# Conflicts:
#	yudao-module-customer/yudao-module-customer-rest/src/main/java/cn/iocoder/yudao/module/customer/controller/admin/customer/CustomerController.java
#	yudao-module-delivery/yudao-module-delivery-rest/src/main/java/cn/iocoder/yudao/module/delivery/listener/CalculateOrderVValueListener.java
#	yudao-module-delivery/yudao-module-delivery-rest/src/main/java/cn/iocoder/yudao/module/delivery/listener/CalculateOrderYeJiTypeListener.java
#	yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/service/order/impl/OrderServiceImpl.java
#	yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/service/orderWarehouseIn/OrderWarehouseInServiceImpl.java
parents 4529299b 9cbc7658
......@@ -1360,7 +1360,6 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper, Custome
@Override
public PageResult<CustomerDO> getWaitToConfirmCustomerPage(CustomerPageReqVO pageReqVO) {
IPage<CustomerDO> mpPage = MyBatisUtils.buildPage(pageReqVO);
LambdaQueryWrapper<CustomerDO> customerDOLambdaQueryWrapperX = new LambdaQueryWrapperX<CustomerDO>()
......
......@@ -365,10 +365,11 @@ public class CustomerController {
@ApiOperation("获得待接收列表")
// @PreAuthorize("@ss.hasPermission('ecw:customer:query')")
public CommonResult<PageResult<CustomerRespVO>> getWaitConfirmList(@Valid CustomerPageReqVO customerPageReqVO) {
//lanbm 2024-05-26 添加注释
customerPageReqVO.setCustomerService(WebFrameworkUtils.getLoginUserId());
PageResult<CustomerDO> pageResult = customerService.getWaitToConfirmCustomerPage(customerPageReqVO);
PageResult<CustomerDO> pageResult =
customerService.getWaitToConfirmCustomerPage(customerPageReqVO);
return success(CustomerConvert.INSTANCE.convertPage(pageResult));
}
......@@ -398,9 +399,10 @@ public class CustomerController {
@GetMapping("/get-wait-for-distribution")
@ApiOperation("获得待分配客户列表")
// @PreAuthorize("@ss.hasPermission('ecw:customer:query')")
public CommonResult<PageResult<CustomerRespVO>> getWaitForDistributionList(@Valid CustomerPageReqDTO customerPageReqVO,PageVO page) {
PageResult<CustomerDO> pageResult = customerService.getWaitToAssignedCustomerPageReq(customerPageReqVO,page);
public CommonResult<PageResult<CustomerRespVO>> getWaitForDistributionList(@Valid CustomerPageReqVO customerPageReqVO) {
//lanbm 2024-05-26 添加注释
PageResult<CustomerDO> pageResult =
customerService.getWaitToAssignedCustomerPage(customerPageReqVO);
return success(CustomerConvert.INSTANCE.convertPage(pageResult));
}
......
......@@ -24,7 +24,7 @@ import static cn.iocoder.yudao.module.delivery.enums.ErrorCodeConstants.VCONFIG_
/*
计算订单V值计算 海运已装柜,空运已入仓 计算V值
lanbm 2024-05-13 add
lanbm 2024-05-26 update
*/
@Component("CalculateOrderVValueListener")
@AllArgsConstructor
......@@ -65,7 +65,7 @@ public class CalculateOrderVValueListener {
EcwVz temp = null;
BigDecimal CalVvalue = new BigDecimal(0);
if (orderDO.getTransportId() == 1) {
//海运计算V值
//海运计算V值 修改查询条件
temp = ecwVzService.getOne(new LambdaQueryWrapperX<EcwVz>()
.eqIfPresent(EcwVz::getFuhao, "M3"));
if (temp == null) {
......@@ -78,7 +78,7 @@ public class CalculateOrderVValueListener {
CalVvalue = new BigDecimal(temp.getVz()).divide(orderDO.getSumVolume());
}
} else if (orderDO.getTransportId() == 3) {
//空运计算V值
//空运计算V值,修改查询条件
temp = ecwVzService.getOne(new LambdaQueryWrapperX<EcwVz>()
.eqIfPresent(EcwVz::getFuhao, "KG"));
if (temp == null) {
......
......@@ -44,33 +44,37 @@ public class CalculateOrderYeJiTypeListener {
public void CalculateOrderYeJiTypePushEvent(
CalculateOrderYeJiTypeEvent event) {
zTest m=new zTest();
String sMsg="计算业绩类型"+event.getCustomerId();
zTest m = new zTest();
String sMsg = "计算业绩类型" + event.getCustomerId();
OrderDO orderDO = orderService.getById(event.getOrderId());
if (orderDO == null) {
throw exception(ORDER_NOT_EXISTS);
}
//获取订单中计算号的业绩归属客户ID
event.setCustomerId(orderDO.getCustomerId());
CustomerDO customerDO = customerService.getById(event.getCustomerId());
if (customerDO == null) {
//throw exception(CUSTOMER_NOT_EXISTS);
sMsg+=",客户不存在先不计算业绩类型";
//lanbm 2024-05-27 添加的逻辑细化
orderService.UpdateOrderYeJiType(event.getOrderId(), 0);
sMsg += ",客户不存,订单业绩属于公司,订单算老业绩";
m.setTestname(sMsg);
m.setCreatedate(new Date());
zTestService.save(m);
return;
}
int isNew = 0;
if (customerDO.getIsNew() == true) {
isNew = 1;//新客户业绩类型
sMsg+=",新业绩";
}
else {
sMsg += ",新业绩";
} else {
isNew = 0;//老客户业绩类型
sMsg+=",老业绩";
sMsg += ",老业绩";
}
orderService.UpdateOrderYeJiType(event.getOrderId(), isNew);
......
......@@ -75,6 +75,7 @@ import cn.iocoder.yudao.module.order.dal.mysql.orderCargoControlPick.OrderCargoC
import cn.iocoder.yudao.module.order.dal.mysql.orderItem.OrderItemMapper;
import cn.iocoder.yudao.module.order.dal.mysql.orderTime.OrderTimeMapper;
import cn.iocoder.yudao.module.order.dal.mysql.orderWarehouseIn.OrderWarehouseInMapper;
import cn.iocoder.yudao.module.order.dal.mysql.targetLog.TargetLogMapper;
import cn.iocoder.yudao.module.order.dto.OrderBackInfoDto;
import cn.iocoder.yudao.module.order.enums.*;
import cn.iocoder.yudao.module.order.service.approval.OrderApprovalService;
......@@ -96,6 +97,7 @@ import cn.iocoder.yudao.module.order.vo.orderItem.OrderItemInWarehouseVO;
import cn.iocoder.yudao.module.order.vo.orderObjective.OrderObjectiveBackVO;
import cn.iocoder.yudao.module.order.vo.orderSpecialNeed.OrderSpecialNeedCreateReqVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInSumBackVO;
import cn.iocoder.yudao.module.order.vo.targetLog.TargetOfferBackVO;
import cn.iocoder.yudao.module.product.dto.FeeDto;
import cn.iocoder.yudao.module.product.enums.FeeTypeEnum;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
......@@ -118,6 +120,7 @@ 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;
......@@ -183,7 +186,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
private final OrderQueryService orderQueryService;
private final UnitApi unitApi;
private final OrderOperateLogService orderOperateLogService;
private TargetLogMapper targetLogMapper;
/*
后台创建订单 memberUserDO 信息为空
......@@ -623,13 +626,28 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
} else {
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
if (order.getDrawee() == 1) {
order.setCustomerId(orderConsignorDO.getCustomerId());
} else {
customerType = 2;
order.setCustomerId(orderConsigneeDO.getCustomerId());
}
}
// if (order.getDrawee() == 1) {
// order.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
// customerType = 2;
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// }
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(0L);
order.setSalesmanId(0L);
}
} else if (order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
if(orderConsigneeDO!=null){
order.setCustomerId(orderConsigneeDO.getCustomerId());
// 补充业绩规则判断
if (!consignorCustomerDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
......@@ -643,66 +661,68 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (createReqVO.getOfferId() != null && 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)) {//订单关联报价单 && 自定义付款 且发货人付运费
order.setCustomerId(orderConsignorDO.getCustomerId());
}
if (createReqVO.getOfferId() != null && (order.getDrawee() == 3 && clearanceFee == 1)) {//订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId());
}else{
order.setSalesmanId(0L);
}
}
} else if (order.getDrawee() == 3) { //自定义付款
}
List<CustomDraweeVO> list = JSONObject.parseArray(order.getCustomDrawee(), CustomDraweeVO.class);
if(CollectionUtil.isNotEmpty(list)){
if (consignorCustomerDO.getDefaultPay() && (order.getDrawee() == 2 || order.getDrawee() == 3)) {//发货人档案设置默认付运费 --层级4
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();//清关费
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 (order.getDrawee() == 1 || (order.getDrawee() == 3 && freight == 1) || (order.getDrawee() == 3 && clearanceFee == 1)) {//如果是发货人付款 或自定义付款且发货人付运费 或自定义付款且发货人付清关费,业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
}
}
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 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
}
if (order.getDrawee() == 2 || order.getDrawee() == 3) {
//如果是收货人付款或是自定义付款 --层级5
if (order.getDrawee() == 2) {
//订单收货人付款,业绩归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId());
} 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 ((order.getDrawee() == 3 && freight == 2) || (order.getDrawee() == 3 && clearanceFee == 2)) {//自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
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 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.setSalesmanId(0L);
}
//end
}
}
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
addOrderCustomerService(order, customerType);
//addOrderCustomerService(order, customerType);
addOrderCustomerServiceAndCustomer(createReqVO,order, customerType);
}
}
}
//新增订单 客户联系人处理
private void adminSaveConsignorAndConsignee(OrderCreateReqVO createReqVO, OrderDO order, String creator,
Date now, DictDataRespDTO dictDataRespDTO) {
OrderConsignorDO orderConsignorDO = new OrderConsignorDO();
......@@ -920,38 +940,41 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// }
// 补充业绩规则判断
if (!consignorDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
order.setCustomerId(orderConsignorDO.getCustomerId());
if(!consignorDO.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());
} else if (order.getDrawee() == 1 && consignorDO.getDefaultPay()) {// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else if(order.getDrawee() == 1 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else{
order.setCustomerId(0L) ;
order.setSalesmanId(0L);
}
} else if (order.getDrawee() == 2) {//收货人付款 层级5 第一个
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setCustomerId(orderConsigneeDO.getCustomerId()) ;
} else if (order.getDrawee() == 3) { //自定义付款
List<CustomDraweeVO> list = JSONObject.parseArray(order.getCustomDrawee(), CustomDraweeVO.class);
if (CollectionUtil.isNotEmpty(list)) {
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();//运费
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());
} else if (createReqVO.getOfferId() != null && (order.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId());
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
} else if (!consignorDO.getDefaultPay() && (order.getDrawee() == 3 && freight == 2) || (order.getDrawee() == 3 && clearanceFee == 2)) {//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else if(consignorDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else if (consignorDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else if(!consignorDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(orderConsigneeDO.getCustomerId());
}
......@@ -959,89 +982,314 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
} else {
//业绩归属公司
order.setCustomerId(0L);
order.setSalesmanId(0L);
}
//end
}
}
//end
}
// 更新所属客户经理(业务员)
if (Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
//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.getCustomerService()!=null?consignorDO.getCustomerService():0) ;
} else{
if(order.getIsCargoControl()){
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0) ;
}else{
if(consignorDO !=null && ! consignorDO.getNoConsignee() && !order.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if(consignorDO!=null){
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(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.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(order.getDrawee() == 1 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}
} else if (order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
if(consigneeDO!=null){
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(consigneeDO.getCustomerService());
}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(CollectionUtil.isNotEmpty(offerBackVOList) && ( order.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else if(CollectionUtil.isNotEmpty(offerBackVOList) && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else if(consignorDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else if (consignorDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else 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 {
//业绩归属公司
order.setSalesmanId(0L);
}
}
}
}
}
//新增判断客户归属
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.getCustomerService()!=null?consignorDO.getCustomerService():0) ;
} else{
if(order.getIsCargoControl()){
order.setCustomerId(orderConsignorDO.getCustomerId());
}else{
if(consignorDO !=null && ! consignorDO.getNoConsignee() && !order.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if(consignorDO!=null){
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}
// if(createReqVO.getOfferId()!=null && order.getDrawee()==1){//订单关联报价单 && 发货人付款
// order.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }
//
// if(createReqVO.getOfferId()!=null && 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 )){//订单关联报价单 && 自定义付款 且发货人付运费
// order.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }
// if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//订单关联报价单 && 自定义付款 且发货人付清关费
// order.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }
// }
//
// }
//
// if(consignorDO.getDefaultPay() && (order.getDrawee()==2 || order.getDrawee()==3) ){//发货人档案设置默认付运费 --层级4
// 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(order.getDrawee()==1 || ( order.getDrawee()==3 && freight==1 ) || ( order.getDrawee()==3 && clearanceFee==1 )){//如果是发货人付款 或自定义付款且发货人付运费 或自定义付款且发货人付清关费,业绩归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId()) ;
//
// }
// }
//
//
// }else if(!consignorDO.getDefaultPay() && order.getDrawee()==1 && createReqVO.getOfferId()!=null){//发货人没有设置默认付款且发货人付款且没有关联报价单 -- 层级6
// //业绩归属公司
// order.setCustomerId(0L) ;
// order.setSalesmanId(0L);
// }
// if(order.getDrawee()==2 || order.getDrawee()==3){//如果是收货人付款或是自定义付款 --层级5
// if(order.getDrawee()==2){//订单收货人付款,业绩归属收货人
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// order.setSalesmanId(orderConsigneeDO.getCustomerId());
// }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((order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
}else{
// else{
// 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() == 1) || (createReqVO.getOfferId()!=null && freight==1) || (createReqVO.getOfferId()!=null && clearanceFee==1)){//层级3
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
// }else{
// if( (consignorDO.getDefaultPay() && order.getDrawee() == 2 ) || (consignorDO.getDefaultPay() && freight==1 ) || (consignorDO.getDefaultPay() && clearanceFee==1 )){//层级4
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
// }else{
// if(order.getDrawee() == 2 || (order.getDrawee() == 3 && freight==2) || (order.getDrawee() == 3 && clearanceFee==2)){//层级5
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// order.setSalesmanId(orderConsigneeDO.getCustomerId());
// order.setSalesmanId(consigneeDO.getCustomerService());
// }else{
// order.setSalesmanId(0L); //层级6
// }
// }
//
// }
//
// }
// if(order.getDrawee()==1 && createReqVO.getOfferId()==null){//如果是发货人付款且没有关联报价单 ,归属公司业绩,无客户经理
// //业绩归属公司
// order.setCustomerId(0L);
// order.setSalesmanId(0L) ;
// }
//
// }
if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && createReqVO.getOfferId()!=null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(order.getDrawee() == 1 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else{
order.setCustomerId(0L);
order.setSalesmanId(0L);
}
} else if (order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
if(consigneeDO!=null){
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(consigneeDO.getCustomerService());
}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(consignorDO.getCustomerService());
}else if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else if(consignorDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else if (consignorDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else 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 {
//业绩归属公司
order.setSalesmanId(0L);
}
}
}
// 更新所属客户经理(业务员)
if (Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
addOrderCustomerService(order, 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 {
//order.setSalesmanId(customerDO.getCustomerService());
addOrderSalesmanCustomerService(createReqVO,order);
}
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(order.getSalesmanId());
if (Objects.nonNull(adminUserRespDTO)) {
order.setDeptId(adminUserRespDTO.getDeptId());
}
} 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) {
//order.setSalesmanId(0L);
addOrderSalesmanCustomerService(createReqVO,order);
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);
}
}
......@@ -1075,7 +1323,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 如果这里的旧客户经理id不为null,说明此客户属于移交新客户经理,但是新客户经理还未接收,业绩算老客户经理的
order.setSalesmanId(oldCustomerService);
} else {
order.setSalesmanId(customerDO.getCustomerService());
//order.setSalesmanId(customerDO.getCustomerService());
addOrderSalesmanCustomerService(order);
}
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(order.getSalesmanId());
if (Objects.nonNull(adminUserRespDTO)) {
......@@ -1086,7 +1335,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 如果客户正在移交新客户经理,但是未接收,并且老客户经理不为null,则不创建客户经理未分配异常
//web下单,业绩为收货人,不产生未分配客户经理异常
if (order.getUserId() != null && order.getUserId() > 0 && customerType == 2) {
order.setSalesmanId(0L);
//order.setSalesmanId(0L);
addOrderSalesmanCustomerService(order);
order.setDeptId(0L);
log.info("web下单,业绩为收货人,不产生未分配客户经理异常 orderNo={}", order.getOrderNo());
} else {
......@@ -1114,50 +1364,130 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
}
private void setOrderCustomerServiceCustomerId(OrderCreateReqVO createReqVO, OrderDO order, CustomerDO consignorDO, OrderConsignorDO orderConsignorDO, OrderConsigneeDO orderConsigneeDO) {
private void setAddOrderCustomerServiceCustomerId(OrderCreateReqVO createReqVO,OrderDO order, CustomerDO consignorDO,CustomerDO consigneeDO,OrderConsignorDO orderConsignorDO,OrderConsigneeDO orderConsigneeDO){
// 补充业绩规则判断
if (!consignorDO.getNoConsignee() && !order.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
order.setCustomerId(orderConsignorDO.getCustomerId());
}
if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && createReqVO.getOfferId() != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
} else if (order.getDrawee() == 1 && consignorDO.getDefaultPay()) {// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
if (Objects.nonNull(order.getType()) && order.getType().contains("2")) { //如果是海外仓
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else {
if(!consignorDO.getNoConsignee() && !order.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}
if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && createReqVO.getOfferId() != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(order.getDrawee() == 1 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}
} else if (order.getDrawee() == 2 && createReqVO.getOfferId()==null && !consignorDO.getDefaultPay()) {//收货人付款 层级5 第一个
order.setCustomerId(orderConsigneeDO.getCustomerId()) ;
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():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(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(consignorDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if (consignorDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(!consignorDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
}
} else {
//业绩归属公司
order.setSalesmanId(0L);
}
} else if (order.getDrawee() == 2) {//收货人付款 层级5 第一个
order.setCustomerId(orderConsigneeDO.getCustomerId());
} 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());
} else if (createReqVO.getOfferId() != null && (order.getDrawee() == 3 && clearanceFee == 1)) {//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId());
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
} else if (consignorDO.getDefaultPay() && (order.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
} else if (!consignorDO.getDefaultPay() && (order.getDrawee() == 3 && freight == 2) || (order.getDrawee() == 3 && clearanceFee == 2)) {//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(orderConsigneeDO.getCustomerId());
private void setUpdateOrderCustomerServiceCustomerId(OrderUpdateReqVO createReqVO,OrderDO order, CustomerDO consignorDO,CustomerDO consigneeDO,OrderConsignorDO orderConsignorDO,OrderConsigneeDO orderConsigneeDO){
// 补充业绩规则判断
if (Objects.nonNull(order.getType()) && order.getType().contains("2")) { //如果是海外仓
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else{
if(!consignorDO.getNoConsignee() && !order.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}
if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && createReqVO.getOfferId() != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(order.getDrawee() == 1 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else{
//业绩归公司
order.setSalesmanId(0L);
}
} else if ( order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
order.setCustomerId(orderConsigneeDO.getCustomerId()) ;
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():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(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(consignorDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if (consignorDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else if(!consignorDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
}
}
} else {
//业绩归属公司
} else {
//业绩归属公司
order.setCustomerId(0L);
order.setSalesmanId(0L);
order.setSalesmanId(0L);
}
}
}
private void compareOrderCustomerService(OrderBackVO vo, List<ApplyInfoVO> applyInfoList, int customerType) {
......@@ -1712,9 +2042,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
//end lanbm 2024-04-13 修改,在创建完订单号,计算订单业绩类型
//入仓完成,计算V值 lanbm 2024-05-13 add
CalculateOrderVValueEvent event = new CalculateOrderVValueEvent();
/*27号注释
CalculateOrderVValueEvent event=new CalculateOrderVValueEvent();
event.setOrderId(updateObj.getOrderId());
applicationContext.publishEvent(event);
*/
//end 入仓完成,计算V值 lanbm 2024-05-13 add
}
......@@ -3013,65 +3346,70 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
} else {
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
if (updateObj.getDrawee() == 1) {
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
} else {
customerType = 2;
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
}
}
// 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());
}
// 补充业绩规则判断
if(!consignorCustomerDO.getNoConsignee() && !updateObj.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else{
if(updateReqVO.getOfferId()!=null && updateObj.getDrawee()==1){//订单关联报价单 && 发货人付款
updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
}
if (updateReqVO.getOfferId() != null && updateObj.getDrawee() == 1) {//订单关联报价单 && 发货人付款
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
}
if(updateReqVO.getOfferId()!=null && updateObj.getDrawee()==3 ){//订单关联报价单 && 自定义付款
if (updateReqVO.getOfferId() != null && updateObj.getDrawee() == 3) {//订单关联报价单 && 自定义付款
List<CustomDraweeVO> list = JSONObject.parseArray(updateObj.getCustomDrawee(), CustomDraweeVO.class);
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 )){//订单关联报价单 && 自定义付款 且发货人付运费
updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
}
if(updateReqVO.getOfferId()!=null && ( updateObj.getDrawee()==3 && clearanceFee==1 )){//订单关联报价单 && 自定义付款 且发货人付清关费
updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
}
}
List<CustomDraweeVO> list = JSONObject.parseArray(updateObj.getCustomDrawee(), CustomDraweeVO.class);
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)) {//订单关联报价单 && 自定义付款 且发货人付运费
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
}
if (updateReqVO.getOfferId() != null && (updateObj.getDrawee() == 3 && clearanceFee == 1)) {//订单关联报价单 && 自定义付款 且发货人付清关费
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
}
}
if(consignorCustomerDO.getDefaultPay() ){//发货人档案设置默认付运费 --层级4
List<CustomDraweeVO> list = JSONObject.parseArray(updateObj.getCustomDrawee(), CustomDraweeVO.class);
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(updateObj.getDrawee()==1 || ( updateObj.getDrawee()==3 && freight==1 ) || ( updateObj.getDrawee()==3 && clearanceFee==1 )){//如果是发货人付款 或自定义付款且发货人付运费 或自定义付款且发货人付清关费,业绩归属发货人
updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
}
if (consignorCustomerDO.getDefaultPay()) {//发货人档案设置默认付运费 --层级4
List<CustomDraweeVO> list = JSONObject.parseArray(updateObj.getCustomDrawee(), CustomDraweeVO.class);
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 (updateObj.getDrawee() == 1 || (updateObj.getDrawee() == 3 && freight == 1) || (updateObj.getDrawee() == 3 && clearanceFee == 1)) {//如果是发货人付款 或自定义付款且发货人付运费 或自定义付款且发货人付清关费,业绩归属发货人
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
}
}
if(updateObj.getDrawee()==2 || updateObj.getDrawee()==3){//如果是收货人付款或是自定义付款 --层级5
if(updateObj.getDrawee()==2){//订单收货人付款,业绩归属收货人
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
}else if(updateObj.getDrawee()==3){
List<CustomDraweeVO> list = JSONObject.parseArray(updateObj.getCustomDrawee(), CustomDraweeVO.class);
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((updateObj.getDrawee()==3 && freight==2 ) || (updateObj.getDrawee()==3 && clearanceFee==2)){//自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
}
}
}
if (updateObj.getDrawee() == 2 || updateObj.getDrawee() == 3) {//如果是收货人付款或是自定义付款 --层级5
if (updateObj.getDrawee() == 2) {//订单收货人付款,业绩归属收货人
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
} else if (updateObj.getDrawee() == 3) {
List<CustomDraweeVO> list = JSONObject.parseArray(updateObj.getCustomDrawee(), CustomDraweeVO.class);
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 ((updateObj.getDrawee() == 3 && freight == 2) || (updateObj.getDrawee() == 3 && clearanceFee == 2)) {//自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
}
}
}
}
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus()) && Objects.nonNull(updateObj.getCustomerId()) && updateObj.getCustomerId() > 0) {
......@@ -3305,130 +3643,72 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 控货订单归属发货人
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
} else {
if (!consignorDO.getNoConsignee() && !updateObj.getHasConsignee()) {//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
}
if (updateObj.getDrawee() == 1) {//发货人付款
if (updateObj.getDrawee() == 1 && updateReqVO.getOfferId() != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
} else if (updateObj.getDrawee() == 1 && consignorDO.getDefaultPay()) {// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
}
} else if (updateObj.getDrawee() == 2) {//收货人付款 层级5 第一个
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
} else if (updateObj.getDrawee() == 3) { //自定义付款
if(!consignorDO.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 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else{
updateObj.setSalesmanId(0L) ;
updateObj.setCustomerId(0L);
}
} 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> 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();//清关费
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 (consignorDO.getDefaultPay() && (updateObj.getDrawee() == 3 && freight == 1)) { //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
} else if (consignorDO.getDefaultPay() && (updateObj.getDrawee() == 3 && clearanceFee == 1)) {// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
} else if (!consignorDO.getDefaultPay() && (updateObj.getDrawee() == 3 && freight == 2) || (updateObj.getDrawee() == 3 && clearanceFee == 2)) {//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
updateObj.setSalesmanId(orderConsigneeDO.getCustomerId());
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(consignorDO.getDefaultPay() && ( updateObj.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else if (consignorDO.getDefaultPay() && ( updateObj.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else if(!consignorDO.getDefaultPay() && (updateObj.getDrawee()==3 && freight==2 ) || (updateObj.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
}
}
} else {
//业绩归属公司
updateObj.setCustomerId(0L) ;
updateObj.setSalesmanId(0L);
}
} else {
//业绩归属公司
updateObj.setCustomerId(0L);
updateObj.setSalesmanId(0L);
}
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
if (updateObj.getDrawee() == 1) {
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
} else {
customerType = 2;
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
}
// if (updateObj.getDrawee() == 1) {
// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
// customerType = 2;
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
// }
}
}
// 补充业绩规则判断
// if(!consignorDO.getNoConsignee() && !updateObj.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }
//
// if(updateReqVO.getOfferId()!=null && updateObj.getDrawee()==1){//订单关联报价单 && 发货人付款
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }
//
// if(updateReqVO.getOfferId()!=null && 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 )){//订单关联报价单 && 自定义付款 且发货人付运费
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }
// if(updateReqVO.getOfferId()!=null && ( updateObj.getDrawee()==3 && clearanceFee==1 )){//订单关联报价单 && 自定义付款 且发货人付清关费
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }
// }
//
// }
//
// if(consignorDO.getDefaultPay() && (updateObj.getDrawee()==2 || updateObj.getDrawee()==3)){//发货人档案设置默认付运费 --层级4
// if(consignorDO.getDefaultPay() && updateObj.getDrawee()==2){
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else if(consignorDO.getDefaultPay() && 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(updateObj.getDrawee()==1 || ( updateObj.getDrawee()==3 && freight==1 ) || ( updateObj.getDrawee()==3 && clearanceFee==1 )){//如果是发货人付款 或自定义付款且发货人付运费 或自定义付款且发货人付清关费,业绩归属发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }
// }
// }
// }
// else if(!consignorDO.getDefaultPay() && updateObj.getDrawee()==1 && updateReqVO.getOfferId()!=null){//发货人没有设置默认付款且发货人付款且没有关联报价单 -- 层级6
// //业绩归属公司
// updateObj.setCustomerId(0L) ;
// updateObj.setSalesmanId(0L);
// }
//
// if(updateObj.getDrawee()==2 || updateObj.getDrawee()==3){//如果是收货人付款或是自定义付款 --层级5
// if(updateObj.getDrawee()==2){//订单收货人付款,业绩归属收货人
// 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((updateObj.getDrawee()==3 && freight==2 ) || (updateObj.getDrawee()==3 && clearanceFee==2)){//自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
// }
// }
//
// }
//
// }
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus()) && Objects.nonNull(updateObj.getCustomerId()) && updateObj.getCustomerId() > 0) {
addOrderCustomerService(updateObj, customerType);
//setUpdateOrderCustomerServiceCustomerId(updateReqVO, updateObj,consignorDO,consigneeDO,orderConsignorDO,orderConsigneeDO);
}
}
}
......
......@@ -1358,10 +1358,13 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
}
//入仓完成,计算V值 lanbm 2024-05-13 add
CalculateOrderVValueEvent event = new CalculateOrderVValueEvent();
/*27号注释掉
CalculateOrderVValueEvent event=new CalculateOrderVValueEvent();
event.setOrderId(orderId);
applicationContext.publishEvent(event);
//end 入仓完成,计算V值 lanbm 2024-05-13 add
*/
// end 入仓完成,计算V值 lanbm 2024-05-13 add
// 返回是否包含异常
return exceptionNum > 0;
......
......@@ -166,73 +166,85 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
OrderBackInfoDto info = orderQueryService.info(orderId);
if (info != null && info.getSalesmanId()!=null && info.getSalesmanId()>0L) {//客户经理
Long customerId = 0L;
CustomerDO consignorDO = customerService.getCustomer(info.getConsignorVO().getCustomerId());
CustomerDO consigneeDO = customerService.getCustomer(info.getConsigneeVO().getCustomerId());//收货人
if (info.getType().contains("2")) {//海外仓归属发货人
customerId = info.getConsignorVO().getCustomerId();
//customerId = info.getConsignorVO().getCustomerId(); //二期需求修改
customerId = consignorDO.getId();
} else {
if (info.getIsCargoControl()) {//非海外控货归属发货人
customerId = info.getConsignorVO().getCustomerId();
} else {
// if (info.getIsCargoControl()) {//非海外控货归属发货人
// customerId = info.getConsignorVO().getCustomerId();
// } else {
// if (info.getDrawee() == 1) {//非海外非控货 付款人为发货人 归属发货人
// customerId = info.getConsignorVO().getCustomerId();
// } else { //非海外非控货 付款人为其他 归属收货人
// customerId = info.getConsigneeVO().getCustomerId();
// }
CustomerDO consignorDO = customerService.getCustomer(info.getConsignorVO().getCustomerId());
CustomerDO consigneeDO = customerService.getCustomer(info.getConsigneeVO().getCustomerId());//收货人
OrderConsigneeDO orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, info.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
OrderConsignorDO orderConsignorDO = orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, info.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
if(consignorDO !=null && ! consignorDO.getNoConsignee() && !info.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if(consignorDO!=null){
customerId = consignorDO.getId();
}
if(info.getIsCargoControl()){
customerId = info.getConsignorVO().getCustomerId();
}else {
if(consignorDO !=null && ! consignorDO.getNoConsignee() && !info.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if(consignorDO!=null){
customerId = consignorDO.getId();
}
}
List<TargetOfferBackVO> offerBackVOList =targetLogMapper.getTargetOfferBackByOrerId(orderId) ;
if (info.getDrawee() == 1) {//发货人付款
if (info.getDrawee() == 1 && CollectionUtil.isNotEmpty(offerBackVOList)) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
}else{
List<TargetOfferBackVO> offerBackVOList =targetLogMapper.getTargetOfferBackByOrerId(orderId) ;
if (info.getDrawee() == 1) {//发货人付款
if (info.getDrawee() == 1 && CollectionUtil.isNotEmpty(offerBackVOList)) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
customerId =orderConsignorDO.getCustomerId();
}else if(info.getDrawee() == 1 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
customerId = consignorDO.getId();
}else if(info.getDrawee() == 1 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
customerId =orderConsignorDO.getCustomerId() ;
}
} else if (info.getDrawee() == 2) {//收货人付款 层级5 第一个
customerId = orderConsigneeDO.getCustomerId()!=null? orderConsigneeDO.getCustomerId():consigneeDO.getId();
} else if (info.getDrawee() == 3) { //自定义付款
customerId = consignorDO.getId();
}else{
customerId = consignorDO.getId();
}
} else if (info.getDrawee() == 2 ) {//收货人付款 层级5 第一个
customerId = orderConsigneeDO.getCustomerId()!=null? orderConsigneeDO.getCustomerId():consigneeDO.getId();
} else if (info.getDrawee() == 3) { //自定义付款
List<CustomDraweeVO> list = JSONObject.parseArray(info.getCustomDrawee(), CustomDraweeVO.class);
if(CollectionUtil.isNotEmpty(list)){
List<CustomDraweeVO> list = JSONObject.parseArray(info.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();//清关费
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) && ( info.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
if(CollectionUtil.isNotEmpty(offerBackVOList) && ( info.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
customerId = orderConsignorDO.getCustomerId() ;
}else if(CollectionUtil.isNotEmpty(offerBackVOList) && ( info.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
customerId = orderConsignorDO.getCustomerId() ;
}else if(CollectionUtil.isNotEmpty(offerBackVOList) && ( info.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
customerId = orderConsignorDO.getCustomerId() ;
}else if(consignorDO.getDefaultPay() && ( info.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
customerId = orderConsignorDO.getCustomerId() ;
}else if(consignorDO.getDefaultPay() && ( info.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
customerId = orderConsignorDO.getCustomerId() ;
}else if (consignorDO.getDefaultPay() && ( info.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
customerId = orderConsignorDO.getCustomerId() ;
}else if (consignorDO.getDefaultPay() && ( info.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
customerId = orderConsignorDO.getCustomerId() ;
}else if(!consignorDO.getDefaultPay() && (info.getDrawee()==3 && freight==2 ) || (info.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
customerId = orderConsigneeDO.getCustomerId() ;
customerId = orderConsignorDO.getCustomerId() ;
}else if(!consignorDO.getDefaultPay() && (info.getDrawee()==3 && freight==2 ) || (info.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
customerId = orderConsigneeDO.getCustomerId() ;
}
}
}
}
} else {
//业绩归属公司
customerId = info.getConsigneeVO().getCustomerId();
} else {
//业绩归属公司
return;
}
}
}
}
// }
}
TargetLogDO targetLogDO = new TargetLogDO();
targetLogDO.setOrderId(orderId);
......
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