Commit b0532416 authored by lanbaoming's avatar lanbaoming

2024-07-04-1提交

parent 42c7d102
...@@ -11,8 +11,10 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; ...@@ -11,8 +11,10 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO; import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO;
import cn.iocoder.yudao.module.customer.service.customer.CustomerService; import cn.iocoder.yudao.module.customer.service.customer.CustomerService;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO; import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.zTest;
import cn.iocoder.yudao.module.order.dal.dataobject.orderConsignee.OrderConsigneeDO; 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.dal.dataobject.orderConsignor.OrderConsignorDO;
import cn.iocoder.yudao.module.order.dal.mysql.order.ZTestMapper2;
import cn.iocoder.yudao.module.order.dto.OrderBackInfoDto; import cn.iocoder.yudao.module.order.dto.OrderBackInfoDto;
import cn.iocoder.yudao.module.order.service.order.OrderConsigneeService; import cn.iocoder.yudao.module.order.service.order.OrderConsigneeService;
import cn.iocoder.yudao.module.order.service.order.OrderConsignorService; import cn.iocoder.yudao.module.order.service.order.OrderConsignorService;
...@@ -61,6 +63,8 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe ...@@ -61,6 +63,8 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
@Resource @Resource
private OrderConsignorService orderConsignorService; private OrderConsignorService orderConsignorService;
@Resource
ZTestMapper2 zTestMapper2;
public List<TargetLogDO> selectList2(String sDate) { public List<TargetLogDO> selectList2(String sDate) {
return targetLogMapper.selectList2(sDate); return targetLogMapper.selectList2(sDate);
...@@ -208,7 +212,6 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe ...@@ -208,7 +212,6 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
orderConsignorService.getOne( orderConsignorService.getOne(
new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, info.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1")); new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, info.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
if (consignorDO != null && !consignorDO.getNoConsignee() if (consignorDO != null && !consignorDO.getNoConsignee()
&& !info.getHasConsignee()) { && !info.getHasConsignee()) {
//getHasConsignee 是否有收货人 //getHasConsignee 是否有收货人
...@@ -331,123 +334,96 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe ...@@ -331,123 +334,96 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
public void dealTargetLogTask(Long orderId, public void dealTargetLogTask(Long orderId,
Date achievementTime, Date achievementTime,
long targetId) { long targetId) {
long selectCount = try {
targetLogMapper.selectCount(TargetLogDO::getOrderId, long selectCount =
orderId); targetLogMapper.selectCount(TargetLogDO::getOrderId,
if (selectCount == 0L) { orderId);
return; if (selectCount == 0L) {
} return;
//获取订单信息
OrderBackInfoDto info = orderQueryService.info(orderId);
if (info == null) {
return;
}
if (info.getSalesmanId() == null) {
return;
}
if (info.getSalesmanId() == 0l) {
return;
}
//客户经理
Long customerId = 0L;
Long saleManid = info.getSalesmanId();
int loglev=0;
CustomerDO consignorDO =
customerService.getCustomer(info.getConsignorVO().getCustomerId());
//收货人
CustomerDO consigneeDO =
customerService.getCustomer(info.getConsigneeVO().getCustomerId());
if (info.getType().contains("2")) {
//层级1: 订单为海外仓订单,业绩归属发货人+
//发货人归属客户经理(判断优先级最高,只要是海外仓,不需要判断其他条件)
//海外仓归属发货人
//customerId = info.getConsignorVO().getCustomerId();
//二期需求修改
customerId = consignorDO.getId();
//客户的客户经理为空,就把业绩归属设为0
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev=11;
} }
loglev=1; //获取订单信息
OrderBackInfoDto info = orderQueryService.info(orderId);
} else { if (info == null) {
OrderConsigneeDO orderConsigneeDO = return;
orderConsigneeService.getOne( }
new LambdaQueryWrapper<OrderConsigneeDO>(). if (info.getSalesmanId() == null) {
eq(OrderConsigneeDO::getOrderId, return;
info.getOrderId()).orderByDesc( }
OrderConsigneeDO::getId).last("limit 1")); if (info.getSalesmanId() == 0l) {
return;
OrderConsignorDO orderConsignorDO = }
orderConsignorService.getOne(
new LambdaQueryWrapper<OrderConsignorDO>(). //客户经理
eq(OrderConsignorDO::getOrderId, Long customerId = 0L;
info.getOrderId()).orderByDesc( Long saleManid = info.getSalesmanId();
OrderConsignorDO::getId).last("limit 1")); int loglev = 0;
if (consignorDO != null && !consignorDO.getNoConsignee() CustomerDO consignorDO =
&& !info.getHasConsignee()) { customerService.getCustomer(info.getConsignorVO().getCustomerId());
//getHasConsignee 是否有收货人 //收货人
//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2 CustomerDO consigneeDO =
if (consignorDO != null) { customerService.getCustomer(info.getConsigneeVO().getCustomerId());
customerId = consignorDO.getId();
loglev=2; if (info.getType().contains("2")) {
//校验客户的客户经理 //层级1: 订单为海外仓订单,业绩归属发货人+
if (consignorDO.getCustomerService() == null || //发货人归属客户经理(判断优先级最高,只要是海外仓,不需要判断其他条件)
consignorDO.getCustomerService() == 0 || //海外仓归属发货人
consignorDO.getIsInOpenSea() == true) { //customerId = info.getConsignorVO().getCustomerId();
//二期需求修改
saleManid = 0L; customerId = consignorDO.getId();
orderService.updateOrderSalesmanId(info.getOrderId(), loglev = 1;
0L); //客户的客户经理为空,就把业绩归属设为0
loglev=21; if (consignorDO.getCustomerService() == null ||
} consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 11;
} }
} else { } else {
List<TargetOfferBackVO> offerBackVOList = OrderConsigneeDO orderConsigneeDO =
targetLogMapper.getTargetOfferBackByOrerId(orderId); orderConsigneeService.getOne(
if (info.getDrawee() == 1) { new LambdaQueryWrapper<OrderConsigneeDO>().
//发货人付款 eq(OrderConsigneeDO::getOrderId,
/* info.getOrderId()).orderByDesc(
if (info.getDrawee() == 1 && OrderConsigneeDO::getId).last("limit 1"));
CollectionUtil.isNotEmpty(offerBackVOList)) {
//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个 OrderConsignorDO orderConsignorDO =
customerId = consignorDO.getId(); orderConsignorService.getOne(
}else if(info.getDrawee() == 1 && new LambdaQueryWrapper<OrderConsignorDO>().
consignorDO.getDefaultPay() ){ eq(OrderConsignorDO::getOrderId,
// 如果是发货人付款且档案设置默认付运费 --层级4 第一个 info.getOrderId()).orderByDesc(
customerId = consignorDO.getId(); OrderConsignorDO::getId).last("limit 1"));
}else{
//业绩归属方是收货人 if (consignorDO != null && !consignorDO.getNoConsignee()
customerId = orderConsigneeDO.getCustomerId() ; && !info.getHasConsignee()) {
}*/ //getHasConsignee 是否有收货人
if (CollectionUtil.isNotEmpty(offerBackVOList)) { //发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个 if (consignorDO != null) {
customerId = consignorDO.getId(); customerId = consignorDO.getId();
loglev=3; loglev = 2;
//校验客户的客户经理 //校验客户的客户经理
if (consignorDO.getCustomerService() == null || if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 || consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) { consignorDO.getIsInOpenSea() == true) {
saleManid = 0L; saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(), orderService.updateOrderSalesmanId(info.getOrderId(),
0L); 0L);
loglev=31; loglev = 21;
} }
} else { }
if (consignorDO.getDefaultPay()) {
//如果是发货人付款且档案设置默认付运费 --层级4 第一个 } else {
List<TargetOfferBackVO> offerBackVOList =
targetLogMapper.getTargetOfferBackByOrerId(orderId);
if (info.getDrawee() == 1) {
if (CollectionUtil.isNotEmpty(offerBackVOList)) {
//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
customerId = consignorDO.getId(); customerId = consignorDO.getId();
loglev=4; loglev = 3;
//校验客户的客户经理 //校验客户的客户经理
if (consignorDO.getCustomerService() == null || if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 || consignorDO.getCustomerService() == 0 ||
...@@ -455,171 +431,189 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe ...@@ -455,171 +431,189 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
saleManid = 0L; saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(), orderService.updateOrderSalesmanId(info.getOrderId(),
0L); 0L);
loglev=41; loglev = 31;
} }
} else { } else {
//业绩归属方是收货人 if (consignorDO.getDefaultPay()) {
loglev=5; //如果是发货人付款且档案设置默认付运费 --层级4 第一个
customerId = orderConsigneeDO.getCustomerId(); customerId = consignorDO.getId();
//校验客户的客户经理 loglev = 4;
if (consigneeDO.getCustomerService() == null || //校验客户的客户经理
consigneeDO.getCustomerService() == 0 || if (consignorDO.getCustomerService() == null ||
consigneeDO.getIsInOpenSea() == true) { consignorDO.getCustomerService() == 0 ||
saleManid = 0L; consignorDO.getIsInOpenSea() == true) {
orderService.updateOrderSalesmanId(info.getOrderId(), saleManid = 0L;
0L); orderService.updateOrderSalesmanId(info.getOrderId(),
loglev=51; 0L);
loglev = 41;
}
} else {
//业绩归属方是收货人
loglev = 5;
customerId = orderConsigneeDO.getCustomerId();
//校验客户的客户经理
if (consigneeDO.getCustomerService() == null ||
consigneeDO.getCustomerService() == 0 ||
consigneeDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 51;
}
} }
} }
}
} else if (info.getDrawee() == 2) {
//收货人付款 层级5 第一个
customerId = orderConsigneeDO.getCustomerId() != null ?
orderConsigneeDO.getCustomerId() : consigneeDO.getId();
loglev=5;
if (consigneeDO != null &&
(consigneeDO.getCustomerService() == null ||
consigneeDO.getCustomerService() == 0)) {
//收货人客户经理为空时不算业绩
//客户来源是发货人推荐,不保留业绩记录 customer_source
//2024-06-03 添加的逻辑
if (consigneeDO.getSource() == 12) {
//删除业绩记录
targetLogMapper.deleteById(targetId);
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
return;
}
}
} else if (info.getDrawee() == 3) { } else if (info.getDrawee() == 2) {
//自定义付款 //收货人付款 层级5 第一个
List<CustomDraweeVO> list = customerId = orderConsigneeDO.getCustomerId() != null ?
JSONObject.parseArray(info.getCustomDrawee(), orderConsigneeDO.getCustomerId() : consigneeDO.getId();
CustomDraweeVO.class); loglev = 5;
if (CollectionUtil.isNotEmpty(list)) { if (consigneeDO != null &&
(consigneeDO.getCustomerService() == null ||
List<CustomDraweeVO> freightList = consigneeDO.getCustomerService() == 0)) {
list.stream().filter(s -> s.getName().equals("freight")).collect(Collectors.toList()); //收货人客户经理为空时不算业绩
List<CustomDraweeVO> clearanceFeeList = //客户来源是发货人推荐,不保留业绩记录 customer_source
list.stream().filter(s -> s.getName().equals("clearanceFee")).collect(Collectors.toList()); //2024-06-03 添加的逻辑
int freight = freightList.get(0).getValue();//运费 if (consigneeDO.getSource() == 12) {
int clearanceFee = clearanceFeeList.get(0).getValue(); //删除业绩记录
//清关费 targetLogMapper.deleteById(targetId);
if (CollectionUtil.isNotEmpty(offerBackVOList) &&
(info.getDrawee() == 3 && freight == 1)) {
//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
customerId = orderConsignorDO.getCustomerId();
loglev=3;
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(), orderService.updateOrderSalesmanId(info.getOrderId(),
0L); 0L);
loglev=31; return;
} }
}
} else if (CollectionUtil.isNotEmpty(offerBackVOList) } else if (info.getDrawee() == 3) {
&& (info.getDrawee() == 3 && clearanceFee == 1)) { //自定义付款
//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费 List<CustomDraweeVO> list =
customerId = orderConsignorDO.getCustomerId(); JSONObject.parseArray(info.getCustomDrawee(),
loglev=3; CustomDraweeVO.class);
//校验客户的客户经理 if (CollectionUtil.isNotEmpty(list)) {
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev=32;
}
} else if (consignorDO.getDefaultPay() && List<CustomDraweeVO> freightList =
(info.getDrawee() == 3 && freight == 1)) { list.stream().filter(s -> s.getName().equals("freight")).collect(Collectors.toList());
//层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人 List<CustomDraweeVO> clearanceFeeList =
customerId = orderConsignorDO.getCustomerId(); list.stream().filter(s -> s.getName().equals("clearanceFee")).collect(Collectors.toList());
loglev=3; int freight = freightList.get(0).getValue();//运费
//校验客户的客户经理 int clearanceFee = clearanceFeeList.get(0).getValue();
if (consignorDO.getCustomerService() == null || //清关费
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev=33;
}
} else if (consignorDO.getDefaultPay() && if (CollectionUtil.isNotEmpty(offerBackVOList) &&
(info.getDrawee() == 3 (info.getDrawee() == 3 && freight == 1)) {
&& clearanceFee == 1)) { //层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人 customerId = orderConsignorDO.getCustomerId();
loglev=4; loglev = 3;
customerId = orderConsignorDO.getCustomerId(); //校验客户的客户经理
//校验客户的客户经理 if (consignorDO.getCustomerService() == null ||
if (consignorDO.getCustomerService() == null || consignorDO.getCustomerService() == 0 ||
consignorDO.getCustomerService() == 0 || consignorDO.getIsInOpenSea() == true) {
consignorDO.getIsInOpenSea() == true) { saleManid = 0L;
saleManid = 0L; orderService.updateOrderSalesmanId(info.getOrderId(),
orderService.updateOrderSalesmanId(info.getOrderId(), 0L);
0L); loglev = 31;
loglev=1; }
}
} else if (CollectionUtil.isNotEmpty(offerBackVOList)
&& (info.getDrawee() == 3 && clearanceFee == 1)) {
//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
customerId = orderConsignorDO.getCustomerId();
loglev = 3;
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 32;
}
} else { } else if (consignorDO.getDefaultPay() &&
customerId = orderConsigneeDO.getCustomerId(); (info.getDrawee() == 3 && freight == 1)) {
loglev=5; //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
//校验客户的客户经理 customerId = orderConsignorDO.getCustomerId();
if (consigneeDO.getCustomerService() == null || loglev = 3;
consigneeDO.getCustomerService() == 0 || //校验客户的客户经理
consigneeDO.getIsInOpenSea() == true) { if (consignorDO.getCustomerService() == null ||
saleManid = 0L; consignorDO.getCustomerService() == 0 ||
orderService.updateOrderSalesmanId(info.getOrderId(), consignorDO.getIsInOpenSea() == true) {
0L); saleManid = 0L;
loglev=51; orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 33;
}
} else if (consignorDO.getDefaultPay() &&
(info.getDrawee() == 3
&& clearanceFee == 1)) {
// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
loglev = 4;
customerId = orderConsignorDO.getCustomerId();
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 1;
}
} else {
customerId = orderConsigneeDO.getCustomerId();
loglev = 5;
//校验客户的客户经理
if (consigneeDO.getCustomerService() == null ||
consigneeDO.getCustomerService() == 0 ||
consigneeDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 51;
}
} }
} }
// if(!consignorDO.getDefaultPay() && (info.getDrawee()==3 && freight==2 ) || (info.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
// customerId = orderConsigneeDO.getCustomerId() ;
//
// }
}
} else { } else {
//业绩归属收货人 //业绩归属收货人
if (orderConsigneeDO != null) { if (orderConsigneeDO != null) {
customerId = customerId =
orderConsigneeDO.getCustomerId() != null ? orderConsigneeDO.getCustomerId() != null ?
orderConsigneeDO.getCustomerId() : 0; orderConsigneeDO.getCustomerId() : 0;
loglev=5; loglev = 5;
//校验客户的客户经理 //校验客户的客户经理
if (consigneeDO != null) { if (consigneeDO != null) {
if (consigneeDO.getCustomerService() == null || if (consigneeDO.getCustomerService() == null ||
consigneeDO.getCustomerService() == 0 || consigneeDO.getCustomerService() == 0 ||
consigneeDO.getIsInOpenSea() == true) { consigneeDO.getIsInOpenSea() == true) {
saleManid = 0L; saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(), orderService.updateOrderSalesmanId(info.getOrderId(),
0L); 0L);
loglev=52; loglev = 52;
}
} }
} }
}
}
} }
} }
TargetLogDO targetLogDO = targetLogMapper.selectById(targetId);
//客户ID
targetLogDO.setCustomerId(customerId);
//客户经理ID
targetLogDO.setUserId(saleManid);
targetLogDO.setLoglev(100);
targetLogDO.setUpdateTime(new Date());
targetLogMapper.updateById(targetLogDO);
}
catch (Exception e)
{
zTest m2 = new zTest();
m2.setTestname(e.getMessage());
m2.setCreatedate(new Date());
zTestMapper2.insert(m2);
} }
TargetLogDO targetLogDO = targetLogMapper.selectById(targetId);
//客户ID
targetLogDO.setCustomerId(customerId);
//客户经理ID
targetLogDO.setUserId(saleManid);
targetLogDO.setUpdateTime(new Date());
targetLogMapper.updateById(targetLogDO);
} }
} }
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