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

Merge branch 'order-update' into dev

parents 102847c5 555bc7f5
......@@ -519,6 +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;
if (Objects.nonNull(customerContacts)) {
//发货人联系人
consignorCustomerDO = customerService.getCustomer(customerContacts.getCustomerId());
......@@ -529,6 +530,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (consignorCountryDO != null) {
orderConsignorDO.setCountryAbbreviation(consignorCountryDO.getNameShort());
}
noConsignee = Objects.nonNull(consignorCustomerDO.getNoConsignee()) && consignorCustomerDO.getNoConsignee();
}
if (StringUtils.isBlank(customerContacts.getPhoneNew())) {
throw exception(CONSIGNOR_PHONE_NOT_NULL);
......@@ -584,8 +586,10 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderCargoControlDO.setIsActual(Boolean.TRUE);
orderCargoControlMapper.insert(orderCargoControlDO);
}
OrderConsigneeDO orderConsigneeDO = new OrderConsigneeDO();
OrderConsigneeDO orderConsigneeDO = null;
// 当订单为控货订单,且发货人客户档案未设置控货无收货人,则需要校验收货人信息
if (order.getIsCargoControl() && !noConsignee) {
orderConsigneeDO = new OrderConsigneeDO();
orderConsigneeDO.setOrderId(order.getOrderId());
orderConsigneeDO.setCreator(creator);
orderConsigneeDO.setUpdater(creator);
......@@ -664,6 +668,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
}
}
orderConsigneeService.save(orderConsigneeDO);
}
if (!Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
//customerType 发货人-1 收货人 2
int customerType = this.checkOrderSalesman(order, createReqVO.getOfferId(), null, null, orderConsignorDO, orderConsigneeDO);
......@@ -687,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());
......@@ -694,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(
......@@ -787,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);
......@@ -898,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
......@@ -1807,15 +1815,30 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
CustomerContactsDO consignorContactsDO = customerContactsService.getCustomerContacts(updateReqVO.getConsignorContactsId());
OrderConsignorBackVO orderConsignorBackVO = vo.getConsignorVO();
CustomerDO consignorDO = null;
boolean noConsignee = false;
if (Objects.nonNull(consignorContactsDO)) {
consignorDO = customerService.getById(updateReqVO.getConsignorId());
consignorDO = customerService.getById(consignorContactsDO.getCustomerId());
if (Objects.nonNull(consignorDO)) {
noConsignee = consignorDO.getNoConsignee();
if (vo.getIsCargoControl() && vo.getHasConsignee() != noConsignee) {
ApplyInfoVO infoVO = new ApplyInfoVO();
infoVO.setName("控货订单发货人控货无收货人");
infoVO.setOrgValue(vo.getHasConsignee()? "是" : "否");
infoVO.setNewValue(noConsignee ? "是" : "否");
vo.setHasConsignee(noConsignee);
applyInfoList.add(infoVO);
// 发货人控货无收货人属性设置变动,需要变动客户业绩
vo.setIsCharge(true);
}
}
this.compareConsignorInfo(updateReqVO, consignorContactsDO, orderConsignorBackVO, applyInfoList, vo);
}
vo.setConsignorVO(orderConsignorBackVO);
// 比较收货人信息
CustomerContactsDO consigneeContactsDO = customerContactsService.getCustomerContacts(updateReqVO.getConsigneeContactsId());
OrderConsigneeBackVO orderConsigneeBackVO = vo.getConsigneeVO();
CustomerDO consigneeDO = customerService.getById(updateReqVO.getConsignorId());
CustomerDO consigneeDO = customerService.getById(updateReqVO.getConsigneeId());
if (vo.getIsCargoControl() && !noConsignee) {
if (Objects.isNull(consigneeContactsDO)) {
//todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码
// consigneeDO = customerService.getById(updateReqVO.getConsignorId());
......@@ -1835,6 +1858,15 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (Objects.nonNull(consigneeContactsDO)) {
this.compareConsigneeInfo(updateReqVO, consigneeContactsDO, orderConsigneeBackVO, applyInfoList, vo, dictDataRespDTO);
}
}else {
// 控货订单发货人设置为控货无收货人,这里需要处理掉订单的收货人信息
if (Objects.nonNull(orderConsigneeBackVO)){
ApplyInfoVO infoVO = new ApplyInfoVO();
infoVO.setName("控货订单发货人设置为控货无收货人,清除订单收货人信息/Set the shipper of the controlled goods order to no consignee, and clear the consignee information of the order");
applyInfoList.add(infoVO);
vo.setIsChargeNoConsignee(true);
}
}
if (vo.getIsCharge() || orderConsignorBackVO.getIsCharge() ||
orderConsigneeBackVO.getIsCharge()) {
// TODO 收发货人有变动,则可能业绩归属有变动, 此变动不放入审批详情,
......@@ -2610,7 +2642,6 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
infoVO.setNewValue(updateReqVO.getIsCargoControl() ? "是/yes" : "否/no");
vo.setIsCargoControl(updateReqVO.getIsCargoControl());
applyInfoList.add(infoVO);
// vo.setIsCharge(true);
}
Map<Integer, CurrencyRespDTO> currencyMap = currencyApi.getAllCurrency();
CurrencyRespDTO orgCurrencyRespDTO = currencyMap.get(vo.getCollectionProxyCurrency());
......@@ -2884,6 +2915,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) {
......@@ -2893,6 +2925,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);
......@@ -2969,6 +3002,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();
}
......@@ -3034,6 +3068,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())) {
......@@ -3067,11 +3108,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)) {
......@@ -3176,6 +3219,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();
}
......@@ -3273,6 +3319,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
......@@ -5372,7 +5426,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
OrderConsignorDO consignorDO = OrderConsignorConvert.INSTANCE.convert(consignorVO);
orderConsignorService.updateById(consignorDO);
OrderConsigneeDO consigneeDO = OrderConsigneeConvert.INSTANCE.convert(consigneeVO);
// 控货订单发货人无收货人属性变动,需要清空订单收货人信息
if (orderBackVO.getIsChargeNoConsignee()){
orderConsigneeService.removeById(consigneeDO.getId());
}else {
orderConsigneeService.updateById(consigneeDO);
}
// 始发地目的地更新
OrderDepartureDO departureDO = OrderDepartureConvert.INSTANCE.convert(orderBackVO.getOrderDepartureVO());
orderDepartureService.updateById(departureDO);
......@@ -5579,6 +5638,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (isConsigneeChange && consigneeVO.getCustomerId() != null) {
customerService.updateCustomerStatusByExistedOrderAndOffer(consigneeVO.getCustomerId(), true);
}
} catch (Exception e) {
log.error("更新收发货人状态时出现异常", e);
}
......
......@@ -561,6 +561,8 @@ public class OrderBackVO {
@ApiModelProperty(value = "是否变动付款人信息")
private Boolean isDrawee = false;
@ApiModelProperty(value = "是否变动发货人设置订单控货无收货人属性")
private Boolean isChargeNoConsignee = false;
@ApiModelProperty(value = "是否需要产生未分配客户经理异常异常")
private Boolean isCreateCustomerServiceException = false;
......
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