Commit 23b8bf3a authored by lanbaoming's avatar lanbaoming

2024-07-04-8提交

parent 5ba9d7be
......@@ -335,6 +335,11 @@ public class TargetLogServiceImpl extends
}
public void dealTargetLogTask2(Long orderId,
Date achievementTime,
long targetId) {
}
//按照新的业务规则计算业绩归属
public void dealTargetLogTask(Long orderId,
Date achievementTime,
......@@ -1097,284 +1102,5 @@ public class TargetLogServiceImpl extends
}
public void dealTargetLogTask2(Long orderId,
Date achievementTime,
long targetId) {
try {
long selectCount =
targetLogMapper.selectCount(TargetLogDO::getOrderId,
orderId);
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;
String s_gsf = "n";
CustomerDO consignorDO =
customerService.getCustomer(info.getConsignorVO().getCustomerId());
//收货人
CustomerDO consigneeDO =
customerService.getCustomer(info.getConsigneeVO().getCustomerId());
if (info.getType().contains("2")) {
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"));
//getHasConsignee 是否有收货人
//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if (consignorDO != null) {
customerId = consignorDO.getId();
loglev = 2;
s_gsf = "f";
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 21;
}
}
if (info.getDrawee() == 1) {
if (consignorDO.getDefaultPay()) {
//如果是发货人付款且档案设置默认付运费 --层级4 第一个
customerId = consignorDO.getId();
loglev = 4;
s_gsf = "f";
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 41;
}
} else {
//业绩归属方是收货人
loglev = 5;
customerId = orderConsigneeDO.getCustomerId();
s_gsf = "s";
//校验客户的客户经理
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;
s_gsf = "s";
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) {
//自定义付款
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();
//清关费
if ((info.getDrawee() == 3 && freight == 1)) {
//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
customerId = orderConsignorDO.getCustomerId();
loglev = 3;
s_gsf = "f";
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 31;
}
} else if ((info.getDrawee() == 3 && clearanceFee == 1)) {
//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
customerId = orderConsignorDO.getCustomerId();
loglev = 3;
s_gsf = "f";
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 32;
}
} else if (consignorDO.getDefaultPay() &&
(info.getDrawee() == 3 && freight == 1)) {
//层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
customerId = orderConsignorDO.getCustomerId();
loglev = 3;
s_gsf = "f";
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 33;
}
} else if (consignorDO.getDefaultPay() &&
(info.getDrawee() == 3
&& clearanceFee == 1)) {
// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
loglev = 4;
customerId = orderConsignorDO.getCustomerId();
s_gsf = "f";
//校验客户的客户经理
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;
s_gsf = "s";
//校验客户的客户经理
if (consigneeDO.getCustomerService() == null ||
consigneeDO.getCustomerService() == 0 ||
consigneeDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 51;
}
}
}
} else {
//业绩归属收货人
if (orderConsigneeDO != null) {
customerId =
orderConsigneeDO.getCustomerId() != null ?
orderConsigneeDO.getCustomerId() : 0;
loglev = 5;
s_gsf = "s";
//校验客户的客户经理
if (consigneeDO != null) {
if (consigneeDO.getCustomerService() == null ||
consigneeDO.getCustomerService() == 0 ||
consigneeDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 52;
}
}
}
}
} else {
//层级1: 订单为海外仓订单,业绩归属发货人+
//发货人归属客户经理(判断优先级最高,只要是海外仓,不需要判断其他条件)
//海外仓归属发货人
//customerId = info.getConsignorVO().getCustomerId();
//二期需求修改
customerId = consignorDO.getId();
loglev = 1;
s_gsf = "f";
//客户的客户经理为空,就把业绩归属设为0
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0 ||
consignorDO.getIsInOpenSea() == true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
loglev = 11;
}
}
TargetLogDO targetLogDO = targetLogMapper.selectById(targetId);
//客户ID
targetLogDO.setCustomerId(customerId);
//客户经理ID
targetLogDO.setUserId(saleManid);
if (loglev == 0) {
loglev = -1;
}
targetLogDO.setLoglev(loglev);
targetLogDO.setGsf(s_gsf);
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);
}
}
}
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