Commit ce5a6042 authored by liuzeheng's avatar liuzeheng

Merge branch 'master' into dev

# Conflicts:
#	yudao-module-order/yudao-module-order-core/src/main/java/cn/iocoder/yudao/module/order/service/order/impl/OrderServiceImpl.java
parents c4dd5f4c 33d47289
......@@ -2921,7 +2921,7 @@ public interface OrderMapper extends AbstractMapper<OrderDO> {
"SELECT",
"s.order_no as value",
"FROM",
" ( SELECT t.order_no FROM ecw_order t GROUP BY t.order_no ) s",
" ( SELECT t.order_no FROM ecw_order t where deleted =0 GROUP BY t.order_no ) s",
"WHERE",
"s.order_no LIKE concat('%',#{keyValue},'%')",
"</script>"
......@@ -2934,7 +2934,7 @@ public interface OrderMapper extends AbstractMapper<OrderDO> {
"SELECT",
"s.tidan_no as value",
"FROM",
" ( SELECT t.tidan_no FROM ecw_order t GROUP BY t.`tidan_no` ) s",
" ( SELECT t.tidan_no FROM ecw_order t WHERE deleted =0 GROUP BY t.`tidan_no` ) s",
"WHERE",
"s.tidan_no LIKE concat('%',#{keyValue},'%')",
"</script>"
......@@ -6017,4 +6017,12 @@ public interface OrderMapper extends AbstractMapper<OrderDO> {
@Param("calVvalue") BigDecimal calVvalue,
@Param("yejiCreateDate") Date yejiCreateDate);
/**
* 报价结果赢单时,同步业绩归属
* @param customerId
* @param salesmanId
* @param orderId
*/
@Update("update ecw_order set customer_id=#{customerId},salesman_id=#{salesmanId} where order_id = #{orderId}")
void updateOrderCustomerAndSalesmanId(@Param("customerId")Long customerId,@Param("salesmanId") Long salesmanId,@Param("orderId") Long orderId);
}
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;
......@@ -259,7 +262,12 @@ public interface OrderService extends IService<OrderDO> {
*/
void addOrderOtherFee(Long orderId, List<FeeDto> feeDtoList);
/**
*设置订单业绩归属
* @param order
* @param offerId
*/
int checkOrderSalesman(OrderDO order, Long offerId, CustomerDO consignorDO, CustomerDO consigneeDO, OrderConsignorDO orderConsignorDO, OrderConsigneeDO orderConsigneeDO) ;
/**
* 更新订单提单号
*
......@@ -370,4 +378,5 @@ public interface OrderService extends IService<OrderDO> {
yejiCreateDate);
void updateOrderCustomerAndSalesmanId(Long customerId, Long salesmanId, Long orderId);
}
......@@ -616,75 +616,95 @@ 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 (order.getIsCargoControl()) {
// // 控货订单归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
// if (order.getDrawee() == 1) {
// order.setCustomerId(orderConsignorDO.getCustomerId());
//customerType 发货人-1 收货人 2
int customerType= this.checkOrderSalesman(order,createReqVO.getOfferId(),null,null,orderConsignorDO,orderConsigneeDO);
// if (Objects.nonNull(order.getType()) && order.getType().contains("2")) {
// // 海外仓归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
//
//
// // 补充业绩规则判断
// if(!consignorCustomerDO.getNoConsignee() && !order.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
// order.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else{
// if (order.getDrawee() == 1) {//发货人付款
// if (order.getDrawee() == 1 && createReqVO.getOfferId()!=null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService()!=null?consignorCustomerDO.getCustomerService():0);
// }else if(order.getDrawee() == 1 && consignorCustomerDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else{
// order.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }
// } else if (order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
// if(orderConsigneeDO!=null){
// order.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }else{
// order.setSalesmanId(0L);
// }
// } else if (order.getDrawee() == 3) { //自定义付款
//
// List<CustomDraweeVO> list = JSONObject.parseArray(order.getCustomDrawee(), CustomDraweeVO.class);
// if(CollectionUtil.isNotEmpty(list)){
//
// List<CustomDraweeVO> freightList = list.stream().filter(s-> s.getName().equals("freight") ).collect(Collectors.toList());
// List<CustomDraweeVO> clearanceFeeList = list.stream().filter(s-> s.getName().equals("clearanceFee") ).collect(Collectors.toList());
// int freight = freightList.get(0).getValue() ;//运费
// int clearanceFee = clearanceFeeList.get(0).getValue();//清关费
//
// if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else if(createReqVO.getOfferId()!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else if(consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
//
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
// }else if (consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
// order.setCustomerId(orderConsignorDO.getCustomerId());
// order.setSalesmanId(consignorCustomerDO.getCustomerService());
//
// }else {
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// }
//
//// if(!consignorCustomerDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
//// order.setCustomerId(orderConsigneeDO.getCustomerId());
//// if(orderConsignorDO!=null){
//// order.setCustomerId(orderConsigneeDO.getCustomerId());
////
//// }else{
////
//// order.setSalesmanId(0L);
//// }
////
////
//// }
//
// }
//
// } else {
// customerType = 2;
// //业绩归属公司
// order.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }
// 补充业绩规则判断
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()) ;
}else if(order.getDrawee() == 1 && consignorCustomerDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else{
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(consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else if (consignorCustomerDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
}else if(!consignorCustomerDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId());
}
}
} else {
//业绩归属公司
order.setSalesmanId(0L);
}
}
}//end
// }
//
//
//
//
//
// }//end
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(order.getStatus()) && Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
......@@ -894,73 +914,9 @@ 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 (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(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 if(!consignorDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId());
}
}
} else {
//业绩归属公司
order.setSalesmanId(0L);
}
// 发货人 1 收货人 2
int customerType = this.checkOrderSalesman(order,createReqVO.getOfferId(),null,null,orderConsignorDO,orderConsigneeDO);
}//end
//}
}
// 更新所属客户经理(业务员)
if (Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
//addOrderCustomerService(order, customerType);
......@@ -981,10 +937,6 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
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());
......@@ -1002,6 +954,10 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else{
//都不符合,归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
} else if (order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
if(consigneeDO!=null){
......@@ -1036,28 +992,34 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
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.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
// if(!consignorDO.getDefaultPay() && (order.getDrawee()==3 && freight==2 ) || (order.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// if(consigneeDO!=null){
// order.setCustomerId(orderConsigneeDO.getCustomerId());
// order.setSalesmanId(consigneeDO.getCustomerService());
// }else{
//
// order.setSalesmanId(0L);
// }
//
//
// }
}
} else {
//业绩归属公司
order.setSalesmanId(0L);
//业绩归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
}
//}
}
......@@ -1075,10 +1037,6 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
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());
......@@ -1086,35 +1044,6 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
}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(consigneeDO.getCustomerService());
// }else{
// order.setSalesmanId(0L); //层级6
// }
// }
// }
// }
//
// }
if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && createReqVO.getOfferId()!=null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
......@@ -1126,15 +1055,20 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
}else{
order.setCustomerId(0L);
order.setSalesmanId(0L);
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 第一个
if(consigneeDO!=null){
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(consigneeDO.getCustomerService());
}else{
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
// order.setSalesmanId(0L);
}
} else if (order.getDrawee() == 3) { //自定义付款
......@@ -1162,30 +1096,144 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
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 {
//去掉层级5、6 ,以上不符合的都归收货人
order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
}
} else {
//业绩归属公司
//业绩归收货人
order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
}
}
}
public int checkOrderSalesman(OrderDO order, Long offerId,CustomerDO consignorDO,CustomerDO consigneeDO,OrderConsignorDO orderConsignorDO,OrderConsigneeDO orderConsigneeDO){
int customerType = 1; //1-业绩归属发货人,2-业绩归属收货人
if(Objects.isNull(orderConsigneeDO)){//订单收货人
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());
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0) ;
customerType = 1 ;
} else{
if(consignorDO !=null && ! consignorDO.getNoConsignee() && !order.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if(consignorDO!=null){
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
customerType = 1 ;
}
}else{
if (order.getDrawee() == 1) {//发货人付款
if (order.getDrawee() == 1 && offerId!=null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
customerType = 1 ;
}else if(order.getDrawee() == 1 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
customerType = 1 ;
}else{
order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
customerType = 2 ;
// order.setCustomerId(0L);
// order.setSalesmanId(0L);
}
} else if (order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
if(consigneeDO!=null){
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(consigneeDO.getCustomerService());
customerType = 1 ;
}else{
//没有收货人
order.setCustomerId(0L);
order.setSalesmanId(0L);
customerType = 0 ;
// 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(offerId!=null && ( order.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
customerType = 1 ;
}else if(offerId!=null && ( order.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
customerType = 1 ;
}else if(consignorDO.getDefaultPay() && ( order.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
customerType = 1 ;
}else if (consignorDO.getDefaultPay() && ( order.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
order.setCustomerId(orderConsignorDO.getCustomerId());
order.setSalesmanId(consignorDO.getCustomerService());
customerType = 1 ;
}else {
//去掉层级5、6 ,以上不符合的都归收货人
order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
customerType = 2 ;
}
}
} else {
//业绩归收货人
order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
customerType = 2 ;
}
//}
}
}
return customerType ;
}
private void addOrderCustomerServiceAndCustomer(OrderCreateReqVO createReqVO,OrderDO order, int customerType) {
......@@ -1229,7 +1277,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
&& (Objects.isNull(customerDO.getCustomerService()) || (!customerDO.getIsCustomerServiceConfirmed() && Objects.isNull(oldCustomerService)))) {
// 如果客户正在移交新客户经理,但是未接收,并且老客户经理不为null,则不创建客户经理未分配异常
//web下单,业绩为收货人,不产生未分配客户经理异常
if (order.getUserId() != null && order.getUserId() > 0 && customerType == 2) {
//if (order.getUserId() != null && order.getUserId() > 0 && customerType == 2) {
if (order.getUserId() != null && order.getUserId() > 0 && order.getSalesmanId()>0) {
//order.setSalesmanId(0L);
addOrderSalesmanCustomerService(createReqVO,order);
order.setDeptId(0L);
......@@ -1410,8 +1459,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
order.setCustomerId(orderConsignorDO.getCustomerId()) ;
order.setSalesmanId(consignorDO.getCustomerService()!=null?consignorDO.getCustomerService():0);
}else{
//业绩归公司
order.setSalesmanId(0L);
//业绩归收货人
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
} else if ( order.getDrawee() == 2 ) {//收货人付款 层级5 第一个
order.setCustomerId(orderConsigneeDO.getCustomerId()) ;
......@@ -1438,18 +1488,23 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}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 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
}else {
//去掉层级5、6 ,如果都不符合条件,归属收货人
order.setCustomerId(orderConsigneeDO.getCustomerId());
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
// 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);
order.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
order.setSalesmanId(consigneeDO.getCustomerService()!=null?consigneeDO.getCustomerService():0);
}
}
......@@ -3302,76 +3357,83 @@ 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()) {
// // 控货订单归属发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
// if (updateObj.getDrawee() == 1) {
// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
// customerType = 2;
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
//customerType 发货人 1 收货人 2
int customerType = 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.getIsCargoControl()) {
//// // 控货订单归属发货人
//// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
//// } else {
// // 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
//// if (updateObj.getDrawee() == 1) {
//// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
//// } else {
//// customerType = 2;
//// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
//// }
//
// // 补充业绩规则判断
// if(!consignorCustomerDO.getNoConsignee() && !updateObj.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else{
// // 补充业绩规则判断
// if (updateObj.getDrawee() == 1) {//发货人付款
// if (updateObj.getDrawee() == 1 && updateReqVO.getOfferId() != null) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else if(updateObj.getDrawee() == 1 && consignorCustomerDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else{
// //不符合的,业绩归属收货人
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0) ;
//
// }
// } else if (updateObj.getDrawee() == 2) {//收货人付款 层级5 第一个
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId()) ;
// } else if (updateObj.getDrawee() == 3) { //自定义付款
//
// List<CustomDraweeVO> list = JSONObject.parseArray(updateObj.getCustomDrawee(), CustomDraweeVO.class);
// if(CollectionUtil.isNotEmpty(list)){
//
// List<CustomDraweeVO> freightList = list.stream().filter(s-> s.getName().equals("freight") ).collect(Collectors.toList());
// List<CustomDraweeVO> clearanceFeeList = list.stream().filter(s-> s.getName().equals("clearanceFee") ).collect(Collectors.toList());
// int freight = freightList.get(0).getValue() ;//运费
// int clearanceFee = clearanceFeeList.get(0).getValue();//清关费
//
// if(updateReqVO.getOfferId()!=null && ( updateObj.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else if(updateReqVO.getOfferId()!=null && ( updateObj.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else if(consignorCustomerDO.getDefaultPay() && ( updateObj.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else if (consignorCustomerDO.getDefaultPay() && ( updateObj.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId()) ;
// }else {
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId()!=null?orderConsigneeDO.getCustomerId():0);
// }
// //去掉层级5、6 ,其他情况的都归收货人
//// if(!consignorDO.getDefaultPay() && (updateObj.getDrawee()==3 && freight==2 ) || (updateObj.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
//// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
//// }
//
// }
//
// } else {
// //业绩归属收获人
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
//
// }
// }
// 补充业绩规则判断
if(!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()==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()) ;
}
}
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 (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus()) && Objects.nonNull(updateObj.getCustomerId()) && updateObj.getCustomerId() > 0) {
addOrderCustomerService(updateObj, customerType);
......@@ -3595,76 +3657,8 @@ 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()) {
// // 控货订单归属发货人
// 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.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> 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());
}
}
} else {
//业绩归属公司
updateObj.setCustomerId(0L) ;
updateObj.setSalesmanId(0L);
}
}
// 非控货订单 + 付款人为发货人 归属发货人, 其他归属收货人
// if (updateObj.getDrawee() == 1) {
// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
// } else {
// customerType = 2;
// updateObj.setCustomerId(orderConsigneeDO.getCustomerId());
// }
// }
}
//customerType 发货人 1 收货人 2
int customerType = this.checkOrderSalesman(updateObj,updateReqVO.getOfferId(),consignorDO,consigneeDO,orderConsignorDO,orderConsigneeDO);
// 更新所属客户经理(业务员)
if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus()) && Objects.nonNull(updateObj.getCustomerId()) && updateObj.getCustomerId() > 0) {
......@@ -6407,5 +6401,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
yejiCreateDate) {
orderMapper.UpdateOrderVValue(orderId, calVvalue, yejiCreateDate);
}
@Transactional(rollbackFor = Exception.class)
public void updateOrderCustomerAndSalesmanId(Long customerId, Long salesmanId, Long orderId){
orderMapper.updateOrderCustomerAndSalesmanId(customerId,salesmanId,orderId) ;
}
}
......@@ -172,14 +172,6 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
//customerId = info.getConsignorVO().getCustomerId(); //二期需求修改
customerId = consignorDO.getId();
} else {
// if (info.getIsCargoControl()) {//非海外控货归属发货人
// customerId = info.getConsignorVO().getCustomerId();
// } else {
// if (info.getDrawee() == 1) {//非海外非控货 付款人为发货人 归属发货人
// customerId = info.getConsignorVO().getCustomerId();
// } else { //非海外非控货 付款人为其他 归属收货人
// customerId = 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"));
......@@ -201,7 +193,7 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
customerId = consignorDO.getId();
}else{
customerId = consignorDO.getId();
customerId = orderConsigneeDO.getCustomerId() ;
}
} else if (info.getDrawee() == 2 ) {//收货人付款 层级5 第一个
customerId = orderConsigneeDO.getCustomerId()!=null? orderConsigneeDO.getCustomerId():consigneeDO.getId();
......@@ -227,24 +219,27 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
}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 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
}else {
customerId = orderConsigneeDO.getCustomerId() ;
}
// if(!consignorDO.getDefaultPay() && (info.getDrawee()==3 && freight==2 ) || (info.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
// customerId = orderConsigneeDO.getCustomerId() ;
//
// }
}
} else {
//业绩归属公司
return;
//业绩归属收货人
if(orderConsigneeDO!=null){
customerId = orderConsigneeDO.getCustomerId() !=null?orderConsigneeDO.getCustomerId():0;
}
}
}
}
// }
}
TargetLogDO targetLogDO = new TargetLogDO();
targetLogDO.setOrderId(orderId);
......
......@@ -893,6 +893,11 @@ public class OfferServiceImpl extends AbstractService<OfferMapper, OfferDO> impl
if (Objects.nonNull(offer)){
throw exception(ORDER_BOUND_OFFER);
}
//如果订单关联上报价单
if(orderDO!=null && offerDO.getOfferId()!=null){
this.checkOrderSalesman(orderDO,offerDO.getOfferId()) ;
}
} else {
orderDO = this.generateOrder(offerDO, offerResultVO);
if (Objects.isNull(orderDO)) {
......@@ -916,6 +921,16 @@ public class OfferServiceImpl extends AbstractService<OfferMapper, OfferDO> impl
return offerDO.getOrderId();
}
/**
* 赢单处理报价单时,再次判断业绩归属
* @param orderDO
* @param offerId
*/
private void checkOrderSalesman(OrderDO orderDO, Long 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()) ;
}
private OrderDO generateOrder(OfferDO offerDO, OfferResultVO offerResultVO) {
OfferTransportDO offerTransportDO = offerTransportMapper.selectOne(new LambdaQueryWrapper<OfferTransportDO>().eq(OfferTransportDO::getOfferId, offerDO.getOfferId()).last("limit 1"));
List<OfferProdDO> prodDOList = offerProdMapper.selectList(new LambdaQueryWrapper<OfferProdDO>().eq(OfferProdDO::getOfferId, offerDO.getOfferId()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment