Commit 59e18dab authored by 332784038@qq.com's avatar 332784038@qq.com

web-app下单对收货人校验规则的修改

parent 910207c2
...@@ -519,6 +519,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -519,6 +519,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
.eq(CustomerContactsDO::getPhoneNew, memberUserDO.getMobile()) .eq(CustomerContactsDO::getPhoneNew, memberUserDO.getMobile())
.eq(CustomerContactsDO::getAreaCode, memberUserDO.getAreaCode())).eq(CustomerContactsDO::getDeleted, 0).last("limit 1")); .eq(CustomerContactsDO::getAreaCode, memberUserDO.getAreaCode())).eq(CustomerContactsDO::getDeleted, 0).last("limit 1"));
} }
Boolean noConsignee = false;
if (Objects.nonNull(customerContacts)) { if (Objects.nonNull(customerContacts)) {
//发货人联系人 //发货人联系人
consignorCustomerDO = customerService.getCustomer(customerContacts.getCustomerId()); consignorCustomerDO = customerService.getCustomer(customerContacts.getCustomerId());
...@@ -529,6 +530,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -529,6 +530,7 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
if (consignorCountryDO != null) { if (consignorCountryDO != null) {
orderConsignorDO.setCountryAbbreviation(consignorCountryDO.getNameShort()); orderConsignorDO.setCountryAbbreviation(consignorCountryDO.getNameShort());
} }
noConsignee = Objects.nonNull(consignorCustomerDO.getNoConsignee()) && consignorCustomerDO.getNoConsignee();
} }
if (StringUtils.isBlank(customerContacts.getPhoneNew())) { if (StringUtils.isBlank(customerContacts.getPhoneNew())) {
throw exception(CONSIGNOR_PHONE_NOT_NULL); throw exception(CONSIGNOR_PHONE_NOT_NULL);
...@@ -584,86 +586,89 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -584,86 +586,89 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderCargoControlDO.setIsActual(Boolean.TRUE); orderCargoControlDO.setIsActual(Boolean.TRUE);
orderCargoControlMapper.insert(orderCargoControlDO); orderCargoControlMapper.insert(orderCargoControlDO);
} }
OrderConsigneeDO orderConsigneeDO = null;
// 当订单为控货订单,且发货人客户档案未设置控货无收货人,则需要校验收货人信息
if (order.getIsCargoControl() && !noConsignee) {
orderConsigneeDO = new OrderConsigneeDO();
orderConsigneeDO.setOrderId(order.getOrderId());
orderConsigneeDO.setCreator(creator);
orderConsigneeDO.setUpdater(creator);
OrderConsigneeDO orderConsigneeDO = new OrderConsigneeDO(); if (StringUtils.isBlank(createReqVO.getConsigneePhone())) {
orderConsigneeDO.setOrderId(order.getOrderId()); throw exception(CONSIGNEE_PHONE_NOT_NULL);
orderConsigneeDO.setCreator(creator); }
orderConsigneeDO.setUpdater(creator); if (StringUtils.isBlank(createReqVO.getCountryCode())) {
throw exception(CONSIGNEE_PHONE_CODE_NOT_NULL);
if (StringUtils.isBlank(createReqVO.getConsigneePhone())) { }
throw exception(CONSIGNEE_PHONE_NOT_NULL); orderConsigneeDO.setPhone(createReqVO.getConsigneePhone());
} orderConsigneeDO.setName(StringUtils.isNotBlank(createReqVO.getConsigneeName()) ? createReqVO.getConsigneeName() : createReqVO.getConsigneePhone());
if (StringUtils.isBlank(createReqVO.getCountryCode())) { orderConsigneeDO.setNameEn(createReqVO.getConsigneeNameEn());
throw exception(CONSIGNEE_PHONE_CODE_NOT_NULL); orderConsigneeDO.setCountryCode(createReqVO.getCountryCode());
} orderConsigneeDO.setEmail(createReqVO.getConsigneeEmail());
orderConsigneeDO.setPhone(createReqVO.getConsigneePhone()); orderConsigneeDO.setCompany(createReqVO.getConsigneeCompany());
orderConsigneeDO.setName(StringUtils.isNotBlank(createReqVO.getConsigneeName()) ? createReqVO.getConsigneeName() : createReqVO.getConsigneePhone()); orderConsigneeDO.setCompanyEn(createReqVO.getConsigneeCompanyEn());
orderConsigneeDO.setNameEn(createReqVO.getConsigneeNameEn());
orderConsigneeDO.setCountryCode(createReqVO.getCountryCode());
orderConsigneeDO.setEmail(createReqVO.getConsigneeEmail());
orderConsigneeDO.setCompany(createReqVO.getConsigneeCompany());
orderConsigneeDO.setCompanyEn(createReqVO.getConsigneeCompanyEn());
orderConsigneeDO.setHarvestMethod(createReqVO.getHarvestMethod()); // 收货方式 orderConsigneeDO.setHarvestMethod(createReqVO.getHarvestMethod()); // 收货方式
if (StringUtils.isNotBlank(createReqVO.getConsigneeAddress())) { if (StringUtils.isNotBlank(createReqVO.getConsigneeAddress())) {
orderConsigneeDO.setAddress(createReqVO.getConsigneeAddress()); orderConsigneeDO.setAddress(createReqVO.getConsigneeAddress());
} }
orderConsigneeDO.setCountry(createReqVO.getCountry()); orderConsigneeDO.setCountry(createReqVO.getCountry());
orderConsigneeDO.setProvince(createReqVO.getProvince()); orderConsigneeDO.setProvince(createReqVO.getProvince());
orderConsigneeDO.setCity(createReqVO.getCity()); orderConsigneeDO.setCity(createReqVO.getCity());
orderConsigneeDO.setRelationId(createReqVO.getUserId()); orderConsigneeDO.setRelationId(createReqVO.getUserId());
orderConsigneeDO.setCreateTime(now); orderConsigneeDO.setCreateTime(now);
orderConsigneeDO.setUpdateTime(now); orderConsigneeDO.setUpdateTime(now);
if (StringUtils.isBlank(orderConsigneeDO.getPhone()) || StringUtils.isBlank(orderConsigneeDO.getCountryCode())) { if (StringUtils.isBlank(orderConsigneeDO.getPhone()) || StringUtils.isBlank(orderConsigneeDO.getCountryCode())) {
throw exception(ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE); throw exception(ORDER_CONSIGNEE_PHONE_INFO_NOT_COMPLETE);
} }
if (StringUtils.isBlank(orderConsigneeDO.getName())) { if (StringUtils.isBlank(orderConsigneeDO.getName())) {
throw exception(ORDER_CONSIGNEE_NAME_NOT_COMPLETE); throw exception(ORDER_CONSIGNEE_NAME_NOT_COMPLETE);
} }
if ((Objects.isNull(createReqVO.getIsCargoControl()) || !createReqVO.getIsCargoControl()) && StringUtils.isNotBlank(orderConsigneeDO.getCountryCode()) && if ((Objects.isNull(createReqVO.getIsCargoControl()) || !createReqVO.getIsCargoControl()) && StringUtils.isNotBlank(orderConsigneeDO.getCountryCode()) &&
Objects.nonNull(dictDataRespDTO) && StringUtils.equals(dictDataRespDTO.getValue(), "11") && StringUtils.equals("86", orderConsigneeDO.getCountryCode())) { Objects.nonNull(dictDataRespDTO) && StringUtils.equals(dictDataRespDTO.getValue(), "11") && StringUtils.equals("86", orderConsigneeDO.getCountryCode())) {
throw exception(CONSIGNEE_PHONE_IS_EXTERNAL); throw exception(CONSIGNEE_PHONE_IS_EXTERNAL);
} }
try { try {
String mobileCode = orderConsigneeDO.getCountryCode() + StrUtil.COLON + orderConsigneeDO.getPhone(); String mobileCode = orderConsigneeDO.getCountryCode() + StrUtil.COLON + orderConsigneeDO.getPhone();
paramValidatorService.validatorMobile(mobileCode); paramValidatorService.validatorMobile(mobileCode);
} catch (Exception e) { } catch (Exception e) {
throw exception(ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT); throw exception(ORDER_CONSIGNEE_PHONE_INCORRECT_FORMAT);
} }
//todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码 //todo 需要判断手机号唯一性,判断规则:1.区号相同,2.先判断手机号码是否存在,然后再判断:a.如果是0开头,判断是否存在非0开头号码;b.如果非0开头,判断是否存在0开头号码
CustomerContactsDO consignee = customerService.getUniqueOneAndValidate(orderConsigneeDO.getCountryCode(), orderConsigneeDO.getPhone(), null); CustomerContactsDO consignee = customerService.getUniqueOneAndValidate(orderConsigneeDO.getCountryCode(), orderConsigneeDO.getPhone(), null);
if (Objects.nonNull(consignee) && if (Objects.nonNull(consignee) &&
Objects.nonNull(consignee.getCustomerId())) { Objects.nonNull(consignee.getCustomerId())) {
orderConsigneeDO.setCustomerId(consignee.getCustomerId()); orderConsigneeDO.setCustomerId(consignee.getCustomerId());
orderConsigneeDO.setCustomerContactsId(consignee.getId()); orderConsigneeDO.setCustomerContactsId(consignee.getId());
} else { } else {
// 客户不存在,新增客户联系人信息 orderConsigneeDO中有值 // 客户不存在,新增客户联系人信息 orderConsigneeDO中有值
// 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。 // 20230511 收货人无客户档案时 判断发货人有无客户经理,没有 生成客户档案,进入待分配。
// 有客户经理,则暂时不生成客户档案。(放在入仓时处理) // 有客户经理,则暂时不生成客户档案。(放在入仓时处理)
if (consignorCustomerDO == null || if (consignorCustomerDO == null ||
consignorCustomerDO.getCustomerService() == null || consignorCustomerDO.getCustomerService() == null ||
consignorCustomerDO.getCustomerService() == 0) { consignorCustomerDO.getCustomerService() == 0) {
//ecw_customer_contacts 客户联系人 //ecw_customer_contacts 客户联系人
//创建收货人客户 //创建收货人客户
CustomerContactsDO consigeeCustomer = CustomerContactsDO consigeeCustomer =
customerService.createConsigeeCustomer( customerService.createConsigeeCustomer(
orderConsigneeDO.getName(), orderConsigneeDO.getName(),
orderConsigneeDO.getCountryCode(), orderConsigneeDO.getCountryCode(),
orderConsigneeDO.getPhone(), orderConsigneeDO.getPhone(),
orderConsigneeDO.getCompany(), orderConsigneeDO.getCompany(),
orderConsigneeDO.getEmail(), orderConsigneeDO.getEmail(),
consignorCustomerDO, consignorCustomerDO,
order.getOrderNo()); order.getOrderNo());
if (consigeeCustomer != null) { if (consigeeCustomer != null) {
orderConsigneeDO.setCustomerId(consigeeCustomer.getCustomerId()); orderConsigneeDO.setCustomerId(consigeeCustomer.getCustomerId());
orderConsigneeDO.setCustomerContactsId(consigeeCustomer.getId()); orderConsigneeDO.setCustomerContactsId(consigeeCustomer.getId());
}
} }
} }
orderConsigneeService.save(orderConsigneeDO);
} }
orderConsigneeService.save(orderConsigneeDO);
if (!Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) { if (!Objects.equals(createReqVO.getStatus(), OrderStatusEnum.DRAFT.getValue())) {
//customerType 发货人-1 收货人 2 //customerType 发货人-1 收货人 2
int customerType = this.checkOrderSalesman(order, createReqVO.getOfferId(), null, null, orderConsignorDO, orderConsigneeDO); int customerType = this.checkOrderSalesman(order, createReqVO.getOfferId(), null, null, orderConsignorDO, orderConsigneeDO);
......
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