Commit e9406f71 authored by 332784038@qq.com's avatar 332784038@qq.com

完善订单下单与编辑时当控货订单发货人设置了控货无收货人,对收货人信息的处理业务逻辑

parent 59e18dab
......@@ -519,7 +519,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
.eq(CustomerContactsDO::getPhoneNew, memberUserDO.getMobile())
.eq(CustomerContactsDO::getAreaCode, memberUserDO.getAreaCode())).eq(CustomerContactsDO::getDeleted, 0).last("limit 1"));
}
Boolean noConsignee = false;
boolean noConsignee = false;
if (Objects.nonNull(customerContacts)) {
//发货人联系人
consignorCustomerDO = customerService.getCustomer(customerContacts.getCustomerId());
......@@ -692,6 +692,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO.setUpdater(creator);
CustomerDO consignorDO =
customerService.getCustomer(createReqVO.getConsignorId());
boolean noConsignee = false;
if (Objects.nonNull(consignorDO)) {
orderConsignorDO.setCompany(consignorDO.getCompany());
orderConsignorDO.setCompanyEn(consignorDO.getCompanyEn());
......@@ -699,6 +700,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (Objects.nonNull(consignorCountryDO)) {
orderConsignorDO.setCountryAbbreviation(consignorCountryDO.getNameShort());
}
noConsignee = consignorDO.getNoConsignee();
}
CustomerContactsDO consignorContactsDO =
customerContactsService.getCustomerContacts(
......@@ -792,9 +794,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderConsignorDO.getCountryCode() + orderConsignorDO.getPhone());
orderBusinessService.createOrderControlLog(orderCargoControlDO.getOrderId(), 1, "创建控货信息", msg, 0L);
}
OrderConsigneeDO orderConsigneeDO = new OrderConsigneeDO();
OrderConsigneeDO orderConsigneeDO = null;
if (order.getIsCargoControl() && !noConsignee) {
orderConsigneeDO = new OrderConsigneeDO();
orderConsigneeDO.setOrderId(order.getOrderId());
orderConsigneeDO.setCreator(creator);
orderConsigneeDO.setUpdater(creator);
......@@ -903,6 +905,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (StringUtils.isNotBlank(orderConsigneeDO.getPhone())) {
orderConsigneeService.save(orderConsigneeDO);
}
}
if (!Objects.equals(createReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
// 发货人 1 收货人 2
......@@ -2889,6 +2892,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
.eq(CustomerContactsDO::getAreaCode, memberUserDO.getAreaCode())).eq(CustomerContactsDO::getDeleted, 0).last("limit 1"));
}
CustomerDO consignorCustomerDO = null;
boolean noConsignee = false;
if (Objects.nonNull(customerContacts)) {
consignorCustomerDO = customerService.getCustomer(customerContacts.getCustomerId());
if (consignorCustomerDO != null) {
......@@ -2898,6 +2902,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (consignorCountryDO != null) {
orderConsignorDO.setCountryAbbreviation(consignorCountryDO.getNameShort());
}
noConsignee = consignorCustomerDO.getNoConsignee();
}
if (StringUtils.isBlank(customerContacts.getPhoneNew())) {
throw exception(CONSIGNOR_PHONE_NOT_NULL);
......@@ -2974,6 +2979,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
OrderConsigneeDO orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, updateObj.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
if (updateObj.getIsCargoControl() && !noConsignee) {
if (Objects.isNull(orderConsigneeDO)) {
orderConsigneeDO = new OrderConsigneeDO();
}
......@@ -3039,6 +3045,13 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
}
orderConsigneeService.saveOrUpdate(orderConsigneeDO);
}else {
// 如果控货订单发货人设置了控货无收货人,则需要删除订单已有收货人
if (Objects.nonNull(orderConsigneeDO)){
orderConsigneeService.removeById(orderConsigneeDO.getId());
orderConsigneeDO = null;
}
}
if (!Objects.equals(updateReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
......@@ -3072,11 +3085,13 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (Objects.isNull(orderConsignorDO)) {
orderConsignorDO = new OrderConsignorDO();
}
boolean noConsignee = false;
if (Objects.nonNull(consignorDO)) {
orderConsignorDO.setCompany(consignorDO.getCompany());
orderConsignorDO.setCompanyEn(consignorDO.getCompanyEn());
CountryDO consignorCountryDO = countryService.getById(consignorDO.getCountry());
orderConsignorDO.setCountryAbbreviation(Objects.isNull(consignorCountryDO) ? null : consignorCountryDO.getNameShort());
noConsignee = consignorDO.getNoConsignee();
}
if (Objects.nonNull(consignorContactsDO)) {
......@@ -3181,6 +3196,9 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
CustomerDO consigneeDO = customerService.getCustomer(updateReqVO.getConsigneeId());
OrderConsigneeDO orderConsigneeDO = orderConsigneeService.getOne(new LambdaQueryWrapper<OrderConsigneeDO>().eq(OrderConsigneeDO::getOrderId, updateObj.getOrderId()).orderByDesc(OrderConsigneeDO::getId).last("limit 1"));
if (updateObj.getIsCargoControl() && !noConsignee) {
orderConsigneeDO = new OrderConsigneeDO();
if (Objects.isNull(orderConsigneeDO)) {
orderConsigneeDO = new OrderConsigneeDO();
}
......@@ -3278,6 +3296,14 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (StringUtils.isNotBlank(orderConsigneeDO.getPhone())) {
orderConsigneeService.saveOrUpdate(orderConsigneeDO);
}
}else {
// 如果控货订单发货人设置了控货无收货人,则需要删除订单已有收货人
if (Objects.nonNull(orderConsigneeDO)){
orderConsigneeService.removeById(orderConsigneeDO.getId());
orderConsigneeDO = null;
}
consigneeDO = null;
}
if (!Objects.equals(updateReqVO.getStatus(),
OrderStatusEnum.DRAFT.getValue())) {
//customerType 发货人 1 收货人 2
......
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