Commit 2e2a73ee authored by liuzeheng's avatar liuzeheng

优化

parent be3de7cc
package cn.iocoder.yudao.module.order.service.order;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderConsignee.OrderConsigneeDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderConsignor.OrderConsignorDO;
import cn.iocoder.yudao.module.order.dto.OrderBackInfoDto;
import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialApplyVO;
import cn.iocoder.yudao.module.order.vo.approval.OrderSpecialBatchApplyVO;
......@@ -261,10 +264,10 @@ public interface OrderService extends IService<OrderDO> {
/**
*设置订单业绩归属
* @param orderDO
* @param order
* @param offerId
*/
void checkOrderSalesman(OrderDO orderDO, Long offerId) ;
void checkOrderSalesman(OrderDO order, Long offerId, CustomerDO consignorDO, CustomerDO consigneeDO, OrderConsignorDO orderConsignorDO, OrderConsigneeDO orderConsigneeDO) ;
/**
* 更新订单提单号
*
......
......@@ -584,93 +584,94 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsigneeService.save(orderConsigneeDO);
if (!Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
int customerType = 1; // 发货人 1 收货人 2
if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {
// 海外仓归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
} else {
// 补充业绩规则判断
if(!consignorCustomerDO.getNoConsignee() && !order.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else{
if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && createReqVO.getOfferId()!=null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorCustomerDO.getCustomerService()!=null?consignorCustomerDO.getCustomerService():0);
}else if(order.getDrawee() == 1 && consignorCustomerDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorCustomerDO.getCustomerService());
}else{
order.setCustomerId(orderConsigneeDO.getCustomerId());
}
} else if (order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
if(orderConsigneeDO!=null){
order.setCustomerId(orderConsigneeDO.getCustomerId());
}else{
order.setSalesmanId(0L);
}
} else if (order.getDrawee() == 3) { //自定义付款
List<CustomDraweeVO> list = JSONObject.parseArray(order.getCustomDrawee(), CustomDraweeVO.class);
if(CollectionUtil.isNotEmpty(list)){
List<CustomDraweeVO> freightList = list.stream().filter(s-> s.getName().equals("freight") ).collect(Collectors.toList());
List<CustomDraweeVO> clearanceFeeList = list.stream().filter(s-> s.getName().equals("clearanceFee") ).collect(Collectors.toList());
int freight = freightList.get(0).getValue() ;//运费
int clearanceFee = clearanceFeeList.get(0).getValue();//清关费
if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorCustomerDO.getCustomerService());
}else if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorCustomerDO.getCustomerService());
}else if(consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorCustomerDO.getCustomerService());
}else if (consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorCustomerDO.getCustomerService());
}else {
order.setCustomerId(orderConsigneeDO.getCustomerId());
}
// if(!consignorCustomerDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
this.checkOrderSalesman(order,createReqVO.getOfferId(),null,null,orderConsignorDO,orderConsigneeDO);
// if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {
// // 海外仓归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
//
//
// // 补充业绩规则判断
// if(!consignorCustomerDO.getNoConsignee() && !order.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
// order.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else{
// if (order.getDrawee() == 1) {//发货人付款
// if (order.getDrawee() == 1 && createReqVO.getOfferId()!=null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService()!=null?consignorCustomerDO.getCustomerService():0);
// }else if(order.getDrawee() == 1 && consignorCustomerDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else{
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// if(orderConsignorDO!=null){
//
// }
// } else if (order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
// if(orderConsigneeDO!=null){
// order.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }else{
//
// order.setSalesmanId(0L);
// }
// } else if (order.getDrawee() == 3) { //自定义付款
//
// List<CustomDraweeVO> list = JSONObject.parseArray(order.getCustomDrawee(), CustomDraweeVO.class);
// if(CollectionUtil.isNotEmpty(list)){
//
// List<CustomDraweeVO> freightList = list.stream().filter(s-> s.getName().equals("freight") ).collect(Collectors.toList());
// List<CustomDraweeVO> clearanceFeeList = list.stream().filter(s-> s.getName().equals("clearanceFee") ).collect(Collectors.toList());
// int freight = freightList.get(0).getValue() ;//运费
// int clearanceFee = clearanceFeeList.get(0).getValue();//清关费
//
// if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else if(consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else if (consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
//
// }else {
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// }
}
} else {
//业绩归属公司
order.setCustomerId(orderConsigneeDO.getCustomerId());
}
}
}//end
//
//// if(!consignorCustomerDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
//// order.setCustomerId(orderConsigneeDO.getCustomerId());
//// if(orderConsignorDO!=null){
//// order.setCustomerId(orderConsigneeDO.getCustomerId());
////
//// }else{
////
//// order.setSalesmanId(0L);
//// }
////
////
//// }
//
// }
//
// } else {
// //业绩归属公司
// order.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }
// }
//
//
//
//
//
// }//end
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
......@@ -880,85 +881,86 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
if (!Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
int customerType = 1; // 发货人 1 收货人 2
if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {
// 海外仓归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
} else {
// if (order.getIsCargoControl()) {
// // 控货订单归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
// if (order.getDrawee() == 1) {
this.checkOrderSalesman(order,createReqVO.getOfferId(),null,null,orderConsignorDO,orderConsigneeDO);
// if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {
// // 海外仓归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
// customerType = 2;
//// if (order.getIsCargoControl()) {
//// // 控货订单归属发货人
//// order.setCustomerId(orderConsignorDO.getCustomerId());
//// } else {
// // 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
//// if (order.getDrawee() == 1) {
//// order.setCustomerId(orderConsignorDO.getCustomerId());
//// } else {
//// customerType = 2;
//// order.setCustomerId(orderConsigneeDO.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()) ;
// }else{
// order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
// order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
//// order.setCustomerId(0L) ;
//// 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 {
// order.setCustomerId(orderConsigneeDO.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()) ;
}else{
order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
// order.setCustomerId(0L) ;
// 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 {
order.setCustomerId(orderConsigneeDO.getCustomerId());
}
// if(!consignorDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
//
//// if(!consignorDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
//// order.setCustomerId(orderConsigneeDO.getCustomerId());
////
////
//// }
//
// }
//
// } else {
// //业绩归属公司
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// }
// //end
// }
// //}
//
//
//
//
//
//
//
//
// }
}
} else {
//业绩归属公司
order.setCustomerId(orderConsigneeDO.getCustomerId());
}
//end
}
//}
}
// 更新所属客户经理(业务员)
if (Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
//addOrderCustomerService(order, customerType);
......@@ -1199,11 +1201,21 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
}
public void checkOrderSalesman(OrderDO order, Long offerId){
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());//收货人
public void checkOrderSalesman(OrderDO order, Long offerId,CustomerDO consignorDO,CustomerDO consigneeDO,OrderConsignorDO orderConsignorDO,OrderConsigneeDO orderConsigneeDO){
if(Objects.isNull(orderConsigneeDO)){//订单收货人
orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, order.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
}
if(Objects.isNull(orderConsignorDO)){//订单发货人
orderConsignorDO = orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, order.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
}
if(Objects.isNull(consignorDO)){//发货人客户
consignorDO = customerService.getCustomer(orderConsignorDO.getCustomerId());
}
if(Objects.isNull(consigneeDO)){
consigneeDO = customerService.getCustomer(orderConsigneeDO.getCustomerId());//收货人客户
}
if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {//层级1
// 海外仓归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
......@@ -3416,81 +3428,82 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsigneeService.saveOrUpdate(orderConsigneeDO);
if (!Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
int customerType = 1; // 发货人 1 收货人 2
if (Objects.nonNull(updateObj.getType()) && updateObj.getType().contains("2")) {
// 海外仓归属发货人
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
} else {
// if (updateObj.getIsCargoControl()) {
// // 控货订单归属发货人
this.checkOrderSalesman(updateObj,updateReqVO.getOfferId(),consignorCustomerDO,null,orderConsignorDO,orderConsigneeDO);
// if (Objects.nonNull(updateObj.getType()) && updateObj.getType().contains("2")) {
// // 海外仓归属发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
// if (updateObj.getDrawee() == 1) {
// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
//// 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 {
// 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()) && Objects.nonNull(updateObj.getCustomerId()) && updateObj.getCustomerId() > 0) {
addOrderCustomerService(updateObj, customerType);
......@@ -3715,63 +3728,64 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
if (!Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
int customerType = 1; // 发货人 1 收货人 2
if (Objects.nonNull(updateObj.getType()) && updateObj.getType().contains("2")) {
// 海外仓归属发货人
updateObj.setCustomerId(orderConsignorDO.getCustomerId());
} else {
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.setCustomerId(orderConsigneeDO.getCustomerId()) ;
}
} 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(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 {
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
}
//去掉层级5、6 ,其他情况的都归收货人
// if(!consignorDO.getDefaultPay() && (updateObj.getDrawee()==3 && freight==2 ) || (updateObj.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
this.checkOrderSalesman(updateObj,updateReqVO.getOfferId(),consignorDO,consigneeDO,orderConsignorDO,orderConsigneeDO);
// if (Objects.nonNull(updateObj.getType()) && updateObj.getType().contains("2")) {
// // 海外仓归属发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
//
// 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.setCustomerId(orderConsigneeDO.getCustomerId()) ;
// }
// } 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(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 {
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
// }
}
} else {
//业绩归属收获人
updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
// updateObj.setCustomerId(0L) ;
// updateObj.setSalesmanId(0L);
}
}
}
// //去掉层级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());
//// updateObj.setCustomerId(0L) ;
//// updateObj.setSalesmanId(0L);
// }
// }
//
// }
......
......@@ -927,7 +927,7 @@ public class OfferServiceImpl extends AbstractService<OfferMapper, OfferDO> impl
* @param offerId
*/
private void checkOrderSalesman(OrderDO orderDO, Long offerId) {
orderService.checkOrderSalesman(orderDO,offerId);
orderService.checkOrderSalesman(orderDO,offerId,null,null,null,null);
orderService.updateOrderCustomerAndSalesmanId(orderDO.getCustomerId()!=null?orderDO.getCustomerId():0,orderDO.getSalesmanId()!=null?orderDO.getSalesmanId():0,orderDO.getOrderId()) ;
}
......
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