Commit ba20d12a authored by lanbaoming's avatar lanbaoming

2024-07-03-4提交

parent 1ca70cc0
......@@ -24,6 +24,15 @@ import java.util.List;
@Mapper
public interface CustomerMapper extends BaseMapperX<CustomerDO> {
//合并操作日志
void doMergeCustomerOperateLog(long customer_id1,long customer_id2);
//合并客户信用日志
void doMergeCustomerCreditLog(long customer_id1,long customer_id2);
//合并客户登记日志
void doMergeCustomerLevelLog(long customer_id1,long customer_id2);
IPage<CustomerDO> getPage(IPage<CustomerDO> page,
@Param(Constants.WRAPPER) Wrapper<CustomerDO> queryWrapper);
......
......@@ -26,6 +26,13 @@ import java.util.List;
*/
public interface CustomerService extends IService<CustomerDO> {
//合并操作日志
void doMergeCustomerOperateLog(long customer_id1,long customer_id2);
//合并客户信用日志
void doMergeCustomerCreditLog(long customer_id1,long customer_id2);
void doMergeCustomerLevelLog(long customer_id1,long customer_id2);
/**
* 新建订单,收货人同步到后台,如果手机号不存在新增一个客户档案,进入待分配客户
......
......@@ -174,6 +174,22 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
public static final String logFormat = "[%d]联系人:%s 区号:%s 电话:%s 默认:(%s)";
//合并操作日志
public void doMergeCustomerOperateLog(long customer_id1, long customer_id2) {
customerMapper.doMergeCustomerOperateLog(customer_id1, customer_id2);
}
//合并客户信用日志
public void doMergeCustomerCreditLog(long customer_id1, long customer_id2) {
customerMapper.doMergeCustomerCreditLog(customer_id1, customer_id2);
}
//合并客户登记日志
public void doMergeCustomerLevelLog(long customer_id1, long customer_id2) {
customerMapper.doMergeCustomerLevelLog(customer_id1, customer_id2);
}
/*
发货人带来的收货人,
......@@ -1148,8 +1164,8 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
log.warn(I18nMessage.getLang().toString());
int start = (page.getPage() - 1) * page.getRows();
int size = page.getRows();
List<CustomerDO> list = customerMapper.getMyPage(start,size,pageReqVO);
long total = customerMapper.getMyPageCount(pageReqVO) ;
List<CustomerDO> list = customerMapper.getMyPage(start, size, pageReqVO);
long total = customerMapper.getMyPageCount(pageReqVO);
return new PageResult<>(list, total,
mpPage.getSize(), page.getPage(),
(total + mpPage.getSize() - 1) / mpPage.getSize());
......@@ -1209,7 +1225,7 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
}
@Override
public PageResult<CustomerDO> getDeptCustomerPageReq(CustomerPageReqDTO pageReqVO,PageVO page){
public PageResult<CustomerDO> getDeptCustomerPageReq(CustomerPageReqDTO pageReqVO, PageVO page) {
IPage<CustomerDO> mpPage = MyBatisUtils.buildPage(page);
log.warn(I18nMessage.getLang().toString());
......@@ -1220,25 +1236,25 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
int start = (page.getPage() - 1) * page.getRows();
int size = page.getRows();
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Long deptId =null;
Long deptId = null;
if (null != loginUser && null != loginUser.getDeptId()) {
deptId = loginUser.getDeptId() ;
deptId = loginUser.getDeptId();
}
List<CustomerDO> list =
customerMapper.getDeptCustomerPageReq(start,size,pageReqVO,deptId);
long total = customerMapper.getDeptCustomerPageReqCount(pageReqVO,deptId) ;
customerMapper.getDeptCustomerPageReq(start, size, pageReqVO, deptId);
long total = customerMapper.getDeptCustomerPageReqCount(pageReqVO, deptId);
return new PageResult<>(list, total, mpPage.getSize(), page.getPage(), (total + mpPage.getSize() - 1) / mpPage.getSize());
}
@Override
public List<CustomerDO> getDeptCustomerExcelVoListReq(CustomerExportReqDTO exportReqVO) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Long deptId =null;
if (null != loginUser && loginUser.getDeptId()>0) {
deptId = loginUser.getDeptId() ;
Long deptId = null;
if (null != loginUser && loginUser.getDeptId() > 0) {
deptId = loginUser.getDeptId();
}
return customerMapper.getDeptCustomerExcelVoListReq(exportReqVO,deptId) ;
return customerMapper.getDeptCustomerExcelVoListReq(exportReqVO, deptId);
}
@Override
......@@ -1348,15 +1364,16 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
/**
* 获得待分配客户列表 支持多个筛选
*
* @param pageReqVO
* @param page
* @return
*/
@Override
public PageResult<CustomerDO> getWaitToAssignedCustomerPageReq(CustomerPageReqDTO pageReqVO,PageVO page) {
pageReqVO.setIsInOpenSea(false) ;
pageReqVO.setIsCustomerServiceConfirmed(false) ;
pageReqVO.setCustomerService(null) ;
public PageResult<CustomerDO> getWaitToAssignedCustomerPageReq(CustomerPageReqDTO pageReqVO, PageVO page) {
pageReqVO.setIsInOpenSea(false);
pageReqVO.setIsCustomerServiceConfirmed(false);
pageReqVO.setCustomerService(null);
IPage<CustomerDO> mpPage = MyBatisUtils.buildPage(page);
log.warn(I18nMessage.getLang().toString());
......@@ -1366,8 +1383,8 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
int start = (page.getPage() - 1) * page.getRows();
int size = page.getRows();
List<CustomerDO> list =
customerMapper.getWaitToAssignedCustomerPageReq(start,size,pageReqVO);
long total = customerMapper.getWaitToAssignedCustomerPageReqCount(pageReqVO) ;
customerMapper.getWaitToAssignedCustomerPageReq(start, size, pageReqVO);
long total = customerMapper.getWaitToAssignedCustomerPageReqCount(pageReqVO);
return new PageResult<>(list, total, mpPage.getSize(), page.getPage(), (total + mpPage.getSize() - 1) / mpPage.getSize());
}
......@@ -1420,8 +1437,9 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
@Override
public List<CustomerDO> getWaitToAssignedCustomerExcelVoListReq(CustomerExportReqDTO exportReqVO) {
return customerMapper.getWaitToAssignedCustomerListReq(exportReqVO) ;
return customerMapper.getWaitToAssignedCustomerListReq(exportReqVO);
}
@Override
public PageResult<CustomerDO> getWaitToConfirmCustomerPage(CustomerPageReqVO pageReqVO) {
......@@ -1478,9 +1496,9 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
}
@Override
public PageResult<CustomerDO> getWaitToConfirmCustomerPageReq(CustomerPageReqDTO pageReqVO, PageVO page){
pageReqVO.setIsCustomerServiceConfirmed(false) ;
pageReqVO.setIsInOpenSea(false) ;
public PageResult<CustomerDO> getWaitToConfirmCustomerPageReq(CustomerPageReqDTO pageReqVO, PageVO page) {
pageReqVO.setIsCustomerServiceConfirmed(false);
pageReqVO.setIsInOpenSea(false);
IPage<CustomerDO> mpPage = MyBatisUtils.buildPage(page);
log.warn(I18nMessage.getLang().toString());
......@@ -1490,8 +1508,8 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
int start = (page.getPage() - 1) * page.getRows();
int size = page.getRows();
List<CustomerDO> list =
customerMapper.getWaitToConfirmCustomerPageReq(start,size,pageReqVO);
long total = customerMapper.getWaitToConfirmCustomerPageReqCount(pageReqVO) ;
customerMapper.getWaitToConfirmCustomerPageReq(start, size, pageReqVO);
long total = customerMapper.getWaitToConfirmCustomerPageReqCount(pageReqVO);
return new PageResult<>(list, total, mpPage.getSize(), page.getPage(), (total + mpPage.getSize() - 1) / mpPage.getSize());
}
......@@ -1544,23 +1562,26 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
return customerMapper.getCustomerExcelVoList(customerDOLambdaQueryWrapperX);
}
/**
* 我的待接收客户列表, 用于 Excel 导出 ,支持多选
*
* @param reqVO
* @return
*/
@Override
public List<CustomerDO> getWaitToConfirmCustomerExcelVoListReq(CustomerExportReqDTO reqVO){
reqVO.setIsCustomerServiceConfirmed(false) ;
reqVO.setIsInOpenSea(false) ;
public List<CustomerDO> getWaitToConfirmCustomerExcelVoListReq(CustomerExportReqDTO reqVO) {
reqVO.setIsCustomerServiceConfirmed(false);
reqVO.setIsInOpenSea(false);
List<Long> setCustomerService = new ArrayList<Long>();
if(getLoginUserId()!=null){
setCustomerService.add(getLoginUserId()) ;
reqVO.setCustomerService(setCustomerService) ;
if (getLoginUserId() != null) {
setCustomerService.add(getLoginUserId());
reqVO.setCustomerService(setCustomerService);
}
return customerMapper.getWaitToConfirmCustomerExcelVoListReq(reqVO) ;
return customerMapper.getWaitToConfirmCustomerExcelVoListReq(reqVO);
}
@Override
public PageResult<CustomerDO> getOpenSeaCustomerPage(CustomerPageReqVO reqVO) {
......@@ -1614,7 +1635,7 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
}
@Override
public PageResult<CustomerDO> getOpenSeaCustomerPageReq(CustomerPageReqDTO pageReqVO,PageVO page){
public PageResult<CustomerDO> getOpenSeaCustomerPageReq(CustomerPageReqDTO pageReqVO, PageVO page) {
pageReqVO.setIsInOpenSea(true);
IPage<CustomerDO> mpPage = MyBatisUtils.buildPage(page);
......@@ -1626,8 +1647,8 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
int start = (page.getPage() - 1) * page.getRows();
int size = page.getRows();
List<CustomerDO> list =
customerMapper.getOpenSeaCustomerPageReq(start,size,pageReqVO);
long total = customerMapper.getOpenSeaCustomerPageReqCount(pageReqVO) ;
customerMapper.getOpenSeaCustomerPageReq(start, size, pageReqVO);
long total = customerMapper.getOpenSeaCustomerPageReqCount(pageReqVO);
return new PageResult<>(list, total, mpPage.getSize(), page.getPage(), (total + mpPage.getSize() - 1) / mpPage.getSize());
}
......@@ -1679,9 +1700,9 @@ public class CustomerServiceImpl extends AbstractService<CustomerMapper,
}
@Override
public List<CustomerDO> getPublicCustomerExcelVoReqList(@Param("query") CustomerExportReqDTO reqVO){
reqVO.setIsInOpenSea(true) ;
return customerMapper.getPublicCustomerExcelVoReqList(reqVO) ;
public List<CustomerDO> getPublicCustomerExcelVoReqList(@Param("query") CustomerExportReqDTO reqVO) {
reqVO.setIsInOpenSea(true);
return customerMapper.getPublicCustomerExcelVoReqList(reqVO);
}
@Override
......
......@@ -60,7 +60,8 @@ public interface CustomerComplaintService extends IService<CustomerComplaintDO>
* @param pageReqVO 分页查询
* @return 客户投诉分页
*/
PageResult<CustomerComplaintRespVO> getCustomerComplaintPage(CustomerComplaintPageReqVO pageReqVO);
PageResult<CustomerComplaintRespVO> getCustomerComplaintPage(
CustomerComplaintPageReqVO pageReqVO);
/**
* 获得客户投诉列表, 用于 Excel 导出
......@@ -68,6 +69,7 @@ public interface CustomerComplaintService extends IService<CustomerComplaintDO>
* @param exportReqVO 查询条件
* @return 客户投诉列表
*/
List<CustomerComplaintExcelVO> getCustomerComplaintList(CustomerComplaintExportReqVO exportReqVO);
List<CustomerComplaintExcelVO> getCustomerComplaintList(
CustomerComplaintExportReqVO exportReqVO);
}
......@@ -81,7 +81,8 @@ public class CustomerOperateLogServiceImpl extends AbstractService<CustomerOpera
}
@Override
public PageResult<CustomerOperateLogDO> getOperateLogPage(CustomerOperateLogQueryVO query, PageVO page) {
public PageResult<CustomerOperateLogDO> getOperateLogPage(
CustomerOperateLogQueryVO query, PageVO page) {
return customerOperateLogMapper.selectPage(page, query);
}
......
......@@ -41,8 +41,6 @@
</select>
<select id="getList" resultType="cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO">
select * from (
<include refid="queryTable"/>
......@@ -50,7 +48,6 @@
${ew.customSqlSegment}
</select>
<select id="getMyCustomerList"
resultType="cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO">
<include refid="queryTable"/>
......@@ -1703,4 +1700,24 @@
</select>
<update id="doMergeCustomerLevelLog">
<!--合并客户登记日志-->
update ecw_customer_level_log set customer_id=#{customer_id1},update_time=now()
where customer_id=#{customer_id2}
</update>
<update id="doMergeCustomerCreditLog">
<!--合并信用日志-->
update ecw_customer_credit_log set customer_id=#{customer_id1},update_time=now()
where customer_id=#{customer_id2}
</update>
<update id="doMergeCustomerOperateLog">
<!--合并操作日志-->
update ecw_customer_operate_log set customer_id=#{customer_id1},update_time=now()
where customer_id=#{customer_id2}
</update>
</mapper>
......@@ -263,7 +263,8 @@ public class CustomerController {
for (CustomerContactsUpdateReqVO customerContact : customerContacts) {
Long userid = customerContact.getUserid();
if (userid != null && userid != 0) { //老数据导入过来后部分userid=0
count = customerContactsService.count(new LambdaQueryWrapperX<CustomerContactsDO>().eq(CustomerContactsDO::getUserid, userid)
count = customerContactsService.count(
new LambdaQueryWrapperX<CustomerContactsDO>().eq(CustomerContactsDO::getUserid, userid)
.ne(CustomerContactsDO::getCustomerId, updateReqVO.getId()).eq(BaseDO::getDeleted, 0));
if (count > 0) {
UserRespDTO user = memberUserApi.getUser(userid);
......@@ -363,6 +364,7 @@ public class CustomerController {
//3. 合并后,非主客户的联系人,跟进记录,报价单,订单,
// 客户投诉,品牌授权都迁移到保留客户中,其他信息不会迁移,
// 如需要维护非主客户的客户档案信息到保留客户中,请先维护好再操作
if (par.getId1() == null) {
return success(false);
}
......@@ -400,7 +402,9 @@ public class CustomerController {
}
private boolean doMergeCus(CustomerDO customerDO1,
CustomerDO customerDO2, long loginUserId) {
CustomerDO customerDO2,
long loginUserId) {
/*
提交验证:
当保留客户和非主客户的客户经理均不为空且不是同一个用户(允许客户在公海),
......@@ -422,22 +426,27 @@ public class CustomerController {
非主客户关联的订单/收款单/佣金情况单,佣金付款单有在途流程,
需要测试这种情况是否影响合并
*/
//把客户2的联系方式合并到客户1
//把客户2的联系方式合并到客户1 1
doMogeContact(customerDO1, customerDO2, loginUserId);
//合并报价单
//合并报价单 2
doMogeOffer(customerDO1, customerDO2, loginUserId);
//合并跟进记录
//合并跟进记录 3
doMergeCustomerFollow(customerDO1, customerDO2, loginUserId);
//合并客户投诉
//合并客户投诉 4
doMergeCustomerComplaint(customerDO1, customerDO2, loginUserId);
//合并收款单信息
//合并收款单信息 5
doMergeeReceipt(customerDO1, customerDO2, loginUserId);
//合并产品品牌授权
//合并产品品牌授权 6
doMergeProductBrandEmpower(customerDO1,customerDO2,loginUserId);
//合并客户信用日志
//合并客户登记日志 7
doMergeCustomerLevelLog(customerDO1,customerDO2,loginUserId);
//合并信用日志 8
customerService.doMergeCustomerCreditLog(customerDO1.getId(),
customerDO2.getId());
//合并操作日志 9
customerService.doMergeCustomerOperateLog(customerDO1.getId(),
customerDO2.getId());
return true;
}
......@@ -446,21 +455,8 @@ public class CustomerController {
CustomerDO customerDO2,
long loginUserId)
{
/*
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<>().
eq(CustomerLevelLogDO::getCustomerId,
customerService.doMergeCustomerLevelLog(customerDO1.getId(),
customerDO2.getId());
List<CustomerLevelLogDO> list =
customerLevelLogService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (CustomerLevelLogDO d : list
) {
d.setCustomerId(customerDO1.getId());
customerLevelLogService.updateById(d);
}*/
}
......@@ -469,7 +465,6 @@ public class CustomerController {
CustomerDO customerDO2,
long loginUserId)
{
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<ProductBrandEmpowerDO>().
eq(ProductBrandEmpowerDO::getCustomerId,
......@@ -490,8 +485,11 @@ public class CustomerController {
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<CustomerComplaintDO>().
eq(CustomerComplaintDO::getCustomerId, customerDO2.getId());
List<CustomerComplaintDO> list = customerComplaintService.selectList(q2);
eq(CustomerComplaintDO::getCustomerId,
customerDO2.getId());
List<CustomerComplaintDO> list =
customerComplaintService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (CustomerComplaintDO d : list
......
......@@ -126,7 +126,8 @@ public class CustomerDetailController {
@GetMapping("/creditLogPage")
@ApiOperation("获得客户信用日志分页")
public CommonResult<PageResult<CustomerCreditLogBackVO>> getCreditLogPage(@RequestParam("customerId") Long customerId, PageParam page) {
public CommonResult<PageResult<CustomerCreditLogBackVO>> getCreditLogPage(
@RequestParam("customerId") Long customerId, PageParam page) {
return success(customerCreditLogService.getCreditLogPage(customerId, page));
}
}
......@@ -77,7 +77,8 @@ public class CustomerOperateLogController {
@ApiOperation("获得客户操作日志分页")
@PreAuthorize("@ss.hasPermission('customer:operate-log:query')")
public CommonResult<PageResult<CustomerOperateLogBackVO>> getOperateLogPage(@Valid CustomerOperateLogQueryVO query, PageVO page) {
PageResult<CustomerOperateLogDO> pageResult = operateLogService.getOperateLogPage(query, page);
PageResult<CustomerOperateLogDO> pageResult =
operateLogService.getOperateLogPage(query, page);
return success(CustomerOperateLogConvert.INSTANCE.convertPage(pageResult));
}
......
......@@ -6016,6 +6016,10 @@ public interface OrderMapper extends AbstractMapper<OrderDO> {
@Param("calVvalue") BigDecimal calVvalue,
@Param("yejiCreateDate") Date yejiCreateDate);
@Update("update ecw_order set salesman_id=#{salesman_id} where order_id = #{orderId}")
void updateOrderSalesmanId(@Param("orderId") Long orderId,
@Param("salesman_id") Long salesman_id);
/**
* 报价结果赢单时,同步业绩归属
* @param customerId
......
......@@ -78,4 +78,14 @@ public interface TargetLogMapper extends AbstractMapper<TargetLogDO> {
})
List<TargetLogDO> selectList2(String sDate);
/*
@Select({
"<script>",
"select * from ecw_target_log where deleted=0 and (DATE_FORMAT(create_time,'%Y-%m')=#{sDate} OR DATE_FORMAT(achievement_time,'%Y-%m')=#{sDate})",
"</script>"
})
List<TargetLogDO> selectList2(String sDate);
*/
}
......@@ -29,6 +29,7 @@ import java.util.List;
*/
public interface OrderService extends IService<OrderDO> {
void updateOrderSalesmanId(Long orderId,Long salesman_id);
/**
* 创建订单
*
......
......@@ -162,16 +162,25 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
return;
}
// 判断该订单、该客户是否有未分配客户异常,如果有,则这个订单不计算业绩
List<OrderExceptionDO> orderExceptionDOList = orderExceptionService.getOrderExceptionByCustomerId(order.getCustomerId());
List<OrderExceptionDO> orderExceptionDOList =
orderExceptionService.getOrderExceptionByCustomerId(
order.getCustomerId());
// 获取当前订单的异常
OrderExceptionDO currentOrderException = orderExceptionDOList.stream()
.filter(orderExceptionDO -> Objects.equals(orderExceptionDO.getOrderId(), order.getOrderId())).findFirst().orElse(null);
CustomerDO customerDO = customerService.getById(order.getCustomerId());
Long oldCustomerService = null; // 老客户经理默认为null
if (Objects.nonNull(customerDO) && Objects.nonNull(customerDO.getCustomerService()) && customerDO.getCustomerService() != 0L && Objects.nonNull(customerDO.getCustomerServiceAssignedTime())
&& !customerDO.getIsCustomerServiceConfirmed() && !customerDO.getIsInOpenSea()) {
// 如果客户存在,客户经理已分配,有分配时间,但是待确认接收,也不是公海捞取,那么需要判断该客户之前是否有客户经理,没有则业绩属于公司客户,有则业绩归属于上个客户经理
CustomerOperateLogDO customerOperateLogDO = customerOperateLogService.getOne(new LambdaQueryWrapper<CustomerOperateLogDO>()
if (Objects.nonNull(customerDO) &&
Objects.nonNull(customerDO.getCustomerService())
&& customerDO.getCustomerService() != 0L
&& Objects.nonNull(customerDO.getCustomerServiceAssignedTime())
&& !customerDO.getIsCustomerServiceConfirmed()
&& !customerDO.getIsInOpenSea()) {
// 如果客户存在,客户经理已分配,有分配时间,但是待确认接收,
// 也不是公海捞取,那么需要判断该客户之前是否有客户经理,
// 没有则业绩属于公司客户,有则业绩归属于上个客户经理
CustomerOperateLogDO customerOperateLogDO =
customerOperateLogService.getOne(new LambdaQueryWrapper<CustomerOperateLogDO>()
.eq(CustomerOperateLogDO::getCustomerId, customerDO.getId())
.eq(CustomerOperateLogDO::getOperateType, 4) // TODO 暂定操作类型4为分配操作,有遗漏后面补充操作类型即可
.orderByDesc(CustomerOperateLogDO::getId).last("limit 1"));
......@@ -192,8 +201,12 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
if (Objects.nonNull(adminUserRespDTO)) {
order.setDeptId(adminUserRespDTO.getDeptId());
}
} else if (CollectionUtil.isEmpty(orderExceptionDOList) && Objects.nonNull(customerDO)
&& (Objects.isNull(customerDO.getCustomerService()) || (!customerDO.getIsCustomerServiceConfirmed() && Objects.isNull(oldCustomerService)))) {
} else if (CollectionUtil.isEmpty(orderExceptionDOList) &&
Objects.nonNull(customerDO)
&& (Objects.isNull(customerDO.getCustomerService()) ||
(!customerDO.getIsCustomerServiceConfirmed()
&& Objects.isNull(oldCustomerService)))) {
// 如果客户正在移交新客户经理,但是未接收,并且老客户经理不为null,则不创建客户经理未分配异常
//web下单,业绩为收货人,不产生未分配客户经理异常
if (order.getUserId() != null && order.getUserId() > 0 && customerType == 2) {
......@@ -219,7 +232,8 @@ public class OrderBusinessServiceImpl extends AbstractService<OrderMapper, Order
orderExceptionService.createOrderException(orderExceptionCreateReqVO);
}
} else {
// 该订单存在该客户未分配客户经理异常,或者该客户的客户经理待接收,则不再生成未分配客户经理异常,且该订单不产生业绩归属
// 该订单存在该客户未分配客户经理异常,
// 或者该客户的客户经理待接收,则不再生成未分配客户经理异常,且该订单不产生业绩归属
order.setSalesmanId(0L);
order.setDeptId(0L);
}
......
......@@ -199,7 +199,10 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
List<DictDataRespDTO> dictList =
dictDataApi.getDictDatas("part_function_switch");
//智慧预装功能开关
DictDataRespDTO dictDataRespDTO = dictList.stream().filter(dto -> "create_order_phone_limit".equals(dto.getLabel())).findFirst().orElse(null);
DictDataRespDTO dictDataRespDTO = dictList.stream().filter(
dto -> "create_order_phone_limit".equals(dto.getLabel())).findFirst().
orElse(null);
if ((Objects.isNull(createReqVO.getIsCargoControl()) ||
!createReqVO.getIsCargoControl()) &&
Objects.nonNull(dictDataRespDTO) &&
......@@ -285,7 +288,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
// 查询始发地与目的地信息
RegionDO departure = regionService.getRegion(createReqVO.getDepartureId());
if (Objects.isNull(departure) || (!StrUtil.equals(departure.getType(), "2") && !StrUtil.equals(departure.getType(), "3"))) {
if (Objects.isNull(departure) || (!StrUtil.equals(departure.getType(), "2")
&& !StrUtil.equals(departure.getType(), "3"))) {
throw exception(DEPARTURE_NOT_EXISTS);
}
RegionDO objective = regionService.getRegion(createReqVO.getObjectiveId());
......@@ -294,7 +298,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
newOrderNo = "DRAFT-" + System.currentTimeMillis();
} else {
newOrderNo = orderBusinessService.saveOrUpdateOrderNo(objective, createReqVO.getTransportId(), createReqVO.getIsExternalWarehouse(),
newOrderNo = orderBusinessService.saveOrUpdateOrderNo(objective,
createReqVO.getTransportId(),
createReqVO.getIsExternalWarehouse(),
StringUtils.isNotBlank(createReqVO.getType()) && createReqVO.getType().contains("1"));
}
order.setOrderNo(newOrderNo);
......@@ -847,8 +853,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (StringUtils.isNotBlank(orderConsignorDO.getPhone())) {
orderConsignorService.save(orderConsignorDO);
}
if (order.getIsCargoControl() && !Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
// 控货订单 添加控货人信息 (当放货人为空时不添加 注:当报价单赢单创建的草稿订单可能发货人为空)
if (order.getIsCargoControl() &&
!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
// 控货订单 添加控货人信息 (当放货人为空时不添加 注:
// 当报价单赢单创建的草稿订单可能发货人为空)
OrderCargoControlDO orderCargoControlDO = new OrderCargoControlDO();
BeanUtils.copyProperties(orderConsignorDO, orderCargoControlDO);
orderCargoControlDO.setId(null); // 置空主键ID
......@@ -860,7 +870,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderCargoControlDO.setCreateTime(now);
orderCargoControlDO.setIsActual(Boolean.TRUE);
orderCargoControlMapper.insert(orderCargoControlDO);
// TODO 订单控货信息日志补充
//TODO 订单控货信息日志补充
String msg = String.format("订单创建默认发货人控货信息,姓名%s,电话+%s", orderConsignorDO.getName() + "/" + (StringUtils.isNotBlank(orderConsignorDO.getNameEn()) ? orderConsignorDO.getNameEn() : "空"),
orderConsignorDO.getCountryCode() + orderConsignorDO.getPhone());
orderBusinessService.createOrderControlLog(orderCargoControlDO.getOrderId(), 1, "创建控货信息", msg, 0L);
......@@ -978,7 +988,6 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
if (!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
// 发货人 1 收货人 2
int customerType = this.checkOrderSalesman(order,
createReqVO.getOfferId(),
......@@ -986,7 +995,6 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
null,
orderConsignorDO,
orderConsigneeDO);
// 更新所属客户经理(业务员)
if (Objects.nonNull(order.getCustomerId()) && order.getCustomerId() > 0) {
//addOrderCustomerService(order, customerType);
......@@ -1405,46 +1413,81 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
}
private void addOrderCustomerService(OrderDO order, int customerType) {
if (Objects.nonNull(order.getParentOrderId()) && order.getParentOrderId() > 0 && !order.getSplitSeparateOrder()) {
private void addOrderCustomerService(OrderDO order,
int customerType) {
if (Objects.nonNull(order.getParentOrderId()) &&
order.getParentOrderId() > 0 &&
!order.getSplitSeparateOrder()) {
// 拆单子订单,并且未标记为独立订单,则不执行客户经理分配规则,以原单为主
return;
}
// 判断该订单、该客户是否有未分配客户异常,如果有,则这个订单不计算业绩
List<OrderExceptionDO> orderExceptionDOList = orderExceptionService.getOrderExceptionByCustomerId(order.getCustomerId());
List<OrderExceptionDO> orderExceptionDOList =
orderExceptionService.getOrderExceptionByCustomerId(
order.getCustomerId());
// 获取当前订单的异常
OrderExceptionDO currentOrderException = orderExceptionDOList.stream()
.filter(orderExceptionDO -> Objects.equals(orderExceptionDO.getOrderId(), order.getOrderId())).findFirst().orElse(null);
OrderExceptionDO currentOrderException =
orderExceptionDOList.stream()
.filter(orderExceptionDO -> Objects.equals(
orderExceptionDO.getOrderId(),
order.getOrderId())).findFirst().orElse(null);
CustomerDO customerDO = customerService.getById(order.getCustomerId());
Long oldCustomerService = null; // 老客户经理默认为null
if (Objects.nonNull(customerDO) && Objects.nonNull(customerDO.getCustomerService()) && customerDO.getCustomerService() != 0L && Objects.nonNull(customerDO.getCustomerServiceAssignedTime())
&& !customerDO.getIsCustomerServiceConfirmed() && !customerDO.getIsInOpenSea()) {
// 如果客户存在,客户经理已分配,有分配时间,但是待确认接收,也不是公海捞取,那么需要判断该客户之前是否有客户经理,没有则业绩属于公司客户,有则业绩归属于上个客户经理
CustomerOperateLogDO customerOperateLogDO = customerOperateLogService.getOne(new LambdaQueryWrapper<CustomerOperateLogDO>()
Long oldCustomerService = null;
// 老客户经理默认为null
if (Objects.nonNull(customerDO) &&
Objects.nonNull(customerDO.getCustomerService())
&& customerDO.getCustomerService() != 0L
&& Objects.nonNull(customerDO.getCustomerServiceAssignedTime())
&& !customerDO.getIsCustomerServiceConfirmed()
&& !customerDO.getIsInOpenSea()) {
// 如果客户存在,客户经理已分配,有分配时间,但是待确认接收,
// 也不是公海捞取,那么需要判断该客户之前是否有客户经理,没有则业绩属于公司客户,有则业绩归属于上个客户经理
CustomerOperateLogDO customerOperateLogDO =
customerOperateLogService.getOne(
new LambdaQueryWrapper<CustomerOperateLogDO>()
.eq(CustomerOperateLogDO::getCustomerId, customerDO.getId())
.eq(CustomerOperateLogDO::getOperateType, 4) // TODO 暂定操作类型4为分配操作,有遗漏后面补充操作类型即可
.orderByDesc(CustomerOperateLogDO::getId).last("limit 1"));
if (Objects.nonNull(customerOperateLogDO) && Objects.nonNull(customerOperateLogDO.getOldCustomerService()) && customerOperateLogDO.getOldCustomerService() != 0L) {
if (Objects.nonNull(customerOperateLogDO) &&
Objects.nonNull(customerOperateLogDO.getOldCustomerService())
&& customerOperateLogDO.getOldCustomerService() != 0L) {
oldCustomerService = customerOperateLogDO.getOldCustomerService();
}
}
// 没有该订单,该客户的未分配客户经理异常
if (Objects.isNull(currentOrderException) && Objects.nonNull(customerDO) && Objects.nonNull(customerDO.getCustomerService()) && customerDO.getCustomerService() != 0L
&& (customerDO.getIsCustomerServiceConfirmed() || (!customerDO.getIsCustomerServiceConfirmed() && Objects.nonNull(oldCustomerService)))) {
if (Objects.isNull(currentOrderException)
&& Objects.nonNull(customerDO)
&& Objects.nonNull(customerDO.getCustomerService())
&& customerDO.getCustomerService() != 0L
&& (customerDO.getIsCustomerServiceConfirmed() ||
(!customerDO.getIsCustomerServiceConfirmed()
&& Objects.nonNull(oldCustomerService)))) {
if (Objects.nonNull(oldCustomerService)) {
// 如果这里的旧客户经理id不为null,说明此客户属于移交新客户经理,但是新客户经理还未接收,业绩算老客户经理的
// 如果这里的旧客户经理id不为null,说明此客户属于移交新客户经理,
// 但是新客户经理还未接收,业绩算老客户经理的
order.setSalesmanId(oldCustomerService);
} else {
//order.setSalesmanId(customerDO.getCustomerService());
addOrderSalesmanCustomerService(order);
}
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(order.getSalesmanId());
AdminUserRespDTO adminUserRespDTO =
adminUserApi.getUser(order.getSalesmanId());
if (Objects.nonNull(adminUserRespDTO)) {
order.setDeptId(adminUserRespDTO.getDeptId());
}
} else if (CollectionUtil.isEmpty(orderExceptionDOList) && Objects.nonNull(customerDO)
&& (Objects.isNull(customerDO.getCustomerService()) || (!customerDO.getIsCustomerServiceConfirmed() && Objects.isNull(oldCustomerService)))) {
// 如果客户正在移交新客户经理,但是未接收,并且老客户经理不为null,则不创建客户经理未分配异常
} else if (CollectionUtil.isEmpty(orderExceptionDOList) &&
Objects.nonNull(customerDO)
&& (Objects.isNull(customerDO.getCustomerService()) ||
(!customerDO.getIsCustomerServiceConfirmed() &&
Objects.isNull(oldCustomerService)))) {
// 如果客户正在移交新客户经理,但是未接收,并且老客户经理不为null,
// 则不创建客户经理未分配异常
//web下单,业绩为收货人,不产生未分配客户经理异常
if (order.getUserId() != null && order.getUserId() > 0 &&
customerType == 2) {
......@@ -1466,12 +1509,20 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
descZh = String.format(descZh, "收货人", customerDO.getNumber());
descEn = String.format(descEn, "consignee", customerDO.getNumber());
}
OrderExceptionCreateReqVO orderExceptionCreateReqVO = this.genOrderException(order.getOrderId(), order, null, order.getCustomerId(), OrderExceptionEnum.NOT_CUSTOMER_SERVICE_EXCEPTION,
descZh, descEn);
orderExceptionService.createOrderException(orderExceptionCreateReqVO);
OrderExceptionCreateReqVO orderExceptionCreateReqVO =
this.genOrderException(order.getOrderId(),
order, null,
order.getCustomerId(),
OrderExceptionEnum.NOT_CUSTOMER_SERVICE_EXCEPTION,
descZh,
descEn);
orderExceptionService.createOrderException(
orderExceptionCreateReqVO);
}
} else {
// 该订单存在该客户未分配客户经理异常,或者该客户的客户经理待接收,则不再生成未分配客户经理异常,且该订单不产生业绩归属
// 该订单存在该客户未分配客户经理异常,或者该客户的客户经理待接收,
// 则不再生成未分配客户经理异常,且该订单不产生业绩归属
order.setSalesmanId(0L);
order.setDeptId(0L);
}
......@@ -1902,7 +1953,8 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
@Override
@Transactional(rollbackFor = Exception.class)
public void updateOrder(OrderUpdateReqVO updateReqVO, MemberUserDO memberUserDO) {
public void updateOrder(OrderUpdateReqVO updateReqVO,
MemberUserDO memberUserDO) {
int type = 2;
if (Objects.equals(TransportTypeShortEnum.SEA_CONTAINER.getValue(), updateReqVO.getTransportId()) || Objects.equals(TransportTypeShortEnum.MARINE_CONTAINER.getValue(), updateReqVO.getTransportId())) {
......@@ -3303,8 +3355,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
}
private void appUpdateConsignorAndConsignee(OrderUpdateReqVO updateReqVO, OrderDO updateObj, String
updater, Date now, MemberUserDO memberUserDO, DictDataRespDTO dictDataRespDTO) {
private void appUpdateConsignorAndConsignee(OrderUpdateReqVO updateReqVO,
OrderDO updateObj,
String updater,
Date now,
MemberUserDO memberUserDO,
DictDataRespDTO dictDataRespDTO) {
// 根据会员ID获取客户联系人ID与客户ID
CustomerContactsDO customerContacts = customerContactsService.getOne(new LambdaQueryWrapper<CustomerContactsDO>()
.and(we -> we.eq(CustomerContactsDO::getUserid, memberUserDO.getId())
......@@ -3478,9 +3534,17 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
}
orderConsigneeService.saveOrUpdate(orderConsigneeDO);
if (!Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (!Objects.equals(updateReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
//customerType 发货人 1 收货人 2
int customerType = this.checkOrderSalesman(updateObj, updateReqVO.getOfferId(), consignorCustomerDO, null, orderConsignorDO, orderConsigneeDO);
int customerType =
this.checkOrderSalesman(updateObj,
updateReqVO.getOfferId(),
consignorCustomerDO,
null,
orderConsignorDO,
orderConsigneeDO);
// if (Objects.nonNull(updateObj.getType()) && updateObj.getType().contains("2")) {
// // 海外仓归属发货人
// updateObj.setCustomerId(orderConsignorDO.getCustomerId());
......@@ -3560,13 +3624,18 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus())
&& Objects.nonNull(updateObj.getCustomerId()) &&
updateObj.getCustomerId() > 0) {
addOrderCustomerService(updateObj, customerType);
}
}
}
private void adminUpdateConsignorAndConsignee(OrderUpdateReqVO updateReqVO, OrderDO updateObj, String updater,
Date now, DictDataRespDTO dictDataRespDTO) {
private void adminUpdateConsignorAndConsignee(OrderUpdateReqVO updateReqVO,
OrderDO updateObj,
String updater,
Date now,
DictDataRespDTO dictDataRespDTO) {
CustomerDO consignorDO = customerService.getCustomer(updateReqVO.getConsignorId());
CustomerContactsDO consignorContactsDO = customerContactsService.getCustomerContacts(updateReqVO.getConsignorContactsId());
......@@ -3780,12 +3849,20 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (StringUtils.isNotBlank(orderConsigneeDO.getPhone())) {
orderConsigneeService.saveOrUpdate(orderConsigneeDO);
}
if (!Objects.equals(updateReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
if (!Objects.equals(updateReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
//customerType 发货人 1 收货人 2
int customerType = this.checkOrderSalesman(updateObj, updateReqVO.getOfferId(), consignorDO, consigneeDO, orderConsignorDO, orderConsigneeDO);
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) {
if (!OrderStatusEnum.DRAFT.getValue().equals(updateObj.getStatus())
&& Objects.nonNull(updateObj.getCustomerId())
&& updateObj.getCustomerId() > 0) {
addOrderCustomerService(updateObj, customerType);
//setUpdateOrderCustomerServiceCustomerId(updateReqVO, updateObj,consignorDO,consigneeDO,orderConsignorDO,orderConsigneeDO);
}
......@@ -6357,13 +6434,16 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
OrderConsignorDO orderConsignorDO =
orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderConsignorDO::getId).last("limit 1"));
OrderConsigneeDO orderConsigneeDO =
orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
orderConsigneeService.getOne(
new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, orderDO.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
// 更新所属客户经理(业务员)
if (Objects.isNull(orderDO.getParentOrderId()) ||
orderDO.getParentOrderId() == 0 ||
orderDO.getSplitSeparateOrder()) {
// 拆单子订单不执行客户经理分配规则,以原单为主
if (Objects.nonNull(orderDO.getCustomerId()) && orderDO.getCustomerId() > 0) {
if (Objects.nonNull(orderDO.getCustomerId()) &&
orderDO.getCustomerId() > 0) {
addOrderCustomerService(orderDO,
Objects.equals(orderConsignorDO.getCustomerId(),
orderDO.getCustomerId()) ? 1 : 2);
......@@ -6562,6 +6642,11 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderMapper.UpdateOrderVValue(orderId, calVvalue, yejiCreateDate);
}
//修改订单的客户经理
public void updateOrderSalesmanId(Long orderId, Long salesman_id) {
orderMapper.updateOrderSalesmanId(orderId, salesman_id);
}
@Transactional(rollbackFor = Exception.class)
public void updateOrderCustomerAndSalesmanId(Long customerId, Long salesmanId, Long orderId) {
orderMapper.updateOrderCustomerAndSalesmanId(customerId, salesmanId, orderId);
......
......@@ -1092,8 +1092,8 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
orderQueryService.isSplitOrderChildren(orderDO);
// 没有入仓数据则提示
Long inCount = orderWarehouseInMapper.selectCount(OrderWarehouseInDO::getOrderId,
orderId);
Long inCount = orderWarehouseInMapper.selectCount(
OrderWarehouseInDO::getOrderId, orderId);
if (inCount == 0) {
throw ServiceExceptionUtil.exception(
ErrorCodeConstants.ORDER_WAREHOUSE_IN_NOT_EXISTS);
......@@ -1135,8 +1135,12 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
orderWarehousePictureService.createWarehousePictureBatch(
finishReqVO.getExceptionUrls(), 4, orderId);
// 异常
String descZh = getOrderOtherExceptionDesc(manualExceptionType, 0, finishReqVO.getDescZh(), finishReqVO.getDescEn());
String descEn = getOrderOtherExceptionDesc(manualExceptionType, 1, finishReqVO.getDescZh(), finishReqVO.getDescEn());
String descZh = getOrderOtherExceptionDesc(manualExceptionType,
0, finishReqVO.getDescZh(),
finishReqVO.getDescEn());
String descEn = getOrderOtherExceptionDesc(manualExceptionType,
1, finishReqVO.getDescZh(),
finishReqVO.getDescEn());
OrderExceptionCreateReqVO orderExceptionCreateReqVO =
genOrderException(orderId,
......@@ -1182,9 +1186,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
// 更新
orderSpecialNeedService.updateBatchById(orderSpecialNeedList);
}
else
{
} else {
}
......@@ -1248,8 +1250,10 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
// orderWarehouseInDOList.stream().map(OrderWarehouseInDO::getWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
// BigDecimal volumeSum = finishReqVO.getSumVolume() != null ? finishReqVO.getSumVolume() :
// orderWarehouseInDOList.stream().map(OrderWarehouseInDO::getVolume).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal weightSum = orderWarehouseInDOList.stream().map(OrderWarehouseInDO::getWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal volumeSum = orderWarehouseInDOList.stream().map(OrderWarehouseInDO::getVolume).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal weightSum =
orderWarehouseInDOList.stream().map(OrderWarehouseInDO::getWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal volumeSum =
orderWarehouseInDOList.stream().map(OrderWarehouseInDO::getVolume).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
orderDO.setSumQuantity(quantitySum);
orderDO.setSumWeight(weightSum);
orderDO.setSumVolume(volumeSum);
......@@ -1373,7 +1377,8 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
// 1、非拆单子订单 2、未发送短信 3、非退场入仓
if (!isSplitOrderChildren && finishReqVO.getSendMsg() && isNotRollbackIn) {
// 当没有异常时,才直接发送入仓短信。 有异常时需要在异常处理完后发送入仓短信。且入仓短信发送后不再次发送
OrderConsignorDO orderConsignorDO2 = orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, orderDO.getOrderId())
OrderConsignorDO orderConsignorDO2 =
orderConsignorService.getOne(new LambdaQueryWrapper<OrderConsignorDO>().eq(OrderConsignorDO::getOrderId, orderDO.getOrderId())
.orderByDesc(OrderConsignorDO::getId)
.last("limit 1"));
orderDO = orderService.getById(orderId);
......@@ -1381,7 +1386,8 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
if (exceptionNum == 0) {
Date appendInTime = new Date();
if (CollectionUtil.isNotEmpty(orderWarehouseInDOList)) {
OrderWarehouseInDO orderWarehouseInDO = orderWarehouseInDOList.stream().max(Comparator.comparing(OrderWarehouseInDO::getId)).get();
OrderWarehouseInDO orderWarehouseInDO =
orderWarehouseInDOList.stream().max(Comparator.comparing(OrderWarehouseInDO::getId)).get();
if (orderWarehouseInDO != null) {
appendInTime = orderWarehouseInDO.getInTime();
}
......@@ -1427,10 +1433,12 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
Objects.nonNull(consigneeCustomer.getCustomerService()) &&
(consignorCustomer.getCustomerService().equals(consigneeCustomer.getCustomerService()) || consignorCustomer.getCustomerService() == consigneeCustomer.getCustomerService())) {
if (orderConsignorDO2 != null && orderConsignorDO2.getCustomerId() != null) {
if (orderConsignorDO2 != null &&
orderConsignorDO2.getCustomerId() != null) {
idSet.add(orderConsignorDO2.getCustomerId());
}
if (orderConsigneeDO2 != null && orderConsigneeDO2.getCustomerId() != null) {
if (orderConsigneeDO2 != null &&
orderConsigneeDO2.getCustomerId() != null) {
idSet.add(orderConsigneeDO2.getCustomerId());
}
}
......@@ -3039,7 +3047,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
//删除储位
orderLocationService.deleteIfPresent(old.getOrderId(),
old.getOrderItemId(),old.getId());
old.getOrderItemId(), old.getId());
}
}
......@@ -3182,7 +3190,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
//删除储位
orderLocationService.deleteIfPresent(old.getOrderId(),
old.getOrderItemId(),old.getId());
old.getOrderItemId(), old.getId());
}
}
......@@ -3518,7 +3526,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
orderWarehouseInMapper.deleteBatchIds(deleteIds);
//根据订单ID删除储位
orderLocationService.deleteIfPresent(orderId,null,null);
orderLocationService.deleteIfPresent(orderId, null, null);
}
orderItemDO.setNum(updateReqVO.getNum());
......
......@@ -331,6 +331,8 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
//客户经理
Long customerId = 0L;
Long saleManid = info.getSalesmanId();
CustomerDO consignorDO =
customerService.getCustomer(info.getConsignorVO().getCustomerId());
//收货人
......@@ -344,6 +346,15 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
//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);
}
} else {
OrderConsigneeDO orderConsigneeDO =
orderConsigneeService.getOne(
......@@ -365,6 +376,14 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
//发货人档案设置控货无收货人且订单无收获人,归属发货人业绩 -- 层级2
if (consignorDO != null) {
customerId = consignorDO.getId();
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0||
consignorDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
}
} else {
......@@ -388,13 +407,37 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
if (CollectionUtil.isNotEmpty(offerBackVOList)) {
//如果是发货人付款且关联报价单,业绩归属发货人 --层级3 第一个
customerId = consignorDO.getId();
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0||
consignorDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
} else {
if (consignorDO.getDefaultPay()) {
//如果是发货人付款且档案设置默认付运费 --层级4 第一个
customerId = consignorDO.getId();
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0||
consignorDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
} else {
//业绩归属方是收货人
customerId = orderConsigneeDO.getCustomerId();
//校验客户的客户经理
if (consigneeDO.getCustomerService() == null ||
consigneeDO.getCustomerService() == 0||
consigneeDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
}
}
......@@ -402,6 +445,17 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
//收货人付款 层级5 第一个
customerId = orderConsigneeDO.getCustomerId() != null ?
orderConsigneeDO.getCustomerId() : consigneeDO.getId();
if (consigneeDO != null) {
//客户来源是发货人推荐,不保留业绩记录 customer_source
//2024-06-03 添加的逻辑
if (consigneeDO.getSource() == 12) {
//删除业绩记录
targetLogMapper.deleteById(targetId);
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
return;
}
}
} else if (info.getDrawee() == 3) {
//自定义付款
......@@ -422,23 +476,66 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
(info.getDrawee() == 3 && freight == 1)) {
//层级3 第二个 订单关联报价单 && 自定义付款 且发货人付运费
customerId = orderConsignorDO.getCustomerId();
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0||
consignorDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
} else if (CollectionUtil.isNotEmpty(offerBackVOList)
&& (info.getDrawee() == 3 && clearanceFee == 1)) {
//层级3 第三个 订单关联报价单 && 自定义付款 且发货人付清关费
customerId = orderConsignorDO.getCustomerId();
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0||
consignorDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
} else if (consignorDO.getDefaultPay() &&
(info.getDrawee() == 3 && freight == 1)) {
//层级4 第二个 发货人档案设置默认付运费 且发货人付运费 业绩归属 发货人
customerId = orderConsignorDO.getCustomerId();
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0||
consignorDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
} else if (consignorDO.getDefaultPay() &&
(info.getDrawee() == 3
&& clearanceFee == 1)) {
// 层级4 第三个 发货人档案设置默认付运费 且发货人付清关费 业绩归属发货人
customerId = orderConsignorDO.getCustomerId();
//校验客户的客户经理
if (consignorDO.getCustomerService() == null ||
consignorDO.getCustomerService() == 0||
consignorDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
} else {
customerId = orderConsigneeDO.getCustomerId();
//校验客户的客户经理
if (consigneeDO.getCustomerService() == null ||
consigneeDO.getCustomerService() == 0||
consigneeDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
}
// if(!consignorDO.getDefaultPay() && (info.getDrawee()==3 && freight==2 ) || (info.getDrawee()==3 && clearanceFee==2)){//层级5 第二、第三点 自定义付款且收款人付运费 或自定义付款且收款人付清关费 ,业绩归属收货人
// customerId = orderConsigneeDO.getCustomerId() ;
......@@ -453,6 +550,17 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
customerId =
orderConsigneeDO.getCustomerId() != null ?
orderConsigneeDO.getCustomerId() : 0;
//校验客户的客户经理
if (consigneeDO != null) {
if (consigneeDO.getCustomerService() == null ||
consigneeDO.getCustomerService() == 0||
consigneeDO.getIsInOpenSea()==true) {
saleManid = 0L;
orderService.updateOrderSalesmanId(info.getOrderId(),
0L);
}
}
}
}
......@@ -462,7 +570,7 @@ public class TargetLogServiceImpl extends AbstractService<TargetLogMapper, Targe
//客户ID
targetLogDO.setCustomerId(customerId);
//客户经理ID
targetLogDO.setUserId(info.getSalesmanId());
targetLogDO.setUserId(saleManid);
targetLogDO.setUpdateTime(new Date());
targetLogMapper.updateById(targetLogDO);
......
......@@ -379,7 +379,9 @@ public class OrderController {
}
private static void addDataScopeQuery(OrderQueryVO query, LoginUser loginUser, List<RoleRespDTO> roleRespDTOS) {
private static void addDataScopeQuery(OrderQueryVO query,
LoginUser loginUser,
List<RoleRespDTO> roleRespDTOS) {
List<Long> deptIdList = new ArrayList<>();
boolean isAll = Boolean.FALSE;
for (RoleRespDTO roleRespDTO : roleRespDTOS) {
......
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