Commit c718e3d1 authored by liuzeheng's avatar liuzeheng

补充业绩规则判断

parent a8ce13fc
......@@ -62,4 +62,11 @@ public interface TargetLogMapper extends AbstractMapper<TargetLogDO> {
"</script>"
})
Date selectCabinetLoadTime(@Param("orderId") Long orderId);
@Select({
"<script>",
"select offer_id as offerId, order_id as orderId,order_no as orderNo from ecw_offer offe where deleted=0 and order_id=#{orderId} limit 1",
"</script>"
})
List<TargetOfferBackVO> getTargetOfferBackByOrerId(Long orderId);
}
......@@ -524,6 +524,9 @@ public class OrderBackInfoDto {
@ApiModelProperty(value = "完成入仓的所有箱内总货物数量")
private Integer sumQuantityAllFinishedWarehouseIn;
@ApiModelProperty(value = "是否有收货人,1-是,0-否")
private Boolean hasConsignee = true;
public void setExceptionReason(String exceptionReason) {
this.exceptionReason = exceptionReason;
if (StringUtils.isNotBlank(exceptionReason) && Objects.nonNull(this.lang)) {
......
package cn.iocoder.yudao.module.order.service.targetLog;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.LoginUser;
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.service.customer.CustomerService;
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.service.order.OrderConsigneeService;
import cn.iocoder.yudao.module.order.service.order.OrderConsignorService;
import cn.iocoder.yudao.module.order.service.order.OrderQueryService;
import cn.iocoder.yudao.module.order.service.order.OrderService;
import cn.iocoder.yudao.module.order.enums.TargetLogEnum;
import cn.iocoder.yudao.module.order.vo.order.CustomDraweeVO;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -45,6 +55,12 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
@Resource
private CustomerService customerService;
@Resource
private OrderConsigneeService orderConsigneeService;
@Resource
private OrderConsignorService orderConsignorService ;
@Override
public Long createTargetLog(TargetLogCreateReqVO createReqVO) {
......@@ -156,10 +172,65 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
if (info.getIsCargoControl()) {//非海外控货归属发货人
customerId = info.getConsignorVO().getCustomerId();
} else {
if (info.getDrawee() == 1) {//非海外非控货 付款人为发货人 归属发货人
customerId = info.getConsignorVO().getCustomerId();
} else { //非海外非控货 付款人为其他 归属收货人
// if (info.getDrawee() == 1) {//非海外非控货 付款人为发货人 归属发货人
// customerId = info.getConsignorVO().getCustomerId();
// } else { //非海外非控货 付款人为其他 归属收货人
// customerId = info.getConsigneeVO().getCustomerId();
// }
CustomerDO consignorDO = customerService.getCustomer(info.getConsignorVO().getCustomerId());
CustomerDO consigneeDO = customerService.getCustomer(info.getConsigneeVO().getCustomerId());//收货人
OrderConsigneeDO orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, info.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
OrderConsignorDO orderConsignorDO = orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, info.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
if(! consignorDO.getNoConsignee() && !info.getHasConsignee()){//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if(consignorDO!=null){
customerId = consignorDO.getId();
}
}
List<TargetOfferBackVO> offerBackVOList =targetLogMapper.getTargetOfferBackByOrerId(orderId) ;
if (info.getDrawee() == 1) {//发货人付款
if (info.getDrawee() == 1 && CollectionUtil.isNotEmpty(offerBackVOList)) {//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
customerId =orderConsignorDO.getCustomerId();
}else if(info.getDrawee() == 1 && consignorDO.getDefaultPay() ){// 如果是发货人付款且档案设置默认付运费 --层级4 第一个
customerId =orderConsignorDO.getCustomerId() ;
}
} else if (info.getDrawee() == 2) {//收货人付款 层级5 第一个
customerId = orderConsigneeDO.getCustomerId()!=null? orderConsigneeDO.getCustomerId():consigneeDO.getId();
} else if (info.getDrawee() == 3) { //自定义付款
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(CollectionUtil.isNotEmpty(offerBackVOList) && ( info.getDrawee()==3 && freight==1 )){//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
customerId = orderConsignorDO.getCustomerId() ;
}else if(CollectionUtil.isNotEmpty(offerBackVOList) && ( info.getDrawee()==3 && clearanceFee==1 )){//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
customerId = orderConsignorDO.getCustomerId() ;
}else if(consignorDO.getDefaultPay() && ( info.getDrawee()==3 && freight==1 )){ //层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
customerId = orderConsignorDO.getCustomerId() ;
}else if (consignorDO.getDefaultPay() && ( info.getDrawee()==3 && clearanceFee==1 )){// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
customerId = orderConsignorDO.getCustomerId() ;
}else if(!consignorDO.getDefaultPay() && (info.getDrawee()==3 && freight==2 ) || (info.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
customerId = orderConsigneeDO.getCustomerId() ;
}
}
} else {
//业绩归属公司
customerId = info.getConsigneeVO().getCustomerId();
}
}
}
......
package cn.iocoder.yudao.module.order.vo.targetLog;
import lombok.Data;
@Data
public class TargetOfferBackVO {
private Long offerId ;
private Long orderId ;
private String orderNo ;
}
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